@@ -369,13 +369,11 @@ pub fn rust_src(build: &Build) {
369
369
370
370
println ! ( "Dist src" ) ;
371
371
372
- let name = pkgname ( build, "rust-src" ) ;
373
- let image = tmpdir ( build) . join ( format ! ( "{}-image" , name) ) ;
374
- let _ = fs:: remove_dir_all ( & image) ;
375
-
376
- let dst = image. join ( "lib/rustlib/src" ) ;
377
- let dst_src = dst. join ( "rust" ) ;
378
- t ! ( fs:: create_dir_all( & dst_src) ) ;
372
+ // Make sure that the root folder of tarball has the correct name
373
+ let plain_name = format ! ( "rustc-{}-src" , build. rust_package_vers( ) ) ;
374
+ let plain_dst_src = tmpdir ( build) . join ( & plain_name) ;
375
+ let _ = fs:: remove_dir_all ( & plain_dst_src) ;
376
+ t ! ( fs:: create_dir_all( & plain_dst_src) ) ;
379
377
380
378
// This is the set of root paths which will become part of the source package
381
379
let src_files = [
@@ -424,13 +422,13 @@ pub fn rust_src(build: &Build) {
424
422
425
423
// Copy the directories using our filter
426
424
for item in & src_dirs {
427
- let dst = & dst_src . join ( item) ;
425
+ let dst = & plain_dst_src . join ( item) ;
428
426
t ! ( fs:: create_dir( dst) ) ;
429
427
cp_filtered ( & build. src . join ( item) , dst, & filter_fn) ;
430
428
}
431
429
// Copy the files normally
432
430
for item in & src_files {
433
- copy ( & build. src . join ( item) , & dst_src . join ( item) ) ;
431
+ copy ( & build. src . join ( item) , & plain_dst_src . join ( item) ) ;
434
432
}
435
433
436
434
// If we're building from git sources, we need to vendor a complete distribution.
@@ -455,10 +453,35 @@ pub fn rust_src(build: &Build) {
455
453
// Vendor all Cargo dependencies
456
454
let mut cmd = Command :: new ( & build. cargo ) ;
457
455
cmd. arg ( "vendor" )
458
- . current_dir ( & dst_src . join ( "src" ) ) ;
456
+ . current_dir ( & plain_dst_src . join ( "src" ) ) ;
459
457
build. run ( & mut cmd) ;
460
458
}
461
459
460
+ // Create the version file
461
+ write_file ( & plain_dst_src. join ( "version" ) , build. rust_version ( ) . as_bytes ( ) ) ;
462
+
463
+ // Create plain source tarball
464
+ let tarball = rust_src_location ( build) ;
465
+ if let Some ( dir) = tarball. parent ( ) {
466
+ t ! ( fs:: create_dir_all( dir) ) ;
467
+ }
468
+ let mut cmd = Command :: new ( "tar" ) ;
469
+ cmd. arg ( "-czf" ) . arg ( sanitize_sh ( & tarball) )
470
+ . arg ( & plain_name)
471
+ . current_dir ( tmpdir ( build) ) ;
472
+ build. run ( & mut cmd) ;
473
+
474
+
475
+ let name = pkgname ( build, "rust-src" ) ;
476
+ let image = tmpdir ( build) . join ( format ! ( "{}-image" , name) ) ;
477
+ let _ = fs:: remove_dir_all ( & image) ;
478
+
479
+ let dst = image. join ( "lib/rustlib/src" ) ;
480
+ let dst_src = dst. join ( "rust" ) ;
481
+ t ! ( fs:: create_dir_all( & dst_src) ) ;
482
+
483
+ cp_r ( & plain_dst_src, & dst_src) ;
484
+
462
485
// Create source tarball in rust-installer format
463
486
let mut cmd = Command :: new ( SH_CMD ) ;
464
487
cmd. arg ( sanitize_sh ( & build. src . join ( "src/rust-installer/gen-installer.sh" ) ) )
@@ -473,23 +496,6 @@ pub fn rust_src(build: &Build) {
473
496
. arg ( "--legacy-manifest-dirs=rustlib,cargo" ) ;
474
497
build. run ( & mut cmd) ;
475
498
476
- // Rename directory, so that root folder of tarball has the correct name
477
- let plain_name = format ! ( "rustc-{}-src" , build. rust_package_vers( ) ) ;
478
- let plain_dst_src = tmpdir ( build) . join ( & plain_name) ;
479
- let _ = fs:: remove_dir_all ( & plain_dst_src) ;
480
- t ! ( fs:: create_dir_all( & plain_dst_src) ) ;
481
- cp_r ( & dst_src, & plain_dst_src) ;
482
-
483
- // Create the version file
484
- write_file ( & plain_dst_src. join ( "version" ) , build. rust_version ( ) . as_bytes ( ) ) ;
485
-
486
- // Create plain source tarball
487
- let mut cmd = Command :: new ( "tar" ) ;
488
- cmd. arg ( "-czf" ) . arg ( sanitize_sh ( & rust_src_location ( build) ) )
489
- . arg ( & plain_name)
490
- . current_dir ( tmpdir ( build) ) ;
491
- build. run ( & mut cmd) ;
492
-
493
499
t ! ( fs:: remove_dir_all( & image) ) ;
494
500
t ! ( fs:: remove_dir_all( & plain_dst_src) ) ;
495
501
}
0 commit comments