pub fn rustc(build: &Build, stage: u32, host: &str) {
    println!("Dist rustc stage{} ({})", stage, host);
    let name = pkgname(build, "rustc");
    let image = tmpdir(build).join(format!("{}-{}-image", name, host));
    let _ = fs::remove_dir_all(&image);
    let overlay = tmpdir(build).join(format!("{}-{}-overlay", name, host));
    let _ = fs::remove_dir_all(&overlay);

    // Prepare the rustc "image", what will actually end up getting installed
    prepare_image(build, stage, host, &image);

    // Prepare the overlay which is part of the tarball but won't actually be
    // installed
    let cp = |file: &str| {
        install(&build.src.join(file), &overlay, 0o644);
    };
    cp("COPYRIGHT");
    cp("LICENSE-APACHE");
    cp("LICENSE-MIT");
    cp("README.md");
    // tiny morsel of metadata is used by rust-packaging
    let version = &build.version;
    t!(t!(File::create(overlay.join("version"))).write_all(version.as_bytes()));

    // On MinGW we've got a few runtime DLL dependencies that we need to
    // include. The first argument to this script is where to put these DLLs
    // (the image we're creating), and the second argument is a junk directory
    // to ignore all other MinGW stuff the script creates.
    //
    // On 32-bit MinGW we're always including a DLL which needs some extra
    // licenses to distribute. On 64-bit MinGW we don't actually distribute
    // anything requiring us to distribute a license, but it's likely the
    // install will *also* include the rust-mingw package, which also needs
    // licenses, so to be safe we just include it here in all MinGW packages.
    //
    // FIXME: this script should be rewritten into Rust
    if host.contains("pc-windows-gnu") {
        let mut cmd = Command::new(build.python());
        cmd.arg(build.src.join("src/etc/make-win-dist.py"))
           .arg(&image)
           .arg(tmpdir(build))
           .arg(host);
        build.run(&mut cmd);

        let dst = image.join("share/doc");
        t!(fs::create_dir_all(&dst));
        cp_r(&build.src.join("src/etc/third-party"), &dst);
    }

    // Finally, wrap everything up in a nice tarball!
    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=Rust-is-ready-to-roll.")
       .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!("--non-installed-overlay={}", sanitize_sh(&overlay)))
       .arg(format!("--package-name={}-{}", name, host))
       .arg("--component-name=rustc")
       .arg("--legacy-manifest-dirs=rustlib,cargo");
    build.run(&mut cmd);
    t!(fs::remove_dir_all(&image));
    t!(fs::remove_dir_all(&overlay));

    fn prepare_image(build: &Build, stage: u32, host: &str, image: &Path) {
        let src = build.sysroot(&Compiler::new(stage, host));
        let libdir = libdir(host);

        // Copy rustc/rustdoc binaries
        t!(fs::create_dir_all(image.join("bin")));
        cp_r(&src.join("bin"), &image.join("bin"));

        // Copy runtime DLLs needed by the compiler
        if libdir != "bin" {
            for entry in t!(src.join(libdir).read_dir()).map(|e| t!(e)) {
                let name = entry.file_name();
                if let Some(s) = name.to_str() {
                    if is_dylib(s) {
                        install(&entry.path(), &image.join(libdir), 0o644);
                    }
                }
            }
        }

        // Man pages
        t!(fs::create_dir_all(image.join("share/man/man1")));
        cp_r(&build.src.join("man"), &image.join("share/man/man1"));

        // Debugger scripts
        debugger_scripts(build, &image, host);

        // Misc license info
        let cp = |file: &str| {
            install(&build.src.join(file), &image.join("share/doc/rust"), 0o644);
        };
        cp("COPYRIGHT");
        cp("LICENSE-APACHE");
        cp("LICENSE-MIT");
        cp("README.md");
    }
}
/// Creates the `rustc` installer component.
Creates the `rustc` installer component.
Creates the ` rustc ` installer component .
pub fn rustc(build: &Build, stage: u32, host: &str) {
    println!("Dist rustc stage{} ({})", stage, host);
    let name = pkgname(build, "rustc");
    let image = tmpdir(build).join(format!("{}-{}-image", name, host));
    let _ = fs::remove_dir_all(&image);
    let overlay = tmpdir(build).join(format!("{}-{}-overlay", name, host));
    let _ = fs::remove_dir_all(&overlay);
    // Prepare the rustc "image", what will actually end up getting installed
    prepare_image(build, stage, host, &image);
    // Prepare the overlay which is part of the tarball but won't actually be
    // installed
    let cp = |file: &str| {
        install(&build.src.join(file), &overlay, 0o644);
    };
    cp("COPYRIGHT");
    cp("LICENSE-APACHE");
    cp("LICENSE-MIT");
    cp("README.md");
    // tiny morsel of metadata is used by rust-packaging
    let version = &build.version;
    t!(t!(File::create(overlay.join("version"))).write_all(version.as_bytes()));
    // On MinGW we've got a few runtime DLL dependencies that we need to
    // include. The first argument to this script is where to put these DLLs
    // (the image we're creating), and the second argument is a junk directory
    // to ignore all other MinGW stuff the script creates.
    //
    // On 32-bit MinGW we're always including a DLL which needs some extra
    // licenses to distribute. On 64-bit MinGW we don't actually distribute
    // anything requiring us to distribute a license, but it's likely the
    // install will *also* include the rust-mingw package, which also needs
    // licenses, so to be safe we just include it here in all MinGW packages.
    //
    // FIXME: this script should be rewritten into Rust
    if host.contains("pc-windows-gnu") {
        let mut cmd = Command::new(build.python());
        cmd.arg(build.src.join("src/etc/make-win-dist.py"))
           .arg(&image)
           .arg(tmpdir(build))
           .arg(host);
        build.run(&mut cmd);
        let dst = image.join("share/doc");
        t!(fs::create_dir_all(&dst));
        cp_r(&build.src.join("src/etc/third-party"), &dst);
    }
    // Finally, wrap everything up in a nice tarball!
    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=Rust-is-ready-to-roll.")
       .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!("--non-installed-overlay={}", sanitize_sh(&overlay)))
       .arg(format!("--package-name={}-{}", name, host))
       .arg("--component-name=rustc")
       .arg("--legacy-manifest-dirs=rustlib,cargo");
    build.run(&mut cmd);
    t!(fs::remove_dir_all(&image));
    t!(fs::remove_dir_all(&overlay));
    fn prepare_image(build: &Build, stage: u32, host: &str, image: &Path) {
        let src = build.sysroot(&Compiler::new(stage, host));
        let libdir = libdir(host);
        // Copy rustc/rustdoc binaries
        t!(fs::create_dir_all(image.join("bin")));
        cp_r(&src.join("bin"), &image.join("bin"));
        // Copy runtime DLLs needed by the compiler
        if libdir != "bin" {
            for entry in t!(src.join(libdir).read_dir()).map(|e| t!(e)) {
                let name = entry.file_name();
                if let Some(s) = name.to_str() {
                    if is_dylib(s) {
                        install(&entry.path(), &image.join(libdir), 0o644);
                    }
                }
            }
        }
        // Man pages
        t!(fs::create_dir_all(image.join("share/man/man1")));
        cp_r(&build.src.join("man"), &image.join("share/man/man1"));
        // Debugger scripts
        debugger_scripts(build, &image, host);
        // Misc license info
        let cp = |file: &str| {
            install(&build.src.join(file), &image.join("share/doc/rust"), 0o644);
        };
        cp("COPYRIGHT");
        cp("LICENSE-APACHE");
        cp("LICENSE-MIT");
        cp("README.md");
    }
}
pub fn rustc ( build : & Build , stage : u32 , host : & str ) { println ! ( " " stage host ) ; let name = pkgname ( build , " " ) ; let image = tmpdir ( build ) . join ( format ! ( " " name host ) ) ; let _ = fs :: remove_dir_all ( & image ) ; let overlay = tmpdir ( build ) . join ( format ! ( " " name host ) ) ; let _ = fs :: remove_dir_all ( & overlay ) ; // Prepare the rustc "image", what will actually end up getting installed prepare_image ( build , stage , host , & image ) ; // Prepare the overlay which is part of the tarball but won't actually be // installed let cp = | file : & str | { install ( & build . src . join ( file ) , & overlay , 0o644 ) ; } ; cp ( " " ) ; cp ( " " ) ; cp ( " " ) ; cp ( " " ) ; // tiny morsel of metadata is used by rust-packaging let version = & build . version ; t ! ( t ( File create ( overlay join ( " " ) ) ) write_all ( version as_bytes ( ) ) ) ; // On MinGW we've got a few runtime DLL dependencies that we need to // include. The first argument to this script is where to put these DLLs // (the image we're creating), and the second argument is a junk directory // to ignore all other MinGW stuff the script creates. // // On 32-bit MinGW we're always including a DLL which needs some extra // licenses to distribute. On 64-bit MinGW we don't actually distribute // anything requiring us to distribute a license, but it's likely the // install will *also* include the rust-mingw package, which also needs // licenses, so to be safe we just include it here in all MinGW packages. // // FIXME: this script should be rewritten into Rust if host . contains ( " " ) { let mut cmd = Command :: new ( build . python ( ) ) ; cmd . arg ( build . src . join ( " " ) ) . arg ( & image ) . arg ( tmpdir ( build ) ) . arg ( host ) ; build . run ( & mut cmd ) ; let dst = image . join ( " " ) ; t ! ( fs create_dir_all ( dst ) ) ; cp_r ( & build . src . join ( " " ) , & dst ) ; } // Finally, wrap everything up in a nice tarball! 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 ! ( " " sanitize_sh ( overlay ) ) ) . arg ( format ! ( " " name host ) ) . arg ( " " ) . arg ( " " ) ; build . run ( & mut cmd ) ; t ! ( fs remove_dir_all ( image ) ) ; t ! ( fs remove_dir_all ( overlay ) ) ; fn prepare_image ( build : & Build , stage : u32 , host : & str , image : & Path ) { let src = build . sysroot ( & Compiler :: new ( stage , host ) ) ; let libdir = libdir ( host ) ; // Copy rustc/rustdoc binaries t ! ( fs create_dir_all ( image join ( " " ) ) ) ; cp_r ( & src . join ( " " ) , & image . join ( " " ) ) ; // Copy runtime DLLs needed by the compiler if libdir != " " { for entry in t ! ( src join ( libdir ) read_dir ( ) ) . map ( | e | t ! ( e ) ) { let name = entry . file_name ( ) ; if let Some ( s ) = name . to_str ( ) { if is_dylib ( s ) { install ( & entry . path ( ) , & image . join ( libdir ) , 0o644 ) ; } } } } // Man pages t ! ( fs create_dir_all ( image join ( " " ) ) ) ; cp_r ( & build . src . join ( " " ) , & image . join ( " " ) ) ; // Debugger scripts debugger_scripts ( build , & image , host ) ; // Misc license info let cp = | file : & str | { install ( & build . src . join ( file ) , & image . join ( " " ) , 0o644 ) ; } ; cp ( " " ) ; cp ( " " ) ; cp ( " " ) ; cp ( " " ) ; } }
Creates the `rustc` installer component.
Creates the ` rustc ` installer component .
build
&Build
stage
u32
host
&str
build
&Build
stage
u32
host
&str