diff options
author | Alon Zakai <alonzakai@gmail.com> | 2018-06-07 19:23:49 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-06-07 19:23:49 -0700 |
commit | 7676221b837bbd20daf1889dbdabf3cb76721658 (patch) | |
tree | 32f5721cdcf90cf0e4316fc2ba131549c8a90f8e /src/tools/wasm-opt.cpp | |
parent | 3af404435b3cfa90704810370703f20921c055dd (diff) | |
download | binaryen-7676221b837bbd20daf1889dbdabf3cb76721658.tar.gz binaryen-7676221b837bbd20daf1889dbdabf3cb76721658.tar.bz2 binaryen-7676221b837bbd20daf1889dbdabf3cb76721658.zip |
wasm-opt source map support (#1557)
* support source map input in wasm-opt, refactoring the loading code into wasm-io
* use wasm-io in wasm-as
* support output source maps in wasm-opt
* add a test for wasm-opt and source maps
Diffstat (limited to 'src/tools/wasm-opt.cpp')
-rw-r--r-- | src/tools/wasm-opt.cpp | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/src/tools/wasm-opt.cpp b/src/tools/wasm-opt.cpp index 7d7d44b2b..43496b34e 100644 --- a/src/tools/wasm-opt.cpp +++ b/src/tools/wasm-opt.cpp @@ -72,6 +72,9 @@ int main(int argc, const char* argv[]) { bool fuzzPasses = false; std::string emitJSWrapper; std::string emitSpecWrapper; + std::string inputSourceMapFilename; + std::string outputSourceMapFilename; + std::string outputSourceMapUrl; OptimizationOptions options("wasm-opt", "Read, write, and optimize files"); options @@ -111,6 +114,15 @@ int main(int argc, const char* argv[]) { .add("--emit-spec-wrapper", "-esw", "Emit a wasm spec interpreter wrapper file that can run the wasm with some test values, useful for fuzzing", Options::Arguments::One, [&](Options *o, const std::string& arguments) { emitSpecWrapper = arguments; }) + .add("--input-source-map", "-ism", "Consume source map from the specified file", + Options::Arguments::One, + [&inputSourceMapFilename](Options *o, const std::string& argument) { inputSourceMapFilename = argument; }) + .add("--output-source-map", "-osm", "Emit source map to the specified file", + Options::Arguments::One, + [&outputSourceMapFilename](Options *o, const std::string& argument) { outputSourceMapFilename = argument; }) + .add("--output-source-map-url", "-osu", "Emit specified string as source map URL", + Options::Arguments::One, + [&outputSourceMapUrl](Options *o, const std::string& argument) { outputSourceMapUrl = argument; }) .add_positional("INFILE", Options::Arguments::One, [](Options* o, const std::string& argument) { o->extra["infile"] = argument; @@ -128,7 +140,7 @@ int main(int argc, const char* argv[]) { ModuleReader reader; reader.setDebug(options.debug); try { - reader.read(options.extra["infile"], wasm); + reader.read(options.extra["infile"], wasm, inputSourceMapFilename); } catch (ParseException& p) { p.dump(std::cerr); std::cerr << '\n'; @@ -256,6 +268,10 @@ int main(int argc, const char* argv[]) { writer.setDebug(options.debug); writer.setBinary(emitBinary); writer.setDebugInfo(debugInfo); + if (outputSourceMapFilename.size()) { + writer.setSourceMapFilename(outputSourceMapFilename); + writer.setSourceMapUrl(outputSourceMapUrl); + } writer.write(*curr, options.extra["output"]); if (extraFuzzCommand.size() > 0) { |