mirror of
https://codeberg.org/fairyglade/ly.git
synced 2026-08-26 15:34:20 +02:00
build.zig: Support rc build descriptions
Signed-off-by: AnErrupTion <anerruption@disroot.org>
This commit is contained in:
parent
11da43d7d9
commit
f17ccf9ea7
1 changed files with 37 additions and 0 deletions
37
build.zig
37
build.zig
|
|
@ -214,6 +214,20 @@ fn getVersionStr(b: *std.Build, name: []const u8, version: std.SemanticVersion)
|
|||
}
|
||||
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 => {
|
||||
// Untagged development build (e.g. 0.10.0-dev.2025+ecf0050a9).
|
||||
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.
|
||||
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 => {
|
||||
std.debug.print("Unexpected `git describe` output: {s}\n", .{git_describe});
|
||||
return version_str;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue