Skip to content

Commit

Permalink
Rollup merge of rust-lang#61639 - Mark-Simulacrum:bootstrap-cleanup, …
Browse files Browse the repository at this point in the history
…r=alexcrichton

Bootstrap cleanup

Each commit is (mostly) standalone and probably best reviewed as such. Nothing too major just some drive-by nits as I was looking through the code.

r? @alexcrichton
  • Loading branch information
Centril authored Jun 11, 2019
2 parents 0d3bf40 + e4c44c7 commit f24ff55
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 108 deletions.
4 changes: 0 additions & 4 deletions src/bootstrap/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1693,10 +1693,6 @@ mod __test {
compiler: Compiler { host: a, stage: 1 },
target: b,
},
compile::Std {
compiler: Compiler { host: a, stage: 2 },
target: b,
},
]
);
assert_eq!(
Expand Down
51 changes: 12 additions & 39 deletions src/bootstrap/doc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,11 @@ macro_rules! book {
}

fn run(self, builder: &Builder<'_>) {
builder.ensure(Rustbook {
builder.ensure(RustbookSrc {
target: self.target,
name: INTERNER.intern_str($book_name),
version: $book_ver,
src: doc_src(builder),
})
}
}
Expand All @@ -75,35 +76,8 @@ enum RustbookVersion {
MdBook2,
}

#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
struct Rustbook {
target: Interned<String>,
name: Interned<String>,
version: RustbookVersion,
}

impl Step for Rustbook {
type Output = ();

// rustbook is never directly called, and only serves as a shim for the nomicon and the
// reference.
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
run.never()
}

/// Invoke `rustbook` for `target` for the doc book `name`.
///
/// This will not actually generate any documentation if the documentation has
/// already been generated.
fn run(self, builder: &Builder<'_>) {
let src = builder.src.join("src/doc");
builder.ensure(RustbookSrc {
target: self.target,
name: self.name,
src: INTERNER.intern_path(src),
version: self.version,
});
}
fn doc_src(builder: &Builder<'_>) -> Interned<PathBuf> {
INTERNER.intern_path(builder.src.join("src/doc"))
}

#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
Expand Down Expand Up @@ -274,33 +248,37 @@ impl Step for TheBook {
let name = self.name;

// build book
builder.ensure(Rustbook {
builder.ensure(RustbookSrc {
target,
name: INTERNER.intern_string(name.to_string()),
version: RustbookVersion::MdBook2,
src: doc_src(builder),
});

// building older edition redirects

let source_name = format!("{}/first-edition", name);
builder.ensure(Rustbook {
builder.ensure(RustbookSrc {
target,
name: INTERNER.intern_string(source_name),
version: RustbookVersion::MdBook2,
src: doc_src(builder),
});

let source_name = format!("{}/second-edition", name);
builder.ensure(Rustbook {
builder.ensure(RustbookSrc {
target,
name: INTERNER.intern_string(source_name),
version: RustbookVersion::MdBook2,
src: doc_src(builder),
});

let source_name = format!("{}/2018-edition", name);
builder.ensure(Rustbook {
builder.ensure(RustbookSrc {
target,
name: INTERNER.intern_string(source_name),
version: RustbookVersion::MdBook2,
src: doc_src(builder),
});

// build the version info page and CSS
Expand Down Expand Up @@ -898,11 +876,6 @@ impl Step for UnstableBookGen {
fn run(self, builder: &Builder<'_>) {
let target = self.target;

builder.ensure(compile::Std {
compiler: builder.compiler(builder.top_stage, builder.config.build),
target,
});

builder.info(&format!("Generating unstable book md files ({})", target));
let out = builder.md_doc_out(target).join("unstable-book");
builder.create_dir(&out);
Expand Down
5 changes: 0 additions & 5 deletions src/bootstrap/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -270,14 +270,9 @@ pub struct Build {
#[derive(Debug)]
struct Crate {
name: Interned<String>,
version: String,
deps: HashSet<Interned<String>>,
id: String,
path: PathBuf,
doc_step: String,
build_step: String,
test_step: String,
bench_step: String,
}

impl Crate {
Expand Down
6 changes: 0 additions & 6 deletions src/bootstrap/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ struct Output {
struct Package {
id: String,
name: String,
version: String,
source: Option<String>,
manifest_path: String,
}
Expand Down Expand Up @@ -84,12 +83,7 @@ fn build_krate(features: &str, build: &mut Build, resolves: &mut Vec<ResolveNode
let mut path = PathBuf::from(package.manifest_path);
path.pop();
build.crates.insert(name, Crate {
build_step: format!("build-crate-{}", name),
doc_step: format!("doc-crate-{}", name),
test_step: format!("test-crate-{}", name),
bench_step: format!("bench-crate-{}", name),
name,
version: package.version,
id: package.id,
deps: HashSet::new(),
path,
Expand Down
63 changes: 9 additions & 54 deletions src/bootstrap/tool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -268,10 +268,6 @@ macro_rules! bootstrap_tool {
}

impl Tool {
pub fn get_mode(&self) -> Mode {
Mode::ToolBootstrap
}

/// Whether this tool requires LLVM to run
pub fn uses_llvm_tools(&self) -> bool {
match self {
Expand Down Expand Up @@ -345,6 +341,7 @@ bootstrap_tool!(
Compiletest, "src/tools/compiletest", "compiletest", llvm_tools = true;
BuildManifest, "src/tools/build-manifest", "build-manifest";
RemoteTestClient, "src/tools/remote-test-client", "remote-test-client";
RemoteTestServer, "src/tools/remote-test-server", "remote-test-server";
RustInstaller, "src/tools/rust-installer", "fabricate", is_external_tool = true;
RustdocTheme, "src/tools/rustdoc-themes", "rustdoc-themes";
);
Expand Down Expand Up @@ -397,40 +394,6 @@ impl Step for ErrorIndex {
}
}

#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
pub struct RemoteTestServer {
pub compiler: Compiler,
pub target: Interned<String>,
}

impl Step for RemoteTestServer {
type Output = PathBuf;

fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
run.path("src/tools/remote-test-server")
}

fn make_run(run: RunConfig<'_>) {
run.builder.ensure(RemoteTestServer {
compiler: run.builder.compiler(run.builder.top_stage, run.builder.config.build),
target: run.target,
});
}

fn run(self, builder: &Builder<'_>) -> PathBuf {
builder.ensure(ToolBuild {
compiler: self.compiler,
target: self.target,
tool: "remote-test-server",
mode: Mode::ToolStd,
path: "src/tools/remote-test-server",
is_optional_tool: false,
source_type: SourceType::InTree,
extra_features: Vec::new(),
}).expect("expected to build -- essential tool")
}
}

#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
pub struct Rustdoc {
/// This should only ever be 0 or 2.
Expand Down Expand Up @@ -659,23 +622,14 @@ impl<'a> Builder<'a> {
pub fn tool_cmd(&self, tool: Tool) -> Command {
let mut cmd = Command::new(self.tool_exe(tool));
let compiler = self.compiler(0, self.config.build);
self.prepare_tool_cmd(compiler, tool, &mut cmd);
cmd
}

/// Prepares the `cmd` provided to be able to run the `compiler` provided.
///
/// Notably this munges the dynamic library lookup path to point to the
/// right location to run `compiler`.
fn prepare_tool_cmd(&self, compiler: Compiler, tool: Tool, cmd: &mut Command) {
let host = &compiler.host;
// Prepares the `cmd` provided to be able to run the `compiler` provided.
//
// Notably this munges the dynamic library lookup path to point to the
// right location to run `compiler`.
let mut lib_paths: Vec<PathBuf> = vec![
if compiler.stage == 0 {
self.build.rustc_snapshot_libdir()
} else {
PathBuf::from(&self.sysroot_libdir(compiler, compiler.host))
},
self.cargo_out(compiler, tool.get_mode(), *host).join("deps"),
self.build.rustc_snapshot_libdir(),
self.cargo_out(compiler, Mode::ToolBootstrap, *host).join("deps"),
];

// On MSVC a tool may invoke a C compiler (e.g., compiletest in run-make
Expand All @@ -696,6 +650,7 @@ impl<'a> Builder<'a> {
}
}

add_lib_path(lib_paths, cmd);
add_lib_path(lib_paths, &mut cmd);
cmd
}
}

0 comments on commit f24ff55

Please sign in to comment.