master
 1const std = @import("std");
 2
 3pub fn build(b: *std.Build) void {
 4    const test_step = b.step("test", "Test the program");
 5    b.default_step = test_step;
 6
 7    const optimize: std.builtin.OptimizeMode = .Debug;
 8    const target = b.graph.host;
 9
10    const obj1 = b.addLibrary(.{
11        .linkage = .static,
12        .name = "obj1",
13        .root_module = b.createModule(.{
14            .root_source_file = b.path("obj1.zig"),
15            .optimize = optimize,
16            .target = target,
17        }),
18    });
19
20    const obj2 = b.addLibrary(.{
21        .linkage = .static,
22        .name = "obj2",
23        .root_module = b.createModule(.{
24            .root_source_file = b.path("obj2.zig"),
25            .optimize = optimize,
26            .target = target,
27        }),
28    });
29
30    const main_mod = b.createModule(.{
31        .root_source_file = b.path("main.zig"),
32        .target = b.graph.host,
33        .optimize = optimize,
34    });
35    main_mod.linkLibrary(obj1);
36    main_mod.linkLibrary(obj2);
37
38    const main = b.addTest(.{ .root_module = main_mod });
39    test_step.dependOn(&b.addRunArtifact(main).step);
40}