Files
Lua-compilateur/build.sh
T
BlackAngelTV d32f73006e build: build only the compiler and drop the example project
The example duplicated what Demo already covers, and the run mode needs the
runtime include path and Lua link flags at execution time, so they are baked in
at configure time.
2026-11-18 08:48:05 +01:00

54 lines
1.5 KiB
Bash
Executable File

#!/usr/bin/env bash
# Builds the luacpp compiler (the C++ program), nothing else.
# Then use the compiler from anywhere, for example:
#
# ./build/luacpp run mon_script.lua # compile le Lua en C++ puis l'exécute
# cd build && ./luacpp run ../script.lua # même chose depuis le dossier build
#
# Options:
# ./build.sh --full # + Demo et tests
#
# Environment:
# BUILD_DIR build directory (default: build)
# JOBS parallel jobs (default: nproc)
set -euo pipefail
cd "$(dirname "$0")"
BUILD_DIR="${BUILD_DIR:-build}"
JOBS="${JOBS:-$(nproc 2>/dev/null || echo 2)}"
echo "==> configuring"
cmake -S . -B "$BUILD_DIR" -DCMAKE_BUILD_TYPE=Release
echo "==> building the compiler"
cmake --build "$BUILD_DIR" -j "$JOBS" --target luacpp
LUACPP="$BUILD_DIR/luacpp"
"$LUACPP" --version
echo
echo "compilateur prêt : $LUACPP"
echo
echo "Utilisation :"
echo " $LUACPP run <script.lua> [args...] # compile le Lua en C++ puis l'exécute"
echo " cd $BUILD_DIR && ./luacpp run ../Demo/hello.lua"
echo " $LUACPP <module.lua> -n demo -o gen # génère seulement .hpp/.cpp"
echo
if [[ "${1:-}" != "--full" ]]; then
exit 0
fi
echo "==> building the Demo and the tests"
cmake --build "$BUILD_DIR" -j "$JOBS"
echo
echo "==> Demo project"
cmake -S Demo -B "$BUILD_DIR/demo" -DCMAKE_BUILD_TYPE=Release
cmake --build "$BUILD_DIR/demo" -j "$JOBS"
echo
"$BUILD_DIR/demo/luacpp_demo"
echo
echo "==> conformance test (compiled modules vs. plain Lua 5.4)"
( cd "$BUILD_DIR" && ctest --output-on-failure )