From eacbba2c07879dbeb29dd0c1d7d64048e83a95ab Mon Sep 17 00:00:00 2001 From: Luca Barbato Date: Thu, 12 Dec 2024 21:32:22 +0100 Subject: [PATCH] Minimal cargo-c support --- .github/workflows/rust.yml | 7 ++++ Cargo.lock | 82 +------------------------------------- Makefile | 9 ++++- sqlite3/Cargo.toml | 9 +++-- sqlite3/build.rs | 8 ---- 5 files changed, 21 insertions(+), 94 deletions(-) delete mode 100644 sqlite3/build.rs diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index d6cd40313..915c938ab 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -53,6 +53,13 @@ jobs: test-limbo: runs-on: ubuntu-latest steps: + - name: Install cargo-c + env: + LINK: https://github.com/lu-zero/cargo-c/releases/download/v0.10.7 + CARGO_C_FILE: cargo-c-x86_64-unknown-linux-musl.tar.gz + run: | + curl -L $LINK/$CARGO_C_FILE | tar xz -C ~/.cargo/bin + - uses: actions/checkout@v2 - name: Test run: make test diff --git a/Cargo.lock b/Cargo.lock index ced65e88c..b2aad9524 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -211,25 +211,6 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5" -[[package]] -name = "cbindgen" -version = "0.27.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fce8dd7fcfcbf3a0a87d8f515194b49d6135acab73e18bd380d1d93bb1a15eb" -dependencies = [ - "clap", - "heck 0.4.1", - "indexmap", - "log", - "proc-macro2", - "quote", - "serde", - "serde_json", - "syn 2.0.90", - "tempfile", - "toml", -] - [[package]] name = "cc" version = "1.2.3" @@ -326,7 +307,7 @@ version = "4.5.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4ac6a0c7b1a9e9a5186361f67dfa1b88213572f427fb9ab038efb2bd8c582dab" dependencies = [ - "heck 0.5.0", + "heck", "proc-macro2", "quote", "syn 2.0.90", @@ -906,12 +887,6 @@ dependencies = [ "hashbrown 0.14.5", ] -[[package]] -name = "heck" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" - [[package]] name = "heck" version = "0.5.0" @@ -1199,7 +1174,6 @@ dependencies = [ name = "limbo_sqlite3" version = "0.0.9" dependencies = [ - "cbindgen", "env_logger 0.11.5", "limbo_core", "log", @@ -1707,7 +1681,7 @@ version = "0.22.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "36c011a03ba1e50152b4b394b479826cad97e7a21eb52df179cd91ac411cbfbe" dependencies = [ - "heck 0.5.0", + "heck", "proc-macro2", "pyo3-build-config", "quote", @@ -2010,15 +1984,6 @@ dependencies = [ "serde", ] -[[package]] -name = "serde_spanned" -version = "0.6.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87607cb1398ed59d48732e575a4c28a7a8ebf2454b964fe3f224f2afc07909e1" -dependencies = [ - "serde", -] - [[package]] name = "sha2" version = "0.10.8" @@ -2233,40 +2198,6 @@ dependencies = [ "serde_json", ] -[[package]] -name = "toml" -version = "0.8.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1ed1f98e3fdc28d6d910e6737ae6ab1a93bf1985935a1193e68f93eeb68d24e" -dependencies = [ - "serde", - "serde_spanned", - "toml_datetime", - "toml_edit", -] - -[[package]] -name = "toml_datetime" -version = "0.6.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0dd7358ecb8fc2f8d014bf86f6f638ce72ba252a2c3a2572f2a795f1d23efb41" -dependencies = [ - "serde", -] - -[[package]] -name = "toml_edit" -version = "0.22.22" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ae48d6208a266e853d946088ed816055e556cc6028c5e8e2b84d9fa5dd7c7f5" -dependencies = [ - "indexmap", - "serde", - "serde_spanned", - "toml_datetime", - "winnow", -] - [[package]] name = "tracing" version = "0.1.41" @@ -2620,15 +2551,6 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" -[[package]] -name = "winnow" -version = "0.6.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36c1fec1a2bb5866f07c25f68c26e565c4c200aebb96d7e55710c19d3e8ac49b" -dependencies = [ - "memchr", -] - [[package]] name = "zerocopy" version = "0.7.35" diff --git a/Makefile b/Makefile index 33f9bd5e9..acb016c65 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,6 @@ MINIMUM_RUST_VERSION := 1.73.0 CURRENT_RUST_VERSION := $(shell rustc -V | sed -E 's/rustc ([0-9]+\.[0-9]+\.[0-9]+).*/\1/') +CURRENT_RUST_TARGET := $(shell rustc -vV | grep host | cut -d ' ' -f 2) RUSTUP := $(shell command -v rustup 2> /dev/null) UNAME_S := $(shell uname -s) @@ -7,7 +8,7 @@ UNAME_S := $(shell uname -s) SQLITE_EXEC ?= ./target/debug/limbo # Static library to use for SQLite C API compatibility tests. -BASE_SQLITE_LIB = ./target/debug/liblimbo_sqlite3.a +BASE_SQLITE_LIB = ./target/$(CURRENT_RUST_TARGET)/debug/liblimbo_sqlite3.a # On darwin link core foundation ifeq ($(UNAME_S),Darwin) @@ -47,6 +48,10 @@ limbo: cargo build .PHONY: limbo +limbo-c: + cargo cbuild +.PHONY: limbo-c + limbo-wasm: rustup target add wasm32-wasi cargo build --package limbo-wasm --target wasm32-wasi @@ -59,6 +64,6 @@ test-compat: SQLITE_EXEC=$(SQLITE_EXEC) ./testing/all.test .PHONY: test-compat -test-sqlite3: +test-sqlite3: limbo-c LIBS="$(SQLITE_LIB)" make -C sqlite3/tests test .PHONY: test-sqlite3 diff --git a/sqlite3/Cargo.toml b/sqlite3/Cargo.toml index 0d9da50ff..bb0bebbfc 100644 --- a/sqlite3/Cargo.toml +++ b/sqlite3/Cargo.toml @@ -9,19 +9,20 @@ license.workspace = true repository.workspace = true [features] +capi = [] lfs = [] [package.metadata.dist] dist = true [lib] -crate-type = ["cdylib", "staticlib"] doc = false -[build-dependencies] -cbindgen = "0.27.0" - [dependencies] env_logger = { version = "0.11.3", default-features = false } limbo_core = { path = "../core" } log = "0.4.22" + + +[package.metadata.capi.header] +name = "sqlite3.h" diff --git a/sqlite3/build.rs b/sqlite3/build.rs deleted file mode 100644 index bf432e910..000000000 --- a/sqlite3/build.rs +++ /dev/null @@ -1,8 +0,0 @@ -use std::path::Path; - -fn main() { - let header_file = Path::new("include").join("sqlite3.h"); - cbindgen::generate(".") - .expect("Failed to generate C bindings") - .write_to_file(header_file); -}