mirror of
https://github.com/fairyglade/ly.git
synced 2026-09-22 03:50:23 +00:00
build.zig: Support rc build descriptions
Signed-off-by: AnErrupTion <anerruption@disroot.org>
This commit is contained in:
37
build.zig
37
build.zig
@@ -214,6 +214,20 @@ fn getVersionStr(b: *std.Build, name: []const u8, version: std.SemanticVersion)
|
|||||||
}
|
}
|
||||||
return version_str;
|
return version_str;
|
||||||
},
|
},
|
||||||
|
1 => {
|
||||||
|
// Release candidate build (e.g. v1.5.0-rc1)
|
||||||
|
var it = std.mem.splitScalar(u8, git_describe, '-');
|
||||||
|
const tagged_ancestor = std.mem.trimStart(u8, it.first(), "v");
|
||||||
|
|
||||||
|
const ancestor_ver = try std.SemanticVersion.parse(tagged_ancestor);
|
||||||
|
if (version.order(ancestor_ver) != .gt) {
|
||||||
|
std.debug.print("{s} version '{f}' must be greater than tagged ancestor '{f}'\n", .{ name, version, ancestor_ver });
|
||||||
|
std.process.exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// The version is reformatted in accordance with the https://semver.org specification.
|
||||||
|
return version_str;
|
||||||
|
},
|
||||||
2 => {
|
2 => {
|
||||||
// Untagged development build (e.g. 0.10.0-dev.2025+ecf0050a9).
|
// Untagged development build (e.g. 0.10.0-dev.2025+ecf0050a9).
|
||||||
var it = std.mem.splitScalar(u8, git_describe, '-');
|
var it = std.mem.splitScalar(u8, git_describe, '-');
|
||||||
@@ -236,6 +250,29 @@ fn getVersionStr(b: *std.Build, name: []const u8, version: std.SemanticVersion)
|
|||||||
// The version is reformatted in accordance with the https://semver.org specification.
|
// The version is reformatted in accordance with the https://semver.org specification.
|
||||||
return b.fmt("{s}-dev.{s}+{s}", .{ version_str, commit_height, commit_id[1..] });
|
return b.fmt("{s}-dev.{s}+{s}", .{ version_str, commit_height, commit_id[1..] });
|
||||||
},
|
},
|
||||||
|
3 => {
|
||||||
|
// Untagged development build (e.g. 0.10.0-dev.2025+ecf0050a9).
|
||||||
|
var it = std.mem.splitScalar(u8, git_describe, '-');
|
||||||
|
const tagged_ancestor = std.mem.trimStart(u8, it.first(), "v");
|
||||||
|
_ = it.next().?;
|
||||||
|
const commit_height = it.next().?;
|
||||||
|
const commit_id = it.next().?;
|
||||||
|
|
||||||
|
const ancestor_ver = try std.SemanticVersion.parse(tagged_ancestor);
|
||||||
|
if (version.order(ancestor_ver) != .gt) {
|
||||||
|
std.debug.print("{s} version '{f}' must be greater than tagged ancestor '{f}'\n", .{ name, version, ancestor_ver });
|
||||||
|
std.process.exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check that the commit hash is prefixed with a 'g' (a Git convention).
|
||||||
|
if (commit_id.len < 1 or commit_id[0] != 'g') {
|
||||||
|
std.debug.print("Unexpected `git describe` output: {s}\n", .{git_describe});
|
||||||
|
return version_str;
|
||||||
|
}
|
||||||
|
|
||||||
|
// The version is reformatted in accordance with the https://semver.org specification.
|
||||||
|
return b.fmt("{s}-dev.{s}+{s}", .{ version_str, commit_height, commit_id[1..] });
|
||||||
|
},
|
||||||
else => {
|
else => {
|
||||||
std.debug.print("Unexpected `git describe` output: {s}\n", .{git_describe});
|
std.debug.print("Unexpected `git describe` output: {s}\n", .{git_describe});
|
||||||
return version_str;
|
return version_str;
|
||||||
|
|||||||
Reference in New Issue
Block a user