Skip to content

Commit 1338596

Browse files
committed
libsql-ffi: Fix build on macOS
The `cp` command does not support `--no-preserve` on macOS.
1 parent 38cfab7 commit 1338596

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

libsql-ffi/build.rs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ fn copy_with_cp(src: impl AsRef<Path>, dst: impl AsRef<Path>) -> io::Result<()>
6262
Ok(())
6363
}
6464

65-
#[cfg(not(target_os = "windows"))]
65+
#[cfg(target_os = "linux")]
6666
fn copy_with_cp(src: impl AsRef<Path>, dst: impl AsRef<Path>) -> io::Result<()> {
6767
let status = Command::new("cp")
6868
.arg("--no-preserve=mode,ownership")
@@ -81,6 +81,24 @@ fn copy_with_cp(src: impl AsRef<Path>, dst: impl AsRef<Path>) -> io::Result<()>
8181
}
8282
}
8383

84+
#[cfg(target_os = "macos")]
85+
fn copy_with_cp(src: impl AsRef<Path>, dst: impl AsRef<Path>) -> io::Result<()> {
86+
let status = Command::new("cp")
87+
.arg("-R")
88+
.arg(src.as_ref().to_str().unwrap())
89+
.arg(dst.as_ref().to_str().unwrap())
90+
.status()?;
91+
92+
if !status.success() {
93+
Err(io::Error::new(
94+
io::ErrorKind::Other,
95+
"Failed to copy using cp",
96+
))
97+
} else {
98+
Ok(())
99+
}
100+
}
101+
84102
fn make_amalgamation() {
85103
let flags = ["-DSQLITE_ENABLE_COLUMN_METADATA=1"];
86104

0 commit comments

Comments
 (0)