aboutsummaryrefslogtreecommitdiffstats
path: root/build.zig
diff options
context:
space:
mode:
Diffstat (limited to 'build.zig')
-rw-r--r--build.zig49
1 files changed, 32 insertions, 17 deletions
diff --git a/build.zig b/build.zig
index 412408b..947511b 100644
--- a/build.zig
+++ b/build.zig
@@ -1,41 +1,56 @@
1const std = @import("std"); 1const std = @import("std");
2 2
3pub fn build(b: *std.build.Builder) !void { 3pub fn build(b: *std.build.Builder) !void {
4 const mode = b.standardReleaseOptions();
5 const target = b.standardTargetOptions(.{}); 4 const target = b.standardTargetOptions(.{});
5 const optimize = b.standardOptimizeOption(.{});
6 6
7 const lib_tests = b.addTest("src/main.zig"); 7 const lib_tests = b.addTest(.{
8 lib_tests.setBuildMode(mode); 8 .root_source_file = .{ .path = "src/main.zig" },
9 .target = target,
10 .optimize = optimize,
11 });
12 const run_lib_tests = b.addRunArtifact(lib_tests);
9 13
10 const test_step = b.step("test", "Run library tests"); 14 const test_step = b.step("test", "Run library tests");
11 test_step.dependOn(&lib_tests.step); 15 test_step.dependOn(&run_lib_tests.step);
12 16
13 const znk_version = "0.2.1"; 17 const znk_version = "0.2.1";
14 18
15 const znk_options = b.addOptions(); 19 const znk_options = b.addOptions();
16 znk_options.addOption([]const u8, "version", znk_version); 20 znk_options.addOption([]const u8, "version", znk_version);
17 21
18 const znk_tests = b.addTest("tool/znk.zig"); 22 const nkeys_module = b.addModule("nkeys", .{
19 znk_tests.setBuildMode(mode); 23 .source_file = .{ .path = "src/main.zig" },
20 znk_tests.addPackagePath("nkeys", "src/main.zig"); 24 });
25
26 const znk_tests = b.addTest(.{
27 .root_source_file = .{ .path = "tool/znk.zig" },
28 .target = target,
29 .optimize = optimize,
30 });
31 znk_tests.addModule("nkeys", nkeys_module);
21 znk_tests.addOptions("build_options", znk_options); 32 znk_tests.addOptions("build_options", znk_options);
33 const run_znk_tests = b.addRunArtifact(znk_tests);
22 34
23 const znk_test_step = b.step("test-znk", "Run znk tests"); 35 const znk_test_step = b.step("test-znk", "Run znk tests");
24 znk_test_step.dependOn(&znk_tests.step); 36 znk_test_step.dependOn(&run_znk_tests.step);
25 37
26 const znk = b.addExecutable("znk", "tool/znk.zig"); 38 const znk = b.addExecutable(.{
27 znk.setBuildMode(mode); 39 .name = "znk",
28 znk.setTarget(target); 40 .root_source_file = .{ .path = "tool/znk.zig" },
29 znk.addPackagePath("nkeys", "src/main.zig"); 41 .target = target,
42 .optimize = optimize,
43 });
44 znk.addModule("nkeys", nkeys_module);
30 znk.addOptions("build_options", znk_options); 45 znk.addOptions("build_options", znk_options);
31 46
32 const znk_install = b.addInstallArtifact(znk); 47 b.installArtifact(znk);
33 48
34 const znk_step = b.step("znk", "Build znk"); 49 const znk_step = b.step("znk", "Build znk");
35 znk_step.dependOn(&znk_install.step); 50 znk_step.dependOn(b.getInstallStep());
36 51
37 const znk_run_cmd = znk.run(); 52 const znk_run_cmd = b.addRunArtifact(znk);
38 znk_run_cmd.step.dependOn(&znk_install.step); 53 znk_run_cmd.step.dependOn(b.getInstallStep());
39 if (b.args) |args| { 54 if (b.args) |args| {
40 znk_run_cmd.addArgs(args); 55 znk_run_cmd.addArgs(args);
41 } 56 }