Debian Codegraph @

third_party/rust/libsqlite3-sys/upgrade.sh

raw
1 #!/bin/sh -e
2
3 SCRIPT_DIR=$(cd "$(dirname "$0")" && pwd)
4 echo "$SCRIPT_DIR"
5 cd "$SCRIPT_DIR" || { echo "fatal error" >&2; exit 1; }
6 cargo clean -p libsqlite3-sys
7 TARGET_DIR="$SCRIPT_DIR/../target"
8 export SQLITE3_LIB_DIR="$SCRIPT_DIR/sqlite3"
9 mkdir -p "$TARGET_DIR" "$SQLITE3_LIB_DIR"
10
11 # Download and extract amalgamation
12 SQLITE=sqlite-amalgamation-3480000
13 curl -O https://sqlite.org/2025/$SQLITE.zip
14 unzip -p "$SQLITE.zip" "$SQLITE/sqlite3.c" > "$SQLITE3_LIB_DIR/sqlite3.c"
15 unzip -p "$SQLITE.zip" "$SQLITE/sqlite3.h" > "$SQLITE3_LIB_DIR/sqlite3.h"
16 unzip -p "$SQLITE.zip" "$SQLITE/sqlite3ext.h" > "$SQLITE3_LIB_DIR/sqlite3ext.h"
17 rm -f "$SQLITE.zip"
18
19 export SQLITE3_INCLUDE_DIR="$SQLITE3_LIB_DIR"
20 # Regenerate bindgen file for sqlite3.h
21 rm -f "$SQLITE3_LIB_DIR/bindgen_bundled_version.rs"
22 cargo update --quiet
23 # Just to make sure there is only one bindgen.rs file in target dir
24 find "$TARGET_DIR" -type f -name bindgen.rs -exec rm {} \;
25 env LIBSQLITE3_SYS_BUNDLING=1 cargo build --features "buildtime_bindgen session" --no-default-features
26 find "$TARGET_DIR" -type f -name bindgen.rs -exec mv {} "$SQLITE3_LIB_DIR/bindgen_bundled_version.rs" \;
27
28 # Regenerate bindgen file for sqlite3ext.h
29 # some sqlite3_api_routines fields are function pointers with va_list arg but currently stable Rust doesn't support this type.
30 # FIXME how to generate portable bindings without :
31 sed -i.bk -e 's/va_list/void*/' "$SQLITE3_LIB_DIR/sqlite3ext.h"
32 rm -f "$SQLITE3_LIB_DIR/bindgen_bundled_version_ext.rs"
33 find "$TARGET_DIR" -type f -name bindgen.rs -exec rm {} \;
34 env LIBSQLITE3_SYS_BUNDLING=1 cargo build --features "buildtime_bindgen loadable_extension" --no-default-features
35 find "$TARGET_DIR" -type f -name bindgen.rs -exec mv {} "$SQLITE3_LIB_DIR/bindgen_bundled_version_ext.rs" \;
36 git checkout "$SQLITE3_LIB_DIR/sqlite3ext.h"
37 rm -f "$SQLITE3_LIB_DIR/sqlite3ext.h.bk"
38
39 # Sanity checks
40 cd "$SCRIPT_DIR/.." || { echo "fatal error" >&2; exit 1; }
41 cargo update --quiet
42 cargo test --features "backup blob chrono functions limits load_extension serde_json trace vtab bundled"
43 printf ' \e[35;1mFinished\e[0m bundled sqlite3 tests\n'