build.sh: make it easier to build Subsurface-mobile

The script now takes a -mobile argument, or -both and then builds the
mobile version or both versions. To make things more consistent across
different invocations the desktop version is built in the "build"
directory and the mobile version is built in "build-mobile".

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2016-01-17 10:44:00 -08:00
parent 69eeb2bf5b
commit f28f03afe2

View file

@ -23,10 +23,25 @@ exec 1> >(tee build.log) 2>&1
SRC=$(pwd) SRC=$(pwd)
PLATFORM=$(uname) PLATFORM=$(uname)
# to build Subsurface-mobile on the desktop change this to # normally this script builds the desktop version in subsurface/build
# SUBSURFACE_EXECUTABLE=MobileExecutable # if the first argument is "-mobile" then build Subsurface-mobile in subsurface/build-mobile
SUBSURFACE_EXECUTABLE=DesktopExecutable # if the first argument is "-both" then build both in subsurface/build and subsurface/build-mobile
BUILD="Desktop"
if [ "$1" = "-mobile" ] ; then
echo "building Subsurface-mobile in subsurface/build-mobile"
BUILDS=( "MobileExecutable" )
BUILDDIRS=( "build-mobile" )
shift
elif [ "$1" = "-both" ] ; then
echo "building both Subsurface and Subsurface-mobile in subsurface/build and subsurface/build-mobile, respectively"
BUILDS=( "DesktopExecutable" "MobileExecutable" )
BUILDDIRS=( "build" "build-mobile" )
shift
else
echo "building Subsurface in subsurface/build"
BUILDS=( "DesktopExecutable" )
BUILDDIRS=( "build" )
fi
if [[ ! -d "subsurface" ]] ; then if [[ ! -d "subsurface" ]] ; then
echo "please start this script from the directory containing the Subsurface source directory" echo "please start this script from the directory containing the Subsurface source directory"
@ -183,25 +198,32 @@ else
fi fi
cd $SRC/subsurface cd $SRC/subsurface
mkdir -p build for (( i=0 ; i < ${#BUILDS[@]} ; i++ )) ; do
cd build SUBSURFACE_EXECUTABLE=${BUILDS[$i]}
export CMAKE_PREFIX_PATH=$INSTALL_ROOT/lib/cmake BUILDDIR=${BUILDDIRS[$i]}
cmake -DCMAKE_BUILD_TYPE=Debug .. \ echo "build $SUBSURFACE_EXECUTABLE in $BUILDDIR"
-DSUBSURFACE_TARGET_EXECUTABLE=$SUBSURFACE_EXECUTABLE \
-DLIBGIT2_INCLUDE_DIR=$INSTALL_ROOT/include \
-DLIBGIT2_LIBRARIES=$INSTALL_ROOT/lib/libgit2.$SH_LIB_EXT \
-DLIBDIVECOMPUTER_INCLUDE_DIR=$INSTALL_ROOT/include \
-DLIBDIVECOMPUTER_LIBRARIES=$INSTALL_ROOT/lib/libdivecomputer.a \
-DMARBLE_INCLUDE_DIR=$INSTALL_ROOT/include \
-DMARBLE_LIBRARIES=$INSTALL_ROOT/lib/libssrfmarblewidget.$SH_LIB_EXT \
-DNO_PRINTING=OFF
if [ $PLATFORM = Darwin ] ; then mkdir -p $SRC/subsurface/$BUILDDIR
rm -rf Subsurface.app cd $SRC/subsurface/$BUILDDIR
fi export CMAKE_PREFIX_PATH=$INSTALL_ROOT/lib/cmake
cmake -DCMAKE_BUILD_TYPE=Debug .. \
-DSUBSURFACE_TARGET_EXECUTABLE=$SUBSURFACE_EXECUTABLE \
-DLIBGIT2_INCLUDE_DIR=$INSTALL_ROOT/include \
-DLIBGIT2_LIBRARIES=$INSTALL_ROOT/lib/libgit2.$SH_LIB_EXT \
-DLIBDIVECOMPUTER_INCLUDE_DIR=$INSTALL_ROOT/include \
-DLIBDIVECOMPUTER_LIBRARIES=$INSTALL_ROOT/lib/libdivecomputer.a \
-DMARBLE_INCLUDE_DIR=$INSTALL_ROOT/include \
-DMARBLE_LIBRARIES=$INSTALL_ROOT/lib/libssrfmarblewidget.$SH_LIB_EXT \
-DNO_PRINTING=OFF
LIBRARY_PATH=$INSTALL_ROOT/lib make -j4 if [ $PLATFORM = Darwin ] ; then
rm -rf Subsurface.app
rm -rf Subsurface-mobile.app
fi
if [ $PLATFORM = Darwin ] ; then LIBRARY_PATH=$INSTALL_ROOT/lib make -j4
LIBRARY_PATH=$INSTALL_ROOT/lib make install
fi if [ $PLATFORM = Darwin ] ; then
LIBRARY_PATH=$INSTALL_ROOT/lib make install
fi
done