pub struct CliConfig { /* private fields */ }Expand description
Rustflags provided via cargo’s --config CLI option.
Cargo merges --config values in left-to-right order with the same logic
used for config files: arrays are joined with higher precedence items
placed later. CLI values take precedence over config files and config
environment variables (CARGO_TARGET_<T>_RUSTFLAGS, CARGO_BUILD_RUSTFLAGS),
but not over the RUSTFLAGS/CARGO_ENCODED_RUSTFLAGS environment
variables, which shortcut the rustflags resolution entirely.
Implementations§
Source§impl CliConfig
impl CliConfig
Sourcepub fn parse(config_args: &[String]) -> Result<Self>
pub fn parse(config_args: &[String]) -> Result<Self>
Parses cargo --config arguments (KEY=VALUE in TOML syntax, or a
path to an extra config file ending in .toml).
target.'cfg(...)' keys are ignored because evaluating cfg
expressions requires querying rustc; cargo still applies them to the
actual build, they just don’t influence zig’s -mcpu.
Sourcepub fn rustflags(
&self,
cargo_config: &Config,
rust_target: &str,
) -> Result<Option<Flags>>
pub fn rustflags( &self, cargo_config: &Config, rust_target: &str, ) -> Result<Option<Flags>>
Resolves the effective rustflags for rust_target, overlaying the
CLI-provided values onto the config file/environment resolution.
Cargo resolves rustflags from four mutually exclusive sources, in order, using the first one that is set:
CARGO_ENCODED_RUSTFLAGSenvironment variableRUSTFLAGSenvironment variable- all matching
target.<triple>.rustflagsandtarget.<cfg>.rustflagsconfig entries joined together build.rustflagsconfig value
--config values participate in sources 3 and 4 with the highest
precedence within those sources (joined last).