2022-01-15 17:35:30 +08:00
|
|
|
#!/bin/sh -e
|
2020-04-15 07:22:35 +08:00
|
|
|
|
2022-01-15 17:35:30 +08:00
|
|
|
SCRIPT_DIR=$(cd "$(dirname "$0")" && pwd)
|
2020-04-15 07:22:35 +08:00
|
|
|
echo "$SCRIPT_DIR"
|
2021-06-03 03:07:56 +08:00
|
|
|
cd "$SCRIPT_DIR" || { echo "fatal error" >&2; exit 1; }
|
2023-07-09 16:39:21 +08:00
|
|
|
cargo clean -p libsqlite3-sys
|
|
|
|
TARGET_DIR="$SCRIPT_DIR/../target"
|
2021-06-03 03:07:56 +08:00
|
|
|
export SQLITE3_LIB_DIR="$SCRIPT_DIR/sqlite3"
|
2023-07-09 16:39:21 +08:00
|
|
|
mkdir -p "$TARGET_DIR" "$SQLITE3_LIB_DIR"
|
2018-02-10 18:04:02 +08:00
|
|
|
|
|
|
|
# Download and extract amalgamation
|
2023-11-04 02:28:08 +08:00
|
|
|
SQLITE=sqlite-amalgamation-3440000
|
2023-02-25 02:40:34 +08:00
|
|
|
curl -O https://sqlite.org/2023/$SQLITE.zip
|
2020-04-15 07:22:35 +08:00
|
|
|
unzip -p "$SQLITE.zip" "$SQLITE/sqlite3.c" > "$SQLITE3_LIB_DIR/sqlite3.c"
|
|
|
|
unzip -p "$SQLITE.zip" "$SQLITE/sqlite3.h" > "$SQLITE3_LIB_DIR/sqlite3.h"
|
|
|
|
unzip -p "$SQLITE.zip" "$SQLITE/sqlite3ext.h" > "$SQLITE3_LIB_DIR/sqlite3ext.h"
|
|
|
|
rm -f "$SQLITE.zip"
|
2018-02-10 18:04:02 +08:00
|
|
|
|
2023-07-09 16:39:21 +08:00
|
|
|
export SQLITE3_INCLUDE_DIR="$SQLITE3_LIB_DIR"
|
|
|
|
# Regenerate bindgen file for sqlite3.h
|
2020-04-15 07:22:35 +08:00
|
|
|
rm -f "$SQLITE3_LIB_DIR/bindgen_bundled_version.rs"
|
2018-02-10 18:04:02 +08:00
|
|
|
cargo update
|
2018-03-24 10:48:09 +08:00
|
|
|
# Just to make sure there is only one bindgen.rs file in target dir
|
2023-07-09 16:39:21 +08:00
|
|
|
find "$TARGET_DIR" -type f -name bindgen.rs -exec rm {} \;
|
2021-07-03 07:48:18 +08:00
|
|
|
env LIBSQLITE3_SYS_BUNDLING=1 cargo build --features "buildtime_bindgen session" --no-default-features
|
2023-07-09 16:39:21 +08:00
|
|
|
find "$TARGET_DIR" -type f -name bindgen.rs -exec mv {} "$SQLITE3_LIB_DIR/bindgen_bundled_version.rs" \;
|
|
|
|
|
|
|
|
# Regenerate bindgen file for sqlite3ext.h
|
|
|
|
# some sqlite3_api_routines fields are function pointers with va_list arg but currently stable Rust doesn't support this type.
|
|
|
|
# FIXME how to generate portable bindings without :
|
2023-11-12 03:11:37 +08:00
|
|
|
sed -i.bk -e 's/va_list/void*/' "$SQLITE3_LIB_DIR/sqlite3ext.h"
|
2023-07-09 16:39:21 +08:00
|
|
|
rm -f "$SQLITE3_LIB_DIR/bindgen_bundled_version_ext.rs"
|
|
|
|
find "$TARGET_DIR" -type f -name bindgen.rs -exec rm {} \;
|
|
|
|
env LIBSQLITE3_SYS_BUNDLING=1 cargo build --features "buildtime_bindgen loadable_extension" --no-default-features
|
|
|
|
find "$TARGET_DIR" -type f -name bindgen.rs -exec mv {} "$SQLITE3_LIB_DIR/bindgen_bundled_version_ext.rs" \;
|
|
|
|
git checkout "$SQLITE3_LIB_DIR/sqlite3ext.h"
|
2023-11-12 03:11:37 +08:00
|
|
|
rm -f "$SQLITE3_LIB_DIR/sqlite3ext.h.bk"
|
2021-06-03 03:07:56 +08:00
|
|
|
|
|
|
|
# Sanity checks
|
|
|
|
cd "$SCRIPT_DIR/.." || { echo "fatal error" >&2; exit 1; }
|
2018-02-10 18:04:02 +08:00
|
|
|
cargo update
|
2018-12-15 17:51:02 +08:00
|
|
|
cargo test --features "backup blob chrono functions limits load_extension serde_json trace vtab bundled"
|
2021-06-03 03:07:56 +08:00
|
|
|
printf ' \e[35;1mFinished\e[0m bundled sqlite3 tests\n'
|