1/**
2 * @file build_info.h
3 *
4 * Build info - query compile-time build configuration of libghostty-vt.
5 */
6
7#ifndef GHOSTTY_VT_BUILD_INFO_H
8#define GHOSTTY_VT_BUILD_INFO_H
9
10/** @defgroup build_info Build Info
11 *
12 * Query compile-time build configuration of libghostty-vt.
13 *
14 * These values reflect the options the library was built with and are
15 * constant for the lifetime of the process.
16 *
17 * ## Basic Usage
18 *
19 * Use ghostty_build_info() to query individual build options:
20 *
21 * @snippet c-vt-build-info/src/main.c build-info-query
22 *
23 * @{
24 */
25
26#include <stddef.h>
27#include <stdbool.h>
28
29#include <ghostty/vt/types.h>
30
31#ifdef __cplusplus
32extern "C" {
33#endif
34
35/**
36 * Build optimization mode.
37 */
38typedef enum GHOSTTY_ENUM_TYPED {
39 GHOSTTY_OPTIMIZE_DEBUG = 0,
40 GHOSTTY_OPTIMIZE_RELEASE_SAFE = 1,
41 GHOSTTY_OPTIMIZE_RELEASE_SMALL = 2,
42 GHOSTTY_OPTIMIZE_RELEASE_FAST = 3,
43 GHOSTTY_OPTIMIZE_MODE_MAX_VALUE = GHOSTTY_ENUM_MAX_VALUE,
44} GhosttyOptimizeMode;
45
46/**
47 * Build info data types that can be queried.
48 *
49 * Each variant documents the expected output pointer type.
50 */
51typedef enum GHOSTTY_ENUM_TYPED {
52 /** Invalid data type. Never results in any data extraction. */
53 GHOSTTY_BUILD_INFO_INVALID = 0,
54
55 /**
56 * Whether SIMD-accelerated code paths are enabled.
57 *
58 * Output type: bool *
59 */
60 GHOSTTY_BUILD_INFO_SIMD = 1,
61
62 /**
63 * Whether Kitty graphics protocol support is available.
64 *
65 * Output type: bool *
66 */
67 GHOSTTY_BUILD_INFO_KITTY_GRAPHICS = 2,
68
69 /**
70 * Whether tmux control mode support is available.
71 *
72 * Output type: bool *
73 */
74 GHOSTTY_BUILD_INFO_TMUX_CONTROL_MODE = 3,
75
76 /**
77 * The optimization mode the library was built with.
78 *
79 * Output type: GhosttyOptimizeMode *
80 */
81 GHOSTTY_BUILD_INFO_OPTIMIZE = 4,
82
83 /**
84 * The full version string (e.g. "1.2.3" or "1.2.3-dev+abcdef").
85 *
86 * Output type: GhosttyString *
87 */
88 GHOSTTY_BUILD_INFO_VERSION_STRING = 5,
89
90 /**
91 * The major version number.
92 *
93 * Output type: size_t *
94 */
95 GHOSTTY_BUILD_INFO_VERSION_MAJOR = 6,
96
97 /**
98 * The minor version number.
99 *
100 * Output type: size_t *
101 */
102 GHOSTTY_BUILD_INFO_VERSION_MINOR = 7,
103
104 /**
105 * The patch version number.
106 *
107 * Output type: size_t *
108 */
109 GHOSTTY_BUILD_INFO_VERSION_PATCH = 8,
110
111 /**
112 * The pre metadata string (e.g. "alpha", "beta", "dev"). Has zero length if
113 * no pre metadata is present.
114 *
115 * Output type: GhosttyString *
116 */
117 GHOSTTY_BUILD_INFO_VERSION_PRE = 9,
118
119 /**
120 * The build metadata string (e.g. commit hash). Has zero length if
121 * no build metadata is present.
122 *
123 * Output type: GhosttyString *
124 */
125 GHOSTTY_BUILD_INFO_VERSION_BUILD = 10,
126 GHOSTTY_BUILD_INFO_MAX_VALUE = GHOSTTY_ENUM_MAX_VALUE,
127} GhosttyBuildInfo;
128
129/**
130 * Query a compile-time build configuration value.
131 *
132 * The caller must pass a pointer to the correct output type for the
133 * requested data (see GhosttyBuildInfo variants for types).
134 *
135 * @param data The build info field to query
136 * @param out Pointer to store the result (type depends on data parameter)
137 * @return GHOSTTY_SUCCESS on success, GHOSTTY_INVALID_VALUE if the
138 * data type is invalid
139 *
140 * @ingroup build_info
141 */
142GHOSTTY_API GhosttyResult ghostty_build_info(GhosttyBuildInfo data, void *out);
143
144#ifdef __cplusplus
145}
146#endif
147
148/** @} */
149
150#endif /* GHOSTTY_VT_BUILD_INFO_H */