Zig rules
The Zig family compiles Zig programs and runs their tests on the farm with a pinned Zig. buildrules uses it for its own command line and tools.
Load from @buildrules//rules/zig:zig.bzl.
| Rule | Key arguments | What it does |
|---|---|---|
zig_exe | src, imports, deps, target, optimize, strip, unit_tests | builds an executable; the default is a static musl executable in ReleaseSafe, stripped |
zig_test | src, imports, deps, target, optimize, data, env_tools | runs zig test as a build action; the result exists only if the tests passed |
zig_module | src, imports, deps, unit_tests | a module other targets import by its target name |
zig_dist | archive, strip_prefix, sha256, size_bytes, max_output | unpacks a pinned Zig release with the pinned unpack, which checks the archive's sha256 and size first and refuses one that decompresses to more than max_output bytes |
Tests are welded #
Pass zig_test targets to unit_tests. Their results are inputs of the executable or module, so the executable is not built unless its tests passed.
BUCK
load("@buildrules//rules/zig:zig.bzl", "zig_exe", "zig_test")
zig_test(name = "tool_test", src = "tool_test.zig", imports = ["tool.zig"])
zig_exe(name = "tool", src = "main.zig", imports = ["tool.zig"], unit_tests = [":tool_test"])Modules #
A zig_module's import name is its target name. Two different modules reached under one name fail the build, and root, std and builtin are reserved.
Note. Every action runs under a pinned busybox and a pinned Zig. There is no
PATH, and the compiler cache directories live in the action's scratch space.Limit. Linux x86_64 execution only.