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

nkd-build: Propagate RUSTFLAGS into CARGO_ENCODED_RUSTFLAGS #357

Merged
merged 10 commits into from
Oct 28, 2022
Prev Previous commit
More feedback
Jake-Shadle committed Oct 28, 2022
commit 05ad042456a2bf29133a634a7d7ef929ad12f4e0
17 changes: 7 additions & 10 deletions ndk-build/src/cargo.rs
Original file line number Diff line number Diff line change
@@ -30,18 +30,15 @@ pub fn cargo_ndk(
Err(std::env::VarError::NotPresent) => {
match std::env::var("RUSTFLAGS") {
Ok(val) => {
// Note cargo also does this very simplified parsing of only
// splitting on spaces, ignoring things like quoting
// https://github.com/rust-lang/cargo/blob/f6de921a5d807746e972d9d10a4d8e1ca21e1b1f/src/cargo/core/compiler/build_context/target_info.rs#L682-L690
let to_join: Vec<_> = val
.split(' ')
.map(|s| s.trim())
.filter(|s| !s.is_empty())
.collect();

cargo.env_remove("RUSTFLAGS");

to_join.join(SEP)
// Same as cargo
// https://github.com/rust-lang/cargo/blob/f6de921a5d807746e972d9d10a4d8e1ca21e1b1f/src/cargo/core/compiler/build_context/target_info.rs#L682-L690
val.split(' ')
.map(str::trim)
.filter(|s| !s.is_empty())
.collect::<Vec<_>>()
.join(SEP)
}
Err(std::env::VarError::NotPresent) => String::new(),
Err(std::env::VarError::NotUnicode(_)) => {