#! /usr/bin/env bash TARGET=$1 BUILD_TYPE=$2 project=$(pwd)/ buildTool="" if [[ $TARGET == gba ]]; then toolchain="-DCMAKE_TOOLCHAIN_FILE=cmake/modules/GBA.cmake" nostalgiaBuildType="-DNOSTALGIA_BUILD_TYPE=GBA" oxUseStdLib="-DOX_USE_STDLIB=OFF" else buildTool="-GNinja" 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 [[ $NOSTALGIA_QT_PATH != "" ]]; then qtPath="-DNOSTALGIA_QT_PATH=${NOSTALGIA_QT_PATH}" 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" \ -DCMAKE_INSTALL_RPATH="$project/dist/${TARGET}-${BUILD_TYPE}/lib/nostalgia" \ -DNOSTALGIA_IDE_BUILD=OFF \ $buildTool \ $nostalgiaBuildType \ $oxUseStdLib \ $BUILD_TYPEArgs \ $sanitizerArgs \ $qtPath \ $toolchain \ $project popd rm -f build/current dist/current mkdir -p dist echo ${TARGET}-${BUILD_TYPE} > .current_build rm -f compile_commands.json ln -s build/${TARGET}-${BUILD_TYPE}/compile_commands.json