Skip to content

Commit

Permalink
Merge pull request #2351 from peterhellberg/templates/zig/update-buil…
Browse files Browse the repository at this point in the history
…d-for-latest-0-12-0-dev

zig: Replace `addSharedLibrary` with `addExecutable`
  • Loading branch information
nesbox authored Nov 11, 2023
2 parents f265d1e + 9992edd commit a062e70
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
6 changes: 3 additions & 3 deletions templates/zig/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# ZIG Starter Project Template

This is a ZIG / TIC-80 starter template. To build it, ensure you have the latest stable Zig release (0.11) or the development release (0.12), then run:
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:

```
zig build -Doptimize=ReleaseSmall
Expand All @@ -9,14 +9,14 @@ zig build -Doptimize=ReleaseSmall
To import the resulting WASM to a cartridge:

```
tic80 --fs . --cmd 'load game.tic & import binary zig-out/lib/cart.wasm & save'
tic80 --fs . --cmd 'load game.tic & import binary zig-out/bin/cart.wasm & save'
```

Or from the TIC-80 console:

```
load game.tic
import binary zig-out/lib/cart.wasm
import binary zig-out/bin/cart.wasm
save
```

Expand Down
19 changes: 10 additions & 9 deletions templates/zig/build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,26 @@ const std = @import("std");
pub fn build(b: *std.Build) !void {
const optimize = b.standardOptimizeOption(.{});

const lib = b.addSharedLibrary(.{
const exe = b.addExecutable(.{
.name = "cart",
.root_source_file = .{ .path = "src/main.zig" },
.target = .{ .cpu_arch = .wasm32, .os_tag = .wasi },
.optimize = optimize,
});

lib.import_memory = true;
lib.stack_size = 8192;
lib.initial_memory = 65536 * 4;
lib.max_memory = 65536 * 4;
exe.entry = .disabled;
exe.import_memory = true;
exe.stack_size = 8192;
exe.initial_memory = 65536 * 4;
exe.max_memory = 65536 * 4;

lib.export_table = true;
exe.export_table = true;

// all the memory below 96kb is reserved for TIC and memory mapped I/O
// so our own usage must start above the 96kb mark
lib.global_base = 96 * 1024;
exe.global_base = 96 * 1024;

lib.export_symbol_names = &[_][]const u8{ "TIC", "OVR", "BDR", "BOOT" };
exe.export_symbol_names = &[_][]const u8{ "TIC", "OVR", "BDR", "BOOT" };

b.installArtifact(lib);
b.installArtifact(exe);
}

0 comments on commit a062e70

Please sign in to comment.