mirror of
https://github.com/ghostty-org/ghostty.git
synced 2026-04-14 03:25:50 +00:00
libghostty-vt: add semver pre info to build info
This commit is contained in:
@@ -19,18 +19,25 @@ void query_build_info() {
|
||||
size_t version_major = 0;
|
||||
size_t version_minor = 0;
|
||||
size_t version_patch = 0;
|
||||
GhosttyString version_pre = {0};
|
||||
GhosttyString version_build = {0};
|
||||
|
||||
ghostty_build_info(GHOSTTY_BUILD_INFO_VERSION_STRING, &version_string);
|
||||
ghostty_build_info(GHOSTTY_BUILD_INFO_VERSION_MAJOR, &version_major);
|
||||
ghostty_build_info(GHOSTTY_BUILD_INFO_VERSION_MINOR, &version_minor);
|
||||
ghostty_build_info(GHOSTTY_BUILD_INFO_VERSION_PATCH, &version_patch);
|
||||
ghostty_build_info(GHOSTTY_BUILD_INFO_VERSION_PRE, &version_pre);
|
||||
ghostty_build_info(GHOSTTY_BUILD_INFO_VERSION_BUILD, &version_build);
|
||||
|
||||
printf("Version: %.*s\n", (int)version_string.len, version_string.ptr);
|
||||
printf("Version major: %zu\n", version_major);
|
||||
printf("Version minor: %zu\n", version_minor);
|
||||
printf("Version patch: %zu\n", version_patch);
|
||||
if (version_pre.len > 0) {
|
||||
printf("Version pre : %.*s\n", (int)version_pre.len, version_pre.ptr);
|
||||
} else {
|
||||
printf("Version pre : (none)\n");
|
||||
}
|
||||
if (version_build.len > 0) {
|
||||
printf("Version build: %.*s\n", (int)version_build.len, version_build.ptr);
|
||||
} else {
|
||||
|
||||
@@ -107,13 +107,21 @@ typedef enum {
|
||||
*/
|
||||
GHOSTTY_BUILD_INFO_VERSION_PATCH = 8,
|
||||
|
||||
/**
|
||||
* The pre metadata string (e.g. "alpha", "beta", "dev"). Has zero length if
|
||||
* no pre metadata is present.
|
||||
*
|
||||
* Output type: GhosttyString *
|
||||
*/
|
||||
GHOSTTY_BUILD_INFO_VERSION_PRE = 9,
|
||||
|
||||
/**
|
||||
* The build metadata string (e.g. commit hash). Has zero length if
|
||||
* no build metadata is present.
|
||||
*
|
||||
* Output type: GhosttyString *
|
||||
*/
|
||||
GHOSTTY_BUILD_INFO_VERSION_BUILD = 9,
|
||||
GHOSTTY_BUILD_INFO_VERSION_BUILD = 10,
|
||||
} GhosttyBuildInfo;
|
||||
|
||||
/**
|
||||
|
||||
@@ -75,15 +75,13 @@ pub const Options = struct {
|
||||
opts.addOption(bool, "tmux_control_mode", self.oniguruma);
|
||||
|
||||
// Version information.
|
||||
var buf: [1024]u8 = undefined;
|
||||
opts.addOption(
|
||||
[]const u8,
|
||||
"version_string",
|
||||
std.fmt.bufPrint(
|
||||
&buf,
|
||||
b.fmt(
|
||||
"{f}",
|
||||
.{self.version},
|
||||
) catch @panic("version string too long"),
|
||||
),
|
||||
);
|
||||
opts.addOption(usize, "version_major", self.version.major);
|
||||
opts.addOption(usize, "version_minor", self.version.minor);
|
||||
|
||||
@@ -25,7 +25,8 @@ pub const BuildInfo = enum(c_int) {
|
||||
version_major = 6,
|
||||
version_minor = 7,
|
||||
version_patch = 8,
|
||||
version_build = 9,
|
||||
version_pre = 9,
|
||||
version_build = 10,
|
||||
|
||||
/// Output type expected for querying the data of the given kind.
|
||||
pub fn OutType(comptime self: BuildInfo) type {
|
||||
@@ -33,7 +34,7 @@ pub const BuildInfo = enum(c_int) {
|
||||
.invalid => void,
|
||||
.simd, .kitty_graphics, .tmux_control_mode => bool,
|
||||
.optimize => OptimizeMode,
|
||||
.version_string, .version_build => lib.String,
|
||||
.version_string, .version_pre, .version_build => lib.String,
|
||||
.version_major, .version_minor, .version_patch => usize,
|
||||
};
|
||||
}
|
||||
@@ -78,6 +79,13 @@ fn getTyped(
|
||||
.version_major => out.* = build_options.version_major,
|
||||
.version_minor => out.* = build_options.version_minor,
|
||||
.version_patch => out.* = build_options.version_patch,
|
||||
.version_pre => {
|
||||
if (build_options.version_pre) |b| {
|
||||
out.* = .{ .ptr = b.ptr, .len = b.len };
|
||||
} else {
|
||||
out.* = .{ .ptr = "", .len = 0 };
|
||||
}
|
||||
},
|
||||
.version_build => {
|
||||
if (build_options.version_build) |b| {
|
||||
out.* = .{ .ptr = b.ptr, .len = b.len };
|
||||
@@ -151,6 +159,12 @@ test "get version_patch" {
|
||||
try testing.expectEqual(build_options.version_patch, value);
|
||||
}
|
||||
|
||||
test "get version_pre" {
|
||||
const testing = std.testing;
|
||||
var value: lib.String = undefined;
|
||||
try testing.expectEqual(Result.success, get(.version_pre, @ptrCast(&value)));
|
||||
}
|
||||
|
||||
test "get version_build" {
|
||||
const testing = std.testing;
|
||||
var value: lib.String = undefined;
|
||||
|
||||
Reference in New Issue
Block a user