aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--README.md5
-rw-r--r--build.zig34
-rw-r--r--tool/znk.zig (renamed from src/znk.zig)2
3 files changed, 24 insertions, 17 deletions
diff --git a/README.md b/README.md
index 815b8f4..b4b81a2 100644
--- a/README.md
+++ b/README.md
@@ -11,9 +11,10 @@ Contains a tool called `znk` which is a clone of the [`nk` tool](https://github.
11 11
12Zig master works at the time of writing. 12Zig master works at the time of writing.
13 13
14Use `zig build` to build (the library and the `znk` tool). 14Use `zig build` to build the library.
15Use `zig build znk` to build the `znk` tool.
15 16
16The `znk` tool can be run by using `zig build run`. 17The `znk` tool can be run by using `zig build znk-run`.
17 18
18Tests for the library can be run by using `zig build test`. 19Tests for the library can be run by using `zig build test`.
19Tests for the `znk` tool can be run by using `zig build znk-test`. 20Tests for the `znk` tool can be run by using `zig build znk-test`.
diff --git a/build.zig b/build.zig
index 436cdf9..18f0b6f 100644
--- a/build.zig
+++ b/build.zig
@@ -22,28 +22,34 @@ pub fn build(b: *std.build.Builder) !void {
22 lib_tests.setBuildMode(mode); 22 lib_tests.setBuildMode(mode);
23 lib_tests.addBuildOption([:0]const u8, "version", try b.allocator.dupeZ(u8, version)); 23 lib_tests.addBuildOption([:0]const u8, "version", try b.allocator.dupeZ(u8, version));
24 24
25 var znk_tests = b.addTest("src/znk.zig");
26 znk_tests.setBuildMode(mode);
27 znk_tests.addBuildOption([:0]const u8, "version", try b.allocator.dupeZ(u8, version));
28
29 const test_step = b.step("test", "Run library tests"); 25 const test_step = b.step("test", "Run library tests");
30 test_step.dependOn(&lib_tests.step); 26 test_step.dependOn(&lib_tests.step);
31 27
28 var znk_tests = b.addTest("tool/znk.zig");
29 znk_tests.setBuildMode(mode);
30 znk_tests.addPackagePath("nkeys", "src/nkeys.zig");
31 znk_tests.addBuildOption([:0]const u8, "version", try b.allocator.dupeZ(u8, version));
32
32 const znk_test_step = b.step("znk-test", "Run znk tests"); 33 const znk_test_step = b.step("znk-test", "Run znk tests");
33 znk_test_step.dependOn(&znk_tests.step); 34 znk_test_step.dependOn(&znk_tests.step);
34 35
35 const exe = b.addExecutable("znk", "src/znk.zig"); 36 const znk = b.addExecutable("znk", "tool/znk.zig");
36 exe.setTarget(target); 37 znk.setTarget(target);
37 exe.setBuildMode(mode); 38 znk.setBuildMode(mode);
38 exe.addBuildOption([:0]const u8, "version", try b.allocator.dupeZ(u8, version)); 39 znk.addPackagePath("nkeys", "src/nkeys.zig");
39 exe.install(); 40 znk.addBuildOption([:0]const u8, "version", try b.allocator.dupeZ(u8, version));
41
42 const znk_install = b.addInstallArtifact(znk);
43
44 const znk_step = b.step("znk", "Build only znk");
45 znk_step.dependOn(&znk_install.step);
40 46
41 const run_cmd = exe.run(); 47 const znk_run_cmd = znk.run();
42 run_cmd.step.dependOn(b.getInstallStep()); 48 znk_run_cmd.step.dependOn(&znk_install.step);
43 if (b.args) |args| { 49 if (b.args) |args| {
44 run_cmd.addArgs(args); 50 znk_run_cmd.addArgs(args);
45 } 51 }
46 52
47 const run_step = b.step("run", "Run znk"); 53 const znk_run_step = b.step("znk-run", "Run znk");
48 run_step.dependOn(&run_cmd.step); 54 znk_run_step.dependOn(&znk_run_cmd.step);
49} 55}
diff --git a/src/znk.zig b/tool/znk.zig
index 8be7713..6097a09 100644
--- a/src/znk.zig
+++ b/tool/znk.zig
@@ -6,7 +6,7 @@ const builtin = std.builtin;
6const fs = std.fs; 6const fs = std.fs;
7const io = std.io; 7const io = std.io;
8const mem = std.mem; 8const mem = std.mem;
9const nkeys = @import("nkeys.zig"); 9const nkeys = @import("nkeys");
10const process = std.process; 10const process = std.process;
11const testing = std.testing; 11const testing = std.testing;
12 12