blob: 890859d6e158fcaad74cec66ebfbdf5a9a409278 [file] [log] [blame]
Joel Galenson610a7512020-07-28 13:41:38 -07001#!/bin/bash
2
3SCRIPT_DIR=$(cd "$(dirname "$_")" && pwd)
4echo "$SCRIPT_DIR"
5cd "$SCRIPT_DIR" || { echo "fatal error"; exit 1; }
6export SQLITE3_LIB_DIR=$SCRIPT_DIR/sqlite3
7
8# Download and extract amalgamation
Joel Galenson7837fda2021-05-19 15:53:50 -07009SQLITE=sqlite-amalgamation-3350400
10curl -O https://sqlite.org/2021/$SQLITE.zip
Joel Galenson610a7512020-07-28 13:41:38 -070011unzip -p "$SQLITE.zip" "$SQLITE/sqlite3.c" > "$SQLITE3_LIB_DIR/sqlite3.c"
12unzip -p "$SQLITE.zip" "$SQLITE/sqlite3.h" > "$SQLITE3_LIB_DIR/sqlite3.h"
13unzip -p "$SQLITE.zip" "$SQLITE/sqlite3ext.h" > "$SQLITE3_LIB_DIR/sqlite3ext.h"
14rm -f "$SQLITE.zip"
15
16# Regenerate bindgen file
17rm -f "$SQLITE3_LIB_DIR/bindgen_bundled_version.rs"
18export SQLITE3_INCLUDE_DIR=$SQLITE3_LIB_DIR
19cargo update
20# Just to make sure there is only one bindgen.rs file in target dir
21find "$SCRIPT_DIR/../target" -type f -name bindgen.rs -exec rm {} \;
22env LIBSQLITE3_SYS_BUNDLING=1 cargo build --features "buildtime_bindgen" --no-default-features
23find "$SCRIPT_DIR/../target" -type f -name bindgen.rs -exec cp {} "$SQLITE3_LIB_DIR/bindgen_bundled_version.rs" \;
24# Sanity check
25cd "$SCRIPT_DIR/.." || { echo "fatal error"; exit 1; }
26cargo update
27cargo test --features "backup blob chrono functions limits load_extension serde_json trace vtab bundled"
28echo 'You should increment the version in libsqlite3-sys/Cargo.toml'