Skip to content

Commit eecb25d

Browse files
authored
Fix: fix osx cp warning. (#2103)
On macos, cp's `--no-preserve` option does not exist. It is enabled by default, and can be disabled with the explicit `-p` (preserve) flag. This lead libsql-ffi's build.rs to warn about an illegal option used: ``` cp: illegal option -- - usage: cp [-R [-H | -L | -P]] [-fi | -n] [-aclpSsvXx] source_file target_file cp [-R [-H | -L | -P]] [-fi | -n] [-aclpSsvXx] source_file ... target_directory ``` This changeset makes sure the option is only passed in non `macos` target_os. It seems like the build.rs file has had quite a lot of bugfixes over time, especially the CP function, so feel free to dismiss this PR if you're not comfortable landing it, as it's just a warning, and if the cp command does not work it will fallback to `copy_dir_all`. I'm also lacking context on this library so if I'm missing anything please let me know! Thanks
2 parents c85ec3d + 6b6efeb commit eecb25d

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

libsql-ffi/build.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,12 @@ fn copy_dir_all(src: impl AsRef<Path>, dst: impl AsRef<Path>) -> io::Result<()>
7676
/// propagate into OUT_DIR. If not present, when trying to rewrite a file, a `Permission denied`
7777
/// error will occur.
7878
fn copy_with_cp(from: impl AsRef<Path>, to: impl AsRef<Path>) -> io::Result<()> {
79-
match Command::new("cp")
80-
.arg("--no-preserve=mode,ownership")
79+
let mut command = Command::new("cp");
80+
// --no-preserve is enabled by default on macos
81+
// preserve must be explicitly enabled with the -p flag
82+
#[cfg(not(target_os = "macos"))]
83+
let command = command.arg("--no-preserve=mode,ownership");
84+
match command
8185
.arg("-R")
8286
.arg(from.as_ref().to_str().unwrap())
8387
.arg(to.as_ref().to_str().unwrap())

0 commit comments

Comments
 (0)