Composability lets simple, interchangeable software parts combine through well-defined interactions. In Zig, this is presented as a key to scaling beyond a small set of core tools. section 2.1.5
Zig build steps show how composability turns small tasks into a useful workflow:
- A step can compile code, run a command, or format source files. section 6.3.1
- Steps can depend on earlier steps: compile tests, run them, then connect the runner to a `test` command. section 6.3.1
Listing 6.3 Making new steps
pub fn build(b: *std.Build) void {
// ... module code ...
const tests = b.addTest(.{ #1
.root_module = test_mod,
});
const run_tests = b.addRunArtifact(tests); #2
const test_cmd = b.step("test", "Run the vm tests"); #3
test_cmd.dependOn(&run_tests.step); #4
}
The build script connects test compilation and execution to a single command. section 6.3.1




