Repository navigation
Expand file tree
/
Copy pathbuild.zig
More file actions
56 lines (45 loc) · 1.6 KB
/
Copy pathbuild.zig
File metadata and controls
56 lines (45 loc) · 1.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
const std = @import("std");
pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
const argonaut_module = b.addModule("argonaut", .{
.root_source_file = b.path("src/main.zig"),
.target = target,
.optimize = optimize,
});
const lib = b.addLibrary(.{
.name = "argonaut",
.root_module = argonaut_module,
.linkage = .static,
});
b.installArtifact(lib);
const main_tests = b.addTest(.{
.root_module = argonaut_module,
});
const run_tests = b.addRunArtifact(main_tests);
const test_step = b.step("test", "Run library tests");
test_step.dependOn(&run_tests.step);
const examples = .{
.{ "example-basic", "examples/basic.zig" },
.{ "example-subcommands", "examples/subcommands.zig" },
.{ "example-advanced", "examples/advanced.zig" },
.{ "example-nested", "examples/nested_subcommands.zig" },
};
inline for (examples) |ex| {
const example_module = b.addModule(ex[0], .{
.root_source_file = b.path(ex[1]),
.target = target,
.optimize = optimize,
});
const exe = b.addExecutable(.{
.name = ex[0],
.root_module = example_module,
});
exe.root_module.addImport("argonaut", argonaut_module);
b.installArtifact(exe);
const run = b.addRunArtifact(exe);
if (b.args) |args| run.addArgs(args);
const step = b.step(ex[0], "Run " ++ ex[0]);
step.dependOn(&run.step);
}
}