build.sh: add flags to only build / not build dependencies

This is mainly intended for use when creating Coverity builds. This
commit is easier to understand with git show -w as almost all changes
are whitespace.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2017-12-27 08:35:13 -08:00
parent 55a3cd13cd
commit 40c6d9521e

View file

@ -59,6 +59,16 @@ while [[ $# -gt 0 ]] ; do
# hack for Travix Mac build # hack for Travix Mac build
SKIP_GOOGLEMAPS="1" SKIP_GOOGLEMAPS="1"
;; ;;
-only-deps)
# for Coverity build we want a mode to just build Subsurface and libdivecomputer (those will be analyzed),
# and build the rest, first.
ONLY_DEPS="1"
;;
-no-deps)
# for Coverity build we want a mode to just build Subsurface and libdivecomputer (those will be analyzed),
# and build the rest, first.
NO_DEPS="1"
;;
*) *)
echo "Unknown command line argument $arg" echo "Unknown command line argument $arg"
;; ;;
@ -304,25 +314,27 @@ if [[ $PLATFORM = Darwin || "$LIBGIT" < "24" ]] ; then
cd $SRC cd $SRC
if [ ! -d libgit2 ] ; then if [ -z "$NO_DEPS" ] ; then
if [[ $1 = local ]] ; then if [ ! -d libgit2 ] ; then
git clone $SRC/../libgit2 libgit2 if [[ $1 = local ]] ; then
else git clone $SRC/../libgit2 libgit2
git clone https://github.com/libgit2/libgit2.git else
git clone https://github.com/libgit2/libgit2.git
fi
fi fi
cd libgit2
# let's build with a recent enough version of master for the latest features
git fetch origin
if ! git checkout $CURRENT_LIBGIT2 ; then
echo "Can't find the right tag in libgit2 - giving up"
exit 1
fi
mkdir -p build
cd build
cmake $OLDER_MAC_CMAKE -DCMAKE_INSTALL_PREFIX=$INSTALL_ROOT -DCMAKE_BUILD_TYPE=Release -DBUILD_CLAR=OFF ..
make -j4
make install
fi fi
cd libgit2
# let's build with a recent enough version of master for the latest features
git fetch origin
if ! git checkout $CURRENT_LIBGIT2 ; then
echo "Can't find the right tag in libgit2 - giving up"
exit 1
fi
mkdir -p build
cd build
cmake $OLDER_MAC_CMAKE -DCMAKE_INSTALL_PREFIX=$INSTALL_ROOT -DCMAKE_BUILD_TYPE=Release -DBUILD_CLAR=OFF ..
make -j4
make install
if [ $PLATFORM = Darwin ] ; then if [ $PLATFORM = Darwin ] ; then
# in order for macdeployqt to do its job correctly, we need the full path in the dylib ID # in order for macdeployqt to do its job correctly, we need the full path in the dylib ID
@ -339,29 +351,31 @@ cd $SRC
# build libdivecomputer # build libdivecomputer
cd subsurface if [ -z "$ONLY_DEPS" ] ; then
cd subsurface
if [ ! -d libdivecomputer/src ] ; then if [ ! -d libdivecomputer/src ] ; then
git submodule init git submodule init
git submodule update --recursive git submodule update --recursive
fi
cd libdivecomputer
mkdir -p build
cd build
if [ ! -f ../configure ] ; then
# this is not a typo
# in some scenarios it appears that autoreconf doesn't copy the
# ltmain.sh file; running it twice, however, fixes that problem
autoreconf --install ..
autoreconf --install ..
fi
CFLAGS="$OLDER_MAC -I$INSTALL_ROOT/include $LIBDC_CFLAGS" ../configure --prefix=$INSTALL_ROOT --disable-examples
make -j4
make install
fi fi
cd libdivecomputer
mkdir -p build
cd build
if [ ! -f ../configure ] ; then
# this is not a typo
# in some scenarios it appears that autoreconf doesn't copy the
# ltmain.sh file; running it twice, however, fixes that problem
autoreconf --install ..
autoreconf --install ..
fi
CFLAGS="$OLDER_MAC -I$INSTALL_ROOT/include $LIBDC_CFLAGS" ../configure --prefix=$INSTALL_ROOT --disable-examples
make -j4
make install
if [ $PLATFORM = Darwin ] ; then if [ $PLATFORM = Darwin ] ; then
if [ -z "$CMAKE_PREFIX_PATH" ] ; then if [ -z "$CMAKE_PREFIX_PATH" ] ; then
libdir=`$QMAKE -query QT_INSTALL_LIBS` libdir=`$QMAKE -query QT_INSTALL_LIBS`
@ -401,28 +415,30 @@ if [ "$BUILDGRANTLEE" = "1" ] ; then
# build grantlee # build grantlee
PRINTING="-DNO_PRINTING=OFF" PRINTING="-DNO_PRINTING=OFF"
cd $SRC if [ -z "$NO_DEPS" ] ; then
cd $SRC
if [ ! -d grantlee ] ; then if [ ! -d grantlee ] ; then
if [[ $1 = local ]] ; then if [[ $1 = local ]] ; then
git clone $SRC/../grantlee grantlee git clone $SRC/../grantlee grantlee
else else
git clone https://github.com/steveire/grantlee.git git clone https://github.com/steveire/grantlee.git
fi
fi fi
cd grantlee
if ! git checkout v5.0.0 ; then
echo "can't check out v5.0.0 of grantlee -- giving up"
exit 1
fi
mkdir -p build
cd build
cmake $OLDER_MAC_CMAKE -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=$INSTALL_ROOT \
-DBUILD_TESTS=NO \
$SRC/grantlee
make -j4
make install
fi fi
cd grantlee
if ! git checkout v5.0.0 ; then
echo "can't check out v5.0.0 of grantlee -- giving up"
exit 1
fi
mkdir -p build
cd build
cmake $OLDER_MAC_CMAKE -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=$INSTALL_ROOT \
-DBUILD_TESTS=NO \
$SRC/grantlee
make -j4
make install
else else
PRINTING="-DNO_PRINTING=ON" PRINTING="-DNO_PRINTING=ON"
fi fi
@ -430,78 +446,84 @@ fi
if [ "$SKIP_GOOGLEMAPS" != "1" ] ; then if [ "$SKIP_GOOGLEMAPS" != "1" ] ; then
# build the googlemaps map plugin # build the googlemaps map plugin
cd $SRC if [ -z "$NO_DEPS" ] ; then
if [ ! -d googlemaps ] ; then cd $SRC
if [[ $1 = local ]] ; then if [ ! -d googlemaps ] ; then
git clone $SRC/../googlemaps googlemaps if [[ $1 = local ]] ; then
else git clone $SRC/../googlemaps googlemaps
git clone https://github.com/Subsurface-divelog/googlemaps.git else
git clone https://github.com/Subsurface-divelog/googlemaps.git
fi
fi fi
fi cd googlemaps
cd googlemaps git checkout master
git checkout master git pull --rebase
git pull --rebase
mkdir -p build mkdir -p build
cd build cd build
$QMAKE -query $QMAKE -query
$QMAKE "INCLUDEPATH=$INSTALL_ROOT/include" ../googlemaps.pro $QMAKE "INCLUDEPATH=$INSTALL_ROOT/include" ../googlemaps.pro
# on Travis the compiler doesn't support c++1z, yet qmake adds that flag; # on Travis the compiler doesn't support c++1z, yet qmake adds that flag;
# since things compile fine with c++11, let's just hack that away # since things compile fine with c++11, let's just hack that away
# similarly, don't use -Wdata-time # similarly, don't use -Wdata-time
mv Makefile Makefile.bak mv Makefile Makefile.bak
cat Makefile.bak | sed -e 's/std=c++1z/std=c++11/g ; s/-Wdate-time//' > Makefile cat Makefile.bak | sed -e 's/std=c++1z/std=c++11/g ; s/-Wdate-time//' > Makefile
make -j4 make -j4
make install make install
fi
fi fi
# finally, build Subsurface # finally, build Subsurface
set -x set -x
cd $SRC/subsurface if [ -z "$ONLY_DEPS" ] ; then
for (( i=0 ; i < ${#BUILDS[@]} ; i++ )) ; do cd $SRC/subsurface
SUBSURFACE_EXECUTABLE=${BUILDS[$i]} for (( i=0 ; i < ${#BUILDS[@]} ; i++ )) ; do
BUILDDIR=${BUILDDIRS[$i]} SUBSURFACE_EXECUTABLE=${BUILDS[$i]}
echo "build $SUBSURFACE_EXECUTABLE in $BUILDDIR" BUILDDIR=${BUILDDIRS[$i]}
echo "build $SUBSURFACE_EXECUTABLE in $BUILDDIR"
# pull the plasma-mobile components from upstream if building Subsurface-mobile # pull the plasma-mobile components from upstream if building Subsurface-mobile
if [ "$SUBSURFACE_EXECUTABLE" = "MobileExecutable" ] ; then if [ "$SUBSURFACE_EXECUTABLE" = "MobileExecutable" ] ; then
cd $SRC/subsurface cd $SRC/subsurface
bash ./scripts/mobilecomponents.sh bash ./scripts/mobilecomponents.sh
fi fi
mkdir -p $SRC/subsurface/$BUILDDIR mkdir -p $SRC/subsurface/$BUILDDIR
cd $SRC/subsurface/$BUILDDIR cd $SRC/subsurface/$BUILDDIR
export CMAKE_PREFIX_PATH="$INSTALL_ROOT/lib/cmake;${CMAKE_PREFIX_PATH}" export CMAKE_PREFIX_PATH="$INSTALL_ROOT/lib/cmake;${CMAKE_PREFIX_PATH}"
cmake -DCMAKE_BUILD_TYPE=Debug .. \ cmake -DCMAKE_BUILD_TYPE=Debug .. \
-DSUBSURFACE_TARGET_EXECUTABLE=$SUBSURFACE_EXECUTABLE \ -DSUBSURFACE_TARGET_EXECUTABLE=$SUBSURFACE_EXECUTABLE \
${LIBGIT_ARGS} \ ${LIBGIT_ARGS} \
-DLIBDIVECOMPUTER_INCLUDE_DIR=$INSTALL_ROOT/include \ -DLIBDIVECOMPUTER_INCLUDE_DIR=$INSTALL_ROOT/include \
-DLIBDIVECOMPUTER_LIBRARIES=$INSTALL_ROOT/lib/libdivecomputer.a \ -DLIBDIVECOMPUTER_LIBRARIES=$INSTALL_ROOT/lib/libdivecomputer.a \
-DCMAKE_PREFIX_PATH=$CMAKE_PREFIX_PATH \ -DCMAKE_PREFIX_PATH=$CMAKE_PREFIX_PATH \
-DBTSUPPORT=${BTSUPPORT} \ -DBTSUPPORT=${BTSUPPORT} \
-DCMAKE_INSTALL_PREFIX=${INSTALL_ROOT} \ -DCMAKE_INSTALL_PREFIX=${INSTALL_ROOT} \
-DLIBGIT2_FROM_PKGCONFIG=ON \ -DLIBGIT2_FROM_PKGCONFIG=ON \
-DFORCE_LIBSSH=OFF \ -DFORCE_LIBSSH=OFF \
$PRINTING $EXTRA_OPTS $PRINTING $EXTRA_OPTS
if [ $PLATFORM = Darwin ] ; then if [ $PLATFORM = Darwin ] ; then
rm -rf Subsurface.app rm -rf Subsurface.app
rm -rf Subsurface-mobile.app rm -rf Subsurface-mobile.app
fi fi
LIBRARY_PATH=$INSTALL_ROOT/lib make -j4 LIBRARY_PATH=$INSTALL_ROOT/lib make -j4
LIBRARY_PATH=$INSTALL_ROOT/lib make install LIBRARY_PATH=$INSTALL_ROOT/lib make install
if [ "$CREATE_APPDIR" = "1" ] ; then if [ "$CREATE_APPDIR" = "1" ] ; then
# if we create an AppImage this makes gives us a sane starting point # if we create an AppImage this makes gives us a sane starting point
cd $SRC cd $SRC
mkdir -p ./appdir mkdir -p ./appdir
mkdir -p appdir/usr/share/metainfo mkdir -p appdir/usr/share/metainfo
mkdir -p appdir/usr/share/icons/hicolor/256x256/apps mkdir -p appdir/usr/share/icons/hicolor/256x256/apps
cp -r ./install-root/* ./appdir/usr cp -r ./install-root/* ./appdir/usr
cp subsurface/appdata/subsurface.appdata.xml appdir/usr/share/metainfo/ cp subsurface/appdata/subsurface.appdata.xml appdir/usr/share/metainfo/
cp subsurface/icons/subsurface-icon.png appdir/usr/share/icons/hicolor/256x256/apps/ cp subsurface/icons/subsurface-icon.png appdir/usr/share/icons/hicolor/256x256/apps/
fi fi
done done
else
echo "Done building the dependencies, did not build libdivecomputer and Subsurface"
fi