Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[package]
name = "sqlite-wasm-rs"
links = "wsqlite3"
version = "0.5.1"
authors = ["Spxg <unsafe@outlook.es>"]
repository = "https://github.com/Spxg/sqlite-wasm-rs"
Expand All @@ -15,15 +16,17 @@ include.workspace = true
[dependencies]
wasm-bindgen = { version = "0.2.104", default-features = false }
js-sys = { version = "0.3.81", default-features = false }
wsqlite3-sys = { path = "crates/wsqlite3-sys" }
rsqlite-vfs = { path = "crates/rsqlite-vfs" }

[features]
# SQLite3MultipleCiphers
# <https://github.com/utelle/SQLite3MultipleCiphers>
# <https://utelle.github.io/SQLite3MultipleCiphers>
sqlite3mc = ["wsqlite3-sys/sqlite3mc"]
bindgen = ["wsqlite3-sys/bindgen"]
sqlite3mc = []

[build-dependencies]
cc = "1.2.27"
bindgen = { version = "0.72", optional = true }

[dev-dependencies]
wasm-bindgen-test = "0.3.54"
Expand All @@ -35,10 +38,9 @@ targets = ["wasm32-unknown-unknown"]
resolver = "2"
members = [
"tests",
"crates/rsqlite-vfs",
"crates/sqlite-wasm-libc",
"crates/sqlite-wasm-vfs",
"crates/rsqlite-vfs",
"crates/wsqlite3-sys",
"extensions/sqlite-vec",
"examples/implement-a-vfs",
"examples/nodejs",
Expand Down
4 changes: 2 additions & 2 deletions crates/wsqlite3-sys/build.rs → build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ fn main() {

if update_bindgen {
#[cfg(not(feature = "sqlite3mc"))]
const SQLITE3_BINDGEN: &str = "src/sqlite3_bindgen.rs";
const SQLITE3_BINDGEN: &str = "src/bindings/sqlite3_bindgen.rs";
#[cfg(feature = "sqlite3mc")]
const SQLITE3_BINDGEN: &str = "src/sqlite3mc_bindgen.rs";
const SQLITE3_BINDGEN: &str = "src/bindings/sqlite3mc_bindgen.rs";
std::fs::copy(&output, SQLITE3_BINDGEN).unwrap();
}
}
Expand Down
25 changes: 0 additions & 25 deletions crates/wsqlite3-sys/Cargo.toml

This file was deleted.

2 changes: 1 addition & 1 deletion extensions/sqlite-vec/cc/shim
2 changes: 1 addition & 1 deletion extensions/sqlite-vec/cc/sqlite3.h
4 changes: 2 additions & 2 deletions script/printf.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
TAG=6.3.0
curl -L https://github.com/eyalroz/printf/archive/refs/tags/v$TAG.zip > $TAG.zip
unzip -p "$TAG.zip" "printf-$TAG/src/printf/printf.c" > "crates/wsqlite3-sys/shim/printf/printf.c"
unzip -p "$TAG.zip" "printf-$TAG/src/printf/printf.h" > "crates/wsqlite3-sys/shim/printf/printf.h"
unzip -p "$TAG.zip" "printf-$TAG/src/printf/printf.c" > "shim/printf/printf.c"
unzip -p "$TAG.zip" "printf-$TAG/src/printf/printf.h" > "shim/printf/printf.h"
rm $TAG.zip
6 changes: 3 additions & 3 deletions script/sqlite3_upgrade.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
SQLITE=sqlite-amalgamation-3510100
curl -O https://sqlite.org/2025/$SQLITE.zip
unzip -p "$SQLITE.zip" "$SQLITE/sqlite3.c" > "crates/wsqlite3-sys/sqlite3/sqlite3.c"
unzip -p "$SQLITE.zip" "$SQLITE/sqlite3.h" > "crates/wsqlite3-sys/sqlite3/sqlite3.h"
unzip -p "$SQLITE.zip" "$SQLITE/sqlite3ext.h" > "crates/wsqlite3-sys/sqlite3/sqlite3ext.h"
unzip -p "$SQLITE.zip" "$SQLITE/sqlite3.c" > "sqlite3/sqlite3.c"
unzip -p "$SQLITE.zip" "$SQLITE/sqlite3.h" > "sqlite3/sqlite3.h"
unzip -p "$SQLITE.zip" "$SQLITE/sqlite3ext.h" > "sqlite3/sqlite3ext.h"
rm -f "$SQLITE.zip"
4 changes: 2 additions & 2 deletions script/sqlite3mc_upgrade.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
SQLITE=sqlite3mc-2.2.6-sqlite-3.51.1-amalgamation
curl -L https://github.com/utelle/SQLite3MultipleCiphers/releases/latest/download/$SQLITE.zip > $SQLITE.zip
unzip -p "$SQLITE.zip" "sqlite3mc_amalgamation.c" > "crates/wsqlite3-sys/sqlite3mc/sqlite3mc_amalgamation.c"
unzip -p "$SQLITE.zip" "sqlite3mc_amalgamation.h" > "crates/wsqlite3-sys/sqlite3mc/sqlite3mc_amalgamation.h"
unzip -p "$SQLITE.zip" "sqlite3mc_amalgamation.c" > "sqlite3mc/sqlite3mc_amalgamation.c"
unzip -p "$SQLITE.zip" "sqlite3mc_amalgamation.h" > "sqlite3mc/sqlite3mc_amalgamation.h"
rm -f "$SQLITE.zip"
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
7 changes: 0 additions & 7 deletions crates/wsqlite3-sys/src/lib.rs → src/bindings/mod.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,8 @@
//! This module is codegen from build.rs
#![no_std]
#![allow(non_camel_case_types)]
#![allow(non_snake_case)]

#[rustfmt::skip]
#[allow(clippy::missing_safety_doc, clippy::type_complexity)]
#[cfg(all(not(feature = "bindgen"), feature = "sqlite3mc"))]
mod sqlite3mc_bindgen;

#[rustfmt::skip]
#[allow(clippy::missing_safety_doc, clippy::type_complexity)]
#[cfg(all(not(feature = "bindgen"), not(feature = "sqlite3mc")))]
mod sqlite3_bindgen;

Expand Down
9 changes: 8 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
#![doc = include_str!("../README.md")]
#![no_std]
#![cfg_attr(target_feature = "atomics", feature(stdarch_wasm_atomic_wait))]
#![allow(clippy::missing_safety_doc)]
#![allow(non_upper_case_globals)]
#![allow(non_camel_case_types)]
#![allow(non_snake_case)]

extern crate alloc;

mod shim;
#[rustfmt::skip]
#[allow(clippy::type_complexity)]
mod bindings;

/// Low-level utilities, traits, and macros for implementing custom SQLite Virtual File Systems (VFS)
pub mod utils {
Expand All @@ -26,7 +33,7 @@ pub mod utils {
pub use self::utils::{bail, check_option, check_result};

/// Raw C-style bindings to the underlying `libsqlite3` library.
pub use wsqlite3_sys::*;
pub use bindings::*;

/// Wasm platform implementation
pub use self::shim::WasmOsCallback;
Expand Down
4 changes: 2 additions & 2 deletions src/shim.rs
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ pub unsafe extern "C" fn rust_sqlite_wasm_calloc(num: c_size_t, size: c_size_t)
#[no_mangle]
pub unsafe extern "C" fn sqlite3_os_init() -> core::ffi::c_int {
rsqlite_vfs::memvfs::install::<WasmOsCallback>();
wsqlite3_sys::SQLITE_OK
crate::bindings::SQLITE_OK
}

/// SQLite OS shutdown entry point.
Expand All @@ -267,7 +267,7 @@ pub unsafe extern "C" fn sqlite3_os_init() -> core::ffi::c_int {
#[no_mangle]
pub unsafe extern "C" fn sqlite3_os_end() -> core::ffi::c_int {
rsqlite_vfs::memvfs::uninstall();
wsqlite3_sys::SQLITE_OK
crate::bindings::SQLITE_OK
}

#[cfg(test)]
Expand Down