diff options
| author | 2018-11-14 14:06:20 +0100 | |
|---|---|---|
| committer | 2018-11-14 14:06:20 +0100 | |
| commit | c564b168785e740c37f47da4942825b25cb8b4ec (patch) | |
| tree | 880252c7a63bdc91f23ba5e13b593d4ca9ad8277 /build.zig | |
| parent | Zig fmt (diff) | |
| download | zig-clap-c564b168785e740c37f47da4942825b25cb8b4ec.tar.gz zig-clap-c564b168785e740c37f47da4942825b25cb8b4ec.tar.xz zig-clap-c564b168785e740c37f47da4942825b25cb8b4ec.zip | |
Restructured and make StreamingClap simpler
* Also added a ComptimeClap
Diffstat (limited to 'build.zig')
| -rw-r--r-- | build.zig | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/build.zig b/build.zig new file mode 100644 index 0000000..06c012b --- /dev/null +++ b/build.zig | |||
| @@ -0,0 +1,48 @@ | |||
| 1 | const builtin = @import("builtin"); | ||
| 2 | const std = @import("std"); | ||
| 3 | |||
| 4 | const Mode = builtin.Mode; | ||
| 5 | const Builder = std.build.Builder; | ||
| 6 | |||
| 7 | pub fn build(b: *Builder) void { | ||
| 8 | const mode = b.standardReleaseOptions(); | ||
| 9 | |||
| 10 | const example_step = b.step("examples", "Build examples"); | ||
| 11 | inline for ([][]const u8{ | ||
| 12 | "comptime-clap", | ||
| 13 | "streaming-clap", | ||
| 14 | }) |example_name| { | ||
| 15 | const example = b.addExecutable(example_name, "example/" ++ example_name ++ ".zig"); | ||
| 16 | example.addPackagePath("clap", "src/index.zig"); | ||
| 17 | example.setBuildMode(mode); | ||
| 18 | example_step.dependOn(&example.step); | ||
| 19 | } | ||
| 20 | |||
| 21 | const test_all_step = b.step("test", "Run all tests in all modes."); | ||
| 22 | inline for ([]Mode{ Mode.Debug, Mode.ReleaseFast, Mode.ReleaseSafe, Mode.ReleaseSmall }) |test_mode| { | ||
| 23 | const mode_str = comptime modeToString(test_mode); | ||
| 24 | |||
| 25 | const tests = b.addTest("src/index.zig"); | ||
| 26 | tests.setBuildMode(test_mode); | ||
| 27 | tests.setNamePrefix(mode_str ++ " "); | ||
| 28 | |||
| 29 | const test_step = b.step("test-" ++ mode_str, "Run all tests in " ++ mode_str ++ "."); | ||
| 30 | test_step.dependOn(&tests.step); | ||
| 31 | test_all_step.dependOn(test_step); | ||
| 32 | } | ||
| 33 | |||
| 34 | const all_step = b.step("all", "Build everything and runs all tests"); | ||
| 35 | all_step.dependOn(test_all_step); | ||
| 36 | all_step.dependOn(example_step); | ||
| 37 | |||
| 38 | b.default_step.dependOn(all_step); | ||
| 39 | } | ||
| 40 | |||
| 41 | fn modeToString(mode: Mode) []const u8 { | ||
| 42 | return switch (mode) { | ||
| 43 | Mode.Debug => "debug", | ||
| 44 | Mode.ReleaseFast => "release-fast", | ||
| 45 | Mode.ReleaseSafe => "release-safe", | ||
| 46 | Mode.ReleaseSmall => "release-small", | ||
| 47 | }; | ||
| 48 | } | ||