Skip to content

Commit

Permalink
simplify and check shell scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
ennorehling committed Dec 28, 2023
1 parent 85c83b4 commit 5c1551a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 45 deletions.
31 changes: 9 additions & 22 deletions s/build
Original file line number Diff line number Diff line change
@@ -1,33 +1,19 @@
#!/bin/sh
ROOT=$(git rev-parse --show-toplevel)
BUILD=build
if [ -z "$JOBS" ] ; then
JOBS=`nproc`
fi
DISTCC=`which distcc`
if [ ! -z "$DISTCC" ] ; then
JOBS=`distcc -j`
if [ -z "$JOBS" ] ; then
JOBS=1
elif [ $JOBS -gt 1 ] ; then
[ -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"
CC="$DISTCC $CC"
MAKEOPTS=-j$JOBS
fi
fi
echo "Building with $JOBS jobs"
[ -z "$CC" ] && [ -n "$(which clang)" ] && CC="clang"
[ -z "$CC" ] && [ -n "$(which gcc)" ] && CC="gcc"
[ -z "$CC" ] && [ -n "$(which tcc)" ] && CC="tcc"
[ -z "$CC" ] && [ -n "$(which cc)" ] && CC="cc"

if [ ! -d $ROOT/$BUILD ]; then
if [ ! -d "$ROOT/$BUILD" ]; then
echo "cannot find build directory $BUILD in $ROOT. did you run cmake-init?"
exit
fi

echo "build eressea"
CMAKE_ARGS=".."
cd $ROOT/$BUILD
cd "$ROOT/$BUILD" || exit
BRANCH=$(git status -s -b | head -1 | cut -d\ -f 2 | sed 's/\..*//')
if [ "$BRANCH" = "master" ] ; then
VERSION=$(git describe --match 'v*.*.*' --tags | sed 's/^v//')
Expand All @@ -39,5 +25,6 @@ CMAKE_ARGS="-DERESSEA_BUILDNO:STRING=$REV $CMAKE_ARGS"
fi

cmake ${CMAKE_ARGS}
make $MAKEOPTS && ctest -LE ci-only
cd $OLDPWD
make "$@" && ctest -LE ci-only
cd "$OLDPWD" || exit

23 changes: 0 additions & 23 deletions s/cmake-init
Original file line number Diff line number Diff line change
Expand Up @@ -72,31 +72,8 @@ fi

DEST=$(dirname $ROOT)/server

LUA_INCLUDE=/usr/include
LUA_DIR=/usr
if [ -d /usr/local/include/lua ]; then
LUA_INCLUDE=/usr/local/include/lua
elif [ -d /usr/include/lua5.4 ]; then
LUA_INCLUDE=/usr/include/lua5.4
elif [ -d /usr/include/lua5.3 ]; then
LUA_INCLUDE=/usr/include/lua5.3
elif [ -d /usr/include/lua5.2 ]; then
LUA_INCLUDE=/usr/include/lua5.2
elif [ -d /usr/include/lua5.1 ]; then
LUA_INCLUDE=/usr/include/lua5.1
elif [ -d /usr/local/include/lua5.1 ]; then
LUA_DIR=/usr/local
LUA_INCLUDE=/usr/local/include/lua5.1
fi

if [ ! -e ${LUA_INCLUDE}/lua.h ]; then
echo "no compatible version of lua is installed in $LUA_INCLUDE."
exit 1
fi

cat >| build/config.cmake <<HEREDOC
SET (ERESSEA_DB "$ERESSEA_DB" CACHE STRING "Database driver")
SET (LUA_DIR "$LUA_DIR" CACHE PATH "Lua root path")
SET (CMAKE_BUILD_TYPE "$BUILD" CACHE STRING "")
SET (CMAKE_LIBRARY_PATH "$LIBRARY_PATH" CACHE PATH "")
SET (CMAKE_PREFIX_PATH "$PREFIX_PATH" CACHE PATH "")
Expand Down

0 comments on commit 5c1551a

Please sign in to comment.