this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Update build.zig (#2460)

* Update zig template

* Update

authored by

Pixeller and committed by
GitHub
fd02c6f8 f4578a2f

+43 -40
+4 -4
demos/bunny/wasmmark/README.md
··· 1 1 # Bunnymark in Zig / WASM 2 2 3 - This is a Zig project. To build it you'll need Zig 0.9 or 0.10. 3 + This is a Zig project. To build it you'll need Zig 0.12 or newer. 4 4 5 5 ### Building 6 6 7 7 ``` 8 - zig build 8 + zig build --release=small 9 9 ``` 10 10 11 11 ### Replacing the assets used to build TIC-80 ··· 13 13 Copy the build over the canonical WASM file: 14 14 15 15 ``` 16 - cp zig-out/lib/cart.wasm wasmmark.wasm 16 + cp zig-out/bin/cart.wasm wasmmark.wasm 17 17 ``` 18 18 19 - During a TIC-80 build the `wasm` and `wasmp` file will be merged into a single demo cartridge and embedded into the TIC-80 binary. 19 + During a TIC-80 build the `wasm` and `wasmp` file will be merged into a single demo cartridge and embedded into the TIC-80 binary.
+12 -13
demos/bunny/wasmmark/build.zig
··· 2 2 3 3 pub fn build(b: *std.Build) !void { 4 4 const optimize = b.standardOptimizeOption(.{}); 5 - 6 - const lib = b.addSharedLibrary(.{ 5 + const target = b.resolveTargetQuery(.{ .cpu_arch = .wasm32, .os_tag = .freestanding }); 6 + const exe = b.addExecutable(.{ 7 7 .name = "cart", 8 8 .root_source_file = .{ .path = "src/main.zig" }, 9 - .target = .{ .cpu_arch = .wasm32, .os_tag = .wasi }, 9 + .target = target, 10 10 .optimize = optimize, 11 11 }); 12 12 13 - lib.import_memory = true; 14 - lib.stack_size = 8192; 15 - lib.initial_memory = 65536 * 4; 16 - lib.max_memory = 65536 * 4; 17 - 18 - lib.export_table = true; 13 + exe.rdynamic = true; 14 + exe.entry = .disabled; 15 + exe.import_memory = true; 16 + exe.stack_size = 8192; 17 + exe.initial_memory = 65536 * 4; 18 + exe.max_memory = 65536 * 4; 19 + exe.export_table = true; 19 20 20 21 // all the memory below 96kb is reserved for TIC and memory mapped I/O 21 22 // so our own usage must start above the 96kb mark 22 - lib.global_base = 96 * 1024; 23 - 24 - lib.export_symbol_names = &[_][]const u8{ "TIC", "OVR", "BDR", "BOOT" }; 23 + exe.global_base = 96 * 1024; 25 24 26 - b.installArtifact(lib); 25 + b.installArtifact(exe); 27 26 }
+12 -13
demos/wasm/build.zig
··· 2 2 3 3 pub fn build(b: *std.Build) !void { 4 4 const optimize = b.standardOptimizeOption(.{}); 5 - 6 - const lib = b.addSharedLibrary(.{ 5 + const target = b.resolveTargetQuery(.{ .cpu_arch = .wasm32, .os_tag = .freestanding }); 6 + const exe = b.addExecutable(.{ 7 7 .name = "cart", 8 8 .root_source_file = .{ .path = "src/main.zig" }, 9 - .target = .{ .cpu_arch = .wasm32, .os_tag = .wasi }, 9 + .target = target, 10 10 .optimize = optimize, 11 11 }); 12 12 13 - lib.import_memory = true; 14 - lib.stack_size = 8192; 15 - lib.initial_memory = 65536 * 4; 16 - lib.max_memory = 65536 * 4; 17 - 18 - lib.export_table = true; 13 + exe.rdynamic = true; 14 + exe.entry = .disabled; 15 + exe.import_memory = true; 16 + exe.stack_size = 8192; 17 + exe.initial_memory = 65536 * 4; 18 + exe.max_memory = 65536 * 4; 19 + exe.export_table = true; 19 20 20 21 // all the memory below 96kb is reserved for TIC and memory mapped I/O 21 22 // so our own usage must start above the 96kb mark 22 - lib.global_base = 96 * 1024; 23 - 24 - lib.export_symbol_names = &[_][]const u8{ "TIC", "OVR", "BDR", "BOOT" }; 23 + exe.global_base = 96 * 1024; 25 24 26 - b.installArtifact(lib); 25 + b.installArtifact(exe); 27 26 }
+11 -5
templates/zig/README.md
··· 1 1 # ZIG Starter Project Template 2 2 3 - This is a ZIG / TIC-80 starter template. To build it, ensure you have the latest development release (`0.12.0-dev.1482+e74ced21b` or newer), then run: 3 + This is a ZIG / TIC-80 starter template. To build it, ensure you have the latest development release (`0.12.0-dev.2727+fad5e7a99` or newer), then run: 4 4 5 5 ``` 6 - zig build -Doptimize=ReleaseSmall 6 + zig build --release=small 7 7 ``` 8 8 9 9 To import the resulting WASM to a cartridge: 10 10 11 11 ``` 12 - tic80 --fs . --cmd 'load game.tic & import binary zig-out/bin/cart.wasm & save' 12 + tic80 --fs . --cmd 'load cart.wasmp & import binary zig-out/bin/cart.wasm & save' 13 13 ``` 14 14 15 15 Or from the TIC-80 console: 16 16 17 17 ``` 18 - load game.tic 19 - import binary zig-out/bin/cart.wasm 18 + tic80 --fs . 19 + 20 + load zig-out/bin/cart.wasmp 21 + import binary cart.wasm 20 22 save 21 23 ``` 22 24 23 25 This is assuming you've run TIC-80 with `--fs .` inside your project directory. 24 26 27 + Or easy call it :) 28 + ```zsh 29 + sh run.sh 30 + ```
+3 -5
templates/zig/build.zig
··· 2 2 3 3 pub fn build(b: *std.Build) !void { 4 4 const optimize = b.standardOptimizeOption(.{}); 5 - 5 + const target = b.resolveTargetQuery(.{ .cpu_arch = .wasm32, .os_tag = .freestanding }); 6 6 const exe = b.addExecutable(.{ 7 7 .name = "cart", 8 8 .root_source_file = .{ .path = "src/main.zig" }, 9 - .target = .{ .cpu_arch = .wasm32, .os_tag = .wasi }, 9 + .target = target, 10 10 .optimize = optimize, 11 11 }); 12 12 13 + exe.rdynamic = true; 13 14 exe.entry = .disabled; 14 15 exe.import_memory = true; 15 16 exe.stack_size = 8192; 16 17 exe.initial_memory = 65536 * 4; 17 18 exe.max_memory = 65536 * 4; 18 - 19 19 exe.export_table = true; 20 20 21 21 // all the memory below 96kb is reserved for TIC and memory mapped I/O 22 22 // so our own usage must start above the 96kb mark 23 23 exe.global_base = 96 * 1024; 24 - 25 - exe.export_symbol_names = &[_][]const u8{ "TIC", "OVR", "BDR", "BOOT" }; 26 24 27 25 b.installArtifact(exe); 28 26 }
+1
templates/zig/run.sh
··· 1 + tic80 --skip --fs . --cmd 'load cart.wasmp & import binary zig-out/bin/cart.wasm & save & run'
templates/zig/wasmdemo.wasm

This is a binary file and will not be displayed.

templates/zig/wasmdemo.wasmp templates/zig/cart.wasmp