mirror of
https://codeberg.org/ziglang/zig.git
synced 2025-12-06 13:54:21 +00:00
build.zig: use Step.UpdateSourceFiles for zig1.wasm
We were already using this for `stage1/zig.h`, but `stage1/zig1.wasm` was being modified directly by the `wasm-opt` command. That's a bad idea because it forces the build system to assume that `wasm-opt` has side effects, so it is re-run every time you run `zig build update-zig1`, i.e. it does not interact with the cache system correctly. It is much better to create non-side-effecting `Run` steps (using `addOutput*Arg`) where possible so that the build system has a more correct understanding of the step graph.
This commit is contained in:
parent
bc78d8efdb
commit
cd8fdd252d
1 changed files with 5 additions and 5 deletions
10
build.zig
10
build.zig
|
|
@ -678,14 +678,14 @@ fn addWasiUpdateStep(b: *std.Build, version: [:0]const u8) !void {
|
||||||
});
|
});
|
||||||
run_opt.addArtifactArg(exe);
|
run_opt.addArtifactArg(exe);
|
||||||
run_opt.addArg("-o");
|
run_opt.addArg("-o");
|
||||||
run_opt.addFileArg(b.path("stage1/zig1.wasm"));
|
const optimized_wasm = run_opt.addOutputFileArg("zig1.wasm");
|
||||||
|
|
||||||
const copy_zig_h = b.addUpdateSourceFiles();
|
const update_zig1 = b.addUpdateSourceFiles();
|
||||||
copy_zig_h.addCopyFileToSource(b.path("lib/zig.h"), "stage1/zig.h");
|
update_zig1.addCopyFileToSource(optimized_wasm, "stage1/zig1.wasm");
|
||||||
|
update_zig1.addCopyFileToSource(b.path("lib/zig.h"), "stage1/zig.h");
|
||||||
|
|
||||||
const update_zig1_step = b.step("update-zig1", "Update stage1/zig1.wasm");
|
const update_zig1_step = b.step("update-zig1", "Update stage1/zig1.wasm");
|
||||||
update_zig1_step.dependOn(&run_opt.step);
|
update_zig1_step.dependOn(&update_zig1.step);
|
||||||
update_zig1_step.dependOn(©_zig_h.step);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const AddCompilerModOptions = struct {
|
const AddCompilerModOptions = struct {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue