diff options
| author | kennytm <kennytm@gmail.com> | 2017-12-07 05:06:48 +0800 |
|---|---|---|
| committer | kennytm <kennytm@gmail.com> | 2017-12-27 00:00:45 +0800 |
| commit | 2566fa25c7fefbd61e4251bda4407747a3023891 (patch) | |
| tree | 981d391ca169cbf67f886f56f79c5dd55887d0b2 /src/bootstrap | |
| parent | 519f92f2aa7f2ec6833c57460283784a5077f73e (diff) | |
Revert "Add a file to trivially disable tool building or testing"
This reverts commit ab018c76e14b87f3c9e0b7384cc9b02d94779cd5. This also adds the `ToolBuild::is_ext_tool` field to replace the previous `ToolBuild::expectation` field, to indicate whether a build-failure of certain tool is essential.
Diffstat (limited to 'src/bootstrap')
| -rw-r--r-- | src/bootstrap/check.rs | 36 | ||||
| -rw-r--r-- | src/bootstrap/config.rs | 15 | ||||
| -rw-r--r-- | src/bootstrap/dist.rs | 10 | ||||
| -rw-r--r-- | src/bootstrap/lib.rs | 28 | ||||
| -rw-r--r-- | src/bootstrap/tool.rs | 37 | ||||
| -rw-r--r-- | src/bootstrap/toolstate.rs | 31 |
6 files changed, 31 insertions, 126 deletions
diff --git a/src/bootstrap/check.rs b/src/bootstrap/check.rs index eee403dcbe3..79a6a39d546 100644 --- a/src/bootstrap/check.rs +++ b/src/bootstrap/check.rs @@ -23,7 +23,7 @@ use std::path::{PathBuf, Path}; use std::process::Command; use std::io::Read; -use build_helper::{self, output, BuildExpectation}; +use build_helper::{self, output}; use builder::{Kind, RunConfig, ShouldRun, Builder, Compiler, Step}; use cache::{INTERNER, Interned}; @@ -65,23 +65,19 @@ impl fmt::Display for TestKind { } } -fn try_run_expecting(build: &Build, cmd: &mut Command, expect: BuildExpectation) -> bool { +fn try_run(build: &Build, cmd: &mut Command) -> bool { if !build.fail_fast { - if !build.try_run(cmd, expect) { + if !build.try_run(cmd) { let mut failures = build.delayed_failures.borrow_mut(); failures.push(format!("{:?}", cmd)); return false; } } else { - build.run_expecting(cmd, expect); + build.run(cmd); } true } -fn try_run(build: &Build, cmd: &mut Command) { - try_run_expecting(build, cmd, BuildExpectation::None); -} - fn try_run_quiet(build: &Build, cmd: &mut Command) { if !build.fail_fast { if !build.try_run_quiet(cmd) { @@ -259,11 +255,7 @@ impl Step for Rls { builder.add_rustc_lib_path(compiler, &mut cargo); - if try_run_expecting( - build, - &mut cargo, - builder.build.config.toolstate.rls.passes(ToolState::Testing), - ) { + if try_run(build, &mut cargo) { build.save_toolstate("rls", ToolState::Testing); } } @@ -309,11 +301,7 @@ impl Step for Rustfmt { builder.add_rustc_lib_path(compiler, &mut cargo); - if try_run_expecting( - build, - &mut cargo, - builder.build.config.toolstate.rustfmt.passes(ToolState::Testing), - ) { + if try_run(build, &mut cargo) { build.save_toolstate("rustfmt", ToolState::Testing); } } @@ -363,11 +351,7 @@ impl Step for Miri { builder.add_rustc_lib_path(compiler, &mut cargo); - if try_run_expecting( - build, - &mut cargo, - builder.build.config.toolstate.miri.passes(ToolState::Testing), - ) { + if try_run(build, &mut cargo) { build.save_toolstate("miri", ToolState::Testing); } } else { @@ -422,11 +406,7 @@ impl Step for Clippy { builder.add_rustc_lib_path(compiler, &mut cargo); - if try_run_expecting( - build, - &mut cargo, - builder.build.config.toolstate.clippy.passes(ToolState::Testing), - ) { + if try_run(build, &mut cargo) { build.save_toolstate("clippy-driver", ToolState::Testing); } } else { diff --git a/src/bootstrap/config.rs b/src/bootstrap/config.rs index 87b1db33a7a..f3ffe9a2761 100644 --- a/src/bootstrap/config.rs +++ b/src/bootstrap/config.rs @@ -27,7 +27,6 @@ use util::exe; use cache::{INTERNER, Interned}; use flags::Flags; pub use flags::Subcommand; -use toolstate::ToolStates; /// Global configuration for the entire build and/or bootstrap. /// @@ -134,8 +133,6 @@ pub struct Config { // These are either the stage0 downloaded binaries or the locally installed ones. pub initial_cargo: PathBuf, pub initial_rustc: PathBuf, - - pub toolstate: ToolStates, } /// Per-target configuration stored in the global configuration structure. @@ -348,18 +345,6 @@ impl Config { } }).unwrap_or_else(|| TomlConfig::default()); - let toolstate_toml_path = config.src.join("src/tools/toolstate.toml"); - let parse_toolstate = || -> Result<_, Box<::std::error::Error>> { - let mut f = File::open(toolstate_toml_path)?; - let mut contents = String::new(); - f.read_to_string(&mut contents)?; - Ok(toml::from_str(&contents)?) - }; - config.toolstate = parse_toolstate().unwrap_or_else(|err| { - println!("failed to parse TOML configuration 'toolstate.toml': {}", err); - process::exit(2); - }); - let build = toml.build.clone().unwrap_or(Build::default()); set(&mut config.build, build.build.clone().map(|x| INTERNER.intern_string(x))); set(&mut config.build, flags.build); diff --git a/src/bootstrap/dist.rs b/src/bootstrap/dist.rs index 78de9ec62d9..3d2795f04e2 100644 --- a/src/bootstrap/dist.rs +++ b/src/bootstrap/dist.rs @@ -1077,11 +1077,6 @@ impl Step for Rls { let target = self.target; assert!(build.config.extended); - if !builder.config.toolstate.rls.testing() { - println!("skipping Dist RLS stage{} ({})", stage, target); - return None - } - println!("Dist RLS stage{} ({})", stage, target); let src = build.src.join("src/tools/rls"); let release_num = build.release_num("rls"); @@ -1164,11 +1159,6 @@ impl Step for Rustfmt { let target = self.target; assert!(build.config.extended); - if !builder.config.toolstate.rustfmt.testing() { - println!("skipping Dist Rustfmt stage{} ({})", stage, target); - return None - } - println!("Dist Rustfmt stage{} ({})", stage, target); let src = build.src.join("src/tools/rustfmt"); let release_num = build.release_num("rustfmt"); diff --git a/src/bootstrap/lib.rs b/src/bootstrap/lib.rs index 2f00c313a0c..d6dc44034a7 100644 --- a/src/bootstrap/lib.rs +++ b/src/bootstrap/lib.rs @@ -143,8 +143,7 @@ use std::path::{PathBuf, Path}; use std::process::{self, Command}; use std::slice; -use build_helper::{run_silent, run_suppressed, try_run_silent, try_run_suppressed, output, mtime, - BuildExpectation}; +use build_helper::{run_silent, run_suppressed, try_run_silent, try_run_suppressed, output, mtime}; use util::{exe, libdir, OutputFolder, CiEnv}; @@ -569,31 +568,24 @@ impl Build { .join(libdir(&self.config.build)) } - /// Runs a command, printing out nice contextual information if its build - /// status is not the expected one - fn run_expecting(&self, cmd: &mut Command, expect: BuildExpectation) { - self.verbose(&format!("running: {:?}", cmd)); - run_silent(cmd, expect) - } - /// Runs a command, printing out nice contextual information if it fails. fn run(&self, cmd: &mut Command) { - self.run_expecting(cmd, BuildExpectation::None) + self.verbose(&format!("running: {:?}", cmd)); + run_silent(cmd) } /// Runs a command, printing out nice contextual information if it fails. fn run_quiet(&self, cmd: &mut Command) { self.verbose(&format!("running: {:?}", cmd)); - run_suppressed(cmd, BuildExpectation::None) + run_suppressed(cmd) } - /// Runs a command, printing out nice contextual information if its build - /// status is not the expected one. - /// Exits if the command failed to execute at all, otherwise returns whether - /// the expectation was met - fn try_run(&self, cmd: &mut Command, expect: BuildExpectation) -> bool { + /// Runs a command, printing out nice contextual information if it fails. + /// Exits if the command failed to execute at all, otherwise returns its + /// `status.success()`. + fn try_run(&self, cmd: &mut Command) -> bool { self.verbose(&format!("running: {:?}", cmd)); - try_run_silent(cmd, expect) + try_run_silent(cmd) } /// Runs a command, printing out nice contextual information if it fails. @@ -601,7 +593,7 @@ impl Build { /// `status.success()`. fn try_run_quiet(&self, cmd: &mut Command) -> bool { self.verbose(&format!("running: {:?}", cmd)); - try_run_suppressed(cmd, BuildExpectation::None) + try_run_suppressed(cmd) } pub fn is_verbose(&self) -> bool { diff --git a/src/bootstrap/tool.rs b/src/bootstrap/tool.rs index fa9bdc43c37..16e8b025b08 100644 --- a/src/bootstrap/tool.rs +++ b/src/bootstrap/tool.rs @@ -22,7 +22,6 @@ use native; use channel::GitInfo; use cache::Interned; use toolstate::ToolState; -use build_helper::BuildExpectation; #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub struct CleanTools { @@ -82,7 +81,7 @@ struct ToolBuild { tool: &'static str, path: &'static str, mode: Mode, - expectation: BuildExpectation, + is_ext_tool: bool, } impl Step for ToolBuild { @@ -102,7 +101,7 @@ impl Step for ToolBuild { let target = self.target; let tool = self.tool; let path = self.path; - let expectation = self.expectation; + let is_ext_tool = self.is_ext_tool; match self.mode { Mode::Libstd => builder.ensure(compile::Std { compiler, target }), @@ -115,34 +114,25 @@ impl Step for ToolBuild { println!("Building stage{} tool {} ({})", compiler.stage, tool, target); let mut cargo = prepare_tool_cargo(builder, compiler, target, "build", path); - let is_expected = build.try_run(&mut cargo, expectation); - // If the expectation is "Failing", `try_run` returning true actually - // means a build-failure is successfully observed, i.e. the tool is - // broken. Thus the XOR here. - // Sorry for the complicated logic, but we can remove this expectation - // logic after #45861 is fully fixed. - build.save_toolstate(tool, if is_expected ^ (expectation == BuildExpectation::Failing) { + let is_expected = build.try_run(&mut cargo); + build.save_toolstate(tool, if is_expected { ToolState::Compiling } else { ToolState::Broken }); if !is_expected { - if expectation == BuildExpectation::None { + if !is_ext_tool { exit(1); } else { return None; } - } - - if expectation == BuildExpectation::Succeeding || expectation == BuildExpectation::None { + } else { let cargo_out = build.cargo_out(compiler, Mode::Tool, target) .join(exe(tool, &compiler.host)); let bin = build.tools_dir(compiler).join(exe(tool, &compiler.host)); copy(&cargo_out, &bin); Some(bin) - } else { - None } } } @@ -251,8 +241,8 @@ macro_rules! tool { tool: $tool_name, mode: $mode, path: $path, - expectation: BuildExpectation::None, - }).expect("expected to build -- BuildExpectation::None") + is_ext_tool: false, + }).expect("expected to build -- essential tool") } } )+ @@ -299,8 +289,8 @@ impl Step for RemoteTestServer { tool: "remote-test-server", mode: Mode::Libstd, path: "src/tools/remote-test-server", - expectation: BuildExpectation::None, - }).expect("expected to build -- BuildExpectation::None") + is_ext_tool: false, + }).expect("expected to build -- essential tool") } } @@ -417,8 +407,8 @@ impl Step for Cargo { tool: "cargo", mode: Mode::Librustc, path: "src/tools/cargo", - expectation: BuildExpectation::None, - }).expect("BuildExpectation::None - expected to build") + is_ext_tool: false, + }).expect("expected to build -- essential tool") } } @@ -455,14 +445,13 @@ macro_rules! tool_extended { fn run($sel, $builder: &Builder) -> Option<PathBuf> { $extra_deps - let toolstate = $builder.build.config.toolstate.$toolstate; $builder.ensure(ToolBuild { compiler: $sel.compiler, target: $sel.target, tool: $tool_name, mode: Mode::Librustc, path: $path, - expectation: toolstate.passes(ToolState::Compiling), + is_ext_tool: true, }) } } diff --git a/src/bootstrap/toolstate.rs b/src/bootstrap/toolstate.rs index 00dbcc86af4..3c490044e4e 100644 --- a/src/bootstrap/toolstate.rs +++ b/src/bootstrap/toolstate.rs @@ -8,8 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use build_helper::BuildExpectation; - #[derive(Copy, Clone, Debug, Deserialize, Serialize, PartialEq, Eq)] /// Whether a tool can be compiled, tested or neither pub enum ToolState { @@ -21,38 +19,9 @@ pub enum ToolState { Broken = 0, } -impl ToolState { - /// If a tool with the current toolstate should be working on - /// the given toolstate - pub fn passes(self, other: ToolState) -> BuildExpectation { - if self as usize >= other as usize { - BuildExpectation::Succeeding - } else { - BuildExpectation::Failing - } - } - - pub fn testing(&self) -> bool { - match *self { - ToolState::Testing => true, - _ => false, - } - } -} - impl Default for ToolState { fn default() -> Self { // err on the safe side ToolState::Broken } } - -#[derive(Copy, Clone, Debug, Deserialize, Default)] -/// Used to express which tools should (not) be compiled or tested. -/// This is created from `toolstate.toml`. -pub struct ToolStates { - pub miri: ToolState, - pub clippy: ToolState, - pub rls: ToolState, - pub rustfmt: ToolState, -} |
