From af553a2ca3c85816318ab6c9acd02a4f36766c42 Mon Sep 17 00:00:00 2001 From: Gary Talent Date: Fri, 5 Jul 2019 15:56:54 -0500 Subject: [PATCH] Add missing setup-build script --- scripts/setup-build | 54 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100755 scripts/setup-build diff --git a/scripts/setup-build b/scripts/setup-build new file mode 100755 index 0000000..531dfe9 --- /dev/null +++ b/scripts/setup-build @@ -0,0 +1,54 @@ +#! /usr/bin/env bash + +TARGET=$1 +BUILD_TYPE=$2 + +project=$(pwd)/ +buildTool="-GNinja" + +if [[ $TARGET == windows ]]; then + toolchain="-DCMAKE_TOOLCHAIN_FILE=cmake/Modules/Mingw.cmake" + buildTool="-GNinja" +elif [[ $TARGET == gba ]]; then + toolchain="-DCMAKE_TOOLCHAIN_FILE=cmake/Modules/GBA.cmake" + oxUseStdLib="-DOX_USE_STDLIB=OFF" +fi + +if [[ $BUILD_TYPE == asan ]]; then + BUILD_TYPEArgs="-DCMAKE_BUILD_TYPE=Debug" + sanitizerArgs="-DUSE_ASAN=ON" +elif [[ $BUILD_TYPE == debug ]]; then + BUILD_TYPEArgs="-DCMAKE_BUILD_TYPE=Debug" + sanitizerArgs="" +elif [[ $BUILD_TYPE == release ]]; then + BUILD_TYPEArgs="-DCMAKE_BUILD_TYPE=Release" + sanitizerArgs="" +fi + +if [[ $QTDIR != "" ]]; then + qtPath="-DQTDIR=${QTDIR}" +fi + +buildDir="${project}/build/${TARGET}-${BUILD_TYPE}" +distDir="${project}/dist/${TARGET}-${BUILD_TYPE}" + +mkdir -p $buildDir +pushd $buildDir +cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON \ + -DCMAKE_INSTALL_PREFIX="$distDir" \ + $buildTool \ + $nostalgiaBuildType \ + $oxUseStdLib \ + $BUILD_TYPEArgs \ + $sanitizerArgs \ + $qtPath \ + $toolchain \ + $project +popd + +rm -f build/current dist/current +mkdir -p dist +ln -s ${TARGET}-${BUILD_TYPE} build/current +rm -f compile_commands.json +ln -s build/current/compile_commands.json +ln -s ${TARGET}-${BUILD_TYPE} dist/current