mirror of
https://github.com/rust-lang/cargo
synced 2024-10-03 22:43:59 +00:00
feat: support target.triple.rustdocflags
officially
`CARGO_TARGET_<TRIPLE>_RUSTDOCFLAGS` was accidentally accepted somehow, so support both config and env officially, given that removing env support would be a breaking change.
This commit is contained in:
parent
44c69d83d6
commit
652a8413d7
|
@ -800,7 +800,6 @@ fn rustflags_from_target(
|
|||
.as_ref()
|
||||
.map(|rustflags| (key, &rustflags.val)),
|
||||
// `target.cfg(…).rustdocflags` is currently not supported.
|
||||
// In fact, neither is `target.<triple>.rustdocflags`.
|
||||
Flags::Rustdoc => None,
|
||||
}
|
||||
})
|
||||
|
|
|
@ -27,6 +27,8 @@ pub struct TargetConfig {
|
|||
pub runner: OptValue<PathAndArgs>,
|
||||
/// Additional rustc flags to pass.
|
||||
pub rustflags: OptValue<StringList>,
|
||||
/// Additional rustdoc flags to pass.
|
||||
pub rustdocflags: OptValue<StringList>,
|
||||
/// The path of the linker for this target.
|
||||
pub linker: OptValue<ConfigRelativePath>,
|
||||
/// Build script override for the given library name.
|
||||
|
@ -98,6 +100,7 @@ pub(super) fn load_host_triple(gctx: &GlobalContext, triple: &str) -> CargoResul
|
|||
Ok(TargetConfig {
|
||||
runner: None,
|
||||
rustflags: None,
|
||||
rustdocflags: None,
|
||||
linker: None,
|
||||
links_overrides: BTreeMap::new(),
|
||||
})
|
||||
|
@ -118,6 +121,7 @@ fn load_config_table(gctx: &GlobalContext, prefix: &str) -> CargoResult<TargetCo
|
|||
// environment variables would not work.
|
||||
let runner: OptValue<PathAndArgs> = gctx.get(&format!("{}.runner", prefix))?;
|
||||
let rustflags: OptValue<StringList> = gctx.get(&format!("{}.rustflags", prefix))?;
|
||||
let rustdocflags: OptValue<StringList> = gctx.get(&format!("{}.rustdocflags", prefix))?;
|
||||
let linker: OptValue<ConfigRelativePath> = gctx.get(&format!("{}.linker", prefix))?;
|
||||
// Links do not support environment variables.
|
||||
let target_key = ConfigKey::from_str(prefix);
|
||||
|
@ -128,6 +132,7 @@ fn load_config_table(gctx: &GlobalContext, prefix: &str) -> CargoResult<TargetCo
|
|||
Ok(TargetConfig {
|
||||
runner,
|
||||
rustflags,
|
||||
rustdocflags,
|
||||
linker,
|
||||
links_overrides,
|
||||
})
|
||||
|
@ -144,7 +149,7 @@ fn parse_links_overrides(
|
|||
// Skip these keys, it shares the namespace with `TargetConfig`.
|
||||
match lib_name.as_str() {
|
||||
// `ar` is a historical thing.
|
||||
"ar" | "linker" | "runner" | "rustflags" => continue,
|
||||
"ar" | "linker" | "runner" | "rustflags" | "rustdocflags" => continue,
|
||||
_ => {}
|
||||
}
|
||||
let mut output = BuildOutput::default();
|
||||
|
|
|
@ -177,13 +177,10 @@ fn target_triple_rustdocflags_works() {
|
|||
.with_stderr_contains("[RUNNING] `rustdoc[..]--cfg[..]foo[..]`")
|
||||
.run();
|
||||
|
||||
// target.triple.rustdocflags in config is not supported.
|
||||
// target.triple.rustdocflags in config works
|
||||
p.cargo("doc -v")
|
||||
.arg("--config")
|
||||
.arg(format!("target.{host}.rustdocflags=['--cfg', 'foo']"))
|
||||
.with_status(101)
|
||||
.with_stderr(format!(
|
||||
"[ERROR] expected a table, but found a array for `target.{host}.rustdocflags` in --config cli option"
|
||||
))
|
||||
.with_stderr_contains("[RUNNING] `rustdoc[..]--cfg[..]foo[..]`")
|
||||
.run();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue