builder: keep wasm temporary files

Don't rename them when -work is set, instead update result.Binary each
time and leave result.Executable be the linker output (as intended:
result.Executable should be the unmodified linker output).
This commit is contained in:
Ayke van Laethem
2024-10-03 16:32:01 +02:00
committed by Ron Evans
parent 9d14489547
commit 666d2bd501
+12 -14
View File
@@ -823,19 +823,13 @@ func Build(pkgName, outpath, tmpdir string, config *compileopts.Config) (BuildRe
args = append(args, "--asyncify") args = append(args, "--asyncify")
} }
exeunopt := result.Executable inputFile := result.Binary
result.Binary = result.Executable + ".wasmopt"
if config.Options.Work {
// Keep the work direction around => don't overwrite the .wasm binary with the optimized version
exeunopt += ".pre-wasm-opt"
os.Rename(result.Executable, exeunopt)
}
args = append(args, args = append(args,
opt, opt,
"-g", "-g",
exeunopt, inputFile,
"--output", result.Executable, "--output", result.Binary,
) )
wasmopt := goenv.Get("WASMOPT") wasmopt := goenv.Get("WASMOPT")
@@ -865,13 +859,15 @@ func Build(pkgName, outpath, tmpdir string, config *compileopts.Config) (BuildRe
// wasm-tools component embed -w wasi:cli/command // wasm-tools component embed -w wasi:cli/command
// $$(tinygo env TINYGOROOT)/lib/wasi-cli/wit/ main.wasm -o embedded.wasm // $$(tinygo env TINYGOROOT)/lib/wasi-cli/wit/ main.wasm -o embedded.wasm
componentEmbedInputFile := result.Binary
result.Binary = result.Executable + ".wasm-component-embed"
args := []string{ args := []string{
"component", "component",
"embed", "embed",
"-w", witWorld, "-w", witWorld,
witPackage, witPackage,
result.Executable, componentEmbedInputFile,
"-o", result.Executable, "-o", result.Binary,
} }
wasmtools := goenv.Get("WASMTOOLS") wasmtools := goenv.Get("WASMTOOLS")
@@ -888,11 +884,13 @@ func Build(pkgName, outpath, tmpdir string, config *compileopts.Config) (BuildRe
} }
// wasm-tools component new embedded.wasm -o component.wasm // wasm-tools component new embedded.wasm -o component.wasm
componentNewInputFile := result.Binary
result.Binary = result.Executable + ".wasm-component-new"
args = []string{ args = []string{
"component", "component",
"new", "new",
result.Executable, componentNewInputFile,
"-o", result.Executable, "-o", result.Binary,
} }
if config.Options.PrintCommands != nil { if config.Options.PrintCommands != nil {