Files
sqlite3/embed/bcw2/build.sh

65 lines
2.0 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"
2024-08-09 12:45:19 +01:00
trap 'rm -rf build/ sqlite/ bcw2.tmp' EXIT
2024-08-09 00:48:25 +01:00
mkdir -p build/ext/
cp "$ROOT"/sqlite3/*.[ch] build/
cp "$ROOT"/sqlite3/*.patch build/
2024-12-17 15:25:25 +00:00
# https://sqlite.org/src/info/ec5d7025cba9f4ac
curl -# https://sqlite.org/src/tarball/sqlite.tar.gz?r=ec5d7025 | tar xz
2024-08-09 00:48:25 +01:00
cd sqlite
2024-08-09 10:19:48 +01:00
if [[ "$OSTYPE" == "msys" || "$OSTYPE" == "cygwin" ]]; then
2024-12-17 15:25:25 +00:00
MSYS_NO_PATHCONV=1 nmake /f makefile.msc sqlite3.c OPTS=-DSQLITE_ENABLE_UPDATE_DELETE_LIMIT
2024-08-09 10:19:48 +01:00
else
2024-12-17 15:25:25 +00:00
sh configure --enable-update-limit && 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
cat *.patch | patch --no-backup-if-mismatch
cd ~-
"$WASI_SDK/clang" --target=wasm32-wasi -std=c23 -g0 -O2 \
-Wall -Wextra -Wno-unused-parameter -Wno-unused-function \
-o bcw2.wasm "build/main.c" \
-I"build" \
-mexec-model=reactor \
2025-01-06 18:22:36 +00:00
-msimd128 -mmutable-globals -mmultivalue \
2024-08-09 00:48:25 +01:00
-mbulk-memory -mreference-types \
-mnontrapping-fptoint -msign-ext \
-fno-stack-protector -fno-stack-clash-protection \
-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 \
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
"$BINARYEN/wasm-opt" -g --strip --strip-producers -c -O3 \
bcw2.tmp -o bcw2.wasm \
--enable-simd --enable-mutable-globals --enable-multivalue \
--enable-bulk-memory --enable-reference-types \
--enable-nontrapping-float-to-int --enable-sign-ext