-
Notifications
You must be signed in to change notification settings - Fork 111
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
Conversation
I think this PR simply refers to the documented behaviour of
Do you want to document this feature in the changelog? |
695486b
to
404a066
Compare
RUSTFLAGS
into CARGO_ENCODED_RUSTFLAGS
Suggestion for the commit/PR message: ndk-build uses `CARGO_ENCODED_RUSTFLAGS` to get around flags/arguments
with spaces in `RUSTFLAGS`, with no defined way to escape them. For
correctness this implementation reads `CARGO_ENCODED_RUSTFLAGS` instead
of blindly overwriting its contents, but as per [`build.rustflags`
precedence rules] setting this environment variable would disregard any
contents in the more common `RUSTFLAGS` environment variable. To make
this more convenient for users, propagate the contents of `RUSTFLAGS`
into `CARGO_ENCODED_RUSTFLAGS` to ensure its contents don't get ignored.
[`build.rustflags` precedence rules]: https://doc.rust-lang.org/cargo/reference/config.html#buildrustflags Couple followup questions:
|
adc81b6
to
3ea5743
Compare
I think the only case that would be relevant would be if there was another non-cargo tool that invoked cargo-apk and set
I've cleared that env var now, since once cargo is invoked the ENCODED ones are the only ones that it cares about barring bugs, and there is already eg https://github.com/dtolnay/rustflags for parsing those if user's need to access them in build scripts. |
I wouldn't mind (prefer, actually) to be on the defensive side, and just disallow the case where Then only @msiglreith's comment remains :) |
I mean I could do that suggestion but would mean an unnecessary extra vector allocation since join is a slice method not an iterator method but if you're ok with that. |
Co-authored-by: Marijn Suijten <[email protected]>
192018e
to
05ad042
Compare
When running the actual cargo build, the
CARGO_ENCODED_RUSTFLAGS
was being read so that the rustflags set by the user are not overwritten when cargo-apk is adding its flags. However, this environment variable will only be set if you are building the APK via a build script, if you are invokingcargo apk build
cargo will not create that environment variable since it doesn't know what actual target/profile is going to be built. IfCARGO_ENCODED_RUSTFLAGS
is not found, this change now falls back toRUSTFLAGS
, and interprets it the same ascargo
does before writing it in the encoded form expected byCARGO_ENCODED_RUSTFLAGS