Auto merge of #75539 - ehuss:fix-crate-version-rustdoc-bootstrap, r=Mark-Simulacrum

Fix crate-version with rustdoc in bootstrap.

Cargo will now automatically use the `--crate-version` flag (see https://github.com/rust-lang/cargo/pull/8509). Cargo has special handling to avoid passing the flag if it is passed in via RUSTDOCFLAGS, but the `rustdoc` wrapper circumvents that check. This causes a problem because rustdoc will fail if the flag is passed in twice. Fix this by using RUSTDOCFLAGS.

This will be necessary when 1.47 is promoted to beta, but should be safe to do now.
This commit is contained in:
bors 2020-08-15 07:55:58 +00:00
commit 5205b974d5
3 changed files with 7 additions and 11 deletions

View File

@ -48,12 +48,6 @@ fn main() {
cmd.arg(arg);
}
// Bootstrap's Cargo-command builder sets this variable to the current Rust version; let's pick
// it up so we can make rustdoc print this into the docs
if let Some(version) = env::var_os("RUSTDOC_CRATE_VERSION") {
cmd.arg("--crate-version").arg(version);
}
// Needed to be able to run all rustdoc tests.
if let Some(ref x) = env::var_os("RUSTDOC_RESOURCE_SUFFIX") {
// This "unstable-options" can be removed when `--resource-suffix` is stabilized

View File

@ -745,7 +745,6 @@ impl<'a> Builder<'a> {
.env("RUSTDOC_LIBDIR", self.rustc_libdir(compiler))
.env("CFG_RELEASE_CHANNEL", &self.config.channel)
.env("RUSTDOC_REAL", self.rustdoc(compiler))
.env("RUSTDOC_CRATE_VERSION", self.rust_version())
.env("RUSTC_BOOTSTRAP", "1")
.arg("-Winvalid_codeblock_attributes");
if self.config.deny_warnings {
@ -1271,7 +1270,11 @@ impl<'a> Builder<'a> {
}
// For `cargo doc` invocations, make rustdoc print the Rust version into the docs
cargo.env("RUSTDOC_CRATE_VERSION", self.rust_version());
// This replaces spaces with newlines because RUSTDOCFLAGS does not
// support arguments with regular spaces. Hopefully someday Cargo will
// have space support.
let rust_version = self.rust_version().replace(' ', "\n");
rustdocflags.arg("--crate-version").arg(&rust_version);
// Environment variables *required* throughout the build
//
@ -1448,14 +1451,14 @@ impl Rustflags {
fn env(&mut self, env: &str) {
if let Ok(s) = env::var(env) {
for part in s.split_whitespace() {
for part in s.split(' ') {
self.arg(part);
}
}
}
fn arg(&mut self, arg: &str) -> &mut Self {
assert_eq!(arg.split_whitespace().count(), 1);
assert_eq!(arg.split(' ').count(), 1);
if !self.0.is_empty() {
self.0.push_str(" ");
}

View File

@ -599,7 +599,6 @@ impl Step for RustdocTheme {
.env("RUSTDOC_LIBDIR", builder.sysroot_libdir(self.compiler, self.compiler.host))
.env("CFG_RELEASE_CHANNEL", &builder.config.channel)
.env("RUSTDOC_REAL", builder.rustdoc(self.compiler))
.env("RUSTDOC_CRATE_VERSION", builder.rust_version())
.env("RUSTC_BOOTSTRAP", "1");
if let Some(linker) = builder.linker(self.compiler.host, true) {
cmd.env("RUSTC_TARGET_LINKER", linker);