Evgenii Akentev
·
2025-10-17
build.zig
1const std = @import("std");
2
3pub fn build(b: *std.Build) void {
4 const target = b.standardTargetOptions(.{});
5 const optimize = b.standardOptimizeOption(.{});
6
7 const libpunycode = b.addLibrary(.{
8 .name = "punycode",
9 .linkage = .static,
10 .root_module = b.createModule(.{
11 .root_source_file = b.path("src/punycode.zig"),
12 .target = target,
13 .optimize = optimize,
14 }),
15 });
16
17 b.installArtifact(libpunycode);
18
19 // Creates an executable that will run `test` blocks from the provided module.
20 // Here `mod` needs to define a target, which is why earlier we made sure to
21 // set the releative field.
22 const mod_tests = b.addTest(.{
23 .root_module = libpunycode.root_module,
24 });
25
26 // A run step that will run the test executable.
27 const run_mod_tests = b.addRunArtifact(mod_tests);
28
29 // A top level step for running all tests. dependOn can be called multiple
30 // times and since the two run steps do not depend on one another, this will
31 // make the two of them run in parallel.
32 const test_step = b.step("test", "Run tests");
33 test_step.dependOn(&run_mod_tests.step);
34
35 // Just like flags, top level steps are also listed in the `--help` menu.
36 //
37 // The Zig build system is entirely implemented in userland, which means
38 // that it cannot hook into private compiler APIs. All compilation work
39 // orchestrated by the build system will result in other Zig compiler
40 // subcommands being invoked with the right flags defined. You can observe
41 // these invocations when one fails (or you pass a flag to increase
42 // verbosity) to validate assumptions and diagnose problems.
43 //
44 // Lastly, the Zig build system is relatively simple and self-contained,
45 // and reading its source code will allow you to master it.
46}