chore(build): make xce-build.sh self-wrap into nix develop

meson/ninja/capnp/Go only exist inside the hermetic nix dev shell, but
xce-build.sh never entered it itself -- the /xce-build skill documented
wrapping every invocation in `nix develop ./src --command ...` by hand,
so a bare `bash src/tools/xce-build.sh ...` (run directly instead of
through the skill) failed opaquely with "meson: command not found". This
was a recurring, previously-logged gap that resurfaced again today mid
bug-1789 verification.

The script now checks IN_NIX_SHELL at the top and re-execs itself under
`nix develop` if unset, so every caller -- the skill, a bare invocation,
CI, a human at a terminal -- gets it automatically. A nested call (already
inside the shell) is a no-op past that check. README.md's daily-develop
section updated to match; the old "or use nix develop --command" example
is now redundant and removed.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GLfB5uWRdmx2WiZSFC7Fm7
This commit is contained in:
Rongsong Shen 2026-09-07 15:31:06 +00:00
parent 924ac32c1d
commit 028d8f6ac7
No known key found for this signature in database
GPG key ID: 5BCDAAE0123E9FE2
8 changed files with 6063 additions and 6025 deletions

View file

@ -114,12 +114,12 @@ git add frontend/apiserver/go.mod frontend/apiserver/go.sum frontend/apiserver/v
## 3.4 build (for daily develop)
日常开发推荐直接使用 `src/tools/xce-build.sh`(若在 Claude Code 中开发,对应的是 `/xce-build` skill),
它会执行 `meson setup` / `meson compile`,并在 `asan` profile 下跑测试。**注意它自己不会进入 `nix develop`
环境**,需要先手动 `nix develop`,或者用 `nix develop --command` 包一层:
它会执行 `meson setup` / `meson compile`,并在 `asan` profile 下跑测试。**该脚本会自动进入 `nix develop`
环境**(脚本开头检测 `IN_NIX_SHELL`,未设置时自动用 `nix develop` 重新执行自身),无需手动
`nix develop` 或额外包一层,直接跑即可:
```sh
cd xce/src
nix develop
tools/xce-build.sh # 全部组件 + 全部测试 (asan profile, 输出到 xce.build/)
tools/xce-build.sh controller # 只构建/测试 controller (lib + controller + xce_test)
@ -128,12 +128,8 @@ tools/xce-build.sh scheduler # 只构建/测试 scheduler
tools/xce-build.sh apiserver # 只构建/测试 apiserver + xcecli (Go)
```
或者不进入交互式 shell,直接一条命令跑:
```sh
cd xce/src
nix develop --command tools/xce-build.sh controller
```
(如果已经身处 `nix develop` 交互式 shell 内运行以上命令,脚本会检测到 `IN_NIX_SHELL` 已设置,跳过重新
进入的步骤,直接执行构建。)
支持三种 profile(`tools/xce-build.sh [component] [profile]`):