From d71cc39a94f3e6ccbad00c25d350c9147de4df9f Mon Sep 17 00:00:00 2001 From: jinzhongjia Date: Thu, 4 Jul 2024 08:32:41 +0800 Subject: Add compatibility code between zig 0.12 and 0.13 The newest version of zig-clap can easily support both 0.12 and 0.13 zig versions with just a few lines of code --- .gitignore | 1 + build.zig | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index d8c8979..55f1256 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ .zig-cache zig-out +zig-cache diff --git a/build.zig b/build.zig index 0e35a04..ef4d191 100644 --- a/build.zig +++ b/build.zig @@ -1,4 +1,9 @@ const std = @import("std"); +const builtin = @import("builtin"); + +const current_zig = builtin.zig_version; +// NOTE: this is just for 12 compatible, when 14 release, we can remove this! +const ProgressNode = if (current_zig.minor == 12) *std.Progress.Node else std.Progress.Node; pub fn build(b: *std.Build) void { 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 { .name = "ReadMeStep", .owner = b, .makeFn = struct { - fn make(step: *std.Build.Step, _: std.Progress.Node) anyerror!void { + fn make(step: *std.Build.Step, _: ProgressNode) anyerror!void { @setEvalBranchQuota(10000); _ = step; const file = try std.fs.cwd().createFile("README.md", .{}); -- cgit v1.2.3