mirror of
https://github.com/i-net-software/JWebAssembly.git
synced 2025-03-25 07:27:52 +01:00
write sourceMappingURL custom section
This commit is contained in:
parent
40fdbaffc5
commit
dd9eb4b049
@ -125,6 +125,7 @@ public class BinaryModuleWriter extends ModuleWriter implements InstructionOpcod
|
|||||||
writeExportSection();
|
writeExportSection();
|
||||||
writeCodeSection();
|
writeCodeSection();
|
||||||
writeDebugNames();
|
writeDebugNames();
|
||||||
|
writeSourceMappingUrl();
|
||||||
writeProducersSection();
|
writeProducersSection();
|
||||||
|
|
||||||
wasm.close();
|
wasm.close();
|
||||||
@ -272,6 +273,26 @@ public class BinaryModuleWriter extends ModuleWriter implements InstructionOpcod
|
|||||||
wasm.writeSection( SectionType.Custom, stream );
|
wasm.writeSection( SectionType.Custom, stream );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Write the source mapping url
|
||||||
|
*
|
||||||
|
* @throws IOException
|
||||||
|
* if any I/O error occur
|
||||||
|
*/
|
||||||
|
private void writeSourceMappingUrl() throws IOException {
|
||||||
|
if( !createSourceMap ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
String url = target.getSourceMappingURL();
|
||||||
|
if( url == null ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
WasmOutputStream stream = new WasmOutputStream();
|
||||||
|
stream.writeString( "sourceMappingURL" ); // Custom Section name "sourceMappingURL", content is part of the section length
|
||||||
|
stream.writeString( url );
|
||||||
|
wasm.writeSection( SectionType.Custom, stream );
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Write producer information to wasm
|
* Write producer information to wasm
|
||||||
*
|
*
|
||||||
|
@ -73,6 +73,19 @@ public class WasmTarget implements Closeable {
|
|||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the URL for the source mapping that should be write into the assembly.
|
||||||
|
*
|
||||||
|
* @return the URL string or null.
|
||||||
|
*/
|
||||||
|
@Nonnull
|
||||||
|
public String getSourceMappingURL() {
|
||||||
|
if( file != null ) {
|
||||||
|
return file.getName() + ".map";
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the source map OutputStream
|
* Get the source map OutputStream
|
||||||
*
|
*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user