-
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
Read environment variables from .cargo/config.toml
's [env]
section
#233
Conversation
cargo-apk/src/apk.rs
Outdated
Some(config) => config | ||
.resolve_env(key) | ||
// IO error is currently only returned when path canonicalization fails | ||
.expect("Failed to resolve environment variable") |
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.
intergrating the queried key
into the error msg would be helpful imo
6735098
to
e2ed7da
Compare
Environment variables can be set and optionally override the process environment through `.cargo/config.toml`'s `[env]` section: https://doc.rust-lang.org/cargo/reference/config.html#env These config variables have specific precedence rules with regards to overriding the environment set in the process, and can optionally represent paths relative to the parent of the containing `.cargo/` folder. The entire handling of these variables is implemented in rust-mobile/cargo-subcommand#12 which can be read as-is from cargo-apk and ndk-build, through a trait to keep ndk-build oblivious for cargo-subcommand.
mmh, don't necessarily like that this env thing needs to be passed in to the |
sorry for being a bit late to the game, hadn't looked at this PR yet. |
I hadn't really even considered that. Is it something we'd like EDIT: That way this PR likely becomes a no-op and can be closed. |
I think so yes. I still think that down the road we want to remove arg parsing and instead have something called |
Wondering what happens if you run the algorithm twice. |
|
Isn't |
well we can have a config struct with all the cmdline arguments. Something like this: #[cfg_attr(feature = "clap", derive(Parser))]
struct Args {
target_dir: Option<PathBuf>,
package: Option<String>,
examples: Option<bool>,
example: Option<String>,
} If a subcommand uses clap and uses all the supported args it can just |
Closing as per discussion |
@dvc94ch Yeah that seems like a really neat solution, but isn't really relevant for this PR. Not sure about preliminarily closing this before we have implemented the |
I guess we can keep it open for now |
…nment Leaving the caller to read and merge config environment values with the process environment is not only cumbersome as seen in [rust-mobile/ndk#233], but these values need to be propagated into the process environment anyway to be usable by any subprocess spawned by the caller (ie. `cargo-apk` spawning `cargo rustc`, which can internally spawn a bunch of compilers and linkers too). Instead, do this automatically when the caller invokes `Subcommand::new` while still leaving the door open for crates to read the environment from the public `subcommand.manifest.env` member. [rust-mobile/ndk#233]: rust-mobile/ndk#233
This is finally unnecessary now that rust-mobile/cargo-subcommand#16 is open 🥳! |
…nment (#16) Leaving the caller to read and merge config environment values with the process environment is not only cumbersome as seen in [rust-mobile/ndk#233], but these values need to be propagated into the process environment anyway to be usable by any subprocess spawned by the caller (ie. `cargo-apk` spawning `cargo rustc`, which can internally spawn a bunch of compilers and linkers too). Instead, do this automatically when the caller invokes `Subcommand::new` while still leaving the door open for crates to read the environment from the public `subcommand.manifest.env` member. [rust-mobile/ndk#233]: rust-mobile/ndk#233
Closes #230
Environment variables can be set and optionally override the process environment through
.cargo/config.toml
's[env]
section: https://doc.rust-lang.org/cargo/reference/config.html#envThese config variables have specific precedence rules with regards to overriding the environment set in the process, and can optionally represent paths relative to the parent of the containing
.cargo/
folder. The entire handling of these variables is implemented in rust-mobile/cargo-subcommand#12 which can be read as-is from cargo-apk and ndk-build, through a trait to keep ndk-build oblivious for cargo-subcommand.