@@ -367,26 +367,70 @@ impl Config {
367
367
368
368
pub ( crate ) fn download_ci_rustc ( & self , commit : & str ) {
369
369
self . verbose ( & format ! ( "using downloaded stage2 artifacts from CI (commit {commit})" ) ) ;
370
+
370
371
let version = self . artifact_version_part ( commit) ;
372
+ // download-rustc doesn't need its own cargo, it can just use beta's. But it does need the
373
+ // `rustc_private` crates for tools.
374
+ let extra_components = [ "rustc-dev" ] ;
375
+
376
+ self . download_toolchain (
377
+ & version,
378
+ "ci-rustc" ,
379
+ commit,
380
+ & extra_components,
381
+ Self :: download_ci_component,
382
+ ) ;
383
+ }
384
+
385
+ pub ( crate ) fn download_beta_toolchain ( & self ) {
386
+ self . verbose ( & format ! ( "downloading stage0 beta artifacts" ) ) ;
387
+
388
+ let date = & self . stage0_metadata . compiler . date ;
389
+ let version = & self . stage0_metadata . compiler . version ;
390
+ let extra_components = [ "cargo" ] ;
391
+
392
+ let download_beta_component = |config : & Config , filename, prefix : & _ , date : & _ | {
393
+ config. download_component ( DownloadSource :: Dist , filename, prefix, date, "stage0" )
394
+ } ;
395
+
396
+ self . download_toolchain (
397
+ version,
398
+ "stage0" ,
399
+ date,
400
+ & extra_components,
401
+ download_beta_component,
402
+ ) ;
403
+ }
404
+
405
+ fn download_toolchain (
406
+ & self ,
407
+ // FIXME(ozkanonur) use CompilerMetadata instead of `version: &str`
408
+ version : & str ,
409
+ sysroot : & str ,
410
+ stamp_key : & str ,
411
+ extra_components : & [ & str ] ,
412
+ download_component : fn ( & Config , String , & str , & str ) ,
413
+ ) {
371
414
let host = self . build . triple ;
372
- let bin_root = self . out . join ( host) . join ( "ci-rustc" ) ;
415
+ let bin_root = self . out . join ( host) . join ( sysroot ) ;
373
416
let rustc_stamp = bin_root. join ( ".rustc-stamp" ) ;
374
417
375
- if !bin_root. join ( "bin" ) . join ( "rustc" ) . exists ( ) || program_out_of_date ( & rustc_stamp, commit)
418
+ if !bin_root. join ( "bin" ) . join ( exe ( "rustc" , self . build ) ) . exists ( )
419
+ || program_out_of_date ( & rustc_stamp, stamp_key)
376
420
{
377
421
if bin_root. exists ( ) {
378
422
t ! ( fs:: remove_dir_all( & bin_root) ) ;
379
423
}
380
424
let filename = format ! ( "rust-std-{version}-{host}.tar.xz" ) ;
381
425
let pattern = format ! ( "rust-std-{host}" ) ;
382
- self . download_ci_component ( filename, & pattern, commit ) ;
426
+ download_component ( self , filename, & pattern, stamp_key ) ;
383
427
let filename = format ! ( "rustc-{version}-{host}.tar.xz" ) ;
384
- self . download_ci_component ( filename, "rustc" , commit ) ;
385
- // download-rustc doesn't need its own cargo, it can just use beta's.
386
- let filename = format ! ( "rustc-dev-{version}-{host}.tar.xz" ) ;
387
- self . download_ci_component ( filename, "rustc-dev" , commit ) ;
388
- let filename = format ! ( "rust-src-{version}.tar.xz" ) ;
389
- self . download_ci_component ( filename , "rust-src" , commit ) ;
428
+ download_component ( self , filename, "rustc" , stamp_key ) ;
429
+
430
+ for component in extra_components {
431
+ let filename = format ! ( "{component}-{version}-{host}.tar.xz" ) ;
432
+ download_component ( self , filename , component , stamp_key ) ;
433
+ }
390
434
391
435
if self . should_fix_bins_and_dylibs ( ) {
392
436
self . fix_bin_or_dylib ( & bin_root. join ( "bin" ) . join ( "rustc" ) ) ;
@@ -403,7 +447,7 @@ impl Config {
403
447
}
404
448
}
405
449
406
- t ! ( fs:: write( rustc_stamp, commit ) ) ;
450
+ t ! ( fs:: write( rustc_stamp, stamp_key ) ) ;
407
451
}
408
452
}
409
453
0 commit comments