nostalgia/scripts/setup_build
2017-12-20 22:53:33 -06:00

47 lines
1.2 KiB
Bash
Executable File

#! /usr/bin/env bash
set -e
project=$(pwd)/
TARGET=$1
BUILD_TYPE=$2
#if [[ $(which ninja) != "ninja not found" ]]; then
# buildTool="-GNinja"
#fi
if [[ $TARGET == windows ]]; then
toolchain="-DCMAKE_TOOLCHAIN_FILE=cmake/Modules/Mingw.cmake"
elif [[ $TARGET == gba ]]; then
toolchain="-DCMAKE_TOOLCHAIN_FILE=cmake/Modules/GBA.cmake -DNOSTALGIA_BUILD_TYPE=GBA -DOX_USE_STDLIB=OFF"
fi
if [[ $BUILD_TYPE == asan ]]; then
buildTypeArgs="-DUSE_ASAN=ON -DCMAKE_BUILD_TYPE=Debug"
elif [[ $BUILD_TYPE == debug ]]; then
buildTypeArgs="-DCMAKE_BUILD_TYPE=Debug"
elif [[ $BUILD_TYPE == release ]]; then
buildTypeArgs="-DCMAKE_BUILD_TYPE=Release"
fi
buildDir="build/${TARGET}-${BUILD_TYPE}"
distDir="../../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 \
$buildTypeArgs \
$toolchain \
$project
popd
rm -f build/current dist/current
mkdir -p dist
ln -s ${TARGET}-${BUILD_TYPE} build/current
ln -s ${TARGET}-${BUILD_TYPE} dist/current