@@ -30,11 +30,11 @@ use {Build, Compiler, Mode};
3030use channel;
3131use util:: { cp_r, libdir, is_dylib, cp_filtered, copy, exe} ;
3232
33- fn pkgname ( build : & Build , component : & str ) -> String {
33+ pub fn pkgname ( build : & Build , component : & str ) -> String {
3434 if component == "cargo" {
3535 format ! ( "{}-{}" , component, build. cargo_package_vers( ) )
3636 } else if component == "rls" {
37- format ! ( "{}-{}" , component, build. package_vers ( & build . release_num ( "rls" ) ) )
37+ format ! ( "{}-{}" , component, build. rls_package_vers ( ) )
3838 } else {
3939 assert ! ( component. starts_with( "rust" ) ) ;
4040 format ! ( "{}-{}" , component, build. rust_package_vers( ) )
@@ -489,38 +489,7 @@ pub fn analysis(build: &Build, compiler: &Compiler, target: &str) {
489489 t ! ( fs:: remove_dir_all( & image) ) ;
490490}
491491
492- const CARGO_VENDOR_VERSION : & ' static str = "0.1.4" ;
493-
494- /// Creates the `rust-src` installer component and the plain source tarball
495- pub fn rust_src ( build : & Build ) {
496- if !build. config . rust_dist_src {
497- return
498- }
499-
500- println ! ( "Dist src" ) ;
501-
502- // Make sure that the root folder of tarball has the correct name
503- let plain_name = format ! ( "rustc-{}-src" , build. rust_package_vers( ) ) ;
504- let plain_dst_src = tmpdir ( build) . join ( & plain_name) ;
505- let _ = fs:: remove_dir_all ( & plain_dst_src) ;
506- t ! ( fs:: create_dir_all( & plain_dst_src) ) ;
507-
508- // This is the set of root paths which will become part of the source package
509- let src_files = [
510- "COPYRIGHT" ,
511- "LICENSE-APACHE" ,
512- "LICENSE-MIT" ,
513- "CONTRIBUTING.md" ,
514- "README.md" ,
515- "RELEASES.md" ,
516- "configure" ,
517- "x.py" ,
518- ] ;
519- let src_dirs = [
520- "man" ,
521- "src" ,
522- ] ;
523-
492+ fn copy_src_dirs ( build : & Build , src_dirs : & [ & str ] , dst_dir : & Path ) {
524493 let filter_fn = move |path : & Path | {
525494 let spath = match path. to_str ( ) {
526495 Some ( path) => path,
@@ -549,60 +518,16 @@ pub fn rust_src(build: &Build) {
549518 } ;
550519
551520 // Copy the directories using our filter
552- for item in & src_dirs {
553- let dst = & plain_dst_src . join ( item) ;
554- t ! ( fs:: create_dir ( dst) ) ;
521+ for item in src_dirs {
522+ let dst = & dst_dir . join ( item) ;
523+ t ! ( fs:: create_dir_all ( dst) ) ;
555524 cp_filtered ( & build. src . join ( item) , dst, & filter_fn) ;
556525 }
557- // Copy the files normally
558- for item in & src_files {
559- copy ( & build. src . join ( item) , & plain_dst_src. join ( item) ) ;
560- }
561-
562- // If we're building from git sources, we need to vendor a complete distribution.
563- if build. src_is_git {
564- // Get cargo-vendor installed, if it isn't already.
565- let mut has_cargo_vendor = false ;
566- let mut cmd = Command :: new ( & build. cargo ) ;
567- for line in output ( cmd. arg ( "install" ) . arg ( "--list" ) ) . lines ( ) {
568- has_cargo_vendor |= line. starts_with ( "cargo-vendor " ) ;
569- }
570- if !has_cargo_vendor {
571- let mut cmd = Command :: new ( & build. cargo ) ;
572- cmd. arg ( "install" )
573- . arg ( "--force" )
574- . arg ( "--debug" )
575- . arg ( "--vers" ) . arg ( CARGO_VENDOR_VERSION )
576- . arg ( "cargo-vendor" )
577- . env ( "RUSTC" , & build. rustc ) ;
578- build. run ( & mut cmd) ;
579- }
580-
581- // Vendor all Cargo dependencies
582- let mut cmd = Command :: new ( & build. cargo ) ;
583- cmd. arg ( "vendor" )
584- . current_dir ( & plain_dst_src. join ( "src" ) ) ;
585- build. run ( & mut cmd) ;
586- }
587-
588- // Create the version file
589- write_file ( & plain_dst_src. join ( "version" ) , build. rust_version ( ) . as_bytes ( ) ) ;
590-
591- // Create plain source tarball
592- let mut tarball = rust_src_location ( build) ;
593- tarball. set_extension ( "" ) ; // strip .gz
594- tarball. set_extension ( "" ) ; // strip .tar
595- if let Some ( dir) = tarball. parent ( ) {
596- t ! ( fs:: create_dir_all( dir) ) ;
597- }
598- let mut cmd = rust_installer ( build) ;
599- cmd. arg ( "tarball" )
600- . arg ( "--input" ) . arg ( & plain_name)
601- . arg ( "--output" ) . arg ( & tarball)
602- . arg ( "--work-dir=." )
603- . current_dir ( tmpdir ( build) ) ;
604- build. run ( & mut cmd) ;
526+ }
605527
528+ /// Creates the `rust-src` installer component
529+ pub fn rust_src ( build : & Build ) {
530+ println ! ( "Dist src" ) ;
606531
607532 let name = pkgname ( build, "rust-src" ) ;
608533 let image = tmpdir ( build) . join ( format ! ( "{}-image" , name) ) ;
@@ -636,11 +561,7 @@ pub fn rust_src(build: &Build) {
636561 "src/rustc/libc_shim" ,
637562 ] ;
638563
639- for item in & std_src_dirs {
640- let dst = & dst_src. join ( item) ;
641- t ! ( fs:: create_dir_all( dst) ) ;
642- cp_r ( & plain_dst_src. join ( item) , dst) ;
643- }
564+ copy_src_dirs ( build, & std_src_dirs[ ..] , & dst_src) ;
644565
645566 // Create source tarball in rust-installer format
646567 let mut cmd = rust_installer ( build) ;
@@ -657,7 +578,86 @@ pub fn rust_src(build: &Build) {
657578 build. run ( & mut cmd) ;
658579
659580 t ! ( fs:: remove_dir_all( & image) ) ;
660- t ! ( fs:: remove_dir_all( & plain_dst_src) ) ;
581+ }
582+
583+ const CARGO_VENDOR_VERSION : & ' static str = "0.1.4" ;
584+
585+ /// Creates the plain source tarball
586+ pub fn plain_source_tarball ( build : & Build ) {
587+ println ! ( "Create plain source tarball" ) ;
588+
589+ // Make sure that the root folder of tarball has the correct name
590+ let plain_name = format ! ( "{}-src" , pkgname( build, "rustc" ) ) ;
591+ let plain_dst_src = tmpdir ( build) . join ( & plain_name) ;
592+ let _ = fs:: remove_dir_all ( & plain_dst_src) ;
593+ t ! ( fs:: create_dir_all( & plain_dst_src) ) ;
594+
595+ // This is the set of root paths which will become part of the source package
596+ let src_files = [
597+ "COPYRIGHT" ,
598+ "LICENSE-APACHE" ,
599+ "LICENSE-MIT" ,
600+ "CONTRIBUTING.md" ,
601+ "README.md" ,
602+ "RELEASES.md" ,
603+ "configure" ,
604+ "x.py" ,
605+ ] ;
606+ let src_dirs = [
607+ "man" ,
608+ "src" ,
609+ ] ;
610+
611+ copy_src_dirs ( build, & src_dirs[ ..] , & plain_dst_src) ;
612+
613+ // Copy the files normally
614+ for item in & src_files {
615+ copy ( & build. src . join ( item) , & plain_dst_src. join ( item) ) ;
616+ }
617+
618+ // Create the version file
619+ write_file ( & plain_dst_src. join ( "version" ) , build. rust_version ( ) . as_bytes ( ) ) ;
620+
621+ // If we're building from git sources, we need to vendor a complete distribution.
622+ if build. src_is_git {
623+ // Get cargo-vendor installed, if it isn't already.
624+ let mut has_cargo_vendor = false ;
625+ let mut cmd = Command :: new ( & build. cargo ) ;
626+ for line in output ( cmd. arg ( "install" ) . arg ( "--list" ) ) . lines ( ) {
627+ has_cargo_vendor |= line. starts_with ( "cargo-vendor " ) ;
628+ }
629+ if !has_cargo_vendor {
630+ let mut cmd = Command :: new ( & build. cargo ) ;
631+ cmd. arg ( "install" )
632+ . arg ( "--force" )
633+ . arg ( "--debug" )
634+ . arg ( "--vers" ) . arg ( CARGO_VENDOR_VERSION )
635+ . arg ( "cargo-vendor" )
636+ . env ( "RUSTC" , & build. rustc ) ;
637+ build. run ( & mut cmd) ;
638+ }
639+
640+ // Vendor all Cargo dependencies
641+ let mut cmd = Command :: new ( & build. cargo ) ;
642+ cmd. arg ( "vendor" )
643+ . current_dir ( & plain_dst_src. join ( "src" ) ) ;
644+ build. run ( & mut cmd) ;
645+ }
646+
647+ // Create plain source tarball
648+ let mut tarball = rust_src_location ( build) ;
649+ tarball. set_extension ( "" ) ; // strip .gz
650+ tarball. set_extension ( "" ) ; // strip .tar
651+ if let Some ( dir) = tarball. parent ( ) {
652+ t ! ( fs:: create_dir_all( dir) ) ;
653+ }
654+ let mut cmd = rust_installer ( build) ;
655+ cmd. arg ( "tarball" )
656+ . arg ( "--input" ) . arg ( & plain_name)
657+ . arg ( "--output" ) . arg ( & tarball)
658+ . arg ( "--work-dir=." )
659+ . current_dir ( tmpdir ( build) ) ;
660+ build. run ( & mut cmd) ;
661661}
662662
663663fn install ( src : & Path , dstdir : & Path , perms : u32 ) {
0 commit comments