Travis: add Mac build

This adds a -skip-googlemaps option to the build script since for some
reason trying to build the googlemaps plugin in the Travis mac
environment causes an error with a missing stack-protector-strong
feature.

The build relies on a custom build Qt and a cached homebrew environment.
And the result is of course not a DMG with a signed app but a zip file
with an unsigned app - so it's a bit harder to consume.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2017-11-11 18:48:27 -08:00
parent 65e65272ce
commit 9c3a45af95
5 changed files with 206 additions and 22 deletions

View file

@ -1,6 +1,12 @@
matrix: matrix:
include: include:
- env: SUBSURFACE_PLATFORM='mac'
os: osx
osx_image: xcode6.4
language: c++ ruby
- env: SUBSURFACE_PLATFORM='windows' - env: SUBSURFACE_PLATFORM='windows'
os: linux os: linux
dist: trusty dist: trusty

View file

@ -59,6 +59,10 @@ while [[ $# -gt 0 ]] ; do
# we are building an AppImage as by product # we are building an AppImage as by product
CREATE_APPDIR="1" CREATE_APPDIR="1"
;; ;;
-skip-googlemaps)
# hack for Travix Mac build
SKIP_GOOGLEMAPS="1"
;;
*) *)
echo "Unknown command line argument $arg" echo "Unknown command line argument $arg"
;; ;;
@ -183,6 +187,7 @@ fi
# set up the right file name extensions # set up the right file name extensions
if [ $PLATFORM = Darwin ] ; then if [ $PLATFORM = Darwin ] ; then
SH_LIB_EXT=dylib SH_LIB_EXT=dylib
pkg-config --exists libgit2 && LIBGIT=$(pkg-config --modversion libgit2 | cut -d. -f2)
else else
SH_LIB_EXT=so SH_LIB_EXT=so
@ -327,13 +332,13 @@ if [[ $PLATFORM = Darwin || "$LIBGIT" < "24" ]] ; 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
cd $INSTALL_ROOT/lib cd $INSTALL_ROOT/lib
NAME=$(otool -L libgit2.dylib | grep -v : | head -1 | cut -f1 -d\ | tr -d '\t') NAME=$(otool -L libgit2.dylib | grep -v : | head -1 | cut -f1 -d\ | tr -d '\t')
echo $NAME | grep / > /dev/null 2>&1 echo $NAME | if grep / > /dev/null 2>&1 ; then
if [ $? -eq 1 ] ; then
install_name_tool -id "$INSTALL_ROOT/lib/$NAME" "$INSTALL_ROOT/lib/$NAME" install_name_tool -id "$INSTALL_ROOT/lib/$NAME" "$INSTALL_ROOT/lib/$NAME"
fi fi
fi fi
fi fi
cd $SRC cd $SRC
# build libdivecomputer # build libdivecomputer
@ -431,32 +436,40 @@ else
PRINTING="-DNO_PRINTING=ON" PRINTING="-DNO_PRINTING=ON"
fi fi
if [ $SKIP_GOOGLEMAPS != "1" ] ; then
# build the googlemaps map plugin
# build the googlemaps map plugin cd $SRC
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 fi
git clone https://github.com/Subsurface-divelog/googlemaps.git
fi fi
cd googlemaps
git checkout master
git pull --rebase
# remove the qt_build_config from .qmake.conf as that fails on Travis
sed -i '' 's/.*qt_build_config.*//' .qmake.conf
mkdir -p build
cd build
$QMAKE -query
$QMAKE "INCLUDEPATH=$INSTALL_ROOT/include" ../googlemaps.pro
# 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
# similarly, don't use -Wdata-time
sed -i 's/std=c++1z/std=c++11/g ; s/-Wdate-time//' Makefile
make -j4
make install
fi fi
cd googlemaps
git checkout master
git pull --rebase
mkdir -p build
cd build
$QMAKE "INCLUDEPATH=$INSTALL_ROOT/include" ../googlemaps.pro
# 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
# similarly, don't use -Wdata-time
sed -i 's/std=c++1z/std=c++11/g ; s/-Wdate-time//' Makefile
make -j4
make install
# finally, build Subsurface # finally, build Subsurface
set -x
cd $SRC/subsurface cd $SRC/subsurface
for (( i=0 ; i < ${#BUILDS[@]} ; i++ )) ; do for (( i=0 ; i < ${#BUILDS[@]} ; i++ )) ; do
SUBSURFACE_EXECUTABLE=${BUILDS[$i]} SUBSURFACE_EXECUTABLE=${BUILDS[$i]}
@ -480,6 +493,8 @@ for (( i=0 ; i < ${#BUILDS[@]} ; i++ )) ; do
-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 \
-DFORCE_LIBSSH=OFF \
$PRINTING $EXTRA_OPTS $PRINTING $EXTRA_OPTS
if [ $PLATFORM = Darwin ] ; then if [ $PLATFORM = Darwin ] ; then

View file

@ -0,0 +1,21 @@
#!/bin/bash
if [ ! -z $TRAVIS_BRANCH ] && [ "$TRAVIS_BRANCH" != "master" ] ; then
export UPLOADTOOL_SUFFIX=$TRAVIS_BRANCH
fi
# same git version magic as in the Makefile
# for the naming of the app
export VERSION=$(cd ${TRAVIS_BUILD_DIR}; ./scripts/get-version linux)
cd ${TRAVIS_BUILD_DIR}/build
zip -r Subsurface-$VERSION.app.zip Subsurface.app
echo "Submitting the folloing App for continuous build release:"
ls -lh Subsurface-$VERSION.app.zip
# get and run the upload script
wget -c https://github.com/probonopd/uploadtool/raw/master/upload.sh
bash ./upload.sh Subsurface-$VERSION.app.zip

View file

@ -0,0 +1,72 @@
#!/bin/bash
set -x
# try to get rid of the insane debug crap
unalias -a
unset -f rvm_debug
unset -f cd
unset -f pushd
unset -f popd
# Travis only pulls shallow repos. But that messes with git describe.
# Sorry Travis, fetching the whole thing and the tags as well...
git fetch --unshallow
git pull --tags
git describe
# for our build we need an updated Homebrew with a few more components
# installed. Since the Travis cache doesn't seem to work, we put it on
# our own server
if curl --output /dev/null --silent --head --fail \
http://subsurface-divelog.org/downloads/TravisMacBuildCache.tar.xz
then
echo "Download Homebrew with all our packages and overwritw /usr/local"
curl --output ${TRAVIS_BUILD_DIR}/TravisMacBuildCache.tar.xz \
https://storage.googleapis.com/travis-cache/TravisMacBuildCache.tar.xz
# curl --output ${TRAVIS_BUILD_DIR}/TravisMacBuildCache.tar.xz \
# http://subsurface-divelog.org/downloads/TravisMacBuildCache.tar.xz
sudo tar xJfC ${TRAVIS_BUILD_DIR}/TravisMacBuildCache.tar.xz /tmp
sudo mv /usr/local /usr/local2
sudo mv /tmp/usr/local /usr/local
else
echo "Cannot find TravisMacBuildCache: recreate it by first updating Homebrew"
brew update
echo "Updated Homebrew, now get our dependencies brewed"
brew install xz hidapi libusb libxml2 libxslt libzip openssl pkg-config libgit2
tar cf - /usr/local | xz -v -z -0 --threads=0 > ${TRAVIS_BUILD_DIR}/TravisMacBuildCache.tar.xz
echo "Sending new cache to transfer.sh - move it into place, please"
ls -lh ${TRAVIS_BUILD_DIR}/TravisMacBuildCache.tar.xz
curl --upload-file ${TRAVIS_BUILD_DIR}/TravisMacBuildCache.tar.xz https://transfer.sh/TravisMacBuildCache.tar.xz
fi
# HACK - needs to be part of cache
brew install libssh2
# libdivecomputer uses the wrong include path for libusb and hidapi
# the pkgconfig file for libusb/hidapi already gives the include path as
# ../include/libusb-1.0 (../include/hidapi) yet libdivecomputer wants to use
# include <libusb-1.0/libusb.h> and include <hidapi/hidapi.h>
sudo ln -s /usr/local/include/libusb-1.0 /usr/local/include/libusb-1.0/libusb-1.0
sudo ln -s /usr/local/include/hidapi /usr/local/include/libusb-1.0/hidapi
# prep things so we can build for Mac
# we have a custom built Qt some gives us just what we need, including QtWebKit
#
# we should just build and install this into /usr/local/ as well and have
# it all be part of the cache...
pushd ${TRAVIS_BUILD_DIR}
mkdir -p Qt/5.9.1
echo "Get custom Qt build and unpack it"
curl --output ${TRAVIS_BUILD_DIR}/Qt-5.9.1-mac.tar.xz \
https://storage.googleapis.com/travis-cache/Qt-5.9.1-mac.tar.xz
# wget -q http://subsurface-divelog.org/downloads/Qt-5.9.1-mac.tar.xz
tar -xJ -C Qt/5.9.1 -f Qt-5.9.1-mac.tar.xz
sudo mkdir -p /Users/hohndel
sudo ln -s ${TRAVIS_BUILD_DIR}//Qt/5.9.1 /Users/hohndel/Qt5.9.1
ls -l /Users/hohndel

View file

@ -0,0 +1,70 @@
#!/bin/bash
# this gets executed by Travis when building an App for Mac
# it gets started from inside the subsurface directory
export QT_ROOT=${TRAVIS_BUILD_DIR}/Qt/5.9.1
export PATH=$QT_ROOT/bin:$PATH # Make sure correct qmake is found on the $PATH
export CMAKE_PREFIX_PATH=$QT_ROOT/lib/cmake
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH
# the global build script expects to be called from the directory ABOVE subsurface
cd ${TRAVIS_BUILD_DIR}/..
DIR=$(pwd)
#bash -e -x ./subsurface/scripts/build.sh -desktop -build-with-webkit # we need to build 'both' and need to build without BT and other variations that we want to exercise
bash -e -x ./subsurface/scripts/build.sh -desktop -build-with-webkit -skip-googlemaps
cd ${TRAVIS_BUILD_DIR}/build
# first build and install Subsurface and then clean up the staging area
LIBRARY_PATH=${DIR}/install-root/lib make -j2 install
# now adjust a few references that macdeployqt appears to miss
EXECUTABLE=Subsurface.app/Contents/MacOS/Subsurface
for i in libgit2 libGrantlee_TextDocument.dylib libGrantlee_Templates.dylib; do
OLD=$(otool -L ${EXECUTABLE} | grep $i | cut -d\ -f1 | tr -d "\t")
if [ ! -z ${OLD} ] ; then
# copy the library into the bundle and make sure its id and the reference to it are correct
cp ${DIR}/install-root/lib/$(basename ${OLD}) Subsurface.app/Contents/Frameworks
SONAME=$(basename $OLD)
install_name_tool -change ${OLD} @executable_path/../Frameworks/${SONAME} ${EXECUTABLE}
install_name_tool -id @executable_path/../Frameworks/${SONAME} Subsurface.app/Contents/Frameworks/${SONAME}
# also fix incorrect references inside of libgit2
if [[ "$i" = "libgit2" ]] ; then
CURLLIB=$(otool -L Subsurface.app/Contents/Frameworks/${SONAME} | grep libcurl | cut -d\ -f1 | tr -d "\t")
install_name_tool -change ${CURLLIB} @executable_path/../Frameworks/$(basename ${CURLLIB}) Subsurface.app/Contents/Frameworks/${SONAME}
SSHLIB=$(otool -L Subsurface.app/Contents/Frameworks/${SONAME} | grep libssh2 | cut -d\ -f1 | tr -d "\t")
install_name_tool -change ${SSHLIB} @executable_path/../Frameworks/$(basename ${SSHLIB}) Subsurface.app/Contents/Frameworks/${SONAME}
fi
fi
done
# next, copy libssh2.1
cp ${DIR}/install-root/lib/libssh2.1.dylib Subsurface.app/Contents/Frameworks
# next, replace @rpath references with @executable_path references in Subsurface
RPATH=$(otool -L ${EXECUTABLE} | grep rpath | cut -d\ -f1 | tr -d "\t" | cut -b 8- )
for i in ${RPATH}; do
install_name_tool -change @rpath/$i @executable_path/../Frameworks/$i ${EXECUTABLE}
done
# next deal with libGrantlee
LIBG=$(ls Subsurface.app/Contents/Frameworks/libGrantlee_Templates*dylib)
for i in QtScript.framework/Versions/5/QtScript QtCore.framework/Versions/5/QtCore ; do
install_name_tool -change @rpath/$i @executable_path/../Frameworks/$i ${LIBG}
done
# clean up shared library dependency in the Grantlee plugins
for i in Subsurface.app/Contents/PlugIns/grantlee/5.0/*.so; do
OLD=$(otool -L $i | grep libGrantlee_Templates | cut -d\ -f1 | tr -d "\t")
SONAME=$(basename $OLD )
install_name_tool -change ${OLD} @executable_path/../Frameworks/${SONAME} $i;
OLD=$(otool -L $i | grep QtCore | cut -d\ -f1 | tr -d "\t")
install_name_tool -change ${OLD} @executable_path/../Frameworks/QtCore.framework/QtCore $i;
mv $i Subsurface.app/Contents/PlugIns/grantlee
done
rmdir Subsurface.app/Contents/PlugIns/grantlee/5.0
pushd Subsurface.app/Contents/PlugIns/grantlee
ln -s . 5.0
popd