Skip to content

Commit

Permalink
fix wasm tests
Browse files Browse the repository at this point in the history
  • Loading branch information
MarinPostma committed Nov 20, 2023
1 parent 9fd18b0 commit 5ee3bcc
Show file tree
Hide file tree
Showing 15 changed files with 1,197 additions and 4,816 deletions.
1,030 changes: 1,008 additions & 22 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions libsql-ffi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ build = "build.rs"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
libsql-wasmtime-bindings = { version = "0.2.1", optional = true }

[build-dependencies]
bindgen = "0.66.1"
cc = "1.0"

[features]
session = []
wasmtime-bindings = ["dep:libsql-wasmtime-bindings"]
19 changes: 16 additions & 3 deletions libsql-ffi/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ fn main() {
let out_dir = env::var("OUT_DIR").unwrap();
let out_path = Path::new(&out_dir).join("bindgen.rs");
println!("cargo:rerun-if-changed={BUNDLED_DIR}/src/");
if std::env::var("LIBSQL_DEV").is_ok() {
if std::env::var("LIBSQL_DEV").is_ok() || cfg!(feature = "wasmtime-bindings") {
println!("cargo:rerun-if-changed={SQLITE_DIR}/src/");
make_amalgation();
}
Expand All @@ -20,9 +20,22 @@ fn main() {
}

fn make_amalgation() {
let flags = [
"-DSQLITE_ENABLE_COLUMN_METADATA=1",
"-DSQLITE_ENABLE_WASM_RUNTIME=1",
];

Command::new("make")
.current_dir(SQLITE_DIR)
.arg("clean")
.output()
.unwrap();

Command::new("./configure")
.current_dir(SQLITE_DIR)
.env("CFLAGS", "-DSQLITE_ENABLE_COLUMN_METADATA=1")
.env("CFLAGS", flags.join(" "))
// .arg("--enable-all")
// .arg("--enable-wasm-runtime")
.output()
.unwrap();
Command::new("make")
Expand Down Expand Up @@ -81,7 +94,7 @@ pub fn build_bundled(out_dir: &str, out_path: &Path) {
.flag("-D_POSIX_THREAD_SAFE_FUNCTIONS") // cross compile with MinGW
.warnings(false);

if cfg!(feature = "libsql-wasm-experimental") {
if cfg!(feature = "wasmtime-bindings") {
cfg.flag("-DLIBSQL_ENABLE_WASM_RUNTIME=1");
}

Expand Down
Loading

0 comments on commit 5ee3bcc

Please sign in to comment.