43 switch (stage & 0xC0) {
48 default:
return "unknown";
53static size_t format_stage(
char* buffer,
size_t bufsize, uint8_t stage) {
54 uint8_t num = stage & 0x3F;
58 return (
size_t)snprintf(buffer, bufsize,
"%s.%u",
stage_type_name(stage), num);
63 char version_string[32];
66 printf(
"%s version %s (0x%08X) [%s] %s build\n",
70 info->
debug ?
"Debug" :
"Release"
75 printf(
"\nBackends:\n");
84 printf(
"\nConfiguration:\n");
85 printf(
" %c checks_abort\n", info->
checks_abort ?
'+' :
'-');
86 printf(
" %c checks_log\n", info->
checks_log ?
'+' :
'-');
87 printf(
" %c fastmath\n", info->
fastmath ?
'+' :
'-');
88 printf(
" %c log_color\n", info->
log_color ?
'+' :
'-');
89 printf(
" %c pedantic\n", info->
pedantic ?
'+' :
'-');
92 printf(
"\nActive video backends (%zu):\n", count);
93 const char* names[16];
95 for (
size_t i = 0; i < got; ++i) {
96 printf(
" %s\n", names[i]);
106 for (
size_t i = 0; info->
name[i]; ++i) {
107 putchar(tolower((
unsigned char)info->
name[i]));
111 printf(
"%s", info->
name);
117 if (printed) putchar(
'-');
132 printf(
"%s", stage_str);
138 if (printed) putchar(
' ');
139 printf(
"Debug Build");
144 if (printed) printf(
", ");
157 const char* names[16];
159 for (
size_t i = 0; i < got; ++i) {
160 printf(
"%s\n", names[i]);
165int main(
int argc,
char* argv[]) {
170 .help =
"Show this help message and exit",
177 .help =
"Print all info (shorthand for -nvsdc)",
182 .name =
"name-lower",
183 .help =
"Print lowercase name (banjo)",
189 .help =
"Print name (Banjo)",
195 .help =
"Print version (1.0.0)",
201 .help =
"Print release stage (rc.1, alpha, stable)",
207 .help =
"Print 'Debug Build' if debug build",
213 .help =
"Print compiler name and version",
219 .help =
"Print available backends (one per line)",
225 .prog =
"banjo-info",
226 .description =
"Query Banjo build information.\n"
227 "Flags can be combined to build custom output with sensible separators.\n"
228 "With no flags, prints full human-readable information.",
229 .epilog =
"Examples:\n"
230 " banjo-info -nvs # banjo-1.0.0-rc.1\n"
231 " banjo-info -Nv # Banjo-1.0.0\n"
232 " banjo-info -a # banjo-1.0.0-rc.1 Debug Build, GCC 13\n"
233 " banjo-info -v # 1.0.0\n"
234 " banjo-info -b # list backends\n"
235 " banjo-info # full output",
236 .arguments_len =
sizeof(args) /
sizeof(args[0]),
General-purpose definitions for Banjo API.
int main(int argc, char *argv[])
static int flag_name_lower
static void print_all(const bj_build_info *info)
static const char * stage_type_name(uint8_t stage)
static void print_combined(const bj_build_info *info)
static size_t format_stage(char *buffer, size_t bufsize, uint8_t stage)
POSIX/GNU-like command-line argument parser.
void bj_print_cli_help(const struct bj_cli *parser)
Print help message using Banjo's logging system.
bj_bool bj_parse_cli(struct bj_cli *parser, int argc, char *argv[], struct bj_error **error)
Parse command-line arguments according to parser configuration.
bj_bool bj_print_cli_help_action(const struct bj_cli *parser, const struct bj_cli_argument *arg, const char *value, void *dest, struct bj_error **error)
Print help argument action.
Parser context and argument list descriptor.
Descriptor for a single command line argument.
bj_bool checks_log
Checks log failures.
const char * name
API name (see BJ_NAME).
bj_bool pedantic
Extra runtime checks enabled.
uint32_t version
Packed API version (see BJ_VERSION).
bj_bool log_color
Colored log output enabled.
bj_bool backend_win32
Built with Win32 window support.
bj_bool backend_alsa
Built with ALSA audio.
bj_bool fastmath
Built with fast-math optimizations.
bj_bool backend_wayland
Built with Wayland window support.
const char * compiler_name
Compiler name string.
bj_bool backend_x11
Built with X11 window support.
bj_bool backend_emscripten
Built with Emscripten support.
const char * variant
API name variant (see BJ_NAME_VARIANT).
bj_bool debug
Non-zero if built with debug info.
bj_bool backend_cocoa
Built with Cocoa/macOS support.
bj_bool checks_abort
Checks abort execution on failure.
int compiler_version
Compiler version number.
bj_bool backend_mme
Built with Windows MME audio.
const struct bj_build_info * bj_build_information(void)
Get runtime build information for the loaded Banjo binaries.
Structure holding build information of the binary.
size_t bj_video_backends(const char **p_names, size_t cap)
Enumerate the video backends compiled into this build.
Logging utility functions.
Portable main() replacement with platform-aware entry shim.
Header file for system interactions.
32-bit packed version storage following the SemVer standard.
#define BJ_VERSION_PREVIEW
Preview (feature freeze, bug fixes only)
#define BJ_VERSION_STAGE(version)
Extract the stage byte from a packed 32-bit version.
#define BJ_VERSION_ALPHA
Version stage flags.
size_t bj_format_version(char *buffer, size_t bufsize, uint32_t version)
Format a packed version number as a SemVer-compatible string.
#define BJ_VERSION_MINOR(version)
Extract the minor version from a packed 32-bit version.
#define BJ_VERSION_MAJOR(version)
Extract the major version from a packed 32-bit version.
#define BJ_VERSION_STABLE
Stable Release.
#define BJ_VERSION_PATCH(version)
Extract the patch version from a packed 32-bit version.
#define BJ_VERSION_RC
Release Candidate (critical fixes only)
#define BJ_VERSION_BETA
Beta (maturing, can still add features)