]> git.lizzy.rs Git - rust.git/commitdiff
Set RUSTDOCFLAGS in `cargo` invocation
authorDylan MacKenzie <ecstaticmorse@gmail.com>
Thu, 23 Apr 2020 18:24:28 +0000 (11:24 -0700)
committerDylan MacKenzie <ecstaticmorse@gmail.com>
Thu, 23 Apr 2020 18:36:24 +0000 (11:36 -0700)
src/bootstrap/builder.rs

index 8d6c2db792645ad0af93f7861768f0c576c4c116..466e2d6e7991942e4199a65baf9802637bfd35b6 100644 (file)
@@ -791,6 +791,11 @@ pub fn cargo(
             rustflags.arg("--cfg=bootstrap");
         }
 
+        // FIXME: It might be better to use the same value for both `RUSTFLAGS` and `RUSTDOCFLAGS`,
+        // but this breaks CI. At the very least, stage0 `rustdoc` needs `--cfg bootstrap`. See
+        // #71458.
+        let rustdocflags = rustflags.clone();
+
         if let Ok(s) = env::var("CARGOFLAGS") {
             cargo.args(s.split_whitespace());
         }
@@ -1269,7 +1274,7 @@ pub fn cargo(
             }
         }
 
-        Cargo { command: cargo, rustflags }
+        Cargo { command: cargo, rustflags, rustdocflags }
     }
 
     /// Ensure that a given step is built, returning its output. This will
@@ -1327,7 +1332,7 @@ pub fn ensure<S: Step>(&'a self, step: S) -> S::Output {
 #[cfg(test)]
 mod tests;
 
-#[derive(Debug)]
+#[derive(Debug, Clone)]
 struct Rustflags(String);
 
 impl Rustflags {
@@ -1367,6 +1372,7 @@ fn arg(&mut self, arg: &str) -> &mut Self {
 pub struct Cargo {
     command: Command,
     rustflags: Rustflags,
+    rustdocflags: Rustflags,
 }
 
 impl Cargo {
@@ -1400,6 +1406,7 @@ pub fn env(&mut self, key: impl AsRef<OsStr>, value: impl AsRef<OsStr>) -> &mut
 impl From<Cargo> for Command {
     fn from(mut cargo: Cargo) -> Command {
         cargo.command.env("RUSTFLAGS", &cargo.rustflags.0);
+        cargo.command.env("RUSTDOCFLAGS", &cargo.rustdocflags.0);
         cargo.command
     }
 }