feat(build-time-versioning): xceadmin generates build-info module
xceadmin/meson.build passes the resolved commit_id/build_time meson options as two new positional args (matching this custom_target's existing all-positional style) to meson-build.sh, which writes a small _build_info.py (GIT_COMMIT/BUILD_TIME, independent per-field "unknown" fallback) into the mirrored source tree's xceadmin package directory, before the pip install step -- same before-install ordering as the existing schema-sync step. A file-existence guard checks the exact path just written and fails loudly rather than silently proceeding with a missing/wrong module. Live-verified via a full real build+test+wheel cycle (run independently twice, once by implementation and once by review): the mirrored tree's _build_info.py and the packaged wheel both contain real, matching, non-"unknown" values (commit id matching git rev-parse --short HEAD plus dirty suffix, real UTC timestamp); full pytest suite passes (258 passed, 3 skipped -- documented live-HA e2e tests, skip-by-design). Task 5.1/13 of build-time-versioning. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
parent
fb09afe6be
commit
e1cd9d257c
3 changed files with 55 additions and 5 deletions
|
|
@ -22,6 +22,21 @@ REPO_ROOT="$3" # real repo root (contains ha/, src/)
|
|||
PYTHON="$4" # meson's resolved python3 (import('python').find_installation()),
|
||||
# NOT a bare `python3` PATH lookup -- see meson.build's comment
|
||||
STAMP_FILE="$5"
|
||||
GIT_COMMIT="$6" # build-time-versioning task 5.1: get_option('commit_id'),
|
||||
# resolved by xce-build.sh (task 2.1) -- empty if meson was
|
||||
# invoked without -Dcommit_id= (e.g. a bare `meson setup`)
|
||||
BUILD_TIME="$7" # build-time-versioning task 5.1: get_option('build_time'), same as above
|
||||
|
||||
# Requirement 1.4 / 4.2: never hand the mirrored tree a genuinely empty
|
||||
# value -- fall back to the literal "unknown", same empty -> "unknown"
|
||||
# discipline as src/tools/go_build's XCE_GIT_COMMIT/XCE_BUILD_TIME handling
|
||||
# and src/lib/utils.c's xce_version_field().
|
||||
if [ -z "$GIT_COMMIT" ]; then
|
||||
GIT_COMMIT=unknown
|
||||
fi
|
||||
if [ -z "$BUILD_TIME" ]; then
|
||||
BUILD_TIME=unknown
|
||||
fi
|
||||
|
||||
SRC_DIR="$REPO_ROOT/src"
|
||||
|
||||
|
|
@ -52,6 +67,33 @@ cp "$SRC_DIR/schema/controller.capnp" "$SCHEMA_DST/controller.capnp"
|
|||
cp "$SRC_DIR/schema/c.capnp" "$SCHEMA_DST/c.capnp"
|
||||
cp "$SRC_DIR/configs/schema/"*.schema.json "$SCHEMA_DST/json/"
|
||||
|
||||
# build-time-versioning task 5.1: generate the build-info module into the
|
||||
# MIRRORED tree's xceadmin package dir (src/xceadmin/, containing cli.py) --
|
||||
# never the real, checked-in src/xceadmin/src/xceadmin/ tree, which stays a
|
||||
# static "unknown"-only fallback stub (task 5.2, separate). Must land before
|
||||
# `pip install` below, same before-install ordering as the schema sync just
|
||||
# above, so both the pinned dev-venv install and the wheel built later from
|
||||
# this same $WORK_DIR package it.
|
||||
BUILD_INFO_DST="$WORK_DIR/src/xceadmin/_build_info.py"
|
||||
echo "=== xceadmin (meson): writing generated build-info module ==="
|
||||
cat > "$BUILD_INFO_DST" <<EOF
|
||||
# Generated by meson-build.sh (build-time-versioning task 5.1) -- do not edit.
|
||||
# Overwritten on every meson build; never checked in. See
|
||||
# src/xceadmin/src/xceadmin/_build_info.py (task 5.2) for the committed,
|
||||
# "unknown"-only fallback stub used by \`pip install -e .\` editable installs,
|
||||
# which never run this script.
|
||||
GIT_COMMIT = "$GIT_COMMIT"
|
||||
BUILD_TIME = "$BUILD_TIME"
|
||||
EOF
|
||||
|
||||
# Requirement 4.2: never silently proceed to pip install/pytest/wheel-build
|
||||
# packaging a fallback-shaped-but-actually-missing module -- confirm the
|
||||
# write actually landed in the mirrored tree first and fail loudly if not.
|
||||
if [ ! -f "$BUILD_INFO_DST" ]; then
|
||||
echo "ERROR: xceadmin (meson): failed to write generated build-info module to $BUILD_INFO_DST -- refusing to proceed to pip install with a missing/wrong build-info module." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "=== xceadmin (meson): pinned install into build-dir venv (python: $PYTHON) ==="
|
||||
rm -rf "$VENV_DIR"
|
||||
"$PYTHON" -m venv --system-site-packages "$VENV_DIR"
|
||||
|
|
|
|||
|
|
@ -40,6 +40,16 @@ xceadmin_stamp = custom_target('xceadmin',
|
|||
meson.current_source_dir() / '..' / '..', # repo root (contains ha/, src/)
|
||||
python3_prog.full_path(),
|
||||
'@OUTPUT@',
|
||||
# build-time-versioning task 5.1: same resolved commit_id/build_time
|
||||
# option values src/meson.build:30-31 (C) and apiserver/xcecli's
|
||||
# meson.build (Go, via XCE_GIT_COMMIT/XCE_BUILD_TIME) already thread
|
||||
# through -- passed here as two more positional args, matching this
|
||||
# custom_target's existing positional (not env-var) style. Empty when
|
||||
# unset (meson.options' default); meson-build.sh is responsible for the
|
||||
# empty -> "unknown" fallback, same discipline as go_build's
|
||||
# XCE_GIT_COMMIT/XCE_BUILD_TIME handling.
|
||||
get_option('commit_id'),
|
||||
get_option('build_time'),
|
||||
],
|
||||
build_by_default: true,
|
||||
build_always_stale: true,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue