make things build
Signed-off-by: Xe Iaso <me@christine.website>
This commit is contained in:
parent
d497fbf302
commit
f47b8b1754
27
build.zig
27
build.zig
|
@ -1,30 +1,27 @@
|
|||
const std = @import("std");
|
||||
|
||||
pub fn build(b: *std.build.Builder) !void {
|
||||
pub fn build(b: *std.build.Builder) void {
|
||||
const mode = b.standardReleaseOptions();
|
||||
const lib = b.addSharedLibrary("cart", "src/main.zig", .unversioned);
|
||||
|
||||
const lib = b.addSharedLibrary("cart", "src/main.zig", .unversioned);
|
||||
lib.setBuildMode(mode);
|
||||
lib.setTarget(.{ .cpu_arch = .wasm32, .os_tag = .freestanding });
|
||||
lib.import_memory = true;
|
||||
lib.initial_memory = 65536;
|
||||
lib.max_memory = 65536;
|
||||
lib.stack_size = 14752;
|
||||
|
||||
// Export WASM-4 symbols
|
||||
lib.global_base = 6560;
|
||||
lib.stack_size = 8192;
|
||||
lib.export_symbol_names = &[_][]const u8{ "start", "update" };
|
||||
|
||||
lib.install();
|
||||
|
||||
const lib_artifact = b.addInstallArtifact(lib);
|
||||
|
||||
const run_cmd = b.addSystemCommand(&.{"w4", "run-native"});
|
||||
run_cmd.step.dependOn(&lib.step);
|
||||
run_cmd.addFileSourceArg(lib.getOutputSource());
|
||||
if (b.args) |args| {
|
||||
run_cmd.addArgs(args);
|
||||
}
|
||||
|
||||
const run_step = b.step("run", "Run Cartridge with w4");
|
||||
run_step.dependOn(&run_cmd.step);
|
||||
const run_command = b.addSystemCommand(&.{
|
||||
"w4", "run", "zig-out/lib/cart.wasm",
|
||||
"--no-open",
|
||||
});
|
||||
run_command.step.dependOn(&lib_artifact.step);
|
||||
|
||||
const run_step = b.step("run", "Run the app");
|
||||
run_step.dependOn(&run_command.step);
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
*.wasm
|
|
@ -0,0 +1,9 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
|
||||
mkdir -p dist
|
||||
rm -rf dist/*
|
||||
zig build -Drelease-small=true
|
||||
wasm-opt -Oz --zero-filled-memory --strip-producers --dce ./zig-out/lib/cart.wasm -o ./dist/tamamo.wasm
|
||||
wasm-strip ./dist/tamamo.wasm
|
|
@ -11,12 +11,14 @@ const smiley = [8]u8{
|
|||
0b11000011,
|
||||
};
|
||||
|
||||
export fn start() void {}
|
||||
|
||||
export fn update() void {
|
||||
w4.m.colors._0 = .p1;
|
||||
w4.text("Hello from Zig!", 10, 10);
|
||||
|
||||
const gamepad = w4.m.gamepads[0];
|
||||
if (gamepad.x) {
|
||||
if (gamepad.a) {
|
||||
w4.m.colors._0 = .p3;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue