Skip to content

Commit

Permalink
Revert "Merge pull request #1791 from awakecoding/libsql-ffi-build-cp…
Browse files Browse the repository at this point in the history
…-fix"

This reverts commit 5ee4723, reversing
changes made to cc1d9c5 because it breaks `libsql-js` build on macOS:

```
penberg@vonneumann libsql-js % cargo check
    Updating git repository `https://github.com/tursodatabase/libsql/`
   Compiling libsql-ffi v0.5.0 (https://github.com/tursodatabase/libsql/?rev=9c73c68f0b034c5e01a51d9dc93a61936a71c801#9c73c68f)
   Compiling libsql-sqlite3-parser v0.13.0 (https://github.com/tursodatabase/libsql/?rev=9c73c68f0b034c5e01a51d9dc93a61936a71c801#9c73c68f)
    Checking reqwest v0.12.9
    Checking libsql-hrana v0.2.0 (https://github.com/tursodatabase/libsql/?rev=9c73c68f0b034c5e01a51d9dc93a61936a71c801#9c73c68f)
error: failed to run custom build command for `libsql-ffi v0.5.0 (https://github.com/tursodatabase/libsql/?rev=9c73c68f0b034c5e01a51d9dc93a61936a71c801#9c73c68f)`

Caused by:
  process didn't exit successfully: `/Users/penberg/src/tursodatabase/libsql-js/target/debug/build/libsql-ffi-755a07789947d931/build-script-build` (exit status: 101)
  --- stdout
  cargo:rustc-link-lib=framework=Security
  cargo:rerun-if-changed=bundled/src/sqlite3.c
  cargo:rerun-if-changed=/Users/penberg/src/tursodatabase/libsql-js/target/debug/build/libsql-ffi-e660048e9fb948a4/out/sqlite3mc/libsqlite3mc_static.a

  --- stderr
  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
  thread 'main' panicked at /Users/penberg/.cargo/git/checkouts/libsql-311658d335deb3b1/9c73c68/libsql-ffi/build.rs:43:44:
  called `Result::unwrap()` on an `Err` value: Custom { kind: Other, error: "Failed to copy using cp" }
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
warning: build failed, waiting for other jobs to finish...
```
  • Loading branch information
penberg committed Nov 15, 2024
1 parent 9c73c68 commit 9499c3c
Showing 1 changed file with 8 additions and 28 deletions.
36 changes: 8 additions & 28 deletions libsql-ffi/build.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::env;
use std::ffi::OsString;
use std::fs::{self, OpenOptions};
use std::io::{self, Write};
use std::io::Write;
use std::path::{Path, PathBuf};
use std::process::Command;

Expand Down Expand Up @@ -39,8 +39,13 @@ fn main() {

let dir = env!("CARGO_MANIFEST_DIR");

let full_src_path = Path::new(dir).join(bindgen_rs_path);
copy_with_cp(full_src_path, &out_path).unwrap();
Command::new("cp")
.arg("--no-preserve=mode,ownership")
.arg("-R")
.arg(format!("{dir}/{bindgen_rs_path}"))
.arg(&out_path)
.output()
.unwrap();

println!("cargo:lib_dir={out_dir}");

Expand All @@ -56,31 +61,6 @@ fn main() {
build_bundled(&out_dir, &out_path);
}

#[cfg(target_os = "windows")]
fn copy_with_cp(src: impl AsRef<Path>, dst: impl AsRef<Path>) -> io::Result<()> {
fs::copy(src, dst)?; // do a regular file copy on Windows
Ok(())
}

#[cfg(not(target_os = "windows"))]
fn copy_with_cp(src: impl AsRef<Path>, dst: impl AsRef<Path>) -> io::Result<()> {
let status = Command::new("cp")
.arg("--no-preserve=mode,ownership")
.arg("-R")
.arg(src.as_ref().to_str().unwrap())
.arg(dst.as_ref().to_str().unwrap())
.status()?;

if !status.success() {
Err(io::Error::new(
io::ErrorKind::Other,
"Failed to copy using cp",
))
} else {
Ok(())
}
}

fn make_amalgamation() {
let flags = ["-DSQLITE_ENABLE_COLUMN_METADATA=1"];

Expand Down

0 comments on commit 9499c3c

Please sign in to comment.