diff options
| author | Mark Simulacrum <mark.simulacrum@gmail.com> | 2018-03-09 19:05:06 -0700 |
|---|---|---|
| committer | Mark Simulacrum <mark.simulacrum@gmail.com> | 2018-04-03 11:39:16 -0600 |
| commit | a5e56b62c5bef0b171785d5b20b3fd4e714db528 (patch) | |
| tree | 73a517bb87dc21591478143d54bb6ff28b08d365 /src/bootstrap | |
| parent | 84b5b340216dc1f086d5de2c7d234aa5883cdce8 (diff) | |
| download | rust-a5e56b62c5bef0b171785d5b20b3fd4e714db528.tar.gz rust-a5e56b62c5bef0b171785d5b20b3fd4e714db528.zip | |
Permit constructing Builder without executing
Diffstat (limited to 'src/bootstrap')
| -rw-r--r-- | src/bootstrap/builder.rs | 19 | ||||
| -rw-r--r-- | src/bootstrap/lib.rs | 8 |
2 files changed, 17 insertions, 10 deletions
diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs index 0464840c3e8..6ae19ac394e 100644 --- a/src/bootstrap/builder.rs +++ b/src/bootstrap/builder.rs @@ -42,6 +42,7 @@ pub struct Builder<'a> { cache: Cache, stack: RefCell<Vec<Box<Any>>>, time_spent_on_dependencies: Cell<Duration>, + pub paths: Vec<PathBuf>, } impl<'a> Deref for Builder<'a> { @@ -351,6 +352,7 @@ impl<'a> Builder<'a> { cache: Cache::new(), stack: RefCell::new(Vec::new()), time_spent_on_dependencies: Cell::new(Duration::new(0, 0)), + paths: vec![], }; let builder = &builder; @@ -367,7 +369,7 @@ impl<'a> Builder<'a> { Some(help) } - pub fn run(build: &Build) { + pub fn new(build: &Build) -> Builder { let (kind, paths) = match build.config.cmd { Subcommand::Build { ref paths } => (Kind::Build, &paths[..]), Subcommand::Check { ref paths } => (Kind::Check, &paths[..]), @@ -379,12 +381,6 @@ impl<'a> Builder<'a> { Subcommand::Clean { .. } => panic!(), }; - if let Some(path) = paths.get(0) { - if path == Path::new("nonexistent/path/to/trigger/cargo/metadata") { - return; - } - } - let builder = Builder { build, top_stage: build.config.stage.unwrap_or(2), @@ -392,15 +388,20 @@ impl<'a> Builder<'a> { cache: Cache::new(), stack: RefCell::new(Vec::new()), time_spent_on_dependencies: Cell::new(Duration::new(0, 0)), + paths: paths.to_owned(), }; if kind == Kind::Dist { - assert!(!build.config.test_miri, "Do not distribute with miri enabled.\n\ + assert!(!builder.config.test_miri, "Do not distribute with miri enabled.\n\ The distributed libraries would include all MIR (increasing binary size). The distributed MIR would include validation statements."); } - StepDescription::run(&Builder::get_step_descriptions(builder.kind), &builder, paths); + builder + } + + pub fn execute_cli(&self) { + StepDescription::run(&Builder::get_step_descriptions(self.kind), self, &self.paths); } pub fn default_doc(&self, paths: Option<&[PathBuf]>) { diff --git a/src/bootstrap/lib.rs b/src/bootstrap/lib.rs index 8b19bff3f6a..cbe19aeb633 100644 --- a/src/bootstrap/lib.rs +++ b/src/bootstrap/lib.rs @@ -394,7 +394,13 @@ impl Build { self.verbose("learning about cargo"); metadata::build(self); - builder::Builder::run(&self); + let builder = builder::Builder::new(&self); + if let Some(path) = builder.paths.get(0) { + if path == Path::new("nonexistent/path/to/trigger/cargo/metadata") { + return; + } + } + builder.execute_cli(); // Check for postponed failures from `test --no-fail-fast`. let failures = self.delayed_failures.borrow(); |
