#!/bin/bash -ex
#
# this script is run on travis for the script stage of mac builds
#

QMAKE=${QMAKE:-qmake}
LUPDATE=${LUPDATE:-lupdate}
LRELEASE=${LRELEASE:-lrelease}
MACDEPLOYQT=${MACDEPLOYQT:-macdeployqt}
# we assume we are on macOS, so date is not gnu date.
VERSIONID=${VERSIONID:-$(date -ju -f %Y-%m-%dT%H:%M:%S%z $(git show -s --format="%aI" HEAD | sed 's/:\(..\)$/\1/') +%Y%m%dT%H%MZ)-$(git rev-parse --short=7 HEAD)}

# debug tokens
"$(cd "$(dirname "${BASH_SOURCE[0]}" )" && pwd)"/ci_tokens

# build and test the CLI
$QMAKE GPSBabel.pro && make -j 2 && make check

# build the GUI
pushd gui
$QMAKE app.pro && make -j 2
make package
popd

# what is in there?
hdiutil attach -noverify gui/GPSBabelFE.dmg
find /Volumes/GPSBabelFE -ls
hdiutil detach /Volumes/GPSBabelFE

mv gui/GPSBabelFE.dmg gui/GPSBabel-${VERSIONID}.dmg


