Zig Recipes¶
must provides two Zig recipe types: zig-bin and zig-test.
Quick start¶
Project structure:
build.zig.zon:
src/main.zig:
const std = @import("std");
pub fn main() !void {
std.debug.print("Hello from {s}!\n", .{"myapp"});
}
Mustfile.toml:
[project]
name = "myapp"
version = "0.1.0"
[recipe.build]
type = "zig-bin"
package = "myapp"
[recipe.test]
type = "zig-test"
package = "."
deps = ["build"]
Build:
Test:
$ must test
[build] zig build myapp -Doptimize=ReleaseSafe
[build] cached
[test] zig build test
[test] All 1 tests passed.
[test] done 0.4s
zig-bin — Build a binary¶
Runs: zig build myapp -Doptimize=ReleaseSafe
Cache key includes: package, env vars.
zig-test — Run tests¶
Runs: zig build test
Cache strategy: never (test results should always be fresh).
Fields¶
| Field | Type | Applies to | Description |
|---|---|---|---|
package |
string | bin | Build step name |
deps |
string[] | all | Dependencies |
env |
map | all | Environment variables |
All recipes also support these common fields: deps, env, cache ("hash" / "mtime" / "none"), phony (always re-run).
Examples¶
[project]
name = "my-zig-project"
[recipe.build]
type = "zig-bin"
package = "myapp"
[recipe.test]
type = "zig-test"
package = "."
deps = ["build"]
See also¶
- Caching — how cache keys are computed
- Cross-Compilation — Zig cross-compilation
- Config Reference — full field reference