Stage ABI-scoped unit generations

This commit is contained in:
udo
2026-07-18 14:09:38 +00:00
parent 810c19b042
commit 1952c7d762
27 changed files with 302 additions and 53 deletions
+28 -17
View File
@@ -1,4 +1,5 @@
#!/bin/bash
set -euo pipefail
cd "$(dirname "$0")"
cd ..
@@ -6,11 +7,14 @@ BUILDMODE=${2:-"debug"}
OPT_FLAG="O0"
GF="uce_fastcgi"
mkdir bin > /dev/null 2>&1
mkdir bin/tmp > /dev/null 2>&1
mkdir bin/assets > /dev/null 2>&1
mkdir bin/wasm > /dev/null 2>&1
mkdir work > /dev/null 2>&1
mkdir -p bin/tmp bin/assets bin/wasm work
exec 9>bin/.build.lock
flock 9
build_tmp_files=()
cleanup_build_tmp() {
((${#build_tmp_files[@]} == 0)) || rm -f "${build_tmp_files[@]}"
}
trap cleanup_build_tmp EXIT
COMPILER="clang++"
# -rdynamic is a link-time flag; the -c compiles below do not need it.
@@ -52,13 +56,16 @@ fi
# SQLite: vendored C, depends only on its own source (not our headers).
if needs_rebuild bin/sqlite3.o src/3rdparty/sqlite/sqlite3.c src/3rdparty/sqlite/sqlite3.h; then
echo "Compiling SQLite..."
tmp="bin/sqlite3.o.tmp.$$"
build_tmp_files+=("$tmp")
clang -g -O2 -fPIC \
-DSQLITE_THREADSAFE=1 \
-DSQLITE_OMIT_LOAD_EXTENSION=1 \
-DSQLITE_DQS=0 \
-DSQLITE_DEFAULT_FOREIGN_KEYS=1 \
-DSQLITE_DEFAULT_WAL_SYNCHRONOUS=1 \
-c src/3rdparty/sqlite/sqlite3.c -o bin/sqlite3.o 2>&1 || exit 1
-c src/3rdparty/sqlite/sqlite3.c -o "$tmp" 2>&1
mv "$tmp" bin/sqlite3.o
else
echo "Reusing bin/sqlite3.o"
fi
@@ -67,7 +74,10 @@ fi
# declarations (not the lib .cpp — those are compiled into main.o).
if needs_rebuild bin/wasm.o src/wasm src/lib/*.h; then
echo "Compiling wasm backend..."
time -p $COMPILER -c src/wasm/wasm_module.cpp $SRCFLAGS $FLAGS $WASM_FLAGS -o bin/wasm.o 2>&1 || exit 1
tmp="bin/wasm.o.tmp.$$"
build_tmp_files+=("$tmp")
time -p $COMPILER -c src/wasm/wasm_module.cpp $SRCFLAGS $FLAGS $WASM_FLAGS -o "$tmp" 2>&1
mv "$tmp" bin/wasm.o
else
echo "Reusing bin/wasm.o"
fi
@@ -77,18 +87,19 @@ fi
# (its only view of the wasm object) — but not the wasm .cpp sources.
if needs_rebuild bin/main.o src/linux_fastcgi.cpp src/lib src/fastcgi src/wasm/backend.h; then
echo "Compiling main..."
time -p $COMPILER -c src/linux_fastcgi.cpp $SRCFLAGS $FLAGS -o bin/main.o 2>&1 || exit 1
tmp="bin/main.o.tmp.$$"
build_tmp_files+=("$tmp")
time -p $COMPILER -c src/linux_fastcgi.cpp $SRCFLAGS $FLAGS -o "$tmp" 2>&1
mv "$tmp" bin/main.o
else
echo "Reusing bin/main.o"
fi
echo "Linking..."
$COMPILER -rdynamic bin/main.o bin/wasm.o bin/sqlite3.o $FLAGS $LIBS -o bin/$GF.linux.bin 2>&1
if [ $? -eq 0 ]
then
ls -lh bin/ | grep $GF
exit 0
else
exit 1
fi
binary_tmp="bin/$GF.linux.bin.tmp.$$"
build_tmp_files+=("$binary_tmp")
$COMPILER -rdynamic bin/main.o bin/wasm.o bin/sqlite3.o $FLAGS $LIBS -o "$binary_tmp" 2>&1
test -s "$binary_tmp"
chmod 0755 "$binary_tmp"
mv "$binary_tmp" "bin/$GF.linux.bin"
ls -lh "bin/$GF.linux.bin"