-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix renaming a project using build scripts #4818
Conversation
r? @matklad (rust_highfive has picked a reviewer for you, use r? to override) |
Am I correct that currently we don't set cwd for build scripts? If so, let's lock cwd here as well? |
Nevermind, we do set cwd in |
@@ -364,6 +391,13 @@ impl BuildOutput { | |||
_ => bail!("Wrong output in {}: `{}`", whence, line), | |||
}; | |||
|
|||
let path = |val: &str| { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we, instead of post-processing after reading, do some pre-processing before writing, so as not to store absolute paths at the moment of generation at all?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm yeah I wasn't sure what was the best option here, we don't have a serialized format for Cargo's parsed data structures for the output file so it'd have to be added, it just wasn't clear to me how much of a benefit we'd get from it.
Do you think that the preprocessed version would be less buggy though?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think there are any tangible benefits one way or the other, but not having absolute paths feels slightly cleaner. But I am fine either way!
0cbd399
to
c3c9fae
Compare
@bors: r+ |
📌 Commit d6f8f45 has been approved by |
Er, @bors: r=matklad |
💡 This pull request was already approved, no need to approve it again.
|
📌 Commit d6f8f45 has been approved by |
⌛ Testing commit d6f8f45979c39bd963f12cd56a5e14645dd1d14d with merge e783bdaa306eff6a86d43840d4319979a3512a15... |
💔 Test failed - status-travis |
This commit fixes an issue in Cargo where if a project's folder was renamed but it also contained a build script the project could break. Cargo would continue to use the previous `rustc-link-search` arguments to configure env vars like `LD_LIBRARY_PATH` but the literal values from the previous compilation would be stale as the directories would no longer be there. To fix this when parsing the build script output we now retain a log of the previous output directory of a build script invocation as well as the current output, tweaking paths as appropriate if they were contained in the output folder. Closes rust-lang#4053
d6f8f45
to
f0c0a6a
Compare
@bors: r=matklad |
📌 Commit f0c0a6a has been approved by |
Fix renaming a project using build scripts This commit fixes an issue in Cargo where if a project's folder was renamed but it also contained a build script the project could break. Cargo would continue to use the previous `rustc-link-search` arguments to configure env vars like `LD_LIBRARY_PATH` but the literal values from the previous compilation would be stale as the directories would no longer be there. To fix this when parsing the build script output we now retain a log of the previous output directory of a build script invocation as well as the current output, tweaking paths as appropriate if they were contained in the output folder. Closes #4053
☀️ Test successful - status-appveyor, status-travis |
Fix renaming directory project using build scripts with cross-compiling. The rename-protection introduced in #4818 checks for paths with a prefix of `/…/target/debug`, but this does not work for paths used during cross-compiling. This change checks for paths with the full `OUT_DIR` prefix, and the `build/PKG/root-output` file now includes that full `OUT_DIR` instead of `/…/target/debug`. This also includes a few other changes: - Support fixing KIND=PATH style paths. - Support fixing paths in metadata (like `cargo:root=…` or `cargo:include=…` which are common). - Adds a "version" value to the metadata hash to ensure that cargo doesn't get confused with the new `root-output` file format. Fixes #6177
This commit fixes an issue in Cargo where if a project's folder was
renamed but it also contained a build script the project could break.
Cargo would continue to use the previous
rustc-link-search
argumentsto configure env vars like
LD_LIBRARY_PATH
but the literal values fromthe previous compilation would be stale as the directories would no
longer be there.
To fix this when parsing the build script output we now retain a log of
the previous output directory of a build script invocation as well as
the current output, tweaking paths as appropriate if they were contained
in the output folder.
Closes #4053