#!/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 # + tests de conformité et démo Lua # # 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 [args...] # compile le Lua en C++ puis l'exécute" echo " cd $BUILD_DIR && ./luacpp run ../Demo/hello.lua" echo " $LUACPP -n demo -o gen # génère seulement .hpp/.cpp" echo if [[ "${1:-}" != "--full" ]]; then exit 0 fi echo "==> building the tests" cmake --build "$BUILD_DIR" -j "$JOBS" echo echo "==> Demo (Lua only, compiled and run by luacpp)" ( cd "$BUILD_DIR" && ./luacpp run ../Demo/main.lua ) echo echo "==> conformance test (compiled modules vs. plain Lua 5.4)" ( cd "$BUILD_DIR" && ctest --output-on-failure )