GT-2913: launch.properties can now take platform-specific VMARGS.

This commit is contained in:
Ryan Kurtz 2019-07-25 11:31:08 -04:00
parent 8c689a0099
commit fa20ba3762
7 changed files with 87 additions and 75 deletions

View file

@ -33,23 +33,46 @@ public abstract class JavaFinder {
}
/**
* Creates a Java finder to use for the current OS.
* The different supported platforms (operating systems).
*/
public enum Platform {
WINDOWS, MACOS, LINUX;
}
/**
* Gets the current {@link Platform}.
*
* @return The Java finder to use for the current OS.
* @return The current {@link Platform}
*/
public static Platform getCurrentPlatform() {
String os = System.getProperty("os.name");
if (os != null) {
os = os.toLowerCase();
if (os.contains("win")) {
return Platform.WINDOWS;
}
if (os.contains("mac")) {
return Platform.MACOS;
}
}
return Platform.LINUX;
}
/**
* Creates a Java finder to use for the current {@link Platform platform}.
*
* @return The Java finder to use for the current {@link Platform platform}
*/
public static JavaFinder create() {
JavaFinder javaFinder;
String os = System.getProperty("os.name").toLowerCase();
if (os != null && os.contains("win")) {
javaFinder = new WindowsJavaFinder();
switch (getCurrentPlatform()) {
case WINDOWS:
return new WindowsJavaFinder();
case MACOS:
return new MacJavaFinder();
case LINUX:
default:
return new LinuxJavaFinder();
}
else if (os != null && os.contains("mac")) {
javaFinder = new MacJavaFinder();
}
else {
javaFinder = new LinuxJavaFinder();
}
return javaFinder;
}
/**

View file

@ -19,6 +19,8 @@ import java.io.*;
import java.text.ParseException;
import java.util.*;
import ghidra.launch.JavaFinder.Platform;
/**
* Parses and provides convenient access to the properties defined in a launch properties file.
* <p>
@ -34,10 +36,15 @@ public class LaunchProperties {
public static String JAVA_HOME_OVERRIDE = "JAVA_HOME_OVERRIDE";
/**
* The VM arguments to use to launch.
* The VM arguments to use to launch (all platforms).
*/
public static String VMARGS = "VMARGS";
/**
* The VM arguments to use to launch (current platform only).
*/
public static String VMARGS_PLATFORM = "VMARGS_" + JavaFinder.getCurrentPlatform();
private Map<String, List<String>> propertyMap;
/**
@ -68,12 +75,11 @@ public class LaunchProperties {
}
/**
* Gets the command line string of VM arguments to use for the launch.
* This will be the union of all VM arguments defined in both the user and installation launch
* properties. If conflicting VM arguments are defined in both files, the user version
* will override the installation version.
* Gets the command line string of VM arguments to use for the launch for the current
* {@link Platform platform}.
*
* @return The command line string of VM arguments to use for the launch.
* @return The command line string of VM arguments to use for the launch for the current
* {@link Platform}
*/
public String getVmArgs() {
StringBuilder sb = new StringBuilder();
@ -84,6 +90,13 @@ public class LaunchProperties {
sb.append(" ");
}
}
List<String> vmargPlatformList = propertyMap.get(VMARGS_PLATFORM);
if (vmargPlatformList != null) {
for (String arg : vmargPlatformList) {
sb.append(arg);
sb.append(" ");
}
}
return sb.toString();
}