42 switch (stage & 0xC0) {
47 default:
return "unknown";
52static size_t format_stage(
char* buffer,
size_t bufsize, uint8_t stage) {
53 uint8_t num = stage & 0x3F;
57 return (
size_t)snprintf(buffer, bufsize,
"%s.%u",
stage_type_name(stage), num);
62 char version_string[32];
65 printf(
"%s version %s (0x%08X) [%s] %s build\n",
69 info->
debug ?
"Debug" :
"Release"
73 printf(
"bj_real: %zu bytes\n", info->
real_size);
75 printf(
"\nBackends:\n");
86 printf(
"\nConfiguration:\n");
87 printf(
" %c checks_abort\n", info->
checks_abort ?
'+' :
'-');
88 printf(
" %c checks_log\n", info->
checks_log ?
'+' :
'-');
89 printf(
" %c fastmath\n", info->
fastmath ?
'+' :
'-');
90 printf(
" %c log_color\n", info->
log_color ?
'+' :
'-');
91 printf(
" %c pedantic\n", info->
pedantic ?
'+' :
'-');
94 printf(
"\nActive video backends (%zu):\n", video_count);
95 const char* names[16];
97 for (
size_t i = 0; i < got; ++i) {
98 printf(
" %s\n", names[i]);
102 printf(
"\nActive audio backends (%zu):\n", audio_count);
104 for (
size_t i = 0; i < got; ++i) {
105 printf(
" %s\n", names[i]);
115 for (
size_t i = 0; info->
name[i]; ++i) {
116 putchar(tolower((
unsigned char)info->
name[i]));
120 printf(
"%s", info->
name);
126 if (printed) putchar(
'-');
141 printf(
"%s", stage_str);
147 if (printed) putchar(
' ');
148 printf(
"Debug Build");
153 if (printed) printf(
", ");
166 const char* names[16];
168 for (
size_t i = 0; i < got; ++i) {
169 printf(
"%s\n", names[i]);
174int main(
int argc,
char* argv[]) {
179 .help =
"Show this help message and exit",
185 .help =
"Print all info (shorthand for -nvsdc)",
189 .name =
"name-lower",
191 .help =
"Print lowercase name (banjo)",
197 .help =
"Print name (Banjo)",
203 .help =
"Print version (1.0.0)",
209 .help =
"Print release stage (rc.1, alpha, stable)",
215 .help =
"Print 'Debug Build' if debug build",
221 .help =
"Print compiler name and version",
227 .help =
"Print available backends (one per line)",
233 .prog =
"banjo-info",
234 .description =
"Query Banjo build information.\n"
235 "Flags can be combined to build custom output with sensible separators.\n"
236 "With no flags, prints full human-readable information.",
237 .epilog =
"Examples:\n"
238 " banjo-info -nvs # banjo-1.0.0-rc.1\n"
239 " banjo-info -Nv # Banjo-1.0.0\n"
240 " banjo-info -a # banjo-1.0.0-rc.1 Debug Build, GCC 13\n"
241 " banjo-info -v # 1.0.0\n"
242 " banjo-info -b # list backends\n"
243 " banjo-info # full output",
244 .arguments_len =
sizeof(args) /
sizeof(args[0]),
General-purpose definitions for Banjo API.
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 the help message to standard output.
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.
size_t real_size
Size of bj_real in the library, in bytes (since 1.1).
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 backend_fake
Built with the fake video and audio backends (since 1.1).
bj_bool log_color
Colored log output enabled.
bj_bool backend_win32
Built with Win32 window support.
bj_bool backend_coreaudio
Built with CoreAudio audio (since 1.1).
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: describes this library's own build, not the including program's ND...
bj_bool backend_cocoa
Built with Cocoa/macOS support.
bj_bool checks_abort
Built with BJ_CONFIG_CHECKS_ABORT, deprecated and without effect.
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.
size_t bj_audio_backends(const char **p_names, size_t cap)
Enumerate the audio 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)