mirror of
https://github.com/i-net-software/JWebAssembly.git
synced 2025-03-25 15:37:52 +01:00
add support for SOURCE_MAP_BASE
This commit is contained in:
parent
77be20ed57
commit
8589dbae66
@ -62,6 +62,12 @@ public class JWebAssembly {
|
|||||||
*/
|
*/
|
||||||
public static final String DEBUG_NAMES = "DebugNames";
|
public static final String DEBUG_NAMES = "DebugNames";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Property for relative path between the final wasm file location and the source files location for the source map.
|
||||||
|
* If not empty it should end with a slash like "../../src/main/java/".
|
||||||
|
*/
|
||||||
|
public static final String SOURCE_MAP_BASE = "SourceMapBase";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The name of the annotation for import functions.
|
* The name of the annotation for import functions.
|
||||||
*/
|
*/
|
||||||
|
@ -63,6 +63,8 @@ public class BinaryModuleWriter extends ModuleWriter implements InstructionOpcod
|
|||||||
|
|
||||||
private final boolean createSourceMap;
|
private final boolean createSourceMap;
|
||||||
|
|
||||||
|
private final String javaSourceMapBase;
|
||||||
|
|
||||||
private WasmOutputStream codeStream = new WasmOutputStream();
|
private WasmOutputStream codeStream = new WasmOutputStream();
|
||||||
|
|
||||||
private List<TypeEntry> functionTypes = new ArrayList<>();
|
private List<TypeEntry> functionTypes = new ArrayList<>();
|
||||||
@ -102,6 +104,7 @@ public class BinaryModuleWriter extends ModuleWriter implements InstructionOpcod
|
|||||||
this.target = target;
|
this.target = target;
|
||||||
// for now we build the source map together with debug names
|
// for now we build the source map together with debug names
|
||||||
createSourceMap = options.debugNames();
|
createSourceMap = options.debugNames();
|
||||||
|
javaSourceMapBase = options.getSourceMapBase();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -560,7 +563,7 @@ public class BinaryModuleWriter extends ModuleWriter implements InstructionOpcod
|
|||||||
protected void writeMethodStart( FunctionName name, String sourceFile ) throws IOException {
|
protected void writeMethodStart( FunctionName name, String sourceFile ) throws IOException {
|
||||||
if( createSourceMap ) {
|
if( createSourceMap ) {
|
||||||
int idx = name.className.lastIndexOf( '/' );
|
int idx = name.className.lastIndexOf( '/' );
|
||||||
this.javaSourceFile = name.className.substring( 0, idx + 1 ) + sourceFile;
|
this.javaSourceFile = javaSourceMapBase + name.className.substring( 0, idx + 1 ) + sourceFile;
|
||||||
}
|
}
|
||||||
codeStream.reset();
|
codeStream.reset();
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,8 @@ package de.inetsoftware.jwebassembly.wasm;
|
|||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
import de.inetsoftware.jwebassembly.JWebAssembly;
|
import de.inetsoftware.jwebassembly.JWebAssembly;
|
||||||
import de.inetsoftware.jwebassembly.module.FunctionName;
|
import de.inetsoftware.jwebassembly.module.FunctionName;
|
||||||
|
|
||||||
@ -31,6 +33,9 @@ public class WasmOptions {
|
|||||||
|
|
||||||
private final boolean useGC;
|
private final boolean useGC;
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
|
private final String sourceMapBase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* NonGC function for ref_eq polyfill.
|
* NonGC function for ref_eq polyfill.
|
||||||
*/
|
*/
|
||||||
@ -45,6 +50,11 @@ public class WasmOptions {
|
|||||||
public WasmOptions( HashMap<String, String> properties ) {
|
public WasmOptions( HashMap<String, String> properties ) {
|
||||||
debugNames = Boolean.parseBoolean( properties.get( JWebAssembly.DEBUG_NAMES ) );
|
debugNames = Boolean.parseBoolean( properties.get( JWebAssembly.DEBUG_NAMES ) );
|
||||||
useGC = Boolean.parseBoolean( properties.getOrDefault( JWebAssembly.WASM_USE_GC, "false" ) );
|
useGC = Boolean.parseBoolean( properties.getOrDefault( JWebAssembly.WASM_USE_GC, "false" ) );
|
||||||
|
String base = properties.getOrDefault( JWebAssembly.SOURCE_MAP_BASE, "" );
|
||||||
|
if( !base.isEmpty() && !base.endsWith( "/" ) ) {
|
||||||
|
base += "/";
|
||||||
|
}
|
||||||
|
sourceMapBase = base;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -64,4 +74,14 @@ public class WasmOptions {
|
|||||||
public boolean useGC() {
|
public boolean useGC() {
|
||||||
return useGC;
|
return useGC;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the relative path between the final wasm file location and the source files location.
|
||||||
|
* If not empty it should end with a slash like "../../src/main/java/".
|
||||||
|
* @return the path
|
||||||
|
*/
|
||||||
|
@Nonnull
|
||||||
|
public String getSourceMapBase() {
|
||||||
|
return sourceMapBase;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user