Skip to content

Commit 1e0ce80

Browse files
authored
Fix libsql-ffi build on Windows (#2005)
libsql-ffi build on Windows has been intermittently broken for a while due _build.rs_ calling `cp` which is not present on Windows. Timeline: - 2024-08-10: Issue #1657 was opened. - 2024-11-14: #1791 was merged. First fix using `#[cfg(windows)]`. - 2024-11-15: #1791 reverted in 9499c3c for breaking libsql-js on macOS. - 2024-12-04: 9499c3c was reverted since #1791 was fine and did not cause the macOS problem. Windows build works again. - 2025-03-17: da54c1b breaks Windows build. - 2025-03-21: 0.9.1 is released with broken Windows build. - 2025-03-27: This commit fixes the bug introduced in da54c1b. This commit fixes a bug introduced by da54c1b. `Command::status()?` was propogating the error so the fallback, `fs::copy`, was never reached. This is now fixed so libsql-ffi builds again on Windows. Closes #1657
2 parents bbeabc9 + 0edf5e3 commit 1e0ce80

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

libsql-ffi/build.rs

+9-11
Original file line numberDiff line numberDiff line change
@@ -76,22 +76,20 @@ 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-
let status = Command::new("cp")
79+
match Command::new("cp")
8080
.arg("--no-preserve=mode,ownership")
8181
.arg("-R")
8282
.arg(from.as_ref().to_str().unwrap())
8383
.arg(to.as_ref().to_str().unwrap())
84-
.status()?;
85-
86-
if status.success() {
87-
return Ok(());
84+
.status()
85+
{
86+
Ok(status) if status.success() => Ok(()),
87+
_ => match fs::copy(from.as_ref(), to.as_ref()) {
88+
Err(err) if err.kind() == io::ErrorKind::InvalidInput => copy_dir_all(from, to),
89+
Ok(_) => Ok(()),
90+
Err(err) => Err(err),
91+
},
8892
}
89-
90-
return match fs::copy(from.as_ref(), to.as_ref()) {
91-
Err(err) if err.kind() == io::ErrorKind::InvalidInput => copy_dir_all(from, to),
92-
Ok(_) => Ok(()),
93-
Err(err) => Err(err),
94-
};
9593
}
9694

9795
fn make_amalgamation() {

0 commit comments

Comments
 (0)