CLI tool to query Banjo build information.
CLI tool to query Banjo build information.This tool outputs version and build information in formats suitable for both human reading and scripting. Flags can be combined to build custom output strings with sensible separators.
Examples: banjo-info -nvs # banjo-1.0.0-rc.1 banjo-info -Nv # Banjo-1.0.0 banjo-info -a # banjo-1.0.0-rc.1 Debug Build, GCC 13 banjo-info -v # 1.0.0 banjo-info -b # x11 (one per line) banjo-info # full human-readable output
#include <ctype.h>
#include <stdio.h>
switch (stage & 0xC0) {
default: return "unknown";
}
}
static size_t format_stage(
char* buffer,
size_t bufsize, uint8_t stage) {
uint8_t num = stage & 0x3F;
}
return (
size_t)snprintf(buffer, bufsize,
"%s.%u",
stage_type_name(stage), num);
}
char version_string[32];
printf("%s version %s (0x%08X) [%s] %s build\n",
info->
debug ?
"Debug" :
"Release"
);
printf("\nBackends:\n");
printf("\nConfiguration:\n");
printf(
" %c checks_abort\n", info->
checks_abort ?
'+' :
'-');
printf(
" %c checks_log\n", info->
checks_log ?
'+' :
'-');
printf(
" %c fastmath\n", info->
fastmath ?
'+' :
'-');
printf(
" %c log_color\n", info->
log_color ?
'+' :
'-');
printf(
" %c pedantic\n", info->
pedantic ?
'+' :
'-');
printf("\nActive video backends (%zu):\n", count);
const char* names[16];
for (size_t i = 0; i < got; ++i) {
printf(" %s\n", names[i]);
}
}
int printed = 0;
for (
size_t i = 0; info->
name[i]; ++i) {
putchar(tolower((
unsigned char)info->
name[i]));
}
printed = 1;
printf(
"%s", info->
name);
printed = 1;
}
if (printed) putchar('-');
}
printf("%u.%u.%u",
printed = 1;
}
char stage_str[16];
printf("%s", stage_str);
printed = 1;
}
if (printed) putchar(' ');
printf("Debug Build");
printed = 1;
}
if (printed) printf(", ");
printed = 1;
}
if (printed) {
putchar('\n');
}
const char* names[16];
for (size_t i = 0; i < got; ++i) {
printf("%s\n", names[i]);
}
}
}
int main(
int argc,
char* argv[]) {
{
.shortname = 'h',
.name = "help",
.help = "Show this help message and exit",
},
{
.shortname = 'a',
.name = "all",
.help = "Print all info (shorthand for -nvsdc)",
},
{
.shortname = 'n',
.name = "name-lower",
.help = "Print lowercase name (banjo)",
},
{
.shortname = 'N',
.name = "name",
.help = "Print name (Banjo)",
},
{
.shortname = 'v',
.name = "version",
.help = "Print version (1.0.0)",
},
{
.shortname = 's',
.name = "stage",
.help = "Print release stage (rc.1, alpha, stable)",
},
{
.shortname = 'd',
.name = "debug",
.help = "Print 'Debug Build' if debug build",
},
{
.shortname = 'c',
.name = "compiler",
.help = "Print compiler name and version",
},
{
.shortname = 'b',
.name = "backends",
.help = "Print available backends (one per line)",
},
};
.prog = "banjo-info",
.description = "Query Banjo build information.\n"
"Flags can be combined to build custom output with sensible separators.\n"
"With no flags, prints full human-readable information.",
.epilog = "Examples:\n"
" banjo-info -nvs # banjo-1.0.0-rc.1\n"
" banjo-info -Nv # Banjo-1.0.0\n"
" banjo-info -a # banjo-1.0.0-rc.1 Debug Build, GCC 13\n"
" banjo-info -v # 1.0.0\n"
" banjo-info -b # list backends\n"
" banjo-info # full output",
.arguments_len = sizeof(args) / sizeof(args[0]),
.arguments = args,
};
return 1;
}
}
if (!any_flag) {
} else {
}
return 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)