summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2017-11-11 18:48:27 -0800
committerGravatar Dirk Hohndel <dirk@hohndel.org>2017-11-14 21:39:15 -0800
commit9c3a45af956dbf529a47e517771797d81df4a902 (patch)
treec7a9ce0a04405eed2021ab220ae6656959d3b65c
parent65e65272ce297dbbece60860d9ffcab148dec5e6 (diff)
downloadsubsurface-9c3a45af956dbf529a47e517771797d81df4a902.tar.gz
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>
-rw-r--r--.travis.yml6
-rwxr-xr-xscripts/build.sh59
-rw-r--r--scripts/mac/after_success.sh21
-rw-r--r--scripts/mac/before_install.sh72
-rw-r--r--scripts/mac/travisbuild.sh70
5 files changed, 206 insertions, 22 deletions
diff --git a/.travis.yml b/.travis.yml
index eac6dc385..c01c72d44 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,6 +1,12 @@
+
matrix:
include:
+ - env: SUBSURFACE_PLATFORM='mac'
+ os: osx
+ osx_image: xcode6.4
+ language: c++ ruby
+
- env: SUBSURFACE_PLATFORM='windows'
os: linux
dist: trusty
diff --git a/scripts/build.sh b/scripts/build.sh
index da2250794..ad0450a44 100755
--- a/scripts/build.sh
+++ b/scripts/build.sh
@@ -59,6 +59,10 @@ while [[ $# -gt 0 ]] ; do
# we are building an AppImage as by product
CREATE_APPDIR="1"
;;
+ -skip-googlemaps)
+ # hack for Travix Mac build
+ SKIP_GOOGLEMAPS="1"
+ ;;
*)
echo "Unknown command line argument $arg"
;;
@@ -183,6 +187,7 @@ fi
# set up the right file name extensions
if [ $PLATFORM = Darwin ] ; then
SH_LIB_EXT=dylib
+ pkg-config --exists libgit2 && LIBGIT=$(pkg-config --modversion libgit2 | cut -d. -f2)
else
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
cd $INSTALL_ROOT/lib
NAME=$(otool -L libgit2.dylib | grep -v : | head -1 | cut -f1 -d\ | tr -d '\t')
- echo $NAME | grep / > /dev/null 2>&1
- if [ $? -eq 1 ] ; then
+ echo $NAME | if grep / > /dev/null 2>&1 ; then
install_name_tool -id "$INSTALL_ROOT/lib/$NAME" "$INSTALL_ROOT/lib/$NAME"
fi
fi
fi
+
cd $SRC
# build libdivecomputer
@@ -431,32 +436,40 @@ else
PRINTING="-DNO_PRINTING=ON"
fi
+if [ $SKIP_GOOGLEMAPS != "1" ] ; then
+ # build the googlemaps map plugin
-# build the googlemaps map plugin
-
-cd $SRC
-if [ ! -d googlemaps ] ; then
- if [[ $1 = local ]] ; then
- git clone $SRC/../googlemaps googlemaps
- else
- git clone https://github.com/Subsurface-divelog/googlemaps.git
+ cd $SRC
+ if [ ! -d googlemaps ] ; then
+ if [[ $1 = local ]] ; then
+ git clone $SRC/../googlemaps googlemaps
+ else
+ 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
-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
+set -x
+
cd $SRC/subsurface
for (( i=0 ; i < ${#BUILDS[@]} ; i++ )) ; do
SUBSURFACE_EXECUTABLE=${BUILDS[$i]}
@@ -480,6 +493,8 @@ for (( i=0 ; i < ${#BUILDS[@]} ; i++ )) ; do
-DCMAKE_PREFIX_PATH=$CMAKE_PREFIX_PATH \
-DBTSUPPORT=${BTSUPPORT} \
-DCMAKE_INSTALL_PREFIX=${INSTALL_ROOT} \
+ -DLIBGIT2_FROM_PKGCONFIG=ON \
+ -DFORCE_LIBSSH=OFF \
$PRINTING $EXTRA_OPTS
if [ $PLATFORM = Darwin ] ; then
diff --git a/scripts/mac/after_success.sh b/scripts/mac/after_success.sh
new file mode 100644
index 000000000..221649e4e
--- /dev/null
+++ b/scripts/mac/after_success.sh
@@ -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
+
diff --git a/scripts/mac/before_install.sh b/scripts/mac/before_install.sh
new file mode 100644
index 000000000..60d7312c9
--- /dev/null
+++ b/scripts/mac/before_install.sh
@@ -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
diff --git a/scripts/mac/travisbuild.sh b/scripts/mac/travisbuild.sh
new file mode 100644
index 000000000..f056f3e86
--- /dev/null
+++ b/scripts/mac/travisbuild.sh
@@ -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