Last active
November 7, 2023 09:37
-
-
Save peterhellberg/30f63ad493b4695ef7ef84f4dde93b12 to your computer and use it in GitHub Desktop.
Updated build.zig to use with MicroW8 (requires Zig ⚡ 0.12.0-dev.1482+e74ced21b or later)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const std = @import("std"); | |
pub fn build(b: *std.Build) void { | |
const exe = b.addExecutable(.{ | |
.name = "cart", | |
.root_source_file = .{ .path = "src/main.zig" }, | |
.target = .{ | |
.cpu_arch = .wasm32, | |
.os_tag = .freestanding, | |
.cpu_features_add = std.Target.wasm.featureSet(&.{.nontrapping_fptoint}), | |
}, | |
.optimize = b.standardOptimizeOption(.{ .preferred_optimize_mode = .ReleaseSmall }), | |
}); | |
exe.entry = .disabled; | |
exe.export_symbol_names = &[_][]const u8{"upd"}; | |
exe.global_base = 81920; | |
exe.import_memory = true; | |
exe.initial_memory = 262144; | |
exe.max_memory = 262144; | |
exe.stack_size = 8192; | |
const run_filter_exports = b.addSystemCommand(&[_][]const u8{ "uw8", "filter-exports", "zig-out/bin/cart.wasm", "zig-out/bin/cart-filtered.wasm" }); | |
run_filter_exports.step.dependOn(b.getInstallStep()); | |
const run_wasm_opt = b.addSystemCommand(&[_][]const u8{ "wasm-opt", "-Oz", "-o", "zig-out/cart.wasm", "zig-out/bin/cart-filtered.wasm" }); | |
run_wasm_opt.step.dependOn(&run_filter_exports.step); | |
const run_uw8_pack = b.addSystemCommand(&[_][]const u8{ "uw8", "pack", "-l", "9", "zig-out/cart.wasm", "zig-out/cart.uw8" }); | |
run_uw8_pack.step.dependOn(&run_wasm_opt.step); | |
const make_opt = b.step("make_opt", "make size optimized cart"); | |
make_opt.dependOn(&run_uw8_pack.step); | |
b.default_step = make_opt; | |
b.installArtifact(exe); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
MicroW8
The current build.zig for the microw8 example written in Zig is quite out of date with the latest version of Zig ⚡
So I had to make some changes in order to be able to build carts (both
.wasm
and.uw8
)