@@ -360,6 +360,8 @@ pub fn analysis(build: &Build, compiler: &Compiler, target: &str) {
360360 t ! ( fs:: remove_dir_all( & image) ) ;
361361}
362362
363+ const CARGO_VENDOR_VERSION : & ' static str = "0.1.4" ;
364+
363365/// Creates the `rust-src` installer component and the plain source tarball
364366pub fn rust_src ( build : & Build ) {
365367 println ! ( "Dist src" ) ;
@@ -404,13 +406,6 @@ pub fn rust_src(build: &Build) {
404406 }
405407 }
406408
407- // If we're inside the vendor directory then we need to preserve
408- // everything as Cargo's vendoring support tracks all checksums and we
409- // want to be sure we don't accidentally leave out a file.
410- if spath. contains ( "vendor" ) {
411- return true
412- }
413-
414409 let excludes = [
415410 "CVS" , "RCS" , "SCCS" , ".git" , ".gitignore" , ".gitmodules" ,
416411 ".gitattributes" , ".cvsignore" , ".svn" , ".arch-ids" , "{arch}" ,
@@ -433,6 +428,29 @@ pub fn rust_src(build: &Build) {
433428 copy ( & build. src . join ( item) , & dst_src. join ( item) ) ;
434429 }
435430
431+ // Get cargo-vendor installed, if it isn't already.
432+ let mut has_cargo_vendor = false ;
433+ let mut cmd = Command :: new ( & build. cargo ) ;
434+ for line in output ( cmd. arg ( "install" ) . arg ( "--list" ) ) . lines ( ) {
435+ has_cargo_vendor |= line. starts_with ( "cargo-vendor " ) ;
436+ }
437+ if !has_cargo_vendor {
438+ let mut cmd = Command :: new ( & build. cargo ) ;
439+ cmd. arg ( "install" )
440+ . arg ( "--force" )
441+ . arg ( "--debug" )
442+ . arg ( "--vers" ) . arg ( CARGO_VENDOR_VERSION )
443+ . arg ( "cargo-vendor" )
444+ . env ( "RUSTC" , & build. rustc ) ;
445+ build. run ( & mut cmd) ;
446+ }
447+
448+ // Vendor all Cargo dependencies
449+ let mut cmd = Command :: new ( & build. cargo ) ;
450+ cmd. arg ( "vendor" )
451+ . current_dir ( & dst_src. join ( "src" ) ) ;
452+ build. run ( & mut cmd) ;
453+
436454 // Create source tarball in rust-installer format
437455 let mut cmd = Command :: new ( "sh" ) ;
438456 cmd. arg ( sanitize_sh ( & build. src . join ( "src/rust-installer/gen-installer.sh" ) ) )
0 commit comments