Repository navigation
Build: the ui-egui build script reads CARGO_MANIFEST_DIR when it runs - #488
Merged
Merged
Conversation
env! fixes the path to contributors/ when the build script is compiled. After a checkout is moved or copied, the compiled script keeps looking in the old location: the About window loses its contributor list, and because the rerun-if-changed path no longer exists, Cargo reruns the script and rebuilds the UI crate on every build. Reading the variable at run time follows the checkout.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
crates/ui-egui/build.rslocatescontributors/withenv!("CARGO_MANIFEST_DIR"). Theenv!macro fixes the path when the build script itself is compiled, not when it runs. If a checkout is moved or copied after the first build, for example into another directory or a Git worktree that reuses a shared target directory, the compiled build script keeps reading the old location. Two effects follow:contributors.jsonandpeople.tomlare not found.rerun-if-changedpaths point at files that no longer exist, so Cargo reruns the build script, and therefore rebuildsgridcraft-ui-egui, on every build.Change
The build script now reads
CARGO_MANIFEST_DIRfrom its environment withstd::env::var_oswhen it runs. Cargo sets this variable for every build-script run, so the path always follows the current checkout. The behaviour is otherwise unchanged.Testing
cargo fmt --check,cargo clippy -p gridcraft-ui-egui --all-targets -D warningsandcargo xtask wasmpass.rerun-if-changedlines are the same as before.Generative AI use: The code and descriptions in this pull request were written with the assistance of Claude Opus 5.5 (Claude Code). I directed the work, chose its scope, and reviewed and tested the changes.