diff options
Diffstat (limited to 'build.zig')
| -rw-r--r-- | build.zig | 18 |
1 files changed, 4 insertions, 14 deletions
| @@ -1,4 +1,3 @@ | |||
| 1 | const builtin = @import("builtin"); | ||
| 2 | const std = @import("std"); | 1 | const std = @import("std"); |
| 3 | 2 | ||
| 4 | const Builder = std.build.Builder; | 3 | const Builder = std.build.Builder; |
| @@ -9,13 +8,13 @@ pub fn build(b: *Builder) void { | |||
| 9 | const target = b.standardTargetOptions(.{}); | 8 | const target = b.standardTargetOptions(.{}); |
| 10 | 9 | ||
| 11 | const test_all_step = b.step("test", "Run all tests in all modes."); | 10 | const test_all_step = b.step("test", "Run all tests in all modes."); |
| 12 | inline for ([_]Mode{ Mode.Debug, Mode.ReleaseFast, Mode.ReleaseSafe, Mode.ReleaseSmall }) |test_mode| { | 11 | inline for (@typeInfo(std.builtin.Mode).Enum.fields) |field| { |
| 13 | const mode_str = comptime modeToString(test_mode); | 12 | const test_mode = @field(std.builtin.Mode, field.name); |
| 13 | const mode_str = @tagName(test_mode); | ||
| 14 | 14 | ||
| 15 | const tests = b.addTest("clap.zig"); | 15 | const tests = b.addTest("clap.zig"); |
| 16 | tests.setBuildMode(test_mode); | 16 | tests.setBuildMode(test_mode); |
| 17 | tests.setTarget(target); | 17 | tests.setTarget(target); |
| 18 | tests.setNamePrefix(mode_str ++ " "); | ||
| 19 | 18 | ||
| 20 | const test_step = b.step("test-" ++ mode_str, "Run all tests in " ++ mode_str ++ "."); | 19 | const test_step = b.step("test-" ++ mode_str, "Run all tests in " ++ mode_str ++ "."); |
| 21 | test_step.dependOn(&tests.step); | 20 | test_step.dependOn(&tests.step); |
| @@ -23,7 +22,7 @@ pub fn build(b: *Builder) void { | |||
| 23 | } | 22 | } |
| 24 | 23 | ||
| 25 | const example_step = b.step("examples", "Build examples"); | 24 | const example_step = b.step("examples", "Build examples"); |
| 26 | inline for ([_][]const u8{ | 25 | inline for (.{ |
| 27 | "simple", | 26 | "simple", |
| 28 | "simple-ex", | 27 | "simple-ex", |
| 29 | //"simple-error", | 28 | //"simple-error", |
| @@ -70,12 +69,3 @@ fn readMeStep(b: *Builder) *std.build.Step { | |||
| 70 | }.make); | 69 | }.make); |
| 71 | return s; | 70 | return s; |
| 72 | } | 71 | } |
| 73 | |||
| 74 | fn modeToString(mode: Mode) []const u8 { | ||
| 75 | return switch (mode) { | ||
| 76 | Mode.Debug => "debug", | ||
| 77 | Mode.ReleaseFast => "release-fast", | ||
| 78 | Mode.ReleaseSafe => "release-safe", | ||
| 79 | Mode.ReleaseSmall => "release-small", | ||
| 80 | }; | ||
| 81 | } | ||