diff options
| author | Joshua Nelson <jyn514@gmail.com> | 2021-02-19 20:11:09 -0500 |
|---|---|---|
| committer | Joshua Nelson <jyn514@gmail.com> | 2021-02-21 11:29:09 -0500 |
| commit | 0238986de7fc584d532f22c981625d666e8ea22b (patch) | |
| tree | 127b3e7600f971336b0af5b401359a52ccf70183 /src/bootstrap | |
| parent | 8599bff5a3556059817503030e248507706e96b4 (diff) | |
| download | rust-0238986de7fc584d532f22c981625d666e8ea22b.tar.gz rust-0238986de7fc584d532f22c981625d666e8ea22b.zip | |
Propagate RUSTDOCFLAGS in the environment when documenting
Previously, RUSTDOCFLAGS would get overriden when bootstrap set `RUSTDOCFLAGS` itself. Propagate the flag manually, using the same logic as `RUSTFLAGS`. This also extracts the logic into a helper function to make sure it's the same.
Diffstat (limited to 'src/bootstrap')
| -rw-r--r-- | src/bootstrap/builder.rs | 30 |
1 files changed, 21 insertions, 9 deletions
diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs index a9099981e64..3beecb11ee9 100644 --- a/src/bootstrap/builder.rs +++ b/src/bootstrap/builder.rs @@ -938,6 +938,12 @@ impl<'a> Builder<'a> { // but this breaks CI. At the very least, stage0 `rustdoc` needs `--cfg bootstrap`. See // #71458. let mut rustdocflags = rustflags.clone(); + rustdocflags.propagate_cargo_env("RUSTDOCFLAGS"); + if stage == 0 { + rustdocflags.env("RUSTDOCFLAGS_BOOTSTRAP"); + } else { + rustdocflags.env("RUSTDOCFLAGS_NOT_BOOTSTRAP"); + } if let Ok(s) = env::var("CARGOFLAGS") { cargo.args(s.split_whitespace()); @@ -1551,21 +1557,27 @@ impl<'a> Builder<'a> { mod tests; #[derive(Debug, Clone)] -struct Rustflags(String); +struct Rustflags(String, TargetSelection); impl Rustflags { fn new(target: TargetSelection) -> Rustflags { - let mut ret = Rustflags(String::new()); + let mut ret = Rustflags(String::new(), target); + ret.propagate_cargo_env("RUSTFLAGS"); + ret + } + /// By default, cargo will pick up on various variables in the environment. However, bootstrap + /// reuses those variables to pass additional flags to rustdoc, so by default they get overriden. + /// Explicitly add back any previous value in the environment. + /// + /// `prefix` is usually `RUSTFLAGS` or `RUSTDOCFLAGS`. + fn propagate_cargo_env(&mut self, prefix: &str) { // Inherit `RUSTFLAGS` by default ... - ret.env("RUSTFLAGS"); - - // ... and also handle target-specific env RUSTFLAGS if they're - // configured. - let target_specific = format!("CARGO_TARGET_{}_RUSTFLAGS", crate::envify(&target.triple)); - ret.env(&target_specific); + self.env(prefix); - ret + // ... and also handle target-specific env RUSTFLAGS if they're configured. + let target_specific = format!("CARGO_TARGET_{}_{}", crate::envify(&self.1.triple), prefix); + self.env(&target_specific); } fn env(&mut self, env: &str) { |
