nostalgia/scripts/setup-build

54 lines
1.3 KiB
Plaintext
Raw Normal View History

#! /usr/bin/env bash
set -e
2020-01-24 18:56:13 -06:00
target=$1
buildType=$2
vcpkg_dir=$3
project=$(pwd)/
2020-01-24 18:56:13 -06:00
if [[ $target == gba ]]; then
toolchain="-DCMAKE_TOOLCHAIN_FILE=cmake/modules/GBA.cmake"
2020-01-24 18:56:13 -06:00
nostalgiaBuildType="GBA"
else
toolchain="-DCMAKE_TOOLCHAIN_FILE=$vcpkg_dir/scripts/buildsystems/vcpkg.cmake"
2020-01-24 18:56:13 -06:00
nostalgiaBuildType="Native"
fi
2020-01-24 18:56:13 -06:00
if [[ $buildType == asan ]]; then
buildTypeArg="Debug"
sanitizerStatus="ON"
elif [[ $buildType == debug ]]; then
buildTypeArg="Debug"
sanitizerStatus="OFF"
elif [[ $buildType == release ]]; then
buildTypeArg="Release"
sanitizerStatus="OFF"
fi
2020-01-24 18:56:13 -06:00
buildConfig=${target}-${buildType}
if [[ $NOSTALGIA_QT_PATH != "" ]]; then
qtPath="-DNOSTALGIA_QT_PATH=${NOSTALGIA_QT_PATH}"
fi
2020-01-24 18:56:13 -06:00
buildDir="${project}/build/${buildConfig}"
mkdir -p $buildDir
2020-01-24 18:56:13 -06:00
cmake -S $project -B $buildDir -GNinja \
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
2020-01-24 18:56:13 -06:00
-DCMAKE_BUILD_TYPE=${buildTypeArg} \
-DUSE_ASAN=${sanitizerStatus} \
-DNOSTALGIA_IDE_BUILD=OFF \
2020-01-24 18:56:13 -06:00
-DNOSTALGIA_BUILD_CONFIG=${buildConfig} \
-DNOSTALGIA_BUILD_TYPE=${nostalgiaBuildType} \
$qtPath \
$toolchain
mkdir -p dist
if [[ $target != gba ]] && [[ $target != gba-debug ]]; then
echo ${buildType} > .current_build
fi
rm -f compile_commands.json
2020-01-24 18:56:13 -06:00
ln -s build/${buildConfig}/compile_commands.json