Skip to content

Commit

Permalink
wasm gc: support source map in gradle plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
konsoletyper committed Oct 14, 2024
1 parent d68018d commit 94c50dd
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions samples/benchmark/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ teavm {
wasmGC {
addedToWebApp = true
mainClass = "org.teavm.samples.benchmark.teavm.BenchmarkStarter"
sourceMap = true
}
wasm {
addedToWebApp = true
Expand Down
1 change: 1 addition & 0 deletions tools/core/src/main/java/org/teavm/tooling/TeaVMTool.java
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,7 @@ private WasmGCTarget prepareWebAssemblyGCTarget() {
target.setDebugInfoLevel(debugInformationGenerated ? WasmDebugInfoLevel.FULL : wasmDebugInfoLevel);
target.setDebugInfoLocation(wasmDebugInfoLocation);
if (sourceMapsFileGenerated) {
wasmSourceMapWriter = new SourceMapBuilder();
target.setSourceMapBuilder(wasmSourceMapWriter);
target.setSourceMapLocation(getResolvedTargetFileName() + ".map");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ private void setupWasmGCDefaults() {
.map(v -> WasmDebugInfoLocation.valueOf(v.toUpperCase())).orElse(WasmDebugInfoLocation.EXTERNAL));
wasmGC.getDebugInfoLevel().convention(property("wasm-gc.debugInformation.level")
.map(v -> WasmDebugInfoLevel.valueOf(v.toUpperCase())).orElse(WasmDebugInfoLevel.DEOBFUSCATION));
wasmGC.getSourceMap().convention(property("wasm-gc.sourceMap").map(Boolean::parseBoolean).orElse(false));
}

private void setupWasiDefaults() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ private void registerWasmGCTask(Project project, Configuration configuration) {
task.getTargetFileName().convention(wasmGC.getTargetFileName());
task.getObfuscated().convention(wasmGC.getObfuscated());
task.getStrict().convention(wasmGC.getStrict());
task.getSourceMap().convention(wasmGC.getSourceMap());
});
project.getTasks().create(WASM_GC_COPY_RUNTIME_TASK_NAME, CopyWasmGCRuntimeTask.class, task -> {
task.setGroup(TASK_GROUP);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,6 @@ public interface TeaVMWasmGCConfiguration extends TeaVMCommonConfiguration, TeaV
Property<WasmDebugInfoLocation> getDebugInfoLocation();

Property<WasmDebugInfoLevel> getDebugInfoLevel();

Property<Boolean> getSourceMap();
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public GenerateWasmGCTask() {
getDebugInfo().convention(true);
getDebugInfoLevel().convention(WasmDebugInfoLevel.DEOBFUSCATION);
getDebugInfoLocation().convention(WasmDebugInfoLocation.EXTERNAL);
getSourceMap().convention(false);
}

@Input
Expand All @@ -46,11 +47,15 @@ public GenerateWasmGCTask() {
@Input
public abstract Property<WasmDebugInfoLocation> getDebugInfoLocation();

@Input
public abstract Property<Boolean> getSourceMap();

@Override
protected void setupBuilder(BuildStrategy builder) {
builder.setStrict(getStrict().get());
builder.setObfuscated(getObfuscated().get());
builder.setDebugInformationGenerated(getDebugInfo().get());
builder.setSourceMapsFileGenerated(getSourceMap().get());
switch (getDebugInfoLevel().get()) {
case FULL:
builder.setWasmDebugInfoLevel(org.teavm.backend.wasm.WasmDebugInfoLevel.FULL);
Expand Down

0 comments on commit 94c50dd

Please sign in to comment.