Created
June 5, 2015 04:34
-
-
Save pcolby/36dafd8119bc36c128ee to your computer and use it in GitHub Desktop.
Bootstrapping out-of-source builds
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
declare -A CC CXX SPEC | |
CC=( [clang]=clang [gcc]=gcc ) | |
CXX=( [clang]=clang++ [gcc]=g++ ) | |
SPEC=( [clang]=clang [gcc]=g++ ) | |
SOURCE_DIR=`pwd` | |
TOPDIR=~/tmp/build | |
function detect-generator { | |
if [ -e "$1/CMakeLists.txt" ]; then | |
GENERATOR=cmake | |
elif [ -n "`find \"$1\" -maxdepth 1 -name '*.pro' -print -quit`" ]; then | |
GENERATOR=qmake | |
else | |
echo "Failed to detect generator for $1" >&2 | |
fi | |
[ -n "$GENERATOR" ] | |
} | |
function run-cmake { | |
CC="${CC[$2]}" CXX="${CXX[$2]}" cmake "$1" | |
} | |
function run-qmake { | |
qmake -Wall -Wlogic -Wparser -spec "linux-${SPEC[$2]}" \ | |
CONFIG+=debug_and_release "$1" | |
} | |
function boot { | |
local BUILD_DIR="$TOPDIR/"`basename "$SOURCE_DIR"`"-$2" | |
mkdir "$BUILD_DIR" || exit | |
pushd "$BUILD_DIR" || exit | |
"run-$GENERATOR" "$@" ; RC=$? | |
popd | |
return $RC | |
} | |
detect-generator "$SOURCE_DIR" || exit | |
for TOOLSET in clang gcc; do | |
which "$TOOLSET" > /dev/null 2>&1 && \ | |
boot "$SOURCE_DIR" "$TOOLSET" || exit | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment