2014-04-11 18:50:12 +02:00
|
|
|
#!/bin/sh
|
2017-01-30 10:26:08 +01:00
|
|
|
ROOT=$(git rev-parse --show-toplevel)
|
2014-04-11 18:50:12 +02:00
|
|
|
|
2015-07-11 23:25:09 +02:00
|
|
|
[ -z "$BUILD" ] && BUILD=Debug
|
2016-08-31 09:50:28 +02:00
|
|
|
if [ -z "$JOBS" ] ; then
|
|
|
|
if [ -e /usr/sbin/sysctl ]; then
|
|
|
|
JOBS=`sysctl -n hw.ncpu`
|
|
|
|
else
|
|
|
|
JOBS=`nproc`
|
|
|
|
fi
|
|
|
|
fi
|
2014-04-12 04:40:48 +02:00
|
|
|
DISTCC=`which distcc`
|
|
|
|
if [ ! -z "$DISTCC" ] ; then
|
|
|
|
JOBS=`distcc -j`
|
|
|
|
if [ -z "$JOBS" ] ; then
|
|
|
|
JOBS=1
|
|
|
|
elif [ $JOBS -gt 1 ] ; then
|
2015-10-27 12:32:32 +01:00
|
|
|
[ -z "$CC" ] && [ ! -z `which clang` ] && CC="clang"
|
|
|
|
[ -z "$CC" ] && [ ! -z `which gcc` ] && CC="gcc"
|
|
|
|
[ -z "$CC" ] && [ ! -z `which tcc` ] && CC="tcc"
|
|
|
|
[ -z "$CC" ] && [ ! -z `which cc` ] && CC="cc"
|
2014-04-12 04:40:48 +02:00
|
|
|
CC="$DISTCC $CC"
|
|
|
|
MAKEOPTS=-j$JOBS
|
|
|
|
fi
|
|
|
|
fi
|
2015-10-27 12:32:32 +01:00
|
|
|
echo "Building with $JOBS jobs"
|
2014-04-12 04:40:48 +02:00
|
|
|
|
2015-07-11 23:25:09 +02:00
|
|
|
if [ ! -d $ROOT/$BUILD ]; then
|
|
|
|
echo "cannot find build directory $BUILD in $ROOT. did you run cmake-init?"
|
2014-04-11 18:50:12 +02:00
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
2015-07-11 20:48:54 +02:00
|
|
|
echo "build eressea"
|
2018-02-02 18:25:18 +01:00
|
|
|
CMAKE_ARGS=".."
|
2015-07-11 23:25:09 +02:00
|
|
|
cd $ROOT/$BUILD
|
2017-01-30 10:26:08 +01:00
|
|
|
BRANCH=$(git status -s -b | head -1 | cut -d\ -f 2 | sed 's/\..*//')
|
2017-04-22 19:06:38 +02:00
|
|
|
if [ "$BRANCH" = "master" ] ; then
|
2016-09-10 18:59:24 +02:00
|
|
|
VERSION=$(git describe --match 'v*.*.*' --tags | sed 's/^v//')
|
2017-04-22 18:57:57 +02:00
|
|
|
echo "$BRANCH $VERSION"
|
2018-02-18 10:37:13 +01:00
|
|
|
CMAKE_ARGS="-DERESSEA_VERSION:STRING=$VERSION ${CMAKE_ARGS}"
|
2017-01-30 10:26:08 +01:00
|
|
|
else
|
|
|
|
REV=$(git rev-parse --short HEAD)
|
2018-02-18 10:37:13 +01:00
|
|
|
CMAKE_ARGS="-DERESSEA_BUILDNO:STRING=$REV $CMAKE_ARGS"
|
2017-01-30 10:26:08 +01:00
|
|
|
fi
|
2018-02-02 18:25:18 +01:00
|
|
|
|
|
|
|
cmake ${CMAKE_ARGS}
|
2016-11-25 21:17:10 +01:00
|
|
|
make $MAKEOPTS && make test
|
2014-07-03 06:35:16 +02:00
|
|
|
cd $OLDPWD
|