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.
This commit is contained in:
8 files changed
+46
-126
No files matched your search
@@ -1,10 +1,12 @@
|
||||
#!/usr/bin/env bash
|
||||
# Builds the luacpp compiler, compiles the Lua modules of the Demo project with
|
||||
# it, then builds and runs the resulting C++ program (plus the test suite).
|
||||
# Builds the luacpp compiler (the C++ program), nothing else.
|
||||
# Then use the compiler from anywhere, for example:
|
||||
#
|
||||
# Usage:
|
||||
# ./build.sh # full build + demo + tests
|
||||
# ./build.sh path/to/x.lua # just compile one module and show the C++ output
|
||||
# ./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)
|
||||
@@ -14,43 +16,33 @@ cd "$(dirname "$0")"
|
||||
|
||||
BUILD_DIR="${BUILD_DIR:-build}"
|
||||
JOBS="${JOBS:-$(nproc 2>/dev/null || echo 2)}"
|
||||
LUACPP="$BUILD_DIR/luacpp"
|
||||
|
||||
echo "==> configuring"
|
||||
cmake -S . -B "$BUILD_DIR" -DCMAKE_BUILD_TYPE=Release
|
||||
|
||||
echo "==> building the compiler"
|
||||
cmake --build "$BUILD_DIR" -j "$JOBS" --target luacpp
|
||||
"$LUACPP" --version
|
||||
|
||||
# Compile a single module on demand.
|
||||
if [[ $# -gt 0 ]]; then
|
||||
out_dir="$BUILD_DIR/single"
|
||||
rm -rf "$out_dir"
|
||||
"$LUACPP" "$1" --root "$(dirname "$1")" --output "$out_dir"
|
||||
echo
|
||||
echo "==> generated header ($out_dir)"
|
||||
find "$out_dir" -name '*.hpp' -exec sh -c 'echo "--- $1"; cat "$1"' _ {} \;
|
||||
echo
|
||||
echo "==> generated source ($out_dir)"
|
||||
find "$out_dir" -name '*.cpp' -exec sh -c 'echo "--- $1"; cat "$1"' _ {} \;
|
||||
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 "==> compiling Demo/lua/*.lua into C++ packages"
|
||||
rm -rf "$BUILD_DIR/demo-generated"
|
||||
"$LUACPP" Demo/lua/todo.lua Demo/lua/report.lua \
|
||||
--root Demo/lua --namespace demo --output "$BUILD_DIR/demo-generated"
|
||||
|
||||
echo "==> building the rest of the repository (example + tests)"
|
||||
echo "==> building the Demo and the tests"
|
||||
cmake --build "$BUILD_DIR" -j "$JOBS"
|
||||
|
||||
echo
|
||||
echo "==> running the example"
|
||||
"$BUILD_DIR/examples/luacpp_example"
|
||||
|
||||
echo
|
||||
echo "==> building and running the Demo project"
|
||||
echo "==> Demo project"
|
||||
cmake -S Demo -B "$BUILD_DIR/demo" -DCMAKE_BUILD_TYPE=Release
|
||||
cmake --build "$BUILD_DIR/demo" -j "$JOBS"
|
||||
echo
|
||||
|
||||
Reference in new issue
Block a user