Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make sqlite3ext optional #19

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
184 changes: 17 additions & 167 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ keywords = ["sqlite"]
license = "MIT/Apache-2.0"

[dependencies]
sqlite3ext-sys = {version="0.0.1", path="./sqlite3ext-sys"}
sqlite3ext-sys = {version="0.0.1", optional = true, path="./sqlite3ext-sys"}
sqlite-loadable-macros={version="0.0.3", path="./sqlite-loadable-macros"}
serde = {version="1.0.147", features = ["derive"]}
serde_json = "1.0.87"
Expand All @@ -22,6 +22,8 @@ rusqlite = "0.29.0"
libsqlite3-sys = {version="0.26.0", default-features = false, features=["bundled"]}

[features]
default = ["dynamic"]
dynamic = ["sqlite3ext-sys"]
static = ["libsqlite3-sys"]
exec = []

Expand Down
8 changes: 4 additions & 4 deletions NOTES → NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ Though there's no `crate_type="cdylib"` macro we can use, so gotta introduce a n
pub unsafe fn sqlite3ext_user_data2(context: *mut sqlite3_context) -> *mut c_void {
libsqlite3_sys::sqlite3_user_data(context)
}
#[cfg(not(feature = "static"))]
#[cfg(all(not(feature = "static"), feature = "dynamic"))]
pub unsafe fn sqlite3ext_user_data2(context: *mut sqlite3_context) -> *mut c_void {
((*SQLITE3_API).user_data.expect(EXPECT_MESSAGE))(context)
}
Expand All @@ -58,7 +58,7 @@ macro_rules! export_sqlite_function {
concat_idents!(libsqlite3_sys::, sqlite3_, $func)(context)
}

#[cfg(not(feature = "static"))]
#[cfg(all(not(feature = "static"), feature = "dynamic"))]
pub unsafe fn $func(context: *mut sqlite3_context) -> *mut c_void {
((*SQLITE3_API).$func.expect(EXPECT_MESSAGE))(context)
}
Expand Down Expand Up @@ -99,15 +99,15 @@ make sqlite3_wasm_extra_init.c=../../../../target/wasm32-unknown-emscripten/debu

//#[cfg(target_os = "emscripten")]
pub extern "C" fn sqlite3_wasm_extra_init(_unused: *const std::ffi::c_char) -> std::ffi::c_int {
use sqlite_loadable::SQLITE_OKAY;
use sqlite_loadable::SQLITE_OK;
println!("sqlite3_wasm_extra_init");
unsafe {
sqlite_loadable::ext::sqlite3ext_auto_extension(std::mem::transmute(
sqlite3_hello_init as *const (),
));
}

SQLITE_OKAY
SQLITE_OK
}

```
4 changes: 2 additions & 2 deletions examples/hello.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ pub fn sqlite3_hello_init(db: *mut sqlite3) -> Result<()> {
#[cfg(target_os = "emscripten")]
#[no_mangle]
pub extern "C" fn sqlite3_wasm_extra_init(_unused: *const std::ffi::c_char) -> std::ffi::c_int {
use sqlite_loadable::SQLITE_OKAY;
use sqlite_loadable::SQLITE_OK;
unsafe {
sqlite_loadable::ext::sqlite3ext_auto_extension(std::mem::transmute(
sqlite3_hello_init as *const (),
));
}

SQLITE_OKAY
SQLITE_OK
}
Loading