diff options
author | Rutger Broekhoff | 2021-05-25 20:32:42 +0200 |
---|---|---|
committer | Rutger Broekhoff | 2021-05-25 20:32:42 +0200 |
commit | 5fc11d694ad86bdb08fe61a3007aa0c44ba894aa (patch) | |
tree | 216c08cdbcfc28e0886c85c4568a36cae2c9aa57 | |
parent | 3b6b7b5eefe6270f126048d7a1ff5919f1da18cf (diff) | |
download | zig-nkeys-5fc11d694ad86bdb08fe61a3007aa0c44ba894aa.tar.gz zig-nkeys-5fc11d694ad86bdb08fe61a3007aa0c44ba894aa.zip |
Put the znk tool into a different directory
-rw-r--r-- | README.md | 5 | ||||
-rw-r--r-- | build.zig | 34 | ||||
-rw-r--r-- | tool/znk.zig (renamed from src/znk.zig) | 2 |
3 files changed, 24 insertions, 17 deletions
@@ -11,9 +11,10 @@ Contains a tool called `znk` which is a clone of the [`nk` tool](https://github. | |||
11 | 11 | ||
12 | Zig master works at the time of writing. | 12 | Zig master works at the time of writing. |
13 | 13 | ||
14 | Use `zig build` to build (the library and the `znk` tool). | 14 | Use `zig build` to build the library. |
15 | Use `zig build znk` to build the `znk` tool. | ||
15 | 16 | ||
16 | The `znk` tool can be run by using `zig build run`. | 17 | The `znk` tool can be run by using `zig build znk-run`. |
17 | 18 | ||
18 | Tests for the library can be run by using `zig build test`. | 19 | Tests for the library can be run by using `zig build test`. |
19 | Tests for the `znk` tool can be run by using `zig build znk-test`. | 20 | Tests for the `znk` tool can be run by using `zig build znk-test`. |
@@ -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; | |||
6 | const fs = std.fs; | 6 | const fs = std.fs; |
7 | const io = std.io; | 7 | const io = std.io; |
8 | const mem = std.mem; | 8 | const mem = std.mem; |
9 | const nkeys = @import("nkeys.zig"); | 9 | const nkeys = @import("nkeys"); |
10 | const process = std.process; | 10 | const process = std.process; |
11 | const testing = std.testing; | 11 | const testing = std.testing; |
12 | 12 | ||