From 071f3895f7051cd9eacb68adf9d6235ab437362b Mon Sep 17 00:00:00 2001 From: Rongsong Shen Date: Thu, 20 Aug 2026 12:50:36 +0000 Subject: [PATCH] feat(build-time-versioning): thread commit_id/build_time into go_build env apiserver/meson.build and xcecli/meson.build now pass XCE_GIT_COMMIT/XCE_BUILD_TIME (from the project's commit_id/build_time meson options) into go_build's environment, mirroring the existing CURRENT_SOURCE_DIR/BUILD_ROOT env-passing mechanism. Deliberately unquoted: go_build's fix_input_envs() only quote-strips CURRENT_SOURCE_DIR/BUILD_ROOT, not these two -- quoting them would embed literal quote characters and corrupt the -ldflags argument. Live-verified: real values (matching git rev-parse --short HEAD plus dirty suffix, and a real UTC timestamp) reach go build's actual invocation and are embedded in both binaries' Go build-info metadata. No main.GitCommit/main.BuildTime symbols exist in either binary yet (confirmed via go tool nm) since apiserver/xcecli's main packages don't declare those vars until tasks 4.4/4.5 -- expected, this task's scope is the env-var plumbing only. Task 4.2/13 of build-time-versioning. Co-Authored-By: Claude Sonnet 5 --- .kiro/specs/build-time-versioning/tasks.md | 7 ++++--- src/frontend/apiserver/meson.build | 2 ++ src/frontend/xcecli/meson.build | 2 ++ 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/.kiro/specs/build-time-versioning/tasks.md b/.kiro/specs/build-time-versioning/tasks.md index 656556ea..bb974511 100644 --- a/.kiro/specs/build-time-versioning/tasks.md +++ b/.kiro/specs/build-time-versioning/tasks.md @@ -56,9 +56,10 @@ - _Requirements: 1.1, 1.2, 1.4, 4.1, 4.2_ - _Boundary: go_build script_ -- [ ] 4.2 apiserver and xcecli meson builds pass resolved values through - - `src/frontend/apiserver/meson.build` and `src/frontend/xcecli/meson.build` read the project's `commit_id`/`build_time` meson options and pass them as `XCE_GIT_COMMIT`/`XCE_BUILD_TIME` env vars into their existing `custom_target()` calls - - Observable: a meson-driven `/xce-build apiserver` (with 2.1's values set) produces an `xce_apiserver` binary whose linked-in vars are non-`unknown` +- [x] 4.2 apiserver and xcecli meson builds pass resolved values through + - Both meson.build files pass `XCE_GIT_COMMIT`/`XCE_BUILD_TIME` (from `get_option('commit_id')`/`get_option('build_time')`) into `go_build`'s env, UNQUOTED (go_build's `fix_input_envs()` only quote-strips `CURRENT_SOURCE_DIR`/`BUILD_ROOT`, not these two -- quoting them would embed literal `"` chars and corrupt the `-ldflags` argument) + - Verified live (independently, by review): real commit id + build time reach `go build`'s actual invocation and are embedded in both binaries' Go build-info metadata (`go version -m`) + - Observable partially deferred by design: no `main.GitCommit`/`main.BuildTime` symbols exist in either binary yet (`go tool nm` confirms) since apiserver/xcecli's `main` packages don't declare those vars until tasks 4.4/4.5 -- this task's own scope (`_Depends: 4.1_` only) is the env-var plumbing itself, not the full round trip; task 6.2 owns re-verifying that once 4.4 lands - _Requirements: 1.1, 1.2, 4.1, 4.2_ - _Boundary: apiserver/meson.build, xcecli/meson.build_ - _Depends: 4.1_ diff --git a/src/frontend/apiserver/meson.build b/src/frontend/apiserver/meson.build index 75d36986..34398cb1 100644 --- a/src/frontend/apiserver/meson.build +++ b/src/frontend/apiserver/meson.build @@ -56,6 +56,8 @@ custom_target('apiserver', command: [env_program, 'CURRENT_SOURCE_DIR="@CURRENT_SOURCE_DIR@"', 'BUILD_ROOT="@BUILD_ROOT@"', + 'XCE_GIT_COMMIT=' + get_option('commit_id'), + 'XCE_BUILD_TIME=' + get_option('build_time'), go_build_program, '@INPUT@', '@OUTPUT@'], env: go_env, diff --git a/src/frontend/xcecli/meson.build b/src/frontend/xcecli/meson.build index d95315ef..e6226298 100644 --- a/src/frontend/xcecli/meson.build +++ b/src/frontend/xcecli/meson.build @@ -12,6 +12,8 @@ custom_target('xcecli', command: [env_program, 'CURRENT_SOURCE_DIR="@CURRENT_SOURCE_DIR@"', 'BUILD_ROOT="@BUILD_ROOT@"', + 'XCE_GIT_COMMIT=' + get_option('commit_id'), + 'XCE_BUILD_TIME=' + get_option('build_time'), go_build_program, '@INPUT@', '@OUTPUT@'], env: go_env,