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

Allow cargo_build_script to forward rustc args to build scripts #1165

Merged
merged 9 commits into from
Mar 4, 2022

Conversation

UebelAndre
Copy link
Collaborator

@UebelAndre UebelAndre commented Mar 3, 2022

rust-lang/cargo#9600 lead to the introduction of CARGO_ENCODED_RUSTFLAGS which was introduced to allow build scripts to access rust flags. This PR add this flag and sets --sysroot so crates like autocfg (which makes use of this flag here) is correctly able to make use of the generated rust_toolchain. This avoids issues like the following for users who create toolchains from separate rustc and rust_std artifacts.

Use --sandbox_debug to see verbose messages from the sandbox
error[E0107]: this struct takes 3 generic arguments but 2 generic arguments were supplied
  --> external/cargo_aliases__clap-3.0.0-beta.2/src/parse/matches/arg_matches.rs:77:22
   |
77 |     pub(crate) args: IndexMap<Id, MatchedArg>,
   |                      ^^^^^^^^ --  ---------- supplied 2 generic arguments
   |                      |
   |                      expected 3 generic arguments
   |
help: add missing generic argument
   |
77 |     pub(crate) args: IndexMap<Id, MatchedArg, S>,
   |                                             +++
 
error: aborting due to previous error

cargo/cargo_build_script.bzl Outdated Show resolved Hide resolved
cargo/cargo_build_script.bzl Outdated Show resolved Hide resolved
cargo/cargo_build_script.bzl Outdated Show resolved Hide resolved
UebelAndre and others added 3 commits March 4, 2022 07:37
Co-authored-by: Daniel Wagner-Hall <dawagner@gmail.com>
Co-authored-by: Daniel Wagner-Hall <dawagner@gmail.com>
@UebelAndre UebelAndre changed the title Updated cargo_build_script to set CARGO_ENCODED_RUSTFLAGS Allow cargo_build_script to forward rustc args to build scripts Mar 4, 2022
Copy link
Collaborator

@illicitonion illicitonion left a comment

Choose a reason for hiding this comment

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

LGTM - could you add a test?

@UebelAndre
Copy link
Collaborator Author

LGTM - could you add a test?

Fixed a bug and added a test!

Copy link
Collaborator

@illicitonion illicitonion left a comment

Choose a reason for hiding this comment

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

LGTM!

test/cargo_build_script/build.rs Outdated Show resolved Hide resolved
UebelAndre and others added 2 commits March 4, 2022 08:55
Co-authored-by: Daniel Wagner-Hall <dawagner@gmail.com>
@UebelAndre UebelAndre merged commit 78d702b into bazelbuild:main Mar 4, 2022
@UebelAndre UebelAndre deleted the build_script branch March 4, 2022 17:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants