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
parent
9e6f07ec0a
commit
8206a9ba99
12
build.sh
12
build.sh
|
@ -1,10 +1,18 @@
|
||||||
#!/bin/bash
|
#!/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.
|
# `.cpp` files in src/lib will be automatically picked up and compiled into dynamic libraries.
|
||||||
echo "Building libs..."
|
echo "Building libs..."
|
||||||
mkdir -pv bin/lib
|
mkdir -pv bin/lib
|
||||||
for lib in $(find ./src/lib -name "*.cpp"); do
|
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
|
echo $COMPILE_COMMAND
|
||||||
$COMPILE_COMMAND
|
$COMPILE_COMMAND
|
||||||
done
|
done
|
||||||
|
@ -27,6 +35,6 @@ mkdir -pv bin/tools
|
||||||
# add compile commands to this variable
|
# add compile commands to this variable
|
||||||
COMPILE_COMMANDS="
|
COMPILE_COMMANDS="
|
||||||
set -v
|
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
|
sh <<< $COMPILE_COMMANDS
|
||||||
|
|
Loading…
Reference in New Issue