-
Notifications
You must be signed in to change notification settings - Fork 17
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: remove from env CARGO_ENCODED_RUSTFLAGS for easier nested builds, simplify RUSTFLAGS computation rule #289
Changes from 2 commits
57c58ec
b8f7a66
1c08f6f
f462957
6a6a7e8
3c168e3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,28 +24,14 @@ where | |
{ | ||
let mut final_env = BTreeMap::new(); | ||
|
||
// this will overwrite any other RUSTFLAGS specified | ||
if hide_warnings { | ||
env.push(("RUSTFLAGS", "-Awarnings")); | ||
} | ||
|
||
// last instance of a key gets inserted | ||
for (key, value) in env { | ||
match key { | ||
"RUSTFLAGS" => { | ||
let rustflags: &mut String = final_env | ||
.entry(key) | ||
.or_insert_with(|| std::env::var(key).unwrap_or_default()); | ||
// helps avoids situation on complete match `RUSTFLAGS="-C link-arg=-s -C link-arg=-s"` | ||
if !rustflags.contains(value) { | ||
if !rustflags.is_empty() { | ||
rustflags.push(' '); | ||
} | ||
rustflags.push_str(value); | ||
} | ||
} | ||
_ => { | ||
final_env.insert(key, value.to_string()); | ||
} | ||
} | ||
final_env.insert(key, value.to_string()); | ||
akorchyn marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
let artifacts = invoke_cargo( | ||
|
@@ -118,6 +104,11 @@ where | |
let cargo = std::env::var("CARGO").unwrap_or_else(|_| "cargo".to_string()); | ||
let mut cmd = Command::new(cargo); | ||
|
||
// removing env, which may be implicitly passed when bulding from within a build-script | ||
// see https://github.com/near/cargo-near/issues/287 | ||
// CARGO_ENCODED_RUSTFLAGS="-Awarnings" and RUSTFLAGS="-Awarnings" both result | ||
// in mysterious failures of `cargo build --target wasm32-unknown-unknown` (rustc bug) | ||
cmd.env_remove("CARGO_ENCODED_RUSTFLAGS"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The comment says that both There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. RUSTFLAGS gets reset to unset in build scripts, so the 2nd or 3rd of 4th build won't inherit this value from |
||
cmd.envs(env); | ||
|
||
if let Some(path) = working_dir { | ||
|
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.
this is just a simplification to avoid concatenating with value from env.
It will be simply
-Awarnings
for abi builds and-C link-arg=-s
for wasm builds