Skip to content

Commit

Permalink
Refactor is_external_tool into source_type
Browse files Browse the repository at this point in the history
  • Loading branch information
ishitatsuyuki committed Jul 26, 2018
1 parent a89f8e1 commit 62f73dc
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 22 deletions.
4 changes: 2 additions & 2 deletions src/bootstrap/check.rs
Expand Up @@ -12,7 +12,7 @@

use compile::{run_cargo, std_cargo, test_cargo, rustc_cargo, rustc_cargo_env, add_to_sysroot};
use builder::{RunConfig, Builder, ShouldRun, Step};
use tool::{self, prepare_tool_cargo};
use tool::{self, prepare_tool_cargo, SourceType};
use {Compiler, Mode};
use cache::{INTERNER, Interned};
use std::path::PathBuf;
Expand Down Expand Up @@ -223,7 +223,7 @@ impl Step for Rustdoc {
target,
"check",
"src/tools/rustdoc",
false);
SourceType::InTree);

let _folder = builder.fold_output(|| format!("stage{}-rustdoc", compiler.stage));
println!("Checking rustdoc artifacts ({} -> {})", &compiler.host, target);
Expand Down
4 changes: 2 additions & 2 deletions src/bootstrap/doc.rs
Expand Up @@ -28,7 +28,7 @@ use build_helper::up_to_date;

use util::symlink_dir;
use builder::{Builder, Compiler, RunConfig, ShouldRun, Step};
use tool::{self, prepare_tool_cargo, Tool};
use tool::{self, prepare_tool_cargo, Tool, SourceType};
use compile;
use cache::{INTERNER, Interned};
use config::Config;
Expand Down Expand Up @@ -814,7 +814,7 @@ impl Step for Rustdoc {
target,
"doc",
"src/tools/rustdoc",
false
SourceType::InTree,
);

cargo.env("RUSTDOCFLAGS", "--document-private-items");
Expand Down
14 changes: 7 additions & 7 deletions src/bootstrap/test.rs
Expand Up @@ -30,7 +30,7 @@ use compile;
use dist;
use flags::Subcommand;
use native;
use tool::{self, Tool};
use tool::{self, Tool, SourceType};
use toolstate::ToolState;
use util::{self, dylib_path, dylib_path_var};
use Crate as CargoCrate;
Expand Down Expand Up @@ -228,7 +228,7 @@ impl Step for Cargo {
self.host,
"test",
"src/tools/cargo",
true);
SourceType::Submodule);

if !builder.fail_fast {
cargo.arg("--no-fail-fast");
Expand Down Expand Up @@ -288,7 +288,7 @@ impl Step for Rls {
host,
"test",
"src/tools/rls",
true);
SourceType::Submodule);

builder.add_rustc_lib_path(compiler, &mut cargo);

Expand Down Expand Up @@ -341,7 +341,7 @@ impl Step for Rustfmt {
host,
"test",
"src/tools/rustfmt",
true);
SourceType::Submodule);

let dir = testdir(builder, compiler.host);
t!(fs::create_dir_all(&dir));
Expand Down Expand Up @@ -396,7 +396,7 @@ impl Step for Miri {
host,
"test",
"src/tools/miri",
true);
SourceType::Submodule);

// miri tests need to know about the stage sysroot
cargo.env("MIRI_SYSROOT", builder.sysroot(compiler));
Expand Down Expand Up @@ -455,7 +455,7 @@ impl Step for Clippy {
host,
"test",
"src/tools/clippy",
true);
SourceType::Submodule);

// clippy tests need to know about the stage sysroot
cargo.env("SYSROOT", builder.sysroot(compiler));
Expand Down Expand Up @@ -1740,7 +1740,7 @@ impl Step for CrateRustdoc {
target,
test_kind.subcommand(),
"src/tools/rustdoc",
false);
SourceType::InTree);
if test_kind.subcommand() == "test" && !builder.fail_fast {
cargo.arg("--no-fail-fast");
}
Expand Down
32 changes: 21 additions & 11 deletions src/bootstrap/tool.rs
Expand Up @@ -75,6 +75,12 @@ impl Step for CleanTools {
}
}

#[derive(Debug, Clone, Hash, PartialEq, Eq)]
pub enum SourceType {
InTree,
Submodule,
}

#[derive(Debug, Clone, Hash, PartialEq, Eq)]
struct ToolBuild {
compiler: Compiler,
Expand All @@ -83,7 +89,7 @@ struct ToolBuild {
path: &'static str,
mode: Mode,
is_optional_tool: bool,
is_external_tool: bool,
source_type: SourceType,
extra_features: Vec<String>,
}

Expand Down Expand Up @@ -123,7 +129,7 @@ impl Step for ToolBuild {
target,
"build",
path,
self.is_external_tool,
self.source_type,
);
cargo.arg("--features").arg(self.extra_features.join(" "));

Expand Down Expand Up @@ -247,7 +253,7 @@ pub fn prepare_tool_cargo(
target: Interned<String>,
command: &'static str,
path: &'static str,
is_external_tool: bool,
source_type: SourceType,
) -> Command {
let mut cargo = builder.cargo(compiler, mode, target, command);
let dir = builder.src.join(path);
Expand All @@ -257,7 +263,7 @@ pub fn prepare_tool_cargo(
// stages and such and it's just easier if they're not dynamically linked.
cargo.env("RUSTC_NO_PREFER_DYNAMIC", "1");

if is_external_tool {
if source_type == SourceType::Submodule {
cargo.env("RUSTC_EXTERNAL_TOOL", "1");
}

Expand Down Expand Up @@ -289,7 +295,7 @@ pub fn prepare_tool_cargo(

macro_rules! tool {
($($name:ident, $path:expr, $tool_name:expr, $mode:expr
$(,llvm_tools = $llvm:expr)* $(,external_tool = $external:expr)*;)+) => {
$(,llvm_tools = $llvm:expr)* $(,is_external_tool = $external:expr)*;)+) => {
#[derive(Copy, PartialEq, Eq, Clone)]
pub enum Tool {
$(
Expand Down Expand Up @@ -367,7 +373,11 @@ macro_rules! tool {
mode: $mode,
path: $path,
is_optional_tool: false,
is_external_tool: false $(|| $external)*,
source_type: if false $(|| $external)* {
SourceType::Submodule
} else {
SourceType::InTree
},
extra_features: Vec::new(),
}).expect("expected to build -- essential tool")
}
Expand All @@ -387,7 +397,7 @@ tool!(
BuildManifest, "src/tools/build-manifest", "build-manifest", Mode::ToolBootstrap;
RemoteTestClient, "src/tools/remote-test-client", "remote-test-client", Mode::ToolBootstrap;
RustInstaller, "src/tools/rust-installer", "fabricate", Mode::ToolBootstrap,
external_tool = true;
is_external_tool = true;
RustdocTheme, "src/tools/rustdoc-themes", "rustdoc-themes", Mode::ToolBootstrap;
);

Expand Down Expand Up @@ -419,7 +429,7 @@ impl Step for RemoteTestServer {
mode: Mode::ToolStd,
path: "src/tools/remote-test-server",
is_optional_tool: false,
is_external_tool: false,
source_type: SourceType::InTree,
extra_features: Vec::new(),
}).expect("expected to build -- essential tool")
}
Expand Down Expand Up @@ -474,7 +484,7 @@ impl Step for Rustdoc {
target,
"build",
"src/tools/rustdoc",
false,
SourceType::InTree,
);

// Most tools don't get debuginfo, but rustdoc should.
Expand Down Expand Up @@ -547,7 +557,7 @@ impl Step for Cargo {
mode: Mode::ToolRustc,
path: "src/tools/cargo",
is_optional_tool: false,
is_external_tool: true,
source_type: SourceType::Submodule,
extra_features: Vec::new(),
}).expect("expected to build -- essential tool")
}
Expand Down Expand Up @@ -597,7 +607,7 @@ macro_rules! tool_extended {
path: $path,
extra_features: $sel.extra_features,
is_optional_tool: true,
is_external_tool: true,
source_type: SourceType::Submodule,
})
}
}
Expand Down

0 comments on commit 62f73dc

Please sign in to comment.