Loading
buildRustCrate: set CARGO_BIN_EXE_<name> for integration tests
Cargo sets `CARGO_BIN_EXE_<name>` when compiling integration tests so they can locate the crate's own binaries via `env!()` and exec them as subprocesses. buildRustCrate previously compiled bin targets as test harnesses only (via `--test`) when buildTests=true, so the real binary never existed and the env var was never set. When buildTests is set, now first build the real (non-test) binaries to `target/cargo-bin-exe/`, install them to `$out/bin/`, and expose `CARGO_BIN_EXE_<name>` to subsequent rustc invocations via an `env` prefix. Using `env` rather than bash `export` is necessary because hyphenated binary names (`CARGO_BIN_EXE_my-crate`) produce env var names that bash rejects as invalid identifiers; `env` sets them via execve's envp array directly and has no such restriction. The env array is populated by iterating `target/cargo-bin-exe/` at build time, so it covers all binary-target shapes: explicit `crateBin` entries, auto-detected `src/main.rs`, and auto-detected `src/bin/*.rs`. `build_bin` in lib.sh gains an optional third argument for the output directory so the real binary and the `--test` harness can coexist without colliding in `target/bin/`. The lib-test build is reordered to after the real-bin build so its compilation also sees the env vars.