Skip to content

Commit

Permalink
Fix C toolchain packager
Browse files Browse the repository at this point in the history
  • Loading branch information
aidanhs authored and luser committed Feb 8, 2019
1 parent bccb383 commit 06421ba
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 29 deletions.
3 changes: 1 addition & 2 deletions src/compiler/c.rs
Original file line number Diff line number Diff line change
Expand Up @@ -381,10 +381,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 @@ -1445,8 +1445,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 @@ -1457,33 +1455,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

0 comments on commit 06421ba

Please sign in to comment.