- Add SQLite amalgamation fetch script (make build-sqlite) - Embed SQLite in release builds, link system lib in dev - Create sqlite_embedded.zig utility module - Unify experiment/run/log commands with auto mode detection - Add Forgejo CI workflow for building with embedded SQLite - Update READMEs for local mode and build instructions SQLite follows rsync embedding pattern: assets/sqlite_release_<os>_<arch>/ Zero external dependencies for release builds.
50 lines
1.5 KiB
Bash
50 lines
1.5 KiB
Bash
#!/bin/bash
|
|
# Build/fetch SQLite amalgamation for embedding
|
|
# Mirrors the rsync pattern: assets/sqlite_release_<os>_<arch>/
|
|
|
|
set -euo pipefail
|
|
|
|
SQLITE_VERSION="${SQLITE_VERSION:-3450000}" # 3.45.0
|
|
SQLITE_YEAR="${SQLITE_YEAR:-2024}"
|
|
SQLITE_SRC_BASE="${SQLITE_SRC_BASE:-https://www.sqlite.org/${SQLITE_YEAR}}"
|
|
|
|
os="$(uname -s | tr '[:upper:]' '[:lower:]')"
|
|
arch="$(uname -m)"
|
|
if [[ "${arch}" == "aarch64" || "${arch}" == "arm64" ]]; then arch="arm64"; fi
|
|
if [[ "${arch}" == "x86_64" ]]; then arch="x86_64"; fi
|
|
|
|
repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
|
out_dir="${repo_root}/src/assets/sqlite_release_${os}_${arch}"
|
|
|
|
echo "Building SQLite ${SQLITE_VERSION} for ${os}/${arch}..."
|
|
|
|
# Create output directory
|
|
mkdir -p "${out_dir}"
|
|
|
|
# Download if not present
|
|
if [[ ! -f "${out_dir}/sqlite3.c" ]]; then
|
|
echo "Fetching SQLite amalgamation..."
|
|
tmp="$(mktemp -d)"
|
|
cleanup() { rm -rf "${tmp}"; }
|
|
trap cleanup EXIT
|
|
|
|
url="${SQLITE_SRC_BASE}/sqlite-amalgamation-${SQLITE_VERSION}.zip"
|
|
echo "Fetching ${url}"
|
|
curl -fsSL "${url}" -o "${tmp}/sqlite.zip"
|
|
|
|
unzip -q "${tmp}/sqlite.zip" -d "${tmp}"
|
|
mv "${tmp}/sqlite-amalgamation-${SQLITE_VERSION}"/* "${out_dir}/"
|
|
|
|
echo "✓ SQLite fetched to ${out_dir}"
|
|
else
|
|
echo "✓ SQLite already present at ${out_dir}"
|
|
fi
|
|
|
|
# Verify
|
|
if [[ -f "${out_dir}/sqlite3.c" && -f "${out_dir}/sqlite3.h" ]]; then
|
|
echo "✓ SQLite ready:"
|
|
ls -lh "${out_dir}/sqlite3.c" "${out_dir}/sqlite3.h"
|
|
else
|
|
echo "Error: SQLite files not found in ${out_dir}"
|
|
exit 1
|
|
fi
|