Bind system properties to Maven properties.

Add heapSize property
This commit is contained in:
Alexey Andreev 2018-11-20 14:55:04 +03:00
parent fc799afcda
commit 7588962212
8 changed files with 49 additions and 14 deletions

View File

@ -165,6 +165,21 @@
<debugInformationGenerated>true</debugInformationGenerated>
<targetType>WEBASSEMBLY</targetType>
<optimizationLevel>FULL</optimizationLevel>
<heapSize>8</heapSize>
</configuration>
</execution>
<execution>
<id>native-client</id>
<goals>
<goal>compile</goal>
</goals>
<configuration>
<targetDirectory>${project.build.directory}/generated/c</targetDirectory>
<mainClass>org.teavm.samples.benchmark.teavm.Gtk3BenchmarkStarter</mainClass>
<debugInformationGenerated>true</debugInformationGenerated>
<targetType>C</targetType>
<optimizationLevel>FULL</optimizationLevel>
<heapSize>8</heapSize>
</configuration>
</execution>
</executions>

View File

@ -331,7 +331,7 @@ public class TeaVMTool {
public void generate() throws TeaVMToolException {
try {
cancelled = false;
log.info("Building JavaScript file");
log.info("Running TeaVM");
TeaVMBuilder vmBuilder = new TeaVMBuilder(prepareTarget());
if (incremental) {
cacheDirectory.mkdirs();

View File

@ -66,5 +66,7 @@ public interface BuildStrategy {
void setWasmVersion(WasmBinaryVersion wasmVersion);
void setHeapSize(int heapSize);
BuildResult build() throws BuildException;
}

View File

@ -56,6 +56,7 @@ public class InProcessBuildStrategy implements BuildStrategy {
private String[] transformers = new String[0];
private String[] classesToPreserve = new String[0];
private WasmBinaryVersion wasmVersion = WasmBinaryVersion.V_0x1;
private int heapSize = 32;
private final List<SourceFileProvider> sourceFileProviders = new ArrayList<>();
private TeaVMProgressListener progressListener;
private Properties properties = new Properties();
@ -172,6 +173,11 @@ public class InProcessBuildStrategy implements BuildStrategy {
this.wasmVersion = wasmVersion;
}
@Override
public void setHeapSize(int heapSize) {
this.heapSize = heapSize;
}
@Override
public BuildResult build() throws BuildException {
TeaVMTool tool = new TeaVMTool();
@ -194,6 +200,7 @@ public class InProcessBuildStrategy implements BuildStrategy {
tool.getClassesToPreserve().addAll(Arrays.asList(classesToPreserve));
tool.setCacheDirectory(cacheDirectory != null ? new File(cacheDirectory) : null);
tool.setWasmVersion(wasmVersion);
tool.setMinHeapSize(heapSize);
tool.getProperties().putAll(properties);

View File

@ -154,6 +154,11 @@ public class RemoteBuildStrategy implements BuildStrategy {
request.wasmVersion = wasmVersion;
}
@Override
public void setHeapSize(int heapSize) {
request.heapSize = heapSize;
}
@Override
public BuildResult build() throws BuildException {
RemoteBuildResponse response;

View File

@ -164,6 +164,7 @@ public class BuildDaemon extends UnicastRemoteObject implements RemoteBuildServi
tool.setOptimizationLevel(request.optimizationLevel);
tool.setMinifying(request.minifying);
tool.setWasmVersion(request.wasmVersion);
tool.setMinHeapSize(request.heapSize);
for (String sourceDirectory : request.sourceDirectories) {
tool.addSourceFileProvider(new DirectorySourceFileProvider(new File(sourceDirectory)));

View File

@ -42,4 +42,5 @@ public class RemoteBuildRequest implements Serializable {
public Properties properties;
public TeaVMOptimizationLevel optimizationLevel;
public WasmBinaryVersion wasmVersion;
public int heapSize;
}

View File

@ -77,22 +77,22 @@ public class TeaVMCompileMojo extends AbstractMojo {
@Parameter
private List<String> compileScopes;
@Parameter
@Parameter(property = "teavm.minifying", defaultValue = "true")
private boolean minifying = true;
@Parameter
private Properties properties;
@Parameter
@Parameter(property = "teavm.debugInformationGenerated", defaultValue = "false")
private boolean debugInformationGenerated;
@Parameter
@Parameter(property = "teavm.sourceMapsGenerated", defaultValue = "false")
private boolean sourceMapsGenerated;
@Parameter
@Parameter(property = "teavm.sourceFilesCopied", defaultValue = "false")
private boolean sourceFilesCopied;
@Parameter
@Parameter(property = "teavm.incremental", defaultValue = "false")
private boolean incremental;
@Parameter
@ -104,30 +104,33 @@ public class TeaVMCompileMojo extends AbstractMojo {
@Parameter(defaultValue = "${project.build.sourceDirectory}")
private File sourceDirectory;
@Parameter
@Parameter(property = "teavm.targetFileName", defaultValue = "")
private String targetFileName = "";
@Parameter
@Parameter(property = "teavm.mainClass")
private String mainClass;
@Parameter
private String[] classesToPreserve;
@Parameter
@Parameter(property = "teavm.stopOnErrors", defaultValue = "true")
private boolean stopOnErrors = true;
@Parameter
@Parameter(property = "teavm.optimizationLevel", defaultValue = "SIMPLE")
private TeaVMOptimizationLevel optimizationLevel = TeaVMOptimizationLevel.SIMPLE;
@Parameter
@Parameter(property = "teavm.targetType", defaultValue = "JAVASCRIPT")
private TeaVMTargetType targetType = TeaVMTargetType.JAVASCRIPT;
@Parameter(defaultValue = "${project.build.directory}/teavm-cache")
private File cacheDirectory;
@Parameter
@Parameter(property = "teavm.wasmVersion", defaultValue = "V_0x1")
private WasmBinaryVersion wasmVersion = WasmBinaryVersion.V_0x1;
@Parameter(property = "teavm.heapSize", defaultValue = "32")
private int heapSize;
@Parameter(property = "teavm.outOfProcess", defaultValue = "false")
private boolean outOfProcess;
@ -154,6 +157,7 @@ public class TeaVMCompileMojo extends AbstractMojo {
builder.setDebugInformationGenerated(debugInformationGenerated);
builder.setSourceMapsFileGenerated(sourceMapsGenerated);
builder.setSourceFilesCopied(sourceFilesCopied);
builder.setHeapSize(heapSize * 1024 * 1024);
} catch (RuntimeException e) {
throw new MojoExecutionException("Unexpected error occurred", e);
}
@ -161,7 +165,7 @@ public class TeaVMCompileMojo extends AbstractMojo {
private List<String> prepareClassPath() {
Log log = getLog();
log.info("Preparing classpath for JavaScript generation");
log.info("Preparing classpath for TeaVM");
List<String> paths = new ArrayList<>();
StringBuilder classpath = new StringBuilder();
for (Artifact artifact : project.getArtifacts()) {
@ -180,7 +184,7 @@ public class TeaVMCompileMojo extends AbstractMojo {
}
classpath.append(classFiles.getPath());
paths.add(classFiles.getAbsolutePath());
log.info("Using the following classpath for JavaScript generation: " + classpath);
log.info("Using the following classpath for TeaVM: " + classpath);
return paths;
}