diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2017-11-11 18:48:27 -0800 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2017-11-14 21:39:15 -0800 |
commit | 9c3a45af956dbf529a47e517771797d81df4a902 (patch) | |
tree | c7a9ce0a04405eed2021ab220ae6656959d3b65c /scripts/mac | |
parent | 65e65272ce297dbbece60860d9ffcab148dec5e6 (diff) | |
download | subsurface-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>
Diffstat (limited to 'scripts/mac')
-rw-r--r-- | scripts/mac/after_success.sh | 21 | ||||
-rw-r--r-- | scripts/mac/before_install.sh | 72 | ||||
-rw-r--r-- | scripts/mac/travisbuild.sh | 70 |
3 files changed, 163 insertions, 0 deletions
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 |