Skip to content

Commit dcb40af

Browse files
committed
---
yaml --- r: 273009 b: refs/heads/beta c: f7b7535 h: refs/heads/master i: 273007: d01145c
1 parent c1f0cfd commit dcb40af

File tree

7 files changed

+77
-12
lines changed

7 files changed

+77
-12
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ refs/tags/0.9: 36870b185fc5f5486636d4515f0e22677493f225
2323
refs/tags/0.10: ac33f2b15782272ae348dbd7b14b8257b2148b5a
2424
refs/tags/0.11.0: e1247cb1d0d681be034adb4b558b5a0c0d5720f9
2525
refs/tags/0.12.0: f0c419429ef30723ceaf6b42f9b5a2aeb5d2e2d1
26-
refs/heads/beta: 0788cd23ea6e3f1b05240d591870899b9d38f5f4
26+
refs/heads/beta: f7b7535fd7cc4df3c137c5ce05bcd9817e8e006c
2727
refs/tags/1.0.0-alpha: e42bd6d93a1d3433c486200587f8f9e12590a4d7
2828
refs/heads/tmp: e06d2ad9fcd5027bcaac5b08fc9aa39a49d0ecd3
2929
refs/tags/1.0.0-alpha.2: 4c705f6bc559886632d3871b04f58aab093bfa2f

branches/beta/src/bootstrap/Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ path = "main.rs"
1515
name = "rustc"
1616
path = "rustc.rs"
1717

18+
[[bin]]
19+
name = "rustdoc"
20+
path = "rustdoc.rs"
21+
1822
[dependencies]
1923
build_helper = { path = "../build_helper" }
2024
cmake = "0.1.10"

branches/beta/src/bootstrap/build/compile.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,4 +325,3 @@ pub fn tool(build: &Build, stage: u32, host: &str, tool: &str) {
325325
.arg(build.src.join(format!("src/tools/{}/Cargo.toml", tool)));
326326
build.run(&mut cargo);
327327
}
328-

branches/beta/src/bootstrap/build/doc.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
use std::path::Path;
1211
use std::fs::{self, File};
1312
use std::io::prelude::*;
13+
use std::path::Path;
14+
use std::process::Command;
1415

1516
use build::{Build, Compiler, Mode};
1617
use build::util::{up_to_date, cp_r};
@@ -69,7 +70,7 @@ pub fn standalone(build: &Build, stage: u32, host: &str, out: &Path) {
6970
}
7071

7172
let html = out.join(filename).with_extension("html");
72-
let rustdoc = build.tool(&compiler, "rustdoc");
73+
let rustdoc = build.rustdoc(&compiler);
7374
if up_to_date(&path, &html) &&
7475
up_to_date(&footer, &html) &&
7576
up_to_date(&favicon, &html) &&
@@ -79,7 +80,7 @@ pub fn standalone(build: &Build, stage: u32, host: &str, out: &Path) {
7980
continue
8081
}
8182

82-
let mut cmd = build.tool_cmd(&compiler, "rustdoc");
83+
let mut cmd = Command::new(&rustdoc);
8384
cmd.arg("--html-after-content").arg(&footer)
8485
.arg("--html-before-content").arg(&version_info)
8586
.arg("--html-in-header").arg(&favicon)
@@ -108,10 +109,9 @@ pub fn std(build: &Build, stage: u32, host: &str, out: &Path) {
108109
let compiler = Compiler::new(stage, host);
109110
let out_dir = build.stage_out(stage, host, Mode::Libstd)
110111
.join(host).join("doc");
111-
let rustdoc = build.tool(&compiler, "rustdoc");
112-
if !up_to_date(&rustdoc, &out_dir.join("std/index.html")) {
113-
t!(fs::remove_dir_all(&out_dir));
114-
}
112+
let rustdoc = build.rustdoc(&compiler);
113+
114+
build.clear_if_dirty(&out_dir, &rustdoc);
115115

116116
let mut cargo = build.cargo(stage, &compiler, Mode::Libstd, Some(host),
117117
"doc");
@@ -127,7 +127,7 @@ pub fn rustc(build: &Build, stage: u32, host: &str, out: &Path) {
127127
let compiler = Compiler::new(stage, host);
128128
let out_dir = build.stage_out(stage, host, Mode::Librustc)
129129
.join(host).join("doc");
130-
let rustdoc = build.tool(&compiler, "rustdoc");
130+
let rustdoc = build.rustdoc(&compiler);
131131
if !up_to_date(&rustdoc, &out_dir.join("rustc/index.html")) {
132132
t!(fs::remove_dir_all(&out_dir));
133133
}

branches/beta/src/bootstrap/build/mod.rs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,8 @@ impl Build {
275275
.env("RUSTC_SYSROOT", self.sysroot(stage, host))
276276
.env("RUSTC_SNAPSHOT_LIBDIR", self.rustc_snapshot_libdir())
277277
.env("RUSTC_RPATH", self.config.rust_rpath.to_string())
278-
.env("RUSTDOC", self.tool(compiler, "rustdoc"));
278+
.env("RUSTDOC", self.out.join("bootstrap/debug/rustdoc"))
279+
.env("RUSTDOC_REAL", self.rustdoc(compiler));
279280

280281
if let Some(target) = target {
281282
cargo.env("RUSTC_FLAGS", self.rustc_flags(target).join(" "));
@@ -317,13 +318,26 @@ impl Build {
317318
}
318319
}
319320

320-
/// Get the specified tool next to the specified compiler
321+
/// Get the specified tool built by the specified compiler
321322
fn tool(&self, compiler: &Compiler, tool: &str) -> PathBuf {
322323
self.stage_out(compiler.stage, compiler.host, Mode::Tool)
323324
.join(self.cargo_dir())
324325
.join(exe(tool, compiler.host))
325326
}
326327

328+
/// Get the `rustdoc` executable next to the specified compiler
329+
fn rustdoc(&self, compiler: &Compiler) -> PathBuf {
330+
let root = if compiler.is_snapshot(self) {
331+
let mut rustdoc = self.rustc.clone();
332+
rustdoc.pop();
333+
rustdoc
334+
} else {
335+
let (stage, host) = (compiler.stage, compiler.host);
336+
self.cargo_out(stage - 1, host, Mode::Librustc, host)
337+
};
338+
root.join(exe("rustdoc", compiler.host))
339+
}
340+
327341
/// Get a `Command` which is ready to run `tool` in `stage` built for
328342
/// `host`.
329343
#[allow(dead_code)] // this will be used soon

branches/beta/src/bootstrap/rustc.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,23 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
//! Shim which is passed to Cargo as "rustc" when running the bootstrap.
12+
//!
13+
//! This shim will take care of some various tasks that our build process
14+
//! requires that Cargo can't quite do through normal configuration:
15+
//!
16+
//! 1. When compiling build scripts and build dependencies, we need a guaranteed
17+
//! full standard library available. The only compiler which actually has
18+
//! this is the snapshot, so we detect this situation and always compile with
19+
//! the snapshot compiler.
20+
//! 2. We pass a bunch of `--cfg` and other flags based on what we're compiling
21+
//! (and this slightly differs based on a whether we're using a snapshot or
22+
//! not), so we do that all here.
23+
//!
24+
//! This may one day be replaced by RUSTFLAGS, but the dynamic nature of
25+
//! switching compilers for the bootstrap and for build scripts will probably
26+
//! never get replaced.
27+
1128
extern crate bootstrap;
1229

1330
use std::env;
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
//! Shim which is passed to Cargo as "rustdoc" when running the bootstrap.
12+
//!
13+
//! See comments in `src/bootstrap/rustc.rs` for more information.
14+
15+
use std::env;
16+
use std::process::Command;
17+
18+
fn main() {
19+
let args = env::args_os().skip(1).collect::<Vec<_>>();
20+
let rustdoc = env::var_os("RUSTDOC_REAL").unwrap();
21+
22+
let mut cmd = Command::new(rustdoc);
23+
cmd.args(&args)
24+
.arg("--cfg").arg(format!("stage{}", env::var("RUSTC_STAGE").unwrap()))
25+
.arg("--cfg").arg("dox");
26+
std::process::exit(match cmd.status() {
27+
Ok(s) => s.code().unwrap_or(1),
28+
Err(e) => panic!("\n\nfailed to run {:?}: {}\n\n", cmd, e),
29+
})
30+
}
31+

0 commit comments

Comments
 (0)