Skip to content

Commit

Permalink
fix build.zig
Browse files Browse the repository at this point in the history
  • Loading branch information
DerryAlex committed Jul 13, 2024
1 parent 81f9d1a commit f65d0a4
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,10 @@ pub fn get_version(b: *std.Build) []const u8 {
}, &code, .Ignore) catch {
return version_string;
};
const git_describe = std.mem.trim(u8, git_describe_untrimmed, " \n\r");
const git_describe = git_describe: {
const git_describe_trimmed = std.mem.trim(u8, git_describe_untrimmed, " \n\r");
break :git_describe if (git_describe_trimmed[0] != 'v') git_describe_trimmed else git_describe_trimmed[1..];
};

switch (std.mem.count(u8, git_describe, "-")) {
0 => {
Expand All @@ -72,7 +75,7 @@ pub fn get_version(b: *std.Build) []const u8 {
const commit_height = it.next().?;
const commit_id = it.next().?;

const ancestor_ver = std.SemanticVersion.parse(tagged_ancestor[@intFromBool(tagged_ancestor[0] == 'v')..]) catch {
const ancestor_ver = std.SemanticVersion.parse(tagged_ancestor) catch {
std.debug.print("Failed to parse tagged ancestor '{s}'", .{tagged_ancestor});
std.process.exit(1);
};
Expand Down

0 comments on commit f65d0a4

Please sign in to comment.