1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
//! Embeds two build-time facts `xr --version`/`xr upgrade` need, neither of
//! which `CARGO_PKG_VERSION` can give (it's a static `"0.1.0"` in this
//! workspace's own `Cargo.toml`, never bumped per milestone - see
//! `upgrade.rs`'s own doc comment for why commit-based freshness is the
//! real signal here instead):
//!
//! - `LARUST_GIT_COMMIT` - the checkout's current commit hash, shown by
//! `xr --version` and compared against `HEAD` on every `xr upgrade` run.
//! - `LARUST_CHECKOUT_ROOT` - the workspace root's absolute path, so an
//! `xr` binary installed via `cargo install --path ...`/`install.sh` (and
//! then run from anywhere - a scaffolded app's own directory, most of
//! the time) still knows where its own source checkout lives.
//!
//! Emits **no real `rerun-if-changed` paths** - the original design here
//! assumed that emitting zero `rerun-if` directives makes Cargo "always
//! rerun this build script," which is wrong: Cargo's actual default
//! (confirmed empirically, not just from docs) is to rerun a build script
//! whenever any file *inside this package* changes, which never includes
//! `.git/` at the workspace root. In practice that meant `xr --version`
//! silently kept reporting a stale commit after `cargo install --path
//! crates/larust-cli --force` any time the change was in some *other*
//! crate (the overwhelmingly common case) - confirmed live: touching a
//! file inside `larust-cli` refreshed the embedded hash, touching a
//! sibling crate and reinstalling did not, even though the reinstalled
//! binary did contain that crate's new code.
//!
//! A real ref-file watch (`.git/HEAD` plus the current branch's
//! `refs/heads/<branch>`) still wouldn't be complete - `git gc` can fold
//! loose refs into `.git/packed-refs` instead, moving the file Cargo would
//! need to watch out from under it. Since the whole point here is
//! "`git rev-parse HEAD`, freshly, every build" and that subprocess is
//! near-instant, the simplest correct fix is Cargo's own documented
//! idiom for an unconditional rerun: `rerun-if-changed` on a path that
//! can never exist, which Cargo therefore always treats as "changed."