84 lines
2.1 KiB
Bash
Executable file
84 lines
2.1 KiB
Bash
Executable file
#!/bin/bash
|
|
|
|
set -o nounset #Error when unset vars are used
|
|
set -o errexit #Exit on errors
|
|
set -o pipefail #Causes failure when input-pipe-program fails
|
|
set -x
|
|
|
|
#########################################################################
|
|
# #
|
|
# Usage: vanillabuild [CMakeBuildType=Debug] [path_to_toolchain_file] #
|
|
# #
|
|
# path_to_toolchain_file will only be used when "CMakeBuildType=mingw" #
|
|
# #
|
|
# Further the number of cores are detected for certain OSes. #
|
|
# Add your own OS specific detection when needed. #
|
|
# #
|
|
#########################################################################
|
|
|
|
set +x
|
|
|
|
linux_number_of_cores_command="nproc"
|
|
nr_cores=8
|
|
list="None Debug Release RelWithDebInfo MinSizeRel"
|
|
|
|
contains() {
|
|
for word in $1; do
|
|
if [ $word = $2 ]; then
|
|
return 1
|
|
fi
|
|
done
|
|
return 0
|
|
}
|
|
|
|
cmake_command='cmake --warn-uninitialized -Wdev'
|
|
mingw_cmake_command="$cmake_command -DBUILD_ASSIMP_TOOLS=OFF -DBUILD_DEMOS=OFF -DBUILD_EXTRAS=OFF -DBUILD_STATIC_LIB=ON -Dfreetype-gl_BUILD_DEMOS=OFF"
|
|
|
|
if [ $# -ge 1 ]; then
|
|
if [ $1 = "mingw" ]; then
|
|
if [ -d "build-$1" ]; then
|
|
mkdir -p build-$1
|
|
cd build-$1
|
|
$mingw_cmake_command ..
|
|
else
|
|
if [ ! $# eq 2 ]; then
|
|
set -x
|
|
echo "Missing cross-build toolchain."
|
|
echo "Please give the toolchain file as second argument to this script."
|
|
set +x
|
|
else
|
|
mkdir -p build-$1
|
|
cd build-$1
|
|
$mingw_cmake_command -DCMAKE_TOOLCHAIN_FILE=$2 ..
|
|
fi
|
|
fi
|
|
elif contains "$list" $1 ; then
|
|
set -x
|
|
echo "No CMake build type detected exiting"
|
|
set +x
|
|
exit
|
|
else
|
|
mkdir -p build-$1
|
|
cd build-$1
|
|
$cmake_command -DCMAKE_BUILD_TYPE=$1 ..
|
|
fi
|
|
else
|
|
mkdir -p build-Debug
|
|
cd build-Debug
|
|
$cmake_command -DCMAKE_BUILD_TYPE=Debug ..
|
|
fi
|
|
|
|
if [ "$OSTYPE" = "linux-gnu" ]; then
|
|
nr_cores=$(eval $linux_number_of_cores_command)
|
|
fi
|
|
set +x
|
|
if [ "$OSTYPE" = "linux-gnu" ]; then
|
|
echo "Detected number of cores: $nr_cores"
|
|
else
|
|
echo "OS detection failed, detected OS: $OSTYPE."
|
|
echo "Defaulting number of cores to $nr_cores"
|
|
fi
|
|
set -x
|
|
|
|
make -j$nr_cores
|
|
cd ..
|