@@ -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( ) )
@@ -369,38 +369,7 @@ pub fn analysis(build: &Build, compiler: &Compiler, target: &str) {
369369 t ! ( fs:: remove_dir_all( & image) ) ;
370370}
371371
372- const CARGO_VENDOR_VERSION : & ' static str = "0.1.4" ;
373-
374- /// Creates the `rust-src` installer component and the plain source tarball
375- pub fn rust_src ( build : & Build ) {
376- if !build. config . rust_dist_src {
377- return
378- }
379-
380- println ! ( "Dist src" ) ;
381-
382- // Make sure that the root folder of tarball has the correct name
383- let plain_name = format ! ( "rustc-{}-src" , build. rust_package_vers( ) ) ;
384- let plain_dst_src = tmpdir ( build) . join ( & plain_name) ;
385- let _ = fs:: remove_dir_all ( & plain_dst_src) ;
386- t ! ( fs:: create_dir_all( & plain_dst_src) ) ;
387-
388- // This is the set of root paths which will become part of the source package
389- let src_files = [
390- "COPYRIGHT" ,
391- "LICENSE-APACHE" ,
392- "LICENSE-MIT" ,
393- "CONTRIBUTING.md" ,
394- "README.md" ,
395- "RELEASES.md" ,
396- "configure" ,
397- "x.py" ,
398- ] ;
399- let src_dirs = [
400- "man" ,
401- "src" ,
402- ] ;
403-
372+ fn copy_src_dirs ( build : & Build , src_dirs : & [ & str ] , dst_dir : & Path ) {
404373 let filter_fn = move |path : & Path | {
405374 let spath = match path. to_str ( ) {
406375 Some ( path) => path,
@@ -429,60 +398,16 @@ pub fn rust_src(build: &Build) {
429398 } ;
430399
431400 // Copy the directories using our filter
432- for item in & src_dirs {
433- let dst = & plain_dst_src . join ( item) ;
434- t ! ( fs:: create_dir ( dst) ) ;
401+ for item in src_dirs {
402+ let dst = & dst_dir . join ( item) ;
403+ t ! ( fs:: create_dir_all ( dst) ) ;
435404 cp_filtered ( & build. src . join ( item) , dst, & filter_fn) ;
436405 }
437- // Copy the files normally
438- for item in & src_files {
439- copy ( & build. src . join ( item) , & plain_dst_src. join ( item) ) ;
440- }
441-
442- // If we're building from git sources, we need to vendor a complete distribution.
443- if build. src_is_git {
444- // Get cargo-vendor installed, if it isn't already.
445- let mut has_cargo_vendor = false ;
446- let mut cmd = Command :: new ( & build. cargo ) ;
447- for line in output ( cmd. arg ( "install" ) . arg ( "--list" ) ) . lines ( ) {
448- has_cargo_vendor |= line. starts_with ( "cargo-vendor " ) ;
449- }
450- if !has_cargo_vendor {
451- let mut cmd = Command :: new ( & build. cargo ) ;
452- cmd. arg ( "install" )
453- . arg ( "--force" )
454- . arg ( "--debug" )
455- . arg ( "--vers" ) . arg ( CARGO_VENDOR_VERSION )
456- . arg ( "cargo-vendor" )
457- . env ( "RUSTC" , & build. rustc ) ;
458- build. run ( & mut cmd) ;
459- }
460-
461- // Vendor all Cargo dependencies
462- let mut cmd = Command :: new ( & build. cargo ) ;
463- cmd. arg ( "vendor" )
464- . current_dir ( & plain_dst_src. join ( "src" ) ) ;
465- build. run ( & mut cmd) ;
466- }
467-
468- // Create the version file
469- write_file ( & plain_dst_src. join ( "version" ) , build. rust_version ( ) . as_bytes ( ) ) ;
470-
471- // Create plain source tarball
472- let mut tarball = rust_src_location ( build) ;
473- tarball. set_extension ( "" ) ; // strip .gz
474- tarball. set_extension ( "" ) ; // strip .tar
475- if let Some ( dir) = tarball. parent ( ) {
476- t ! ( fs:: create_dir_all( dir) ) ;
477- }
478- let mut cmd = rust_installer ( build) ;
479- cmd. arg ( "tarball" )
480- . arg ( "--input" ) . arg ( & plain_name)
481- . arg ( "--output" ) . arg ( & tarball)
482- . arg ( "--work-dir=." )
483- . current_dir ( tmpdir ( build) ) ;
484- build. run ( & mut cmd) ;
406+ }
485407
408+ /// Creates the `rust-src` installer component
409+ pub fn rust_src ( build : & Build ) {
410+ println ! ( "Dist src" ) ;
486411
487412 let name = pkgname ( build, "rust-src" ) ;
488413 let image = tmpdir ( build) . join ( format ! ( "{}-image" , name) ) ;
@@ -516,11 +441,7 @@ pub fn rust_src(build: &Build) {
516441 "src/rustc/libc_shim" ,
517442 ] ;
518443
519- for item in & std_src_dirs {
520- let dst = & dst_src. join ( item) ;
521- t ! ( fs:: create_dir_all( dst) ) ;
522- cp_r ( & plain_dst_src. join ( item) , dst) ;
523- }
444+ copy_src_dirs ( build, & std_src_dirs[ ..] , & dst_src) ;
524445
525446 // Create source tarball in rust-installer format
526447 let mut cmd = rust_installer ( build) ;
@@ -537,7 +458,86 @@ pub fn rust_src(build: &Build) {
537458 build. run ( & mut cmd) ;
538459
539460 t ! ( fs:: remove_dir_all( & image) ) ;
540- t ! ( fs:: remove_dir_all( & plain_dst_src) ) ;
461+ }
462+
463+ const CARGO_VENDOR_VERSION : & ' static str = "0.1.4" ;
464+
465+ /// Creates the plain source tarball
466+ pub fn plain_source_tarball ( build : & Build ) {
467+ println ! ( "Create plain source tarball" ) ;
468+
469+ // Make sure that the root folder of tarball has the correct name
470+ let plain_name = format ! ( "{}-src" , pkgname( build, "rustc" ) ) ;
471+ let plain_dst_src = tmpdir ( build) . join ( & plain_name) ;
472+ let _ = fs:: remove_dir_all ( & plain_dst_src) ;
473+ t ! ( fs:: create_dir_all( & plain_dst_src) ) ;
474+
475+ // This is the set of root paths which will become part of the source package
476+ let src_files = [
477+ "COPYRIGHT" ,
478+ "LICENSE-APACHE" ,
479+ "LICENSE-MIT" ,
480+ "CONTRIBUTING.md" ,
481+ "README.md" ,
482+ "RELEASES.md" ,
483+ "configure" ,
484+ "x.py" ,
485+ ] ;
486+ let src_dirs = [
487+ "man" ,
488+ "src" ,
489+ ] ;
490+
491+ copy_src_dirs ( build, & src_dirs[ ..] , & plain_dst_src) ;
492+
493+ // Copy the files normally
494+ for item in & src_files {
495+ copy ( & build. src . join ( item) , & plain_dst_src. join ( item) ) ;
496+ }
497+
498+ // Create the version file
499+ write_file ( & plain_dst_src. join ( "version" ) , build. rust_version ( ) . as_bytes ( ) ) ;
500+
501+ // If we're building from git sources, we need to vendor a complete distribution.
502+ if build. src_is_git {
503+ // Get cargo-vendor installed, if it isn't already.
504+ let mut has_cargo_vendor = false ;
505+ let mut cmd = Command :: new ( & build. cargo ) ;
506+ for line in output ( cmd. arg ( "install" ) . arg ( "--list" ) ) . lines ( ) {
507+ has_cargo_vendor |= line. starts_with ( "cargo-vendor " ) ;
508+ }
509+ if !has_cargo_vendor {
510+ let mut cmd = Command :: new ( & build. cargo ) ;
511+ cmd. arg ( "install" )
512+ . arg ( "--force" )
513+ . arg ( "--debug" )
514+ . arg ( "--vers" ) . arg ( CARGO_VENDOR_VERSION )
515+ . arg ( "cargo-vendor" )
516+ . env ( "RUSTC" , & build. rustc ) ;
517+ build. run ( & mut cmd) ;
518+ }
519+
520+ // Vendor all Cargo dependencies
521+ let mut cmd = Command :: new ( & build. cargo ) ;
522+ cmd. arg ( "vendor" )
523+ . current_dir ( & plain_dst_src. join ( "src" ) ) ;
524+ build. run ( & mut cmd) ;
525+ }
526+
527+ // Create plain source tarball
528+ let mut tarball = rust_src_location ( build) ;
529+ tarball. set_extension ( "" ) ; // strip .gz
530+ tarball. set_extension ( "" ) ; // strip .tar
531+ if let Some ( dir) = tarball. parent ( ) {
532+ t ! ( fs:: create_dir_all( dir) ) ;
533+ }
534+ let mut cmd = rust_installer ( build) ;
535+ cmd. arg ( "tarball" )
536+ . arg ( "--input" ) . arg ( & plain_name)
537+ . arg ( "--output" ) . arg ( & tarball)
538+ . arg ( "--work-dir=." )
539+ . current_dir ( tmpdir ( build) ) ;
540+ build. run ( & mut cmd) ;
541541}
542542
543543fn install ( src : & Path , dstdir : & Path , perms : u32 ) {
0 commit comments