mirror of
https://github.com/ghostty-org/ghostty.git
synced 2026-07-28 11:36:34 +00:00
c api: add ghostty_info to get metadata about the build
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
const std = @import("std");
|
||||
const assert = std.debug.assert;
|
||||
const builtin = @import("builtin");
|
||||
const build_config = @import("build_config.zig");
|
||||
const main = @import("main.zig");
|
||||
const apprt = @import("apprt.zig");
|
||||
|
||||
@@ -23,6 +24,20 @@ pub const std_options = main.std_options;
|
||||
pub usingnamespace @import("config.zig").CAPI;
|
||||
pub usingnamespace apprt.runtime.CAPI;
|
||||
|
||||
/// ghostty_info_s
|
||||
const Info = extern struct {
|
||||
mode: BuildMode,
|
||||
version: [*]const u8,
|
||||
version_len: usize,
|
||||
|
||||
const BuildMode = enum(c_int) {
|
||||
debug,
|
||||
release_safe,
|
||||
release_fast,
|
||||
release_small,
|
||||
};
|
||||
};
|
||||
|
||||
/// Initialize ghostty global state. It is possible to have more than
|
||||
/// one global state but it has zero practical benefit.
|
||||
export fn ghostty_init() c_int {
|
||||
@@ -30,3 +45,16 @@ export fn ghostty_init() c_int {
|
||||
main.state.init();
|
||||
return 0;
|
||||
}
|
||||
|
||||
export fn ghostty_info() Info {
|
||||
return .{
|
||||
.mode = switch (builtin.mode) {
|
||||
.Debug => .debug,
|
||||
.ReleaseSafe => .release_safe,
|
||||
.ReleaseFast => .release_fast,
|
||||
.ReleaseSmall => .release_small,
|
||||
},
|
||||
.version = build_config.version_string.ptr,
|
||||
.version_len = build_config.version_string.len,
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user