From 7588962212e690edd5e9e5a566aa4902b3d907d0 Mon Sep 17 00:00:00 2001 From: Alexey Andreev Date: Tue, 20 Nov 2018 14:55:04 +0300 Subject: [PATCH] Bind system properties to Maven properties. Add heapSize property --- samples/benchmark/pom.xml | 15 ++++++++++ .../java/org/teavm/tooling/TeaVMTool.java | 2 +- .../teavm/tooling/builder/BuildStrategy.java | 2 ++ .../builder/InProcessBuildStrategy.java | 7 +++++ .../tooling/builder/RemoteBuildStrategy.java | 5 ++++ .../org/teavm/tooling/daemon/BuildDaemon.java | 1 + .../tooling/daemon/RemoteBuildRequest.java | 1 + .../org/teavm/maven/TeaVMCompileMojo.java | 30 +++++++++++-------- 8 files changed, 49 insertions(+), 14 deletions(-) diff --git a/samples/benchmark/pom.xml b/samples/benchmark/pom.xml index e8b570e7b..f1ab7abb7 100644 --- a/samples/benchmark/pom.xml +++ b/samples/benchmark/pom.xml @@ -165,6 +165,21 @@ true WEBASSEMBLY FULL + 8 + + + + native-client + + compile + + + ${project.build.directory}/generated/c + org.teavm.samples.benchmark.teavm.Gtk3BenchmarkStarter + true + C + FULL + 8 diff --git a/tools/core/src/main/java/org/teavm/tooling/TeaVMTool.java b/tools/core/src/main/java/org/teavm/tooling/TeaVMTool.java index 2b27e2f9d..49ca0b8f1 100644 --- a/tools/core/src/main/java/org/teavm/tooling/TeaVMTool.java +++ b/tools/core/src/main/java/org/teavm/tooling/TeaVMTool.java @@ -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(); diff --git a/tools/core/src/main/java/org/teavm/tooling/builder/BuildStrategy.java b/tools/core/src/main/java/org/teavm/tooling/builder/BuildStrategy.java index 6bfcc1b3d..93717a5c0 100644 --- a/tools/core/src/main/java/org/teavm/tooling/builder/BuildStrategy.java +++ b/tools/core/src/main/java/org/teavm/tooling/builder/BuildStrategy.java @@ -66,5 +66,7 @@ public interface BuildStrategy { void setWasmVersion(WasmBinaryVersion wasmVersion); + void setHeapSize(int heapSize); + BuildResult build() throws BuildException; } diff --git a/tools/core/src/main/java/org/teavm/tooling/builder/InProcessBuildStrategy.java b/tools/core/src/main/java/org/teavm/tooling/builder/InProcessBuildStrategy.java index 63c957a40..d681621f0 100644 --- a/tools/core/src/main/java/org/teavm/tooling/builder/InProcessBuildStrategy.java +++ b/tools/core/src/main/java/org/teavm/tooling/builder/InProcessBuildStrategy.java @@ -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 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); diff --git a/tools/core/src/main/java/org/teavm/tooling/builder/RemoteBuildStrategy.java b/tools/core/src/main/java/org/teavm/tooling/builder/RemoteBuildStrategy.java index 207c7ea96..6be5447cc 100644 --- a/tools/core/src/main/java/org/teavm/tooling/builder/RemoteBuildStrategy.java +++ b/tools/core/src/main/java/org/teavm/tooling/builder/RemoteBuildStrategy.java @@ -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; diff --git a/tools/core/src/main/java/org/teavm/tooling/daemon/BuildDaemon.java b/tools/core/src/main/java/org/teavm/tooling/daemon/BuildDaemon.java index 223f4eb8a..8552cc3ee 100644 --- a/tools/core/src/main/java/org/teavm/tooling/daemon/BuildDaemon.java +++ b/tools/core/src/main/java/org/teavm/tooling/daemon/BuildDaemon.java @@ -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))); diff --git a/tools/core/src/main/java/org/teavm/tooling/daemon/RemoteBuildRequest.java b/tools/core/src/main/java/org/teavm/tooling/daemon/RemoteBuildRequest.java index 78e4cf865..0f8eb32bb 100644 --- a/tools/core/src/main/java/org/teavm/tooling/daemon/RemoteBuildRequest.java +++ b/tools/core/src/main/java/org/teavm/tooling/daemon/RemoteBuildRequest.java @@ -42,4 +42,5 @@ public class RemoteBuildRequest implements Serializable { public Properties properties; public TeaVMOptimizationLevel optimizationLevel; public WasmBinaryVersion wasmVersion; + public int heapSize; } diff --git a/tools/maven/plugin/src/main/java/org/teavm/maven/TeaVMCompileMojo.java b/tools/maven/plugin/src/main/java/org/teavm/maven/TeaVMCompileMojo.java index 9fde07aba..cba4835da 100644 --- a/tools/maven/plugin/src/main/java/org/teavm/maven/TeaVMCompileMojo.java +++ b/tools/maven/plugin/src/main/java/org/teavm/maven/TeaVMCompileMojo.java @@ -77,22 +77,22 @@ public class TeaVMCompileMojo extends AbstractMojo { @Parameter private List 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 prepareClassPath() { Log log = getLog(); - log.info("Preparing classpath for JavaScript generation"); + log.info("Preparing classpath for TeaVM"); List 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; }