Skip to content

Commit a64575c

Browse files
Fix default Steps without paths.
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()`.
1 parent f104b12 commit a64575c

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

src/bootstrap/builder.rs

+10-5
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ pub struct RunConfig<'a> {
9595
pub builder: &'a Builder<'a>,
9696
pub host: Interned<String>,
9797
pub target: Interned<String>,
98-
pub path: &'a Path,
98+
pub path: PathBuf,
9999
}
100100

101101
struct StepDescription {
@@ -114,6 +114,10 @@ struct PathSet {
114114
}
115115

116116
impl PathSet {
117+
fn empty() -> PathSet {
118+
PathSet { set: BTreeSet::new() }
119+
}
120+
117121
fn one<P: Into<PathBuf>>(path: P) -> PathSet {
118122
let mut set = BTreeSet::new();
119123
set.insert(path.into());
@@ -124,8 +128,8 @@ impl PathSet {
124128
self.set.iter().any(|p| p.ends_with(needle))
125129
}
126130

127-
fn path(&self) -> &Path {
128-
self.set.iter().next().unwrap()
131+
fn path(&self, builder: &Builder) -> PathBuf {
132+
self.set.iter().next().unwrap_or(&builder.build.src).to_path_buf()
129133
}
130134
}
131135

@@ -174,7 +178,7 @@ impl StepDescription {
174178
for target in targets {
175179
let run = RunConfig {
176180
builder,
177-
path: pathset.path(),
181+
path: pathset.path(builder),
178182
host: *host,
179183
target: *target,
180184
};
@@ -278,7 +282,8 @@ impl<'a> ShouldRun<'a> {
278282
}
279283

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

0 commit comments

Comments
 (0)