Skip to content

Commit

Permalink
Fix default Steps without paths.
Browse files Browse the repository at this point in the history
Some Steps are by-default run but don't have any paths associated with
them. We need to have at least one PathSet per each Step, though, so we
add an empty one on calls to `never()`.
  • Loading branch information
Mark-Simulacrum committed Feb 14, 2018
1 parent f104b12 commit a64575c
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/bootstrap/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ pub struct RunConfig<'a> {
pub builder: &'a Builder<'a>,
pub host: Interned<String>,
pub target: Interned<String>,
pub path: &'a Path,
pub path: PathBuf,
}

struct StepDescription {
Expand All @@ -114,6 +114,10 @@ struct PathSet {
}

impl PathSet {
fn empty() -> PathSet {
PathSet { set: BTreeSet::new() }
}

fn one<P: Into<PathBuf>>(path: P) -> PathSet {
let mut set = BTreeSet::new();
set.insert(path.into());
Expand All @@ -124,8 +128,8 @@ impl PathSet {
self.set.iter().any(|p| p.ends_with(needle))
}

fn path(&self) -> &Path {
self.set.iter().next().unwrap()
fn path(&self, builder: &Builder) -> PathBuf {
self.set.iter().next().unwrap_or(&builder.build.src).to_path_buf()
}
}

Expand Down Expand Up @@ -174,7 +178,7 @@ impl StepDescription {
for target in targets {
let run = RunConfig {
builder,
path: pathset.path(),
path: pathset.path(builder),
host: *host,
target: *target,
};
Expand Down Expand Up @@ -278,7 +282,8 @@ impl<'a> ShouldRun<'a> {
}

// allows being more explicit about why should_run in Step returns the value passed to it
pub fn never(self) -> ShouldRun<'a> {
pub fn never(mut self) -> ShouldRun<'a> {
self.paths.insert(PathSet::empty());
self
}

Expand Down

0 comments on commit a64575c

Please sign in to comment.