@@ -10,60 +10,19 @@ use std::process::Command;
10
10
11
11
use build_helper:: t;
12
12
13
- use crate :: dist:: { self , pkgname, sanitize_sh, tmpdir} ;
13
+ use crate :: dist:: { self , sanitize_sh} ;
14
+ use crate :: tarball:: GeneratedTarball ;
14
15
use crate :: Compiler ;
15
16
16
17
use crate :: builder:: { Builder , RunConfig , ShouldRun , Step } ;
17
18
use crate :: config:: { Config , TargetSelection } ;
18
19
19
- pub fn install_docs ( builder : & Builder < ' _ > , stage : u32 , host : TargetSelection ) {
20
- install_sh ( builder, "docs" , "rust-docs" , stage, Some ( host) ) ;
21
- }
22
-
23
- pub fn install_std ( builder : & Builder < ' _ > , stage : u32 , target : TargetSelection ) {
24
- install_sh ( builder, "std" , "rust-std" , stage, Some ( target) ) ;
25
- }
26
-
27
- pub fn install_cargo ( builder : & Builder < ' _ > , stage : u32 , host : TargetSelection ) {
28
- install_sh ( builder, "cargo" , "cargo" , stage, Some ( host) ) ;
29
- }
30
-
31
- pub fn install_rls ( builder : & Builder < ' _ > , stage : u32 , host : TargetSelection ) {
32
- install_sh ( builder, "rls" , "rls" , stage, Some ( host) ) ;
33
- }
34
-
35
- pub fn install_rust_analyzer ( builder : & Builder < ' _ > , stage : u32 , host : TargetSelection ) {
36
- install_sh ( builder, "rust-analyzer" , "rust-analyzer" , stage, Some ( host) ) ;
37
- }
38
-
39
- pub fn install_clippy ( builder : & Builder < ' _ > , stage : u32 , host : TargetSelection ) {
40
- install_sh ( builder, "clippy" , "clippy" , stage, Some ( host) ) ;
41
- }
42
- pub fn install_miri ( builder : & Builder < ' _ > , stage : u32 , host : TargetSelection ) {
43
- install_sh ( builder, "miri" , "miri" , stage, Some ( host) ) ;
44
- }
45
-
46
- pub fn install_rustfmt ( builder : & Builder < ' _ > , stage : u32 , host : TargetSelection ) {
47
- install_sh ( builder, "rustfmt" , "rustfmt" , stage, Some ( host) ) ;
48
- }
49
-
50
- pub fn install_analysis ( builder : & Builder < ' _ > , stage : u32 , host : TargetSelection ) {
51
- install_sh ( builder, "analysis" , "rust-analysis" , stage, Some ( host) ) ;
52
- }
53
-
54
- pub fn install_src ( builder : & Builder < ' _ > , stage : u32 ) {
55
- install_sh ( builder, "src" , "rust-src" , stage, None ) ;
56
- }
57
- pub fn install_rustc ( builder : & Builder < ' _ > , stage : u32 , host : TargetSelection ) {
58
- install_sh ( builder, "rustc" , "rustc" , stage, Some ( host) ) ;
59
- }
60
-
61
20
fn install_sh (
62
21
builder : & Builder < ' _ > ,
63
22
package : & str ,
64
- name : & str ,
65
23
stage : u32 ,
66
24
host : Option < TargetSelection > ,
25
+ tarball : & GeneratedTarball ,
67
26
) {
68
27
builder. info ( & format ! ( "Install {} stage{} ({:?})" , package, stage, host) ) ;
69
28
@@ -108,15 +67,10 @@ fn install_sh(
108
67
let empty_dir = builder. out . join ( "tmp/empty_dir" ) ;
109
68
110
69
t ! ( fs:: create_dir_all( & empty_dir) ) ;
111
- let package_name = if let Some ( host) = host {
112
- format ! ( "{}-{}" , pkgname( builder, name) , host. triple)
113
- } else {
114
- pkgname ( builder, name)
115
- } ;
116
70
117
71
let mut cmd = Command :: new ( "sh" ) ;
118
72
cmd. current_dir ( & empty_dir)
119
- . arg ( sanitize_sh ( & tmpdir ( builder ) . join ( & package_name ) . join ( "install.sh" ) ) )
73
+ . arg ( sanitize_sh ( & tarball . decompressed_output ( ) . join ( "install.sh" ) ) )
120
74
. arg ( format ! ( "--prefix={}" , sanitize_sh( & prefix) ) )
121
75
. arg ( format ! ( "--sysconfdir={}" , sanitize_sh( & sysconfdir) ) )
122
76
. arg ( format ! ( "--datadir={}" , sanitize_sh( & datadir) ) )
@@ -191,75 +145,77 @@ macro_rules! install {
191
145
192
146
install ! ( ( self , builder, _config) ,
193
147
Docs , "src/doc" , _config. docs, only_hosts: false , {
194
- builder. ensure( dist:: Docs { host: self . target } ) ;
195
- install_docs ( builder, self . compiler. stage, self . target) ;
148
+ let tarball = builder. ensure( dist:: Docs { host: self . target } ) . expect ( "missing docs" ) ;
149
+ install_sh ( builder, "docs" , self . compiler. stage, Some ( self . target) , & tarball ) ;
196
150
} ;
197
151
Std , "library/std" , true , only_hosts: false , {
198
152
for target in & builder. targets {
199
- builder. ensure( dist:: Std {
153
+ let tarball = builder. ensure( dist:: Std {
200
154
compiler: self . compiler,
201
155
target: * target
202
- } ) ;
203
- install_std ( builder, self . compiler. stage, * target) ;
156
+ } ) . expect ( "missing std" ) ;
157
+ install_sh ( builder, "std" , self . compiler. stage, Some ( * target) , & tarball ) ;
204
158
}
205
159
} ;
206
160
Cargo , "cargo" , Self :: should_build( _config) , only_hosts: true , {
207
- builder. ensure( dist:: Cargo { compiler: self . compiler, target: self . target } ) ;
208
- install_cargo ( builder, self . compiler. stage, self . target) ;
161
+ let tarball = builder. ensure( dist:: Cargo { compiler: self . compiler, target: self . target } ) ;
162
+ install_sh ( builder, "cargo" , self . compiler. stage, Some ( self . target) , & tarball ) ;
209
163
} ;
210
164
Rls , "rls" , Self :: should_build( _config) , only_hosts: true , {
211
- if builder. ensure( dist:: Rls { compiler: self . compiler, target: self . target } ) . is_some ( ) {
212
- install_rls ( builder, self . compiler. stage, self . target) ;
165
+ if let Some ( tarball ) = builder. ensure( dist:: Rls { compiler: self . compiler, target: self . target } ) {
166
+ install_sh ( builder, "rls" , self . compiler. stage, Some ( self . target) , & tarball ) ;
213
167
} else {
214
168
builder. info(
215
169
& format!( "skipping Install RLS stage{} ({})" , self . compiler. stage, self . target) ,
216
170
) ;
217
171
}
218
172
} ;
219
173
RustAnalyzer , "rust-analyzer" , Self :: should_build( _config) , only_hosts: true , {
220
- builder. ensure( dist:: RustAnalyzer { compiler: self . compiler, target: self . target } ) ;
221
- install_rust_analyzer( builder, self . compiler. stage, self . target) ;
174
+ let tarball = builder
175
+ . ensure( dist:: RustAnalyzer { compiler: self . compiler, target: self . target } )
176
+ . expect( "missing rust-analyzer" ) ;
177
+ install_sh( builder, "rust-analyzer" , self . compiler. stage, Some ( self . target) , & tarball) ;
222
178
} ;
223
179
Clippy , "clippy" , Self :: should_build( _config) , only_hosts: true , {
224
- builder. ensure( dist:: Clippy { compiler: self . compiler, target: self . target } ) ;
225
- install_clippy ( builder, self . compiler. stage, self . target) ;
180
+ let tarball = builder. ensure( dist:: Clippy { compiler: self . compiler, target: self . target } ) ;
181
+ install_sh ( builder, "clippy" , self . compiler. stage, Some ( self . target) , & tarball ) ;
226
182
} ;
227
183
Miri , "miri" , Self :: should_build( _config) , only_hosts: true , {
228
- if builder. ensure( dist:: Miri { compiler: self . compiler, target: self . target } ) . is_some ( ) {
229
- install_miri ( builder, self . compiler. stage, self . target) ;
184
+ if let Some ( tarball ) = builder. ensure( dist:: Miri { compiler: self . compiler, target: self . target } ) {
185
+ install_sh ( builder, "miri" , self . compiler. stage, Some ( self . target) , & tarball ) ;
230
186
} else {
231
187
builder. info(
232
188
& format!( "skipping Install miri stage{} ({})" , self . compiler. stage, self . target) ,
233
189
) ;
234
190
}
235
191
} ;
236
192
Rustfmt , "rustfmt" , Self :: should_build( _config) , only_hosts: true , {
237
- if builder. ensure( dist:: Rustfmt {
193
+ if let Some ( tarball ) = builder. ensure( dist:: Rustfmt {
238
194
compiler: self . compiler,
239
195
target: self . target
240
- } ) . is_some ( ) {
241
- install_rustfmt ( builder, self . compiler. stage, self . target) ;
196
+ } ) {
197
+ install_sh ( builder, "rustfmt" , self . compiler. stage, Some ( self . target) , & tarball ) ;
242
198
} else {
243
199
builder. info(
244
200
& format!( "skipping Install Rustfmt stage{} ({})" , self . compiler. stage, self . target) ,
245
201
) ;
246
202
}
247
203
} ;
248
204
Analysis , "analysis" , Self :: should_build( _config) , only_hosts: false , {
249
- builder. ensure( dist:: Analysis {
205
+ let tarball = builder. ensure( dist:: Analysis {
250
206
// Find the actual compiler (handling the full bootstrap option) which
251
207
// produced the save-analysis data because that data isn't copied
252
208
// through the sysroot uplifting.
253
209
compiler: builder. compiler_for( builder. top_stage, builder. config. build, self . target) ,
254
210
target: self . target
255
- } ) ;
256
- install_analysis ( builder, self . compiler. stage, self . target) ;
211
+ } ) . expect ( "missing analysis" ) ;
212
+ install_sh ( builder, "analysis" , self . compiler. stage, Some ( self . target) , & tarball ) ;
257
213
} ;
258
214
Rustc , "src/librustc" , true , only_hosts: true , {
259
- builder. ensure( dist:: Rustc {
215
+ let tarball = builder. ensure( dist:: Rustc {
260
216
compiler: builder. compiler( builder. top_stage, self . target) ,
261
217
} ) ;
262
- install_rustc ( builder, self . compiler. stage, self . target) ;
218
+ install_sh ( builder, "rustc" , self . compiler. stage, Some ( self . target) , & tarball ) ;
263
219
} ;
264
220
) ;
265
221
@@ -284,7 +240,7 @@ impl Step for Src {
284
240
}
285
241
286
242
fn run ( self , builder : & Builder < ' _ > ) {
287
- builder. ensure ( dist:: Src ) ;
288
- install_src ( builder, self . stage ) ;
243
+ let tarball = builder. ensure ( dist:: Src ) ;
244
+ install_sh ( builder, "src" , self . stage , None , & tarball ) ;
289
245
}
290
246
}
0 commit comments