Files
sqlite3/embed/bcw2/build.sh

73 lines
2.4 KiB
Bash
Raw Normal View History

2024-08-09 00:48:25 +01:00
#!/usr/bin/env bash
set -euo pipefail
cd -P -- "$(dirname -- "$0")"
ROOT=../../
BINARYEN="$ROOT/tools/binaryen/bin"
WASI_SDK="$ROOT/tools/wasi-sdk/bin"
2025-08-16 19:44:46 +01:00
trap 'rm -rf sqlite/ build/ bcw2.tmp' EXIT
2024-08-09 00:48:25 +01:00
2025-08-16 19:44:46 +01:00
mkdir -p sqlite/
2024-08-09 00:48:25 +01:00
mkdir -p build/ext/
cp "$ROOT"/sqlite3/*.[ch] build/
cp "$ROOT"/sqlite3/*.patch build/
2025-08-16 19:44:46 +01:00
cd sqlite/
2024-08-09 00:48:25 +01:00
2025-11-20 11:35:01 +00:00
# https://sqlite.org/src/info/352b363a5d727047
curl -#L https://github.com/sqlite/sqlite/archive/dbd613c.tar.gz | tar xz --strip-components=1
# curl -#L https://sqlite.org/src/tarball/sqlite.tar.gz?r=352b363a5d | tar xz --strip-components=1
2024-08-09 00:48:25 +01:00
2024-08-09 10:19:48 +01:00
if [[ "$OSTYPE" == "msys" || "$OSTYPE" == "cygwin" ]]; then
2025-01-11 19:22:04 +00:00
MSYS_NO_PATHCONV=1 nmake /f makefile.msc sqlite3.c "OPTS=-DSQLITE_ENABLE_UPDATE_DELETE_LIMIT -DSQLITE_ENABLE_ORDERED_SET_AGGREGATES"
2024-08-09 10:19:48 +01:00
else
2025-01-11 19:22:04 +00:00
sh configure --enable-update-limit
OPTS=-DSQLITE_ENABLE_ORDERED_SET_AGGREGATES make sqlite3.c
2024-08-09 10:19:48 +01:00
fi
2024-08-09 00:48:25 +01:00
cd ~-
mv sqlite/sqlite3.c build/
mv sqlite/sqlite3.h build/
mv sqlite/sqlite3ext.h build/
mv sqlite/ext/misc/anycollseq.c build/ext/
mv sqlite/ext/misc/base64.c build/ext/
mv sqlite/ext/misc/decimal.c build/ext/
mv sqlite/ext/misc/ieee754.c build/ext/
mv sqlite/ext/misc/regexp.c build/ext/
mv sqlite/ext/misc/series.c build/ext/
2024-09-27 16:27:54 +01:00
mv sqlite/ext/misc/spellfix.c build/ext/
2024-08-09 00:48:25 +01:00
mv sqlite/ext/misc/uint.c build/ext/
cd build
2025-01-14 17:28:05 +00:00
cat *.patch | patch -p0 --no-backup-if-mismatch
2024-08-09 00:48:25 +01:00
cd ~-
"$WASI_SDK/clang" --target=wasm32-wasi -std=c23 -g0 -O2 \
-Wall -Wextra -Wno-unused-parameter -Wno-unused-function \
2025-05-06 10:22:02 +01:00
-o bcw2.wasm build/main.c \
-I"$ROOT/sqlite3/libc" -I"build" \
2024-08-09 00:48:25 +01:00
-mexec-model=reactor \
2025-05-13 14:27:26 +01:00
-mmutable-globals -mnontrapping-fptoint \
-msimd128 -mbulk-memory -msign-ext \
-mreference-types -mmultivalue \
2025-07-29 16:48:33 +01:00
-mno-extended-const \
-fno-stack-protector \
2024-08-09 00:48:25 +01:00
-Wl,--stack-first \
-Wl,--import-undefined \
-Wl,--initial-memory=327680 \
-D_HAVE_SQLITE_CONFIG_H \
2024-12-17 15:25:25 +00:00
-DSQLITE_ENABLE_UPDATE_DELETE_LIMIT \
2025-11-18 17:58:26 +00:00
-DSQLITE_ENABLE_ORDERED_SET_AGGREGATES \
-DSQLITE_EXPERIMENTAL_PRAGMA_20251114 \
2024-08-09 00:48:25 +01:00
-DSQLITE_CUSTOM_INCLUDE=sqlite_opt.h \
$(awk '{print "-Wl,--export="$0}' ../exports.txt)
"$BINARYEN/wasm-ctor-eval" -g -c _initialize bcw2.wasm -o bcw2.tmp
2025-09-08 12:23:58 +01:00
"$BINARYEN/wasm-opt" -g bcw2.tmp -o bcw2.wasm \
--low-memory-unused --gufa --generate-global-effects --converge -O3 \
2025-05-13 14:27:26 +01:00
--enable-mutable-globals --enable-nontrapping-float-to-int \
--enable-simd --enable-bulk-memory --enable-sign-ext \
2025-09-08 12:23:58 +01:00
--enable-reference-types --enable-multivalue \
2025-10-18 11:06:50 +01:00
--strip --strip-producers