@@ -168,28 +168,35 @@ fn add_steps<'a>(build: &'a Build,
168
168
host : & Step < ' a > ,
169
169
target : & Step < ' a > ,
170
170
targets : & mut Vec < Step < ' a > > ) {
171
+ struct Context < ' a > {
172
+ stage : u32 ,
173
+ compiler : Compiler < ' a > ,
174
+ _dummy : ( ) ,
175
+ host : & ' a str ,
176
+ }
171
177
for step in build. flags . step . iter ( ) {
172
- let compiler = host. target ( & build. config . build ) . compiler ( stage) ;
173
- match & step[ ..] {
174
- "libstd" => targets. push ( target. libstd ( stage, compiler) ) ,
175
- "librustc" => targets. push ( target. librustc ( stage, compiler) ) ,
176
- "libstd-link" => targets. push ( target. libstd_link ( stage, compiler,
177
- host. target ) ) ,
178
- "librustc-link" => targets. push ( target. librustc_link ( stage, compiler,
179
- host. target ) ) ,
180
- "rustc" => targets. push ( host. rustc ( stage) ) ,
181
- "llvm" => targets. push ( target. llvm ( ( ) ) ) ,
182
- "compiler-rt" => targets. push ( target. compiler_rt ( ( ) ) ) ,
183
- "doc-style" => targets. push ( host. doc_style ( stage) ) ,
184
- "doc-standalone" => targets. push ( host. doc_standalone ( stage) ) ,
185
- "doc-nomicon" => targets. push ( host. doc_nomicon ( stage) ) ,
186
- "doc-book" => targets. push ( host. doc_book ( stage) ) ,
187
- "doc-std" => targets. push ( host. doc_std ( stage) ) ,
188
- "doc-rustc" => targets. push ( host. doc_rustc ( stage) ) ,
189
- "doc" => targets. push ( host. doc ( stage) ) ,
190
- "check" => targets. push ( host. check ( stage, compiler) ) ,
191
- _ => panic ! ( "unknown build target: `{}`" , step) ,
178
+
179
+ // The macro below insists on hygienic access to all local variables, so
180
+ // we shove them all in a struct and subvert hygiene by accessing struct
181
+ // fields instead,
182
+ let cx = Context {
183
+ stage : stage,
184
+ compiler : host. target ( & build. config . build ) . compiler ( stage) ,
185
+ _dummy : ( ) ,
186
+ host : host. target ,
187
+ } ;
188
+ macro_rules! add_step {
189
+ ( $( ( $short: ident, $name: ident { $( $arg: ident: $t: ty) ,* } ) , ) * ) => ( { $(
190
+ let name = stringify!( $short) . replace( "_" , "-" ) ;
191
+ if & step[ ..] == & name[ ..] {
192
+ targets. push( target. $short( $( cx. $arg) ,* ) ) ;
193
+ continue
194
+ }
195
+ drop( name) ;
196
+ ) * } )
192
197
}
198
+
199
+ targets ! ( add_step) ;
193
200
}
194
201
}
195
202
0 commit comments