feat(build-time-versioning): controller/scheduler --version and startup log
Migrates argp_program_version in controller/main.c, scheduler/main.c, and xce_test's test.c from the compile-time MK_VERSION/STR construction to xce_compose_version(), computed into a static buffer and assigned before argp_parse() runs (argp_program_version is a file-scope pointer, not a constant expression it can be initialized from at compile time). Each daemon's startup log now carries the identical version string (never recomputed) on its first INFO line -- scheduler's BOTH mutually-exclusive branches (--peers and no-peers), not just the one literally named in the task text, since "when the daemon starts" is unconditional. Live-verified: --version and startup-log output are byte-identical for both daemons across all branches. No remaining MK_VERSION callers repo-wide. Task 3.2/13 of build-time-versioning. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
parent
854f776733
commit
88649a0462
4 changed files with 65 additions and 15 deletions
|
|
@ -658,8 +658,13 @@ static int break_out = 0;
|
|||
static char doc[] = "xce_test";
|
||||
static char args_doc[] = "";
|
||||
|
||||
const char* argp_program_version
|
||||
= MK_VERSION("xce v0.0.1-", STR(VERSION_COMMIT_ID));
|
||||
/* build-time-versioning task 3.2: no longer a compile-time initializer --
|
||||
* argp reads this by pointer when --version/-V is processed, and
|
||||
* xce_compose_version() (utils.h) is a runtime function, not a constant
|
||||
* expression, so it cannot initialize a file-scope global. main() assigns
|
||||
* this to a static buffer, computed via xce_compose_version(), before
|
||||
* argp_parse() runs. See utils.h's NOTE FOR TASK 3.2 above MK_VERSION. */
|
||||
const char* argp_program_version = NULL;
|
||||
const char* argp_program_bug_address = BUG_EMAIL;
|
||||
|
||||
struct arguments {
|
||||
|
|
@ -4382,8 +4387,19 @@ int main(int argc, char* argv[])
|
|||
char* loglevel = "info";
|
||||
int logsize = 64 * 1024 * 1024;
|
||||
int logcount = 10;
|
||||
/* build-time-versioning task 3.2: xce_test's own --version/-V output
|
||||
* (via argp_program_version) -- static so it outlives this point in
|
||||
* main() (contract documented on xce_compose_version() in utils.c). */
|
||||
static char version_buf[128];
|
||||
|
||||
memset(&arguments, 0x0, sizeof(arguments));
|
||||
|
||||
/* Must run before argp_parse(): argp reads argp_program_version by
|
||||
* pointer when --version/-V is processed. */
|
||||
xce_compose_version(version_buf, sizeof(version_buf), "xce v0.0.1-",
|
||||
STR(VERSION_COMMIT_ID), STR(VERSION_BUILD_TIME));
|
||||
argp_program_version = version_buf;
|
||||
|
||||
argp_parse(&argp, argc, argv, 0, 0, &arguments);
|
||||
|
||||
if (arguments.verbose != 0) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue