@@ -75,14 +75,21 @@ impl Step for CleanTools {
75
75
}
76
76
}
77
77
78
+ #[ derive( Debug , Clone , Hash , PartialEq , Eq ) ]
79
+ pub enum SourceType {
80
+ InTree ,
81
+ Submodule ,
82
+ }
83
+
78
84
#[ derive( Debug , Clone , Hash , PartialEq , Eq ) ]
79
85
struct ToolBuild {
80
86
compiler : Compiler ,
81
87
target : Interned < String > ,
82
88
tool : & ' static str ,
83
89
path : & ' static str ,
84
90
mode : Mode ,
85
- is_ext_tool : bool ,
91
+ is_optional_tool : bool ,
92
+ source_type : SourceType ,
86
93
extra_features : Vec < String > ,
87
94
}
88
95
@@ -102,7 +109,7 @@ impl Step for ToolBuild {
102
109
let target = self . target ;
103
110
let tool = self . tool ;
104
111
let path = self . path ;
105
- let is_ext_tool = self . is_ext_tool ;
112
+ let is_optional_tool = self . is_optional_tool ;
106
113
107
114
match self . mode {
108
115
Mode :: ToolRustc => {
@@ -115,7 +122,15 @@ impl Step for ToolBuild {
115
122
_ => panic ! ( "unexpected Mode for tool build" )
116
123
}
117
124
118
- let mut cargo = prepare_tool_cargo ( builder, compiler, self . mode , target, "build" , path) ;
125
+ let mut cargo = prepare_tool_cargo (
126
+ builder,
127
+ compiler,
128
+ self . mode ,
129
+ target,
130
+ "build" ,
131
+ path,
132
+ self . source_type ,
133
+ ) ;
119
134
cargo. arg ( "--features" ) . arg ( self . extra_features . join ( " " ) ) ;
120
135
121
136
let _folder = builder. fold_output ( || format ! ( "stage{}-{}" , compiler. stage, tool) ) ;
@@ -216,7 +231,7 @@ impl Step for ToolBuild {
216
231
} ) ;
217
232
218
233
if !is_expected {
219
- if !is_ext_tool {
234
+ if !is_optional_tool {
220
235
exit ( 1 ) ;
221
236
} else {
222
237
return None ;
@@ -238,6 +253,7 @@ pub fn prepare_tool_cargo(
238
253
target : Interned < String > ,
239
254
command : & ' static str ,
240
255
path : & ' static str ,
256
+ source_type : SourceType ,
241
257
) -> Command {
242
258
let mut cargo = builder. cargo ( compiler, mode, target, command) ;
243
259
let dir = builder. src . join ( path) ;
@@ -247,6 +263,10 @@ pub fn prepare_tool_cargo(
247
263
// stages and such and it's just easier if they're not dynamically linked.
248
264
cargo. env ( "RUSTC_NO_PREFER_DYNAMIC" , "1" ) ;
249
265
266
+ if source_type == SourceType :: Submodule {
267
+ cargo. env ( "RUSTC_EXTERNAL_TOOL" , "1" ) ;
268
+ }
269
+
250
270
if let Some ( dir) = builder. openssl_install_dir ( target) {
251
271
cargo. env ( "OPENSSL_STATIC" , "1" ) ;
252
272
cargo. env ( "OPENSSL_DIR" , dir) ;
@@ -274,7 +294,8 @@ pub fn prepare_tool_cargo(
274
294
}
275
295
276
296
macro_rules! tool {
277
- ( $( $name: ident, $path: expr, $tool_name: expr, $mode: expr $( , llvm_tools = $llvm: expr) * ; ) +) => {
297
+ ( $( $name: ident, $path: expr, $tool_name: expr, $mode: expr
298
+ $( , llvm_tools = $llvm: expr) * $( , is_external_tool = $external: expr) * ; ) +) => {
278
299
#[ derive( Copy , PartialEq , Eq , Clone ) ]
279
300
pub enum Tool {
280
301
$(
@@ -351,7 +372,12 @@ macro_rules! tool {
351
372
tool: $tool_name,
352
373
mode: $mode,
353
374
path: $path,
354
- is_ext_tool: false ,
375
+ is_optional_tool: false ,
376
+ source_type: if false $( || $external) * {
377
+ SourceType :: Submodule
378
+ } else {
379
+ SourceType :: InTree
380
+ } ,
355
381
extra_features: Vec :: new( ) ,
356
382
} ) . expect( "expected to build -- essential tool" )
357
383
}
@@ -370,7 +396,8 @@ tool!(
370
396
Compiletest , "src/tools/compiletest" , "compiletest" , Mode :: ToolBootstrap , llvm_tools = true ;
371
397
BuildManifest , "src/tools/build-manifest" , "build-manifest" , Mode :: ToolBootstrap ;
372
398
RemoteTestClient , "src/tools/remote-test-client" , "remote-test-client" , Mode :: ToolBootstrap ;
373
- RustInstaller , "src/tools/rust-installer" , "fabricate" , Mode :: ToolBootstrap ;
399
+ RustInstaller , "src/tools/rust-installer" , "fabricate" , Mode :: ToolBootstrap ,
400
+ is_external_tool = true ;
374
401
RustdocTheme , "src/tools/rustdoc-themes" , "rustdoc-themes" , Mode :: ToolBootstrap ;
375
402
) ;
376
403
@@ -401,7 +428,8 @@ impl Step for RemoteTestServer {
401
428
tool : "remote-test-server" ,
402
429
mode : Mode :: ToolStd ,
403
430
path : "src/tools/remote-test-server" ,
404
- is_ext_tool : false ,
431
+ is_optional_tool : false ,
432
+ source_type : SourceType :: InTree ,
405
433
extra_features : Vec :: new ( ) ,
406
434
} ) . expect ( "expected to build -- essential tool" )
407
435
}
@@ -449,12 +477,15 @@ impl Step for Rustdoc {
449
477
target : builder. config . build ,
450
478
} ) ;
451
479
452
- let mut cargo = prepare_tool_cargo ( builder,
453
- build_compiler,
454
- Mode :: ToolRustc ,
455
- target,
456
- "build" ,
457
- "src/tools/rustdoc" ) ;
480
+ let mut cargo = prepare_tool_cargo (
481
+ builder,
482
+ build_compiler,
483
+ Mode :: ToolRustc ,
484
+ target,
485
+ "build" ,
486
+ "src/tools/rustdoc" ,
487
+ SourceType :: InTree ,
488
+ ) ;
458
489
459
490
// Most tools don't get debuginfo, but rustdoc should.
460
491
cargo. env ( "RUSTC_DEBUGINFO" , builder. config . rust_debuginfo . to_string ( ) )
@@ -525,7 +556,8 @@ impl Step for Cargo {
525
556
tool : "cargo" ,
526
557
mode : Mode :: ToolRustc ,
527
558
path : "src/tools/cargo" ,
528
- is_ext_tool : false ,
559
+ is_optional_tool : false ,
560
+ source_type : SourceType :: Submodule ,
529
561
extra_features : Vec :: new ( ) ,
530
562
} ) . expect ( "expected to build -- essential tool" )
531
563
}
@@ -574,7 +606,8 @@ macro_rules! tool_extended {
574
606
mode: Mode :: ToolRustc ,
575
607
path: $path,
576
608
extra_features: $sel. extra_features,
577
- is_ext_tool: true ,
609
+ is_optional_tool: true ,
610
+ source_type: SourceType :: Submodule ,
578
611
} )
579
612
}
580
613
}
0 commit comments