Skip to content

Commit ef8921a

Browse files
committed
add concept of Step::noop()
1 parent e70415b commit ef8921a

File tree

1 file changed

+15
-16
lines changed

1 file changed

+15
-16
lines changed

src/bootstrap/step.rs

+15-16
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ pub fn build_rules(build: &Build) -> Rules {
8686
//
8787
// To handle this we do a bit of dynamic dispatch to see what the dependency
8888
// is. If we're building a LLVM for the build triple, then we don't actually
89-
// have any dependencies! To do that we return a dependency on the "dummy"
89+
// have any dependencies! To do that we return a dependency on the `Step::noop()`
9090
// target which does nothing.
9191
//
9292
// If we're build a cross-compiled LLVM, however, we need to assemble the
@@ -104,7 +104,7 @@ pub fn build_rules(build: &Build) -> Rules {
104104
.host(true)
105105
.dep(move |s| {
106106
if s.target == build.config.build {
107-
dummy(s, build)
107+
Step::noop()
108108
} else {
109109
s.target(&build.config.build)
110110
}
@@ -115,14 +115,11 @@ pub fn build_rules(build: &Build) -> Rules {
115115
// going on here. You can check out the API docs below and also see a bunch
116116
// more examples of rules directly below as well.
117117

118-
// dummy rule to do nothing, useful when a dep maps to no deps
119-
rules.build("dummy", "path/to/nowhere");
120-
121118
// the compiler with no target libraries ready to go
122119
rules.build("rustc", "src/rustc")
123120
.dep(move |s| {
124121
if s.stage == 0 {
125-
dummy(s, build)
122+
Step::noop()
126123
} else {
127124
s.name("librustc")
128125
.host(&build.config.build)
@@ -165,7 +162,7 @@ pub fn build_rules(build: &Build) -> Rules {
165162
.dep(move |s| s.name("rustc").host(&build.config.build).target(s.host))
166163
.dep(move |s| {
167164
if s.host == build.config.build {
168-
dummy(s, build)
165+
Step::noop()
169166
} else {
170167
s.host(&build.config.build)
171168
}
@@ -183,7 +180,7 @@ pub fn build_rules(build: &Build) -> Rules {
183180
.dep(|s| s.name("libstd"))
184181
.dep(move |s| {
185182
if s.host == build.config.build {
186-
dummy(s, build)
183+
Step::noop()
187184
} else {
188185
s.host(&build.config.build)
189186
}
@@ -203,7 +200,7 @@ pub fn build_rules(build: &Build) -> Rules {
203200
.dep(move |s| s.name("llvm").host(&build.config.build).stage(0))
204201
.dep(move |s| {
205202
if s.host == build.config.build {
206-
dummy(s, build)
203+
Step::noop()
207204
} else {
208205
s.host(&build.config.build)
209206
}
@@ -233,7 +230,7 @@ pub fn build_rules(build: &Build) -> Rules {
233230
if s.target.contains("android") {
234231
s.name("android-copy-libs")
235232
} else {
236-
dummy(s, build)
233+
Step::noop()
237234
}
238235
})
239236
.default(true)
@@ -514,12 +511,6 @@ pub fn build_rules(build: &Build) -> Rules {
514511

515512
rules.verify();
516513
return rules;
517-
518-
fn dummy<'a>(s: &Step<'a>, build: &'a Build) -> Step<'a> {
519-
s.name("dummy").stage(0)
520-
.target(&build.config.build)
521-
.host(&build.config.build)
522-
}
523514
}
524515

525516
#[derive(PartialEq, Eq, Hash, Clone, Debug)]
@@ -543,6 +534,10 @@ struct Step<'a> {
543534
}
544535

545536
impl<'a> Step<'a> {
537+
fn noop() -> Step<'a> {
538+
Step { name: "", stage: 0, host: "", target: "" }
539+
}
540+
546541
/// Creates a new step which is the same as this, except has a new name.
547542
fn name(&self, name: &'a str) -> Step<'a> {
548543
Step { name: name, ..*self }
@@ -738,6 +733,9 @@ impl<'a> Rules<'a> {
738733
if self.rules.contains_key(&dep.name) || dep.name.starts_with("default:") {
739734
continue
740735
}
736+
if dep == Step::noop() {
737+
continue
738+
}
741739
panic!("\
742740
743741
invalid rule dependency graph detected, was a rule added and maybe typo'd?
@@ -864,6 +862,7 @@ invalid rule dependency graph detected, was a rule added and maybe typo'd?
864862
// of what we need to do.
865863
let mut order = Vec::new();
866864
let mut added = HashSet::new();
865+
added.insert(Step::noop());
867866
for step in steps.iter().cloned() {
868867
self.fill(step, &mut order, &mut added);
869868
}

0 commit comments

Comments
 (0)