From 8da1b77aa54eb75782d3b2dcddc59cc01e14cd1b Mon Sep 17 00:00:00 2001 From: Gary Talent Date: Sat, 2 Feb 2019 13:08:22 -0600 Subject: [PATCH] [nostalgia] Port setup-build back to Bash --- Makefile | 14 +++++----- scripts/setup-build | 57 ++++++++++++++++++++++++++++++++++++++ scripts/setup-build.ps1 | 61 ----------------------------------------- 3 files changed, 64 insertions(+), 68 deletions(-) create mode 100755 scripts/setup-build delete mode 100755 scripts/setup-build.ps1 diff --git a/Makefile b/Makefile index 1da5c550..f2dbffbd 100644 --- a/Makefile +++ b/Makefile @@ -63,28 +63,28 @@ shell: release: ${ENV_RUN} rm -rf build/${HOST_ENV}-release - ${ENV_RUN} ./scripts/setup-build.ps1 ${HOST_ENV} release + ${ENV_RUN} ./scripts/setup-build ${HOST_ENV} release debug: ${ENV_RUN} rm -rf build/${HOST_ENV}-debug - ${ENV_RUN} ./scripts/setup-build.ps1 ${HOST_ENV} debug + ${ENV_RUN} ./scripts/setup-build ${HOST_ENV} debug asan: ${ENV_RUN} rm -rf build/${HOST_ENV}-asan - ${ENV_RUN} ./scripts/setup-build.ps1 ${HOST_ENV} asan + ${ENV_RUN} ./scripts/setup-build ${HOST_ENV} asan windows: ${ENV_RUN} rm -rf build/windows - ${ENV_RUN} ./scripts/setup-build.ps1 windows + ${ENV_RUN} ./scripts/setup-build windows windows-debug: ${ENV_RUN} rm -rf build/windows - ${ENV_RUN} ./scripts/setup-build.ps1 windows debug + ${ENV_RUN} ./scripts/setup-build windows debug gba: ${ENV_RUN} rm -rf build/gba-release - ${ENV_RUN} ./scripts/setup-build.ps1 gba release + ${ENV_RUN} ./scripts/setup-build gba release gba-debug: ${ENV_RUN} rm -rf build/gba-debug - ${ENV_RUN} ./scripts/setup-build.ps1 gba debug + ${ENV_RUN} ./scripts/setup-build gba debug diff --git a/scripts/setup-build b/scripts/setup-build new file mode 100755 index 00000000..292501d5 --- /dev/null +++ b/scripts/setup-build @@ -0,0 +1,57 @@ +#! /usr/bin/env bash + +TARGET=$1 +BUILD_TYPE=$2 + +project=$(pwd)/ +buildTool="" + +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" + 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 +ln -s ${TARGET}-${BUILD_TYPE} build/current +ln -s ${TARGET}-${BUILD_TYPE} dist/current diff --git a/scripts/setup-build.ps1 b/scripts/setup-build.ps1 deleted file mode 100755 index 8978414a..00000000 --- a/scripts/setup-build.ps1 +++ /dev/null @@ -1,61 +0,0 @@ -#! /usr/bin/env pwsh - -Param( - [parameter(Mandatory=$true,Position=0)][String] ${target}, - [parameter(Mandatory=$true,Position=1)][String] ${buildType} -) - -$project=(Get-Location).Path -$buildTool="" - -if (${target} -eq "windows") { - $toolchain="-DCMAKE_TOOLCHAIN_FILE=cmake/Modules/Mingw.cmake" - $buildTool="-GNinja" -} elseif (${target} -eq "gba") { - $toolchain="-DCMAKE_TOOLCHAIN_FILE=cmake/Modules/GBA.cmake" - $nostalgiaBuildType="-DNOSTALGIA_BUILD_TYPE=GBA" - $oxUseStdLib="-DOX_USE_STDLIB=OFF" -} else { - $buildTool="-GNinja" -} - -if (${buildType} -eq "asan") { - $buildTypeArgs="-DCMAKE_BUILD_TYPE=Debug" - $sanitizerArgs="-DUSE_ASAN=ON" -} elseif (${buildType} -eq "debug") { - $buildTypeArgs="-DCMAKE_BUILD_TYPE=Debug" - $sanitizerArgs="" -} elseif (${buildType} -eq "release") { - $buildTypeArgs="-DCMAKE_BUILD_TYPE=Release" - $sanitizerArgs="" -} - -if (${env:NOSTALGIA_QT_PATH} -ne "") { - $qtPath="-DNOSTALGIA_QT_PATH=${env:NOSTALGIA_QT_PATH}" -} - -$buildDir="${project}/build/${target}-${buildType}" -$distDir="${project}/dist/${target}-${buildType}" - -New-Item -ItemType Directory -Path $buildDir | Out-Null -Push-Location $buildDir -cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON ` - -DCMAKE_INSTALL_PREFIX="$distDir" ` - -DCMAKE_INSTALL_RPATH="$project/dist/${target}-${buildType}/lib/nostalgia" ` - -DNOSTALGIA_IDE_BUILD=OFF ` - $buildTool ` - $nostalgiaBuildType ` - $oxUseStdLib ` - $buildTypeArgs ` - $sanitizerArgs ` - $qtPath ` - $toolchain ` - $project -Pop-Location - -rm -f build/current dist/current -if (!(Test-Path -Path dist)) { - New-Item -ItemType Directory -Path dist | Out-Null -} -ln -s ${target}-${buildType} build/current -ln -s ${target}-${buildType} dist/current