libghostty-vt 0.0.0
Loading...
Searching...
No Matches
c-vt-build-info/src/main.c

Query build options like SIMD and Kitty graphics, then check that the loaded library matches the headers you compiled against.

#include <stdio.h>
#include <ghostty/vt.h>
void query_build_info() {
bool simd = false;
bool kitty_graphics = false;
bool tmux_control_mode = false;
printf("SIMD: %s\n", simd ? "enabled" : "disabled");
printf("Kitty graphics: %s\n", kitty_graphics ? "enabled" : "disabled");
printf("Tmux control mode: %s\n", tmux_control_mode ? "enabled" : "disabled");
GhosttyString version_string = {0};
size_t version_major = 0;
size_t version_minor = 0;
size_t version_patch = 0;
GhosttyString version_pre = {0};
GhosttyString version_build = {0};
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 {
printf("Version build: (none)\n");
}
}
// Stop the build if the headers are older than this program needs.
#if !GHOSTTY_VT_VERSION_AT_LEAST(0, 1, 0)
#error "libghostty-vt 0.1.0 or newer is required"
#endif
void print_library_version() {
// The full version, which is the easiest form to log or display. A
// development build has a suffix, such as "0.2.0-dev+abc1234".
printf("Library version: %s\n", ghostty_version());
// The same version as numbers, which is the easiest form to compare.
size_t major = 0;
size_t minor = 0;
size_t patch = 0;
printf("Library version numbers: %zu.%zu.%zu\n", major, minor, patch);
}
// Returns true if the library loaded at runtime can be used with the
// headers this program was compiled against.
bool library_is_compatible() {
size_t major = 0;
size_t minor = 0;
// Until 1.0, any minor release may change the ABI, so the minor
// versions must match exactly.
return major == 0 && minor == GHOSTTY_VT_VERSION_MINOR;
}
// From 1.0, the major versions must match. The library may be newer
// than the headers but not older, because an older library is missing
// the functions that newer headers declare.
return major == GHOSTTY_VT_VERSION_MAJOR &&
}
int main() {
query_build_info();
printf("Header version: %s\n", GHOSTTY_VT_VERSION);
print_library_version();
if (!library_is_compatible()) {
fprintf(stderr, "This program needs libghostty-vt %d.%d.\n",
return 1;
}
return 0;
}
GHOSTTY_API const char * ghostty_version(void)
GHOSTTY_API GhosttyResult ghostty_build_info(GhosttyBuildInfo data, void *out)
@ GHOSTTY_BUILD_INFO_VERSION_PATCH
Definition build_info.h:121
@ GHOSTTY_BUILD_INFO_VERSION_PRE
Definition build_info.h:129
@ GHOSTTY_BUILD_INFO_TMUX_CONTROL_MODE
Definition build_info.h:86
@ GHOSTTY_BUILD_INFO_VERSION_STRING
Definition build_info.h:100
@ GHOSTTY_BUILD_INFO_VERSION_MAJOR
Definition build_info.h:107
@ GHOSTTY_BUILD_INFO_KITTY_GRAPHICS
Definition build_info.h:79
@ GHOSTTY_BUILD_INFO_SIMD
Definition build_info.h:69
@ GHOSTTY_BUILD_INFO_VERSION_BUILD
Definition build_info.h:137
@ GHOSTTY_BUILD_INFO_VERSION_MINOR
Definition build_info.h:114
#define GHOSTTY_VT_VERSION_MAJOR
Definition version.h:35
#define GHOSTTY_VT_VERSION
Definition version.h:60
#define GHOSTTY_VT_VERSION_MINOR
Definition version.h:38
size_t len
Definition types.h:444
const uint8_t * ptr
Definition types.h:441