Support preserve-class option in CLI

This commit is contained in:
Alexey Andreev 2018-01-09 23:46:24 +03:00
parent 85c686c72a
commit 09d857f572

View File

@ -32,6 +32,7 @@ import java.nio.file.WatchKey;
import java.nio.file.WatchService; import java.nio.file.WatchService;
import java.nio.file.attribute.BasicFileAttributes; import java.nio.file.attribute.BasicFileAttributes;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -130,6 +131,12 @@ public final class TeaVMRunner {
.withDescription("Additional classpath that will be reloaded by TeaVM each time in wait mode") .withDescription("Additional classpath that will be reloaded by TeaVM each time in wait mode")
.withLongOpt("classpath") .withLongOpt("classpath")
.create('p')); .create('p'));
options.addOption(OptionBuilder
.withArgName("class name")
.hasArgs()
.withDescription("Tell optimizer to not remove class, so that it can be found by Class.forName")
.withLongOpt("preserve-class")
.create());
options.addOption(OptionBuilder options.addOption(OptionBuilder
.withLongOpt("wasm-version") .withLongOpt("wasm-version")
.withArgName("version") .withArgName("version")
@ -167,6 +174,7 @@ public final class TeaVMRunner {
parseTargetOption(); parseTargetOption();
parseOutputOptions(); parseOutputOptions();
parseDebugOptions(); parseDebugOptions();
parsePreserveClassOptions();
parseOptimizationOption(); parseOptimizationOption();
parseIncrementalOptions(); parseIncrementalOptions();
parseJavaScriptOptions(); parseJavaScriptOptions();
@ -240,6 +248,12 @@ public final class TeaVMRunner {
} }
} }
private void parsePreserveClassOptions() {
if (commandLine.hasOption("preserve-class")) {
tool.getClassesToPreserve().addAll(Arrays.asList(commandLine.getOptionValues("preserve-class")));
}
}
private void parseOptimizationOption() { private void parseOptimizationOption() {
if (commandLine.hasOption("O")) { if (commandLine.hasOption("O")) {
int level; int level;