@@ -93,36 +93,46 @@ impl Step for ToolBuild {
93
93
let _folder = build. fold_output ( || format ! ( "stage{}-{}" , compiler. stage, tool) ) ;
94
94
println ! ( "Building stage{} tool {} ({})" , compiler. stage, tool, target) ;
95
95
96
- let mut cargo = builder. cargo ( compiler, Mode :: Tool , target, "build" ) ;
97
- let dir = build. src . join ( "src/tools" ) . join ( tool) ;
98
- cargo. arg ( "--manifest-path" ) . arg ( dir. join ( "Cargo.toml" ) ) ;
99
-
100
- // We don't want to build tools dynamically as they'll be running across
101
- // stages and such and it's just easier if they're not dynamically linked.
102
- cargo. env ( "RUSTC_NO_PREFER_DYNAMIC" , "1" ) ;
103
-
104
- if let Some ( dir) = build. openssl_install_dir ( target) {
105
- cargo. env ( "OPENSSL_STATIC" , "1" ) ;
106
- cargo. env ( "OPENSSL_DIR" , dir) ;
107
- cargo. env ( "LIBZ_SYS_STATIC" , "1" ) ;
108
- }
96
+ let mut cargo = prepare_tool_cargo ( builder, compiler, target, tool) ;
97
+ build. run ( & mut cargo) ;
98
+ build. cargo_out ( compiler, Mode :: Tool , target) . join ( exe ( tool, & compiler. host ) )
99
+ }
100
+ }
109
101
110
- cargo. env ( "CFG_RELEASE_CHANNEL" , & build. config . channel ) ;
102
+ fn prepare_tool_cargo (
103
+ builder : & Builder ,
104
+ compiler : Compiler ,
105
+ target : Interned < String > ,
106
+ tool : & ' static str ,
107
+ ) -> Command {
108
+ let build = builder. build ;
109
+ let mut cargo = builder. cargo ( compiler, Mode :: Tool , target, "build" ) ;
110
+ let dir = build. src . join ( "src/tools" ) . join ( tool) ;
111
+ cargo. arg ( "--manifest-path" ) . arg ( dir. join ( "Cargo.toml" ) ) ;
112
+
113
+ // We don't want to build tools dynamically as they'll be running across
114
+ // stages and such and it's just easier if they're not dynamically linked.
115
+ cargo. env ( "RUSTC_NO_PREFER_DYNAMIC" , "1" ) ;
116
+
117
+ if let Some ( dir) = build. openssl_install_dir ( target) {
118
+ cargo. env ( "OPENSSL_STATIC" , "1" ) ;
119
+ cargo. env ( "OPENSSL_DIR" , dir) ;
120
+ cargo. env ( "LIBZ_SYS_STATIC" , "1" ) ;
121
+ }
111
122
112
- let info = GitInfo :: new ( & build. config , & dir) ;
113
- if let Some ( sha) = info. sha ( ) {
114
- cargo. env ( "CFG_COMMIT_HASH" , sha) ;
115
- }
116
- if let Some ( sha_short) = info. sha_short ( ) {
117
- cargo. env ( "CFG_SHORT_COMMIT_HASH" , sha_short) ;
118
- }
119
- if let Some ( date) = info. commit_date ( ) {
120
- cargo. env ( "CFG_COMMIT_DATE" , date) ;
121
- }
123
+ cargo. env ( "CFG_RELEASE_CHANNEL" , & build. config . channel ) ;
122
124
123
- build. run ( & mut cargo) ;
124
- build. cargo_out ( compiler, Mode :: Tool , target) . join ( exe ( tool, & compiler. host ) )
125
+ let info = GitInfo :: new ( & build. config , & dir) ;
126
+ if let Some ( sha) = info. sha ( ) {
127
+ cargo. env ( "CFG_COMMIT_HASH" , sha) ;
125
128
}
129
+ if let Some ( sha_short) = info. sha_short ( ) {
130
+ cargo. env ( "CFG_SHORT_COMMIT_HASH" , sha_short) ;
131
+ }
132
+ if let Some ( date) = info. commit_date ( ) {
133
+ cargo. env ( "CFG_COMMIT_DATE" , date) ;
134
+ }
135
+ cargo
126
136
}
127
137
128
138
macro_rules! tool {
@@ -245,7 +255,9 @@ impl Step for Rustdoc {
245
255
}
246
256
247
257
fn run ( self , builder : & Builder ) -> PathBuf {
258
+ let build = builder. build ;
248
259
let target_compiler = self . target_compiler ;
260
+ let target = target_compiler. host ;
249
261
let build_compiler = if target_compiler. stage == 0 {
250
262
builder. compiler ( 0 , builder. build . build )
251
263
} else {
@@ -255,12 +267,16 @@ impl Step for Rustdoc {
255
267
builder. compiler ( target_compiler. stage - 1 , builder. build . build )
256
268
} ;
257
269
258
- let tool_rustdoc = builder. ensure ( ToolBuild {
259
- compiler : build_compiler,
260
- target : target_compiler. host ,
261
- tool : "rustdoc" ,
262
- mode : Mode :: Librustc ,
263
- } ) ;
270
+ builder. ensure ( CleanTools { compiler : build_compiler, target, mode : Mode :: Librustc } ) ;
271
+ builder. ensure ( compile:: Rustc { compiler : build_compiler, target } ) ;
272
+
273
+ let _folder = build. fold_output ( || format ! ( "stage{}-rustdoc" , target_compiler. stage) ) ;
274
+ println ! ( "Building rustdoc for stage{} ({})" , target_compiler. stage, target_compiler. host) ;
275
+
276
+ let mut cargo = prepare_tool_cargo ( builder, build_compiler, target, "rustdoc" ) ;
277
+ build. run ( & mut cargo) ;
278
+ let tool_rustdoc = build. cargo_out ( build_compiler, Mode :: Tool , target)
279
+ . join ( exe ( "rustdoc" , & target_compiler. host ) ) ;
264
280
265
281
// don't create a stage0-sysroot/bin directory.
266
282
if target_compiler. stage > 0 {
0 commit comments