From 880c697a392d1056ba0b19f752968b08cbdd1136 Mon Sep 17 00:00:00 2001 From: Gary Talent Date: Fri, 23 Dec 2016 14:40:01 -0600 Subject: [PATCH] Cleanup build setup --- .gitignore | 5 ++--- Makefile | 38 +++++++++++++++++++++++--------------- build/Makefile | 21 +++++++++++++-------- scripts/setup_build | 18 +++++++++++++++--- scripts/setup_build_debug | 8 -------- scripts/setup_build_gba | 10 ---------- 6 files changed, 53 insertions(+), 47 deletions(-) delete mode 100755 scripts/setup_build_debug delete mode 100755 scripts/setup_build_gba diff --git a/.gitignore b/.gitignore index afd55d07e..41c3c78f1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,5 @@ build/current build/gba -build/debug -build/release -build/windows +build/*-debug +build/*-release tags diff --git a/Makefile b/Makefile index bbbcc17f8..8aaa0bede 100644 --- a/Makefile +++ b/Makefile @@ -1,23 +1,25 @@ +OS=$(shell uname | tr [:upper:] [:lower:]) +TARGET=${OS}-$(shell uname -m) DEVENV=devenv$(shell pwd | sed 's/\//-/g') ifeq ($(shell docker inspect --format="{{.State.Status}}" ${DEVENV} 2>&1),running) ENV_RUN=docker exec --user $(shell id -u ${USER}) ${DEVENV} endif make: - ${ENV_RUN} make -j -C build + ${ENV_RUN} make -j -C build TARGET=${TARGET} preinstall: - ${ENV_RUN} make -j -C build ARGS="preinstall" + ${ENV_RUN} make -j -C build ARGS="preinstall" TARGET=${TARGET} install: - ${ENV_RUN} make -j -C build ARGS="install" + ${ENV_RUN} make -j -C build ARGS="install" TARGET=${TARGET} clean: - ${ENV_RUN} make -j -C build ARGS="clean" + ${ENV_RUN} make -j -C build ARGS="clean" TARGET=${TARGET} purge: ${ENV_RUN} rm -rf $(shell find build -mindepth 1 -maxdepth 1 -type d) test: - ${ENV_RUN} make -j -C build ARGS="test" + ${ENV_RUN} make -j -C build ARGS="test" TARGET=${TARGET} run: make ./build/current/src/wombat/wombat -debug -debug: make +gdb: make gdb ./build/current/src/wombat/wombat devenv: docker pull wombatant/devenv @@ -29,17 +31,17 @@ devenv-destroy: devenv-shell: docker exec -i --user $(shell id -u ${USER}) ${DEVENV} ls /usr/bin/x86_64-w64-mingw32-g++ -native: - ${ENV_RUN} rm -rf build/release - ${ENV_RUN} ./scripts/setup_build +release: + ${ENV_RUN} rm -rf build/${TARGET}-release + ${ENV_RUN} ./scripts/setup_build ${TARGET} ${ENV_RUN} rm -f build/current - ${ENV_RUN} ln -s release build/current + ${ENV_RUN} ln -s ${TARGET}-release build/current -native_debug: - ${ENV_RUN} rm -rf build/debug - ${ENV_RUN} ./scripts/setup_build_debug +debug: + ${ENV_RUN} rm -rf build/${TARGET}-debug + ${ENV_RUN} ./scripts/setup_build ${TARGET} debug ${ENV_RUN} rm -f build/current - ${ENV_RUN} ln -s debug build/current + ${ENV_RUN} ln -s ${TARGET}-debug build/current windows: ${ENV_RUN} rm -rf build/windows @@ -47,8 +49,14 @@ windows: ${ENV_RUN} rm -f build/current ${ENV_RUN} ln -s windows build/current +windows-debug: + ${ENV_RUN} rm -rf build/windows + ${ENV_RUN} ./scripts/setup_build windows debug + ${ENV_RUN} rm -f build/current + ${ENV_RUN} ln -s windows build/current + gba: ${ENV_RUN} rm -rf build/gba - ${ENV_RUN} ./scripts/setup_build_gba + ${ENV_RUN} ./scripts/setup_build gba ${ENV_RUN} rm -f build/current ${ENV_RUN} ln -s gba build/current diff --git a/build/Makefile b/build/Makefile index 1298dd119..b94c7d9be 100644 --- a/build/Makefile +++ b/build/Makefile @@ -1,4 +1,4 @@ -all: gba_build native_build native_debug_build windows_build +all: gba_build native_build native_debug_build windows_release windows_debug gba_build: @if [ -d gba ]; then \ @@ -6,16 +6,21 @@ gba_build: fi native_build: - @if [ -d release ]; then \ - make -C release ${ARGS}; \ + @if [ -d ${TARGET}-release ]; then \ + make -C ${TARGET}-release ${ARGS}; \ fi native_debug_build: - @if [ -d debug ]; then \ - make -C debug ${ARGS}; \ + @if [ -d ${TARGET}-debug ]; then \ + make -C ${TARGET}-debug ${ARGS}; \ fi -windows_build: - @if [ -d windows ]; then \ - make -C windows ${ARGS}; \ +windows_release: + @if [ -d windows-release ]; then \ + make -C windows-release ${ARGS}; \ + fi + +windows_debug: + @if [ -d windows-debug ]; then \ + make -C windows-debug ${ARGS}; \ fi diff --git a/scripts/setup_build b/scripts/setup_build index ed586683e..7826a3754 100755 --- a/scripts/setup_build +++ b/scripts/setup_build @@ -1,18 +1,30 @@ #! /usr/bin/env bash + +set -e + project=$(pwd)/ TARGET=$1 +BUILD_TYPE=$2 if [[ $TARGET == windows ]]; then toolchain="-DCMAKE_TOOLCHAIN_FILE=cmake/Modules/Mingw.cmake" - buildDir="build/windows" +elif [[ $TARGET == gba ]]; then + toolchain="-DCMAKE_TOOLCHAIN_FILE=cmake/Modules/GBA.cmake -DOX_BUILD_EXEC=OFF" +fi + +if [[ $BUILD_TYPE == debug ]]; then + buildTypeArgs="-DUSE_ASAN=ON -DCMAKE_BUILD_TYPE=Debug" + buildDir="build/${TARGET}-debug" else - buildDir="build/release" + buildTypeArgs="-DCMAKE_BUILD_TYPE=Release" + buildDir="build/${TARGET}-release" fi mkdir -p $buildDir pushd $buildDir -cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_BUILD_TYPE=Release \ +cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON \ + $buildTypeArgs \ $toolchain \ $project popd diff --git a/scripts/setup_build_debug b/scripts/setup_build_debug deleted file mode 100755 index 5649e1b43..000000000 --- a/scripts/setup_build_debug +++ /dev/null @@ -1,8 +0,0 @@ -#! /usr/bin/env bash -project=$(pwd) -buildDir="build/debug" - -mkdir -p $buildDir -pushd $buildDir -cmake -DUSE_ASAN=ON -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_BUILD_TYPE=Debug $project -popd diff --git a/scripts/setup_build_gba b/scripts/setup_build_gba deleted file mode 100755 index 3a227c609..000000000 --- a/scripts/setup_build_gba +++ /dev/null @@ -1,10 +0,0 @@ -#! /usr/bin/env bash -project=$(pwd) -buildDir="build/gba" - -mkdir -p $buildDir -pushd $buildDir -cmake -DCMAKE_BUILD_TYPE=Release -DOX_BUILD_EXEC=OFF \ - -DCMAKE_EXPORT_COMPILE_COMMANDS=ON \ - -DCMAKE_TOOLCHAIN_FILE=cmake/Modules/GBA.cmake $project -popd