Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix C toolchain packager #1

Merged
merged 1 commit into from
Nov 23, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/compiler/c.rs
Original file line number Diff line number Diff line change
Expand Up @@ -378,10 +378,9 @@ struct CToolchainPackager {
impl pkg::ToolchainPackager for CToolchainPackager {
fn write_pkg(self: Box<Self>, f: fs::File) -> Result<()> {
use std::os::unix::ffi::OsStringExt;
use pkg::ToolchainPackageBuilder as Builder;

info!("Generating toolchain {}", self.executable.display());
let mut package_builder = Builder::new();
let mut package_builder = pkg::ToolchainPackageBuilder::new();
package_builder.add_common()?;
package_builder.add_executable_and_deps(self.executable.clone())?;

Expand Down
29 changes: 2 additions & 27 deletions src/compiler/rust.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1403,8 +1403,6 @@ struct RustToolchainPackager {
#[cfg(all(target_os = "linux", target_arch = "x86_64"))]
impl pkg::ToolchainPackager for RustToolchainPackager {
fn write_pkg(self: Box<Self>, f: fs::File) -> Result<()> {
use walkdir::WalkDir;

info!("Packaging Rust compiler for sysroot {}", self.sysroot.display());
let RustToolchainPackager { sysroot } = *self;

Expand All @@ -1415,33 +1413,10 @@ impl pkg::ToolchainPackager for RustToolchainPackager {
let sysroot_executable = bins_path.join("rustc").with_extension(EXE_EXTENSION);
package_builder.add_executable_and_deps(sysroot_executable)?;

// Although by not following symlinks we could break a custom constructed toolchain with
// links everywhere, this is just a best-effort auto packaging
fn walk_and_add(path: &Path, package_builder: &mut pkg::ToolchainPackageBuilder) -> Result<()> {
for entry in WalkDir::new(path).follow_links(false) {
let entry = entry?;
let file_type = entry.file_type();
if file_type.is_dir() {
continue
} else if file_type.is_symlink() {
let metadata = fs::metadata(entry.path())?;
if !metadata.file_type().is_file() {
continue
}
} else if !file_type.is_file() {
// Device or other oddity
continue
}
// It's either a file, or a symlink pointing to a file
package_builder.add_file(entry.path().to_owned())?
}
Ok(())
}

walk_and_add(&bins_path, &mut package_builder)?;
package_builder.add_dir_contents(&bins_path)?;
if BINS_DIR != LIBS_DIR {
let libs_path = sysroot.join(LIBS_DIR);
walk_and_add(&libs_path, &mut package_builder)?
package_builder.add_dir_contents(&libs_path)?
}

package_builder.into_compressed_tar(f)
Expand Down
2 changes: 1 addition & 1 deletion src/dist/pkg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ mod toolchain_imp {
#[cfg(all(target_os = "linux", target_arch = "x86_64"))]
mod toolchain_imp {
use std::collections::BTreeMap;
use std::io::{Write, Read};
use std::io::Write;
use std::fs;
use std::path::{Component, Path, PathBuf};
use std::process;
Expand Down