Allow for manually overriding the compiler and some flags using make-style environment variables

This adds support for using the CXX and CXXFLAGS environment varibles, they work as you would expect.
BodgeMaster-unfinished
BodgeMaster 2022-06-24 10:23:12 +02:00
parent 9e6f07ec0a
commit 8206a9ba99
1 changed files with 10 additions and 2 deletions

View File

@ -1,10 +1,18 @@
#!/bin/bash
if [ -z "$CXX" ]; then
CXX="c++"
fi
if [ -z "$CXXFLAGS" ]; then
CXXFLAGS="-std=c++20 -Wall"
fi
CXX_WITH_FLAGS="$CXX $CXXFLAGS"
# `.cpp` files in src/lib will be automatically picked up and compiled into dynamic libraries.
echo "Building libs..."
mkdir -pv bin/lib
for lib in $(find ./src/lib -name "*.cpp"); do
COMPILE_COMMAND="c++ -shared -o $(sed -e 's/^.\/src/.\/bin/;s/cpp$/so/' <<< $lib) $lib"
COMPILE_COMMAND="$CXX_WITH_FLAGS -shared -o $(sed -e 's/^.\/src/.\/bin/;s/cpp$/so/' <<< $lib) $lib"
echo $COMPILE_COMMAND
$COMPILE_COMMAND
done
@ -27,6 +35,6 @@ mkdir -pv bin/tools
# add compile commands to this variable
COMPILE_COMMANDS="
set -v
c++ src/tools/dumpnbt.cpp -Lbin/lib -lnbt -o bin/tools/dumpnbt
$CXX_WITH_FLAGS src/tools/dumpnbt.cpp -Lbin/lib -lnbt -o bin/tools/dumpnbt
"
sh <<< $COMPILE_COMMANDS