mirror of
https://github.com/roc-lang/roc.git
synced 2025-08-04 04:08:19 +00:00
Don't copy zig-cache when building builtins
This commit is contained in:
parent
fffe9ca8ee
commit
1071aa8eac
1 changed files with 34 additions and 10 deletions
|
@ -162,16 +162,7 @@ fn copy_zig_builtins_to_target_dir(bitcode_path: &Path) {
|
|||
|
||||
let zig_src_dir = bitcode_path.join("src");
|
||||
|
||||
std::fs::create_dir_all(&target_profile_dir).unwrap_or_else(|err| {
|
||||
panic!(
|
||||
"Failed to create output library directory for zig bitcode {:?}: {:?}",
|
||||
target_profile_dir, err
|
||||
);
|
||||
});
|
||||
let mut options = fs_extra::dir::CopyOptions::new();
|
||||
options.content_only = true;
|
||||
options.overwrite = true;
|
||||
fs_extra::dir::copy(&zig_src_dir, &target_profile_dir, &options).unwrap_or_else(|err| {
|
||||
cp_unless_zig_cache(&zig_src_dir, &target_profile_dir).unwrap_or_else(|err| {
|
||||
panic!(
|
||||
"Failed to copy zig bitcode files {:?} to {:?}: {:?}",
|
||||
zig_src_dir, target_profile_dir, err
|
||||
|
@ -179,6 +170,39 @@ fn copy_zig_builtins_to_target_dir(bitcode_path: &Path) {
|
|||
});
|
||||
}
|
||||
|
||||
// recursively copy all the .zig files from this directory, but do *not* recurse into zig-cache/
|
||||
fn cp_unless_zig_cache(src_dir: &Path, target_dir: &Path) -> io::Result<()> {
|
||||
// Make sure the destination directory exists before we try to copy anything into it.
|
||||
std::fs::create_dir_all(&target_dir).unwrap_or_else(|err| {
|
||||
panic!(
|
||||
"Failed to create output library directory for zig bitcode {:?}: {:?}",
|
||||
target_dir, err
|
||||
);
|
||||
});
|
||||
|
||||
for entry in fs::read_dir(src_dir)? {
|
||||
let src_path = entry?.path();
|
||||
let src_filename = src_path.file_name().unwrap();
|
||||
|
||||
// Only copy individual files if they have the .zig extension
|
||||
if src_path.extension().unwrap_or_default() == "zig" {
|
||||
let dest = target_dir.join(src_filename);
|
||||
|
||||
fs::copy(&src_path, &dest).unwrap_or_else(|err| {
|
||||
panic!(
|
||||
"Failed to copy zig bitcode file {:?} to {:?}: {:?}",
|
||||
src_path, dest, err
|
||||
);
|
||||
});
|
||||
} else if src_path.is_dir() && src_filename != "zig-cache" {
|
||||
// Recursively copy all directories except zig-cache
|
||||
cp_unless_zig_cache(&src_path, &target_dir.join(src_filename))?;
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn run_command<S, I: Copy, P: AsRef<Path> + Copy>(path: P, command_str: &str, args: I)
|
||||
where
|
||||
I: IntoIterator<Item = S>,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue