diff options
author | Rutger Broekhoff | 2023-11-01 16:48:02 +0100 |
---|---|---|
committer | Rutger Broekhoff | 2023-11-01 16:48:02 +0100 |
commit | e33788715ce08f9410290dcea9ca0ddb26692eed (patch) | |
tree | c64bce995bd38f89d855983caf929a98c5ffe825 /build.zig | |
parent | 04252bac0d7a9383f943337366d6a6631ce44e91 (diff) | |
download | zig-nkeys-e33788715ce08f9410290dcea9ca0ddb26692eed.tar.gz zig-nkeys-e33788715ce08f9410290dcea9ca0ddb26692eed.zip |
Update for Zig 0.11.0
Diffstat (limited to 'build.zig')
-rw-r--r-- | build.zig | 49 |
1 files changed, 32 insertions, 17 deletions
@@ -1,41 +1,56 @@ | |||
1 | const std = @import("std"); | 1 | const std = @import("std"); |
2 | 2 | ||
3 | pub fn build(b: *std.build.Builder) !void { | 3 | pub 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 | } |