#!/bin/sh # SQLite binding tests and showcase. set -e cd "$(dirname "$0")" ROOT="$(cd ../.. && pwd)" M2MAKE="$ROOT/tools/m2make/b_v3/M2make" if [ ! -x "$M2MAKE" ]; then echo "missing $M2MAKE; run tools/m2make/build_m2.sh" >&2 exit 1 fi SQLITE_LIBS="$(pkg-config --libs sqlite3 2>/dev/null || true)" if [ -z "$SQLITE_LIBS" ]; then # Runtime-only installations often have no .pc/header; use the # versioned shared object directly. SQLITE_LIBS="/usr/lib/x86_64-linux-gnu/libsqlite3.so.0" fi build_and_run() { name="$1" src="${2:-tests/$name.mod}" out="${TMPDIR:-/tmp}/m2-sqlite-$name" "$M2MAKE" -c m2 \ --m2bin "$ROOT/compiler/M2" \ --shim "$ROOT/runtime/syslib/shim.c" \ --lib "$SQLITE_LIBS" \ -I "$ROOT/bindings/sqlite3" \ -I "$ROOT/runtime/syslib" \ -I "$ROOT/lib/common" \ -o "$out" \ "$src" set +e "$out" rc=$? set -e if [ "$rc" = 42 ]; then return 0; fi return 1 } build_and_run SQLiteSmoke build_and_run SQLitePrepared build_and_run SQLiteScalar build_and_run SQLiteErrors build_and_run SQLiteBlob build_and_run SQLiteConnection build_and_run SQLiteCallback build_and_run SQLiteShowcase showcase/SQLiteShowcase.mod