diff options
Diffstat (limited to 'build.zig')
-rw-r--r-- | build.zig | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/build.zig b/build.zig new file mode 100644 index 0000000..3053d64 --- /dev/null +++ b/build.zig | |||
@@ -0,0 +1,49 @@ | |||
1 | const std = @import("std"); | ||
2 | |||
3 | pub fn build(b: *std.build.Builder) !void { | ||
4 | // Standard target options allows the person running `zig build` to choose | ||
5 | // what target to build for. Here we do not override the defaults, which | ||
6 | // means any target is allowed, and the default is native. Other options | ||
7 | // for restricting supported target set are available. | ||
8 | const target = b.standardTargetOptions(.{}); | ||
9 | |||
10 | // Standard release options allow the person running `zig build` to select | ||
11 | // between Debug, ReleaseSafe, ReleaseFast, and ReleaseSmall. | ||
12 | const mode = b.standardReleaseOptions(); | ||
13 | |||
14 | const version = "0.1.0-dev"; | ||
15 | |||
16 | const lib = b.addStaticLibrary("zats", "src/main.zig"); | ||
17 | lib.setBuildMode(mode); | ||
18 | lib.addBuildOption([:0]const u8, "version", try b.allocator.dupeZ(u8, version)); | ||
19 | lib.install(); | ||
20 | |||
21 | var main_tests = b.addTest("src/nkeys.zig"); | ||
22 | main_tests.setBuildMode(mode); | ||
23 | main_tests.addBuildOption([:0]const u8, "version", try b.allocator.dupeZ(u8, version)); | ||
24 | |||
25 | var znk_tests = b.addTest("src/znk.zig"); | ||
26 | main_tests.setBuildMode(mode); | ||
27 | main_tests.addBuildOption([:0]const u8, "version", try b.allocator.dupeZ(u8, version)); | ||
28 | |||
29 | const test_step = b.step("test", "Run library tests"); | ||
30 | test_step.dependOn(&main_tests.step); | ||
31 | |||
32 | const znk_test_step = b.step("znk-test", "Run znk tests"); | ||
33 | znk_test_step.dependOn(&znk_tests.step); | ||
34 | |||
35 | const exe = b.addExecutable("znk", "src/znk.zig"); | ||
36 | exe.setTarget(target); | ||
37 | exe.setBuildMode(mode); | ||
38 | exe.addBuildOption([:0]const u8, "version", try b.allocator.dupeZ(u8, version)); | ||
39 | exe.install(); | ||
40 | |||
41 | const run_cmd = exe.run(); | ||
42 | run_cmd.step.dependOn(b.getInstallStep()); | ||
43 | if (b.args) |args| { | ||
44 | run_cmd.addArgs(args); | ||
45 | } | ||
46 | |||
47 | const run_step = b.step("run", "Run znk"); | ||
48 | run_step.dependOn(&run_cmd.step); | ||
49 | } | ||