diff options
| author | 2024-07-04 08:32:41 +0800 | |
|---|---|---|
| committer | 2024-07-05 09:00:05 +0200 | |
| commit | d71cc39a94f3e6ccbad00c25d350c9147de4df9f (patch) | |
| tree | a0d3788a7f56399c97ac19c95b8c3f1d02c9dfe9 | |
| parent | Update to latest zig (diff) | |
| download | zig-clap-d71cc39a94f3e6ccbad00c25d350c9147de4df9f.tar.gz zig-clap-d71cc39a94f3e6ccbad00c25d350c9147de4df9f.tar.xz zig-clap-d71cc39a94f3e6ccbad00c25d350c9147de4df9f.zip | |
Add compatibility code between zig 0.12 and 0.130.9.1release-0.9.1
The newest version of zig-clap can easily support both 0.12 and 0.13 zig
versions with just a few lines of code
| -rw-r--r-- | .gitignore | 1 | ||||
| -rw-r--r-- | build.zig | 7 |
2 files changed, 7 insertions, 1 deletions
| @@ -1,2 +1,3 @@ | |||
| 1 | .zig-cache | 1 | .zig-cache |
| 2 | zig-out | 2 | zig-out |
| 3 | zig-cache | ||
| @@ -1,4 +1,9 @@ | |||
| 1 | const std = @import("std"); | 1 | const std = @import("std"); |
| 2 | const builtin = @import("builtin"); | ||
| 3 | |||
| 4 | const current_zig = builtin.zig_version; | ||
| 5 | // NOTE: this is just for 12 compatible, when 14 release, we can remove this! | ||
| 6 | const ProgressNode = if (current_zig.minor == 12) *std.Progress.Node else std.Progress.Node; | ||
| 2 | 7 | ||
| 3 | pub fn build(b: *std.Build) void { | 8 | pub fn build(b: *std.Build) void { |
| 4 | const clap_mod = b.addModule("clap", .{ .root_source_file = b.path("clap.zig") }); | 9 | const clap_mod = b.addModule("clap", .{ .root_source_file = b.path("clap.zig") }); |
| @@ -63,7 +68,7 @@ fn readMeStep(b: *std.Build) *std.Build.Step { | |||
| 63 | .name = "ReadMeStep", | 68 | .name = "ReadMeStep", |
| 64 | .owner = b, | 69 | .owner = b, |
| 65 | .makeFn = struct { | 70 | .makeFn = struct { |
| 66 | fn make(step: *std.Build.Step, _: std.Progress.Node) anyerror!void { | 71 | fn make(step: *std.Build.Step, _: ProgressNode) anyerror!void { |
| 67 | @setEvalBranchQuota(10000); | 72 | @setEvalBranchQuota(10000); |
| 68 | _ = step; | 73 | _ = step; |
| 69 | const file = try std.fs.cwd().createFile("README.md", .{}); | 74 | const file = try std.fs.cwd().createFile("README.md", .{}); |