Skip to content
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

buildRustCrate: dont clobber src /w gen code #78414

Conversation

nagisa
Copy link
Contributor

@nagisa nagisa commented Jan 24, 2020

If a crate happened to have a build script that generates a file with
the name that’s the same with another file in src/, this little
snippet of code would overwrite the source with generated code…

Having looked at the history I failed to find justification for this
behaviour and since it makes actual crates (rustversion) fail to build,
this snippet has to go. See ya!

Fixes #78412

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS linux)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Ensured that relevant documentation is up to date
  • Fits CONTRIBUTING.md.

r? @andir

@nagisa nagisa requested a review from andir as a code owner January 24, 2020 13:51
@ofborg ofborg bot added the 6.topic: rust label Jan 24, 2020
@@ -140,11 +140,8 @@ in ''

set -e
if [[ -n "$(ls target/build/${crateName}.out)" ]]; then
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't nest two if with a single clause each. You can chain conditions inside [[ with &&.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’m not super confident dealing with the mess that bash is to start refactoring this code.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if [[ -n "$(ls target/build/${crateName}.out)" && -e "${libPath}" ]]; then
  cp -r target/build/${crateName}.out/* $(dirname ${libPath}) #*/
fi

Basically.

Although there's some quoting I could be fussy about, that seems off topic.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please make sure I didn't accidentally copy paste the wrong thing 😄

If a crate happened to have a build script that generates a file with
the name that’s the same with another file in `src/`, this little
snippet of code would overwrite the source with generated code…

Having looked at the history I failed to find justification for this
behaviour and since it makes actual crates (rustversion) fail to build,
this snippet has to go. See ya!
@nagisa nagisa force-pushed the nagisa/unclobberize-configure-crate-upstream branch from d98810c to 503c13d Compare January 24, 2020 14:13
Copy link
Member

@andir andir left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Before I saw this PR I crated another one that just removes the whole overlaying mechanism as it seems to not be relevant (anymore?). It also adds as test case so we don't silently break this in the next refactor:

#78706

@@ -139,13 +139,8 @@ in ''
| sed -e "s/cargo:\([^=]*\)=\(.*\)/export DEP_$(echo $CRATENAME)_\U\1\E=\2/" > target/env

set -e
if [[ -n "$(ls target/build/${crateName}.out)" ]]; then
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we have to keep the libPath version of this. This would just cause the same issue for any crate that has a custom path to the lib.rs file configured.

@nagisa nagisa closed this Jan 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

buildRustCrate fails to build rustversion 1.0.2
3 participants