mirror of
https://github.com/wesnoth/wesnoth
synced 2025-05-19 10:25:54 +00:00
120 lines
3.7 KiB
Bash
Executable File
120 lines
3.7 KiB
Bash
Executable File
#!/bin/sh
|
|
die() { echo >&2 "$@"; exit 1; }
|
|
[ $# -gt 0 ] && [ $# -lt 4 ] || die "Syntax: $(basename $0) [-c] <server version> [<revision>]"
|
|
set -o errexit
|
|
|
|
case "$1" in
|
|
-c) shift
|
|
BASE=campaignd
|
|
TYPE=campaignd ;;
|
|
*) BASE=servers # should be moved to wesnothd at some point. (several other scripts depend on the position though!)
|
|
TYPE=wesnothd ;;
|
|
esac
|
|
|
|
VERSION=$(readlink "$HOME/$BASE/$1" || true)
|
|
VERSION="${VERSION:=$1}"
|
|
SERVERBASE="$HOME/$BASE/$VERSION"
|
|
echo "building $TYPE-$VERSION..."
|
|
|
|
SOCKET="$SERVERBASE/build/var/run/socket"
|
|
SOURCE="$HOME/source"
|
|
|
|
[ -d "$SERVERBASE" ] || die "Server base dir '$SERVERBASE' not found!"
|
|
[ -d "$SOURCE" ] || die "Source dir '$SOURCE' not found!"
|
|
|
|
SCONS=yes
|
|
CXXFLAGS="$CXXFLAGS"
|
|
LDFLAGS="$LDFLAGS"
|
|
case "$VERSION" in
|
|
1.2) CXXFLAGS="$CXXFLAGS -ggdb3"
|
|
SCONS=no
|
|
cd "$SOURCE"/1.2 ;;
|
|
1.4) CXXFLAGS="$CXXFLAGS -ggdb3 -DNUM_SHARDS=7 -DBANDWIDTH_MONITOR"
|
|
SCONS=no
|
|
cd "$SOURCE"/1.4 ;;
|
|
1.6|1.8|1.10|1.12)
|
|
CXXFLAGS="$CXXFLAGS -ggdb3 -DNUM_SHARDS=7 -DBANDWIDTH_MONITOR"
|
|
cd "$SOURCE"/$VERSION ;;
|
|
1.9)
|
|
[ "$TYPE" = "campaignd" ] || die "1.9 is currently a special case for the 1.10 campaignd only"
|
|
CXXFLAGS="$CXXFLAGS -ggdb3 -DNUM_SHARDS=7 -DBANDWIDTH_MONITOR"
|
|
cd "$SOURCE"/1.10 ;;
|
|
trunk|master)
|
|
CXXFLAGS="$CXXFLAGS -ggdb3 -DNUM_SHARDS=7 -O0 -DBANDWIDTH_MONITOR"
|
|
cd "$SOURCE"/master ;;
|
|
*) CXXFLAGS="$CXXFLAGS -ggdb3 -DNUM_SHARDS=7 -DBANDWIDTH_MONITOR"
|
|
cd "$SOURCE"/master ;;
|
|
esac
|
|
|
|
if [ $TYPE = campaignd ]; then
|
|
case "$VERSION" in
|
|
1.4)
|
|
SCONS=no ;;
|
|
1.8|trunk)
|
|
CXXFLAGS="$CXXFLAGS -ggdb3 -pg"
|
|
LDFLAGS="$LDFLAGS -pg" ;;
|
|
esac
|
|
fi
|
|
set -o nounset
|
|
|
|
printf 'Updating git working tree... '
|
|
COMMIT="${2:+-r $2}"
|
|
git checkout -f $COMMIT > /dev/null
|
|
COMMIT=$(git describe --long)
|
|
echo "to $COMMIT"
|
|
[ "$COMMIT" != "" ] || die "No revision information found. Odd, exiting..."
|
|
|
|
# reminder for local changes
|
|
#git status
|
|
BUILD="builds/$TYPE-$VERSION-git-${COMMIT}"
|
|
BUILD_DIR="$HOME/$BUILD"
|
|
|
|
set -x
|
|
mkdir -p "$BUILD_DIR"
|
|
|
|
BUILD_FLAGS=
|
|
if [ $SCONS = yes ]; then
|
|
if [ $TYPE = wesnothd ]; then
|
|
BUILD_FLAGS="fifodir=$BUILD_DIR/var/run raw_sockets=1 forum_user_handler=1"
|
|
case $(hostname) in
|
|
gonzo.dicp.de) BUILD_FLAGS="fifodir=$BUILD_DIR/var/run raw_sockets=1 boostdir=$HOME/tools/include boostlibdir=$HOME/tools/lib boost_suffix=-mt" ;;
|
|
basilic) BUILD_FLAGS="fifodir=$BUILD_DIR/var/run raw_sockets=1" ;;
|
|
esac
|
|
fi
|
|
mkdir -p "$BUILD_DIR"/var/run
|
|
# need to remove .scons-option-cache when parameters get removed!
|
|
CXXFLAGS="$CXXFLAGS" LDFLAGS="$LDFLAGS" scons install-$TYPE prefix="$BUILD_DIR" program_suffix=-"$VERSION" $BUILD_FLAGS use_network_ana=false profile=0 fribidi=0 python=0 localedir= prefsdir= > "$BUILD_DIR"/scons.log
|
|
else
|
|
if [ $TYPE = wesnothd ]; then
|
|
BUILD_FLAGS="--enable-server --enable-raw-sockets --with-fifodir=$BUILD_DIR/var/run --with-boost=$HOME/tools"
|
|
else
|
|
BUILD_FLAGS="--enable-campaign-server"
|
|
fi
|
|
#echo 'autogen.sh and configure...'
|
|
./autogen.sh > "$BUILD_DIR"/autogen.log
|
|
CXXFLAGS="$CXXFLAGS" LDFLAGS="$LDFLAGS" ./configure --prefix="$BUILD_DIR" --program-suffix=-"$VERSION" $BUILD_FLAGS --disable-game --disable-nls --enable-lite > "$BUILD_DIR"/configure.log
|
|
make clean > /dev/null
|
|
#echo 'make...'
|
|
make > "$BUILD_DIR"/make.log
|
|
#echo 'make install...'
|
|
make install > "$BUILD_DIR"/install.log
|
|
fi
|
|
|
|
# remove the man pages
|
|
rm -rf "$BUILD_DIR"/share/
|
|
|
|
cd "$SERVERBASE"
|
|
|
|
test -L build &&
|
|
if [ -p "$SOCKET" ] || [ $TYPE = campaignd ]; then
|
|
rm -f oldbuild
|
|
mv build oldbuild
|
|
else #the server under build has never been started, keep the oldbuild link to the (currently) running server
|
|
rm -f build
|
|
fi
|
|
ln -s ../../"$BUILD" build
|
|
|
|
cd "$HOME"/bin || exit 1
|
|
ln -sf "../$BUILD/bin/$TYPE-$VERSION" "$TYPE-$VERSION"
|
|
set +x
|