pub fn rust_src(build: &Build) {
    println!("Dist src");

    let name = pkgname(build, "rust-src");
    let image = tmpdir(build).join(format!("{}-image", name));
    let _ = fs::remove_dir_all(&image);

    let dst = image.join("lib/rustlib/src");
    let dst_src = dst.join("rust");
    t!(fs::create_dir_all(&dst_src));

    // This is the set of root paths which will become part of the source package
    let src_files = [
        "COPYRIGHT",
        "LICENSE-APACHE",
        "LICENSE-MIT",
        "CONTRIBUTING.md",
        "README.md",
        "RELEASES.md",
        "configure",
        "Makefile.in"
    ];
    let src_dirs = [
        "man",
        "src",
        "mk"
    ];

    let filter_fn = move |path: &Path| {
        let spath = match path.to_str() {
            Some(path) => path,
            None => return false,
        };
        if spath.ends_with("~") || spath.ends_with(".pyc") {
            return false
        }
        if spath.contains("llvm/test") || spath.contains("llvm\\test") {
            if spath.ends_with(".ll") ||
               spath.ends_with(".td") ||
               spath.ends_with(".s") {
                return false
            }
        }

        // If we're inside the vendor directory then we need to preserve
        // everything as Cargo's vendoring support tracks all checksums and we
        // want to be sure we don't accidentally leave out a file.
        if spath.contains("vendor") {
            return true
        }

        let excludes = [
            "CVS", "RCS", "SCCS", ".git", ".gitignore", ".gitmodules",
            ".gitattributes", ".cvsignore", ".svn", ".arch-ids", "{arch}",
            "=RELEASE-ID", "=meta-update", "=update", ".bzr", ".bzrignore",
            ".bzrtags", ".hg", ".hgignore", ".hgrags", "_darcs",
        ];
        !path.iter()
             .map(|s| s.to_str().unwrap())
             .any(|s| excludes.contains(&s))
    };

    // Copy the directories using our filter
    for item in &src_dirs {
        let dst = &dst_src.join(item);
        t!(fs::create_dir(dst));
        cp_filtered(&build.src.join(item), dst, &filter_fn);
    }
    // Copy the files normally
    for item in &src_files {
        copy(&build.src.join(item), &dst_src.join(item));
    }

    // Create source tarball in rust-installer format
    let mut cmd = Command::new("sh");
    cmd.arg(sanitize_sh(&build.src.join("src/rust-installer/gen-installer.sh")))
       .arg("--product-name=Rust")
       .arg("--rel-manifest-dir=rustlib")
       .arg("--success-message=Awesome-Source.")
       .arg(format!("--image-dir={}", sanitize_sh(&image)))
       .arg(format!("--work-dir={}", sanitize_sh(&tmpdir(build))))
       .arg(format!("--output-dir={}", sanitize_sh(&distdir(build))))
       .arg(format!("--package-name={}", name))
       .arg("--component-name=rust-src")
       .arg("--legacy-manifest-dirs=rustlib,cargo");
    build.run(&mut cmd);

    // Rename directory, so that root folder of tarball has the correct name
    let plain_name = format!("rustc-{}-src", package_vers(build));
    let plain_dst_src = tmpdir(build).join(&plain_name);
    let _ = fs::remove_dir_all(&plain_dst_src);
    t!(fs::create_dir_all(&plain_dst_src));
    cp_r(&dst_src, &plain_dst_src);

    // Create the version file
    write_file(&plain_dst_src.join("version"), build.version.as_bytes());

    // Create plain source tarball
    let mut cmd = Command::new("tar");
    cmd.arg("-czf").arg(sanitize_sh(&rust_src_location(build)))
       .arg(&plain_name)
       .current_dir(tmpdir(build));
    build.run(&mut cmd);

    t!(fs::remove_dir_all(&image));
    t!(fs::remove_dir_all(&plain_dst_src));
}
/// Creates the `rust-src` installer component and the plain source tarball
Creates the `rust-src` installer component and the plain source tarball
Creates the ` rust - src ` installer component and the plain source tarball
pub fn rust_src(build: &Build) {
    println!("Dist src");
    let name = pkgname(build, "rust-src");
    let image = tmpdir(build).join(format!("{}-image", name));
    let _ = fs::remove_dir_all(&image);
    let dst = image.join("lib/rustlib/src");
    let dst_src = dst.join("rust");
    t!(fs::create_dir_all(&dst_src));
    // This is the set of root paths which will become part of the source package
    let src_files = [
        "COPYRIGHT",
        "LICENSE-APACHE",
        "LICENSE-MIT",
        "CONTRIBUTING.md",
        "README.md",
        "RELEASES.md",
        "configure",
        "Makefile.in"
    ];
    let src_dirs = [
        "man",
        "src",
        "mk"
    ];
    let filter_fn = move |path: &Path| {
        let spath = match path.to_str() {
            Some(path) => path,
            None => return false,
        };
        if spath.ends_with("~") || spath.ends_with(".pyc") {
            return false
        }
        if spath.contains("llvm/test") || spath.contains("llvm\\test") {
            if spath.ends_with(".ll") ||
               spath.ends_with(".td") ||
               spath.ends_with(".s") {
                return false
            }
        }
        // If we're inside the vendor directory then we need to preserve
        // everything as Cargo's vendoring support tracks all checksums and we
        // want to be sure we don't accidentally leave out a file.
        if spath.contains("vendor") {
            return true
        }
        let excludes = [
            "CVS", "RCS", "SCCS", ".git", ".gitignore", ".gitmodules",
            ".gitattributes", ".cvsignore", ".svn", ".arch-ids", "{arch}",
            "=RELEASE-ID", "=meta-update", "=update", ".bzr", ".bzrignore",
            ".bzrtags", ".hg", ".hgignore", ".hgrags", "_darcs",
        ];
        !path.iter()
             .map(|s| s.to_str().unwrap())
             .any(|s| excludes.contains(&s))
    };
    // Copy the directories using our filter
    for item in &src_dirs {
        let dst = &dst_src.join(item);
        t!(fs::create_dir(dst));
        cp_filtered(&build.src.join(item), dst, &filter_fn);
    }
    // Copy the files normally
    for item in &src_files {
        copy(&build.src.join(item), &dst_src.join(item));
    }
    // Create source tarball in rust-installer format
    let mut cmd = Command::new("sh");
    cmd.arg(sanitize_sh(&build.src.join("src/rust-installer/gen-installer.sh")))
       .arg("--product-name=Rust")
       .arg("--rel-manifest-dir=rustlib")
       .arg("--success-message=Awesome-Source.")
       .arg(format!("--image-dir={}", sanitize_sh(&image)))
       .arg(format!("--work-dir={}", sanitize_sh(&tmpdir(build))))
       .arg(format!("--output-dir={}", sanitize_sh(&distdir(build))))
       .arg(format!("--package-name={}", name))
       .arg("--component-name=rust-src")
       .arg("--legacy-manifest-dirs=rustlib,cargo");
    build.run(&mut cmd);
    // Rename directory, so that root folder of tarball has the correct name
    let plain_name = format!("rustc-{}-src", package_vers(build));
    let plain_dst_src = tmpdir(build).join(&plain_name);
    let _ = fs::remove_dir_all(&plain_dst_src);
    t!(fs::create_dir_all(&plain_dst_src));
    cp_r(&dst_src, &plain_dst_src);
    // Create the version file
    write_file(&plain_dst_src.join("version"), build.version.as_bytes());
    // Create plain source tarball
    let mut cmd = Command::new("tar");
    cmd.arg("-czf").arg(sanitize_sh(&rust_src_location(build)))
       .arg(&plain_name)
       .current_dir(tmpdir(build));
    build.run(&mut cmd);
    t!(fs::remove_dir_all(&image));
    t!(fs::remove_dir_all(&plain_dst_src));
}
pub fn rust_src ( build : & Build ) { println ! ( " " ) ; let name = pkgname ( build , " " ) ; let image = tmpdir ( build ) . join ( format ! ( " " name ) ) ; let _ = fs :: remove_dir_all ( & image ) ; let dst = image . join ( " " ) ; let dst_src = dst . join ( " " ) ; t ! ( fs create_dir_all ( dst_src ) ) ; // This is the set of root paths which will become part of the source package let src_files = [ " " , " " , " " , " " , " " , " " , " " , " " ] ; let src_dirs = [ " " , " " , " " ] ; let filter_fn = move | path : & Path | { let spath = match path . to_str ( ) { Some ( path ) => path , None => return false , } ; if spath . ends_with ( " " ) || spath . ends_with ( " " ) { return false } if spath . contains ( " " ) || spath . contains ( " \\ " ) { if spath . ends_with ( " " ) || spath . ends_with ( " " ) || spath . ends_with ( " " ) { return false } } // If we're inside the vendor directory then we need to preserve // everything as Cargo's vendoring support tracks all checksums and we // want to be sure we don't accidentally leave out a file. if spath . contains ( " " ) { return true } let excludes = [ " " , " " , " " , " " , " " , " " , " " , " " , " " , " " , " " , " " , " " , " " , " " , " " , " " , " " , " " , " " , " " , ] ; ! path . iter ( ) . map ( | s | s . to_str ( ) . unwrap ( ) ) . any ( | s | excludes . contains ( & s ) ) } ; // Copy the directories using our filter for item in & src_dirs { let dst = & dst_src . join ( item ) ; t ! ( fs create_dir ( dst ) ) ; cp_filtered ( & build . src . join ( item ) , dst , & filter_fn ) ; } // Copy the files normally for item in & src_files { copy ( & build . src . join ( item ) , & dst_src . join ( item ) ) ; } // Create source tarball in rust-installer format let mut cmd = Command :: new ( " " ) ; cmd . arg ( sanitize_sh ( & build . src . join ( " " ) ) ) . arg ( " " ) . arg ( " " ) . arg ( " " ) . arg ( format ! ( " " sanitize_sh ( image ) ) ) . arg ( format ! ( " " sanitize_sh ( tmpdir ( build ) ) ) ) . arg ( format ! ( " " sanitize_sh ( distdir ( build ) ) ) ) . arg ( format ! ( " " name ) ) . arg ( " " ) . arg ( " " ) ; build . run ( & mut cmd ) ; // Rename directory, so that root folder of tarball has the correct name let plain_name = format ! ( " " package_vers ( build ) ) ; let plain_dst_src = tmpdir ( build ) . join ( & plain_name ) ; let _ = fs :: remove_dir_all ( & plain_dst_src ) ; t ! ( fs create_dir_all ( plain_dst_src ) ) ; cp_r ( & dst_src , & plain_dst_src ) ; // Create the version file write_file ( & plain_dst_src . join ( " " ) , build . version . as_bytes ( ) ) ; // Create plain source tarball let mut cmd = Command :: new ( " " ) ; cmd . arg ( " " ) . arg ( sanitize_sh ( & rust_src_location ( build ) ) ) . arg ( & plain_name ) . current_dir ( tmpdir ( build ) ) ; build . run ( & mut cmd ) ; t ! ( fs remove_dir_all ( image ) ) ; t ! ( fs remove_dir_all ( plain_dst_src ) ) ; }
Creates the `rust-src` installer component and the plain source tarball
Creates the ` rust - src ` installer component and the plain source tarball
build
&Build
build
&Build