Skip to content

Commit

Permalink
Add compatibility code between zig 0.12 and 0.13
Browse files Browse the repository at this point in the history
The newest version of zig-clap can easily support both 0.12 and 0.13 zig
versions with just a few lines of code
  • Loading branch information
jinzhongjia authored and Hejsil committed Jul 5, 2024
1 parent c0193e9 commit d71cc39
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
.zig-cache
zig-out
zig-cache
7 changes: 6 additions & 1 deletion build.zig
Original file line number Diff line number Diff line change
@@ -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") });
Expand Down Expand Up @@ -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", .{});
Expand Down

0 comments on commit d71cc39

Please sign in to comment.