Skip to content

Commit

Permalink
Permit constructing Builder without executing
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark-Simulacrum committed Apr 3, 2018
1 parent 84b5b34 commit a5e56b6
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 10 deletions.
19 changes: 10 additions & 9 deletions src/bootstrap/builder.rs
Expand Up @@ -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> {
Expand Down Expand Up @@ -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;
Expand All @@ -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[..]),
Expand All @@ -379,28 +381,27 @@ 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),
kind,
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]>) {
Expand Down
8 changes: 7 additions & 1 deletion src/bootstrap/lib.rs
Expand Up @@ -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();
Expand Down

0 comments on commit a5e56b6

Please sign in to comment.