macos: honor Cargo target directories in setup and launcher #38

Manually merged
github merged 2 commits from gh-pr/38/head into gh-pr/38/base 2026-11-26 14:43:33 +00:00
Owner

@⁠shabouwcaw on GitHub · 2026-11-26 10:53 UTC · original
shabouwcaw:fix/macos-cargo-target-dir → main · +240 −5 · 6 files · 2 commits · merged 2026-11-26 11:10 UTC

What this changes

A global Cargo build.target-dir lets setup build successfully outside the checkout, but the launcher still looks under target/. It either refuses to launch or silently starts an older executable left there. This addresses the Setup notes in #13, not its separate story-loading stall; it does not close that issue.

Both scripts now use a shared resolver based on cargo metadata --format-version 1 --no-deps --offline, keeping the explicit x86_64-apple-darwin/release/victory selection. macOS's built-in plutil decodes the JSON path, so no additional runtime dependency is introduced. Metadata/configuration errors stop the scripts; a missing or non-executable file reports the resolved path and setup command. The launcher also returns the child's exit status after printing the log.

This follows Cargo's documented absolute target_directory metadata field and configuration precedence. Setup and launching must use the same configuration; a one-off build's --target-dir flag is not persisted by Cargo. The launcher now requires Cargo on PATH.

How it was tested

The regression runner uses temporary workspaces, an isolated HOME/CARGO_HOME, real Cargo configuration resolution, harmless placeholder input, and fixture executables that record their exact path and argument vector. Custom-directory cases also plant a stale default executable, so launching the wrong file cannot pass. It runs with /bin/bash (stock 3.2) and is included in a new macOS CI job.

Central regression Original upstream scripts Fixed scripts
Global target-dir, no default executable Launcher exits 2: “victory is not built yet” Configured fixture runs
Global target-dir, stale default executable Wrong default fixture runs; exact-path assertion fails Configured fixture runs
  • /bin/bash tools/macos/tests/target-directory.sh: 15 cases pass. Covers default output; CARGO_TARGET_DIR and CARGO_BUILD_TARGET_DIR; global config both with explicit CARGO_HOME and HOME/.cargo; project-relative config and precedence; relative environment paths; spaces and quotes; missing/non-executable output; malformed or unsuccessful metadata and invalid config; exact arguments with/without headless; child exit 37; setup's matching output report and error propagation.
  • nice cargo test -j6 --locked -p victory-shader -p victory-hle -p victory -p victory-gpu -p xtask: passed on native Apple Silicon (502 passed, 4 ignored).
  • nice cargo test -j6 --locked --target x86_64-apple-darwin -p victory-hle -p victory-loader -p victory: passed under Rosetta, including actual execution of the 16 native-probe tests. Architecture-filtered arm64 tests are not counted as native execution coverage.
  • Windows-target Clippy, both default and --all-features, with --workspace --all-targets --locked -- -D warnings: passed.
  • cargo xtask policy, Bash syntax checks for all changed shell files, and git diff --check: passed.

All Rust checks used the sourced local environment, nice, and at most six build jobs, on the rebased commit after #31 merged. No game was run. Setup's installation/prerequisite commands and expensive release build are stubbed in the script tests; its metadata resolution is real. Full fresh-install setup and real-game launch are not claimed.

Upstream CI run 45805580822 passed on a657417: macOS script regressions (20 s) and the Windows check job (2 m 55 s, both Clippy configurations and full workspace tests).

Checklist

  • Focused change, with before/after regression evidence
  • No game files, game code, disassembly listings or SDK files included
  • No undocumented console behavior assumptions or new runtime tracing
  • Relevant setup/launcher behavior documented in docs/native-host.md
**@⁠shabouwcaw** on GitHub · 2026-11-26 10:53 UTC · [original](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/38) `shabouwcaw:fix/macos-cargo-target-dir` → `main` · +240 −5 · 6 files · 2 commits · merged 2026-11-26 11:10 UTC ## What this changes A global Cargo `build.target-dir` lets setup build successfully outside the checkout, but the launcher still looks under `target/`. It either refuses to launch or silently starts an older executable left there. This addresses the **Setup notes** in [#13](https://git.gtahub.st/github/LakshanSivakumar--Native-Victory-macOS/issues/13), not its separate story-loading stall; it does not close that issue. Both scripts now use a shared resolver based on `cargo metadata --format-version 1 --no-deps --offline`, keeping the explicit `x86_64-apple-darwin/release/victory` selection. macOS's built-in `plutil` decodes the JSON path, so no additional runtime dependency is introduced. Metadata/configuration errors stop the scripts; a missing or non-executable file reports the resolved path and setup command. The launcher also returns the child's exit status after printing the log. This follows Cargo's documented [absolute `target_directory` metadata field](https://doc.rust-lang.org/cargo/commands/cargo-metadata.html) and [configuration precedence](https://doc.rust-lang.org/cargo/reference/config.html#hierarchical-structure). Setup and launching must use the same configuration; a one-off build's `--target-dir` flag is not persisted by Cargo. The launcher now requires Cargo on PATH. ## How it was tested The regression runner uses temporary workspaces, an isolated HOME/CARGO_HOME, real Cargo configuration resolution, harmless placeholder input, and fixture executables that record their exact path and argument vector. Custom-directory cases also plant a stale default executable, so launching the wrong file cannot pass. It runs with `/bin/bash` (stock 3.2) and is included in a new macOS CI job. | Central regression | Original upstream scripts | Fixed scripts | | --- | --- | --- | | Global target-dir, no default executable | Launcher exits 2: “victory is not built yet” | Configured fixture runs | | Global target-dir, stale default executable | Wrong default fixture runs; exact-path assertion fails | Configured fixture runs | - `/bin/bash tools/macos/tests/target-directory.sh`: **15 cases pass**. Covers default output; `CARGO_TARGET_DIR` and `CARGO_BUILD_TARGET_DIR`; global config both with explicit CARGO_HOME and HOME/.cargo; project-relative config and precedence; relative environment paths; spaces and quotes; missing/non-executable output; malformed or unsuccessful metadata and invalid config; exact arguments with/without headless; child exit 37; setup's matching output report and error propagation. - `nice cargo test -j6 --locked -p victory-shader -p victory-hle -p victory -p victory-gpu -p xtask`: passed on native Apple Silicon (502 passed, 4 ignored). - `nice cargo test -j6 --locked --target x86_64-apple-darwin -p victory-hle -p victory-loader -p victory`: passed under Rosetta, including actual execution of the 16 native-probe tests. Architecture-filtered arm64 tests are not counted as native execution coverage. - Windows-target Clippy, both default and `--all-features`, with `--workspace --all-targets --locked -- -D warnings`: passed. - `cargo xtask policy`, Bash syntax checks for all changed shell files, and `git diff --check`: passed. All Rust checks used the sourced local environment, `nice`, and at most six build jobs, on the rebased commit after #31 merged. No game was run. Setup's installation/prerequisite commands and expensive release build are stubbed in the script tests; its metadata resolution is real. Full fresh-install setup and real-game launch are not claimed. Upstream [CI run 45805580822](https://github.com/LakshanSivakumar/Native-Victory-macOS/actions/runs/45805580822) passed on `a657417`: macOS script regressions (20 s) and the Windows check job (2 m 55 s, both Clippy configurations and full workspace tests). ## Checklist - [x] Focused change, with before/after regression evidence - [x] No game files, game code, disassembly listings or SDK files included - [x] No undocumented console behavior assumptions or new runtime tracing - [x] Relevant setup/launcher behavior documented in `docs/native-host.md`
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 14:43:32 +00:00
github manually merged commit f500512bb4 into gh-pr/38/base 2026-11-26 14:43:33 +00:00
Author
Owner

@⁠LakshanSivakumar on GitHub · 2026-11-26 11:07 UTC · original · approved these changes

Nice, careful work. Resolving through cargo metadata plus plutil avoids any new dependency, and the stale-binary case is exactly the trap. The 15-case script passes locally under /bin/bash 3.2, and the Rust tests, Windows clippy and policy pass merged with main alongside #39. The CI job addition looks fine.

**@⁠LakshanSivakumar** on GitHub · 2026-11-26 11:07 UTC · [original](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/38#pullrequestreview-6073050032) · **approved these changes** Nice, careful work. Resolving through `cargo metadata` plus `plutil` avoids any new dependency, and the stale-binary case is exactly the trap. The 15-case script passes locally under /bin/bash 3.2, and the Rust tests, Windows clippy and policy pass merged with main alongside #39. The CI job addition looks fine.
This discussion has been locked. Commenting is limited to contributors.
No description provided.