fix(tauri-build): emit absolute capabilities rerun-if-changed path - #15918
Open
valorkin wants to merge 1 commit into
Open
fix(tauri-build): emit absolute capabilities rerun-if-changed path#15918valorkin wants to merge 1 commit into
valorkin wants to merge 1 commit into
Conversation
The relative `cargo:rerun-if-changed=capabilities` is resolved by cargo against the package that owns the build script, while the glob in the same branch is resolved against the process working directory. A caller that `set_current_dir`s before `try_build[_context]` — e.g. a crate generating a context byte-identical to the app's — ends up watching `<caller-manifest-dir>/capabilities`, which usually does not exist. A missing watched path is dirty on every fingerprint check, so the build script re-runs on every build and recompiles the whole downstream chain (measured: a zero-change build of a 1.9k-unit workspace app went from ~140s to ~1s after making the watched dir exist). Emit the watch path anchored to the current dir the glob already uses.
Contributor
Package Changes Through a1a6d28There are 14 changes which include tauri with minor, tauri-cli with minor, @tauri-apps/cli with minor, tauri-build with minor, tauri-runtime with minor, tauri-runtime-wry with minor, tauri-utils with minor, tauri-bundler with minor, tauri-macos-sign with minor, @tauri-apps/api with minor, tauri-codegen with minor, tauri-macros with minor, tauri-plugin with minor, tauri-driver with minor Planned Package VersionsThe following package releases are the planned based on the context of changes in this pull request.
Add another change file through the GitHub UI by following this link. Read about change files or the docs at github.com/jbolda/covector |
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
tauri-buildemits a relativecargo:rerun-if-changed=capabilitiesin the default capabilities branch ofacl::build. Cargo resolves a relative watch path against the package that owns the build script, while the glob right below it (./capabilities/**/*) is resolved against the process working directory.Those two are the same directory for a normal app crate, so the bug is invisible there. But any caller that
set_current_dirs beforetry_build/try_build_context— for example a separate crate that generates a context byte-identical to the app's, or a workspace layout where the build script runs from a different directory — ends up watching<caller-manifest-dir>/capabilities, which usually does not exist.A missing watched path is dirty on every fingerprint check. The build script then re-runs on every build, which recompiles the crate and everything downstream of it. Measured in a 1.9k-unit workspace app: a zero-change
cargo buildtook ~140s; with the watched directory present it takes ~1s.Fix
Anchor the emitted watch path to the same base the glob already uses (
std::env::current_dir()), so the watch and the parse can never disagree about whichcapabilities/they mean.Testing
rustfmt --checkon the modified file: clean.capabilities/dir with an explanatory marker, which this PR makes removable).