Add opt build step
parent
b1b25753a3
commit
105d7d3395
18
build.zig
18
build.zig
|
@ -72,4 +72,22 @@ pub fn build(b: *std.build.Builder) !void {
|
|||
// prevents them from being removed even if unused.
|
||||
lib.export_symbol_names = &[_][]const u8{ "start", "update" };
|
||||
lib.install();
|
||||
|
||||
const prefix = b.getInstallPath(.lib, "");
|
||||
const opt = b.addSystemCommand(&[_][]const u8{
|
||||
"wasm-opt",
|
||||
"-Oz",
|
||||
"--strip-debug",
|
||||
"--strip-producers",
|
||||
"--zero-filled-memory",
|
||||
});
|
||||
|
||||
opt.addArtifactArg(lib);
|
||||
const optout = try std.fs.path.join(b.allocator, &.{ prefix, "opt.wasm" });
|
||||
defer b.allocator.free(optout);
|
||||
opt.addArgs(&.{ "--output", optout });
|
||||
|
||||
const opt_step = b.step("opt", "Run wasm-opt on cart.wasm, producing opt.wasm");
|
||||
opt_step.dependOn(&lib.step);
|
||||
opt_step.dependOn(&opt.step);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue