From f65d0a479724229f51b15475c68d0836c22a940c Mon Sep 17 00:00:00 2001 From: DerryAlex Date: Sat, 13 Jul 2024 11:54:26 +0800 Subject: [PATCH] fix build.zig --- build.zig | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/build.zig b/build.zig index 344c637..500b907 100644 --- a/build.zig +++ b/build.zig @@ -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 => { @@ -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); };