2016-08-17 19:36:50 +00:00
|
|
|
#!/bin/bash -e
|
2014-12-31 18:20:28 +00:00
|
|
|
|
2020-10-30 21:14:28 +00:00
|
|
|
# build Subsurface for Windows
|
2014-12-31 18:20:28 +00:00
|
|
|
#
|
2015-09-22 04:38:26 +00:00
|
|
|
# this file assumes that you have installed MXE on your system
|
2017-09-14 19:27:10 +00:00
|
|
|
# and installed a number of dependencies as well.
|
2015-09-22 04:38:26 +00:00
|
|
|
#
|
2017-01-29 20:45:02 +00:00
|
|
|
# cd ~/src
|
2017-09-14 19:27:10 +00:00
|
|
|
# git clone https://github.com/mxe/mxe
|
2015-09-22 04:38:26 +00:00
|
|
|
# cd mxe
|
2015-09-22 05:22:03 +00:00
|
|
|
#
|
|
|
|
# now create a file settings.mk
|
|
|
|
#---
|
|
|
|
# # This variable controls the number of compilation processes
|
|
|
|
# # within one package ("intra-package parallelism").
|
2017-01-29 20:45:02 +00:00
|
|
|
# # Set to higher value if you have a powerful machine.
|
|
|
|
# JOBS := 1
|
2015-09-22 05:22:03 +00:00
|
|
|
#
|
|
|
|
# # This variable controls the targets that will build.
|
2020-10-28 17:55:02 +00:00
|
|
|
# MXE_TARGETS := x86_64-w64-mingw32.shared
|
2017-03-26 17:51:53 +00:00
|
|
|
#
|
|
|
|
# # Uncomment the next line if you want to do debug builds later
|
|
|
|
# # qtbase_CONFIGURE_OPTS=-debug-and-release
|
2015-09-22 05:22:03 +00:00
|
|
|
#---
|
|
|
|
# (documenting this in comments is hard... you need to remove
|
|
|
|
# the first '#' of course)
|
|
|
|
#
|
|
|
|
# now you can start the build
|
2019-10-14 14:31:05 +00:00
|
|
|
#
|
|
|
|
# make libxml2 libxslt libusb1 libzip libssh2 libftdi1 curl qt5 nsis
|
2018-10-21 11:59:09 +00:00
|
|
|
#
|
|
|
|
# (if you intend to build Subsurface without user space FTDI support
|
|
|
|
# you can drop libftdi1 from that list and start this script with
|
|
|
|
# -noftdi )
|
2015-09-22 04:38:26 +00:00
|
|
|
#
|
|
|
|
# After quite a while (depending on your machine anywhere from 15-20
|
|
|
|
# minutes to several hours) you should have a working MXE install in
|
2017-01-29 20:45:02 +00:00
|
|
|
# ~/src/mxe
|
2015-09-22 04:38:26 +00:00
|
|
|
#
|
|
|
|
# Now this script will come in:
|
|
|
|
#
|
2017-01-29 20:45:02 +00:00
|
|
|
# This makes some assumption about the filesystem layout so you
|
|
|
|
# can build linux and windows build out of the same sources
|
2014-12-31 18:20:28 +00:00
|
|
|
# Something like this:
|
|
|
|
#
|
2017-01-29 20:45:02 +00:00
|
|
|
# ~/src/mxe <- MXE git with Qt5, automake (see above)
|
|
|
|
# /subsurface <- current subsurface git
|
2017-09-14 19:30:35 +00:00
|
|
|
# /googlemaps <- Google Maps plugin for QtLocation from git
|
2019-10-14 14:31:05 +00:00
|
|
|
# /hidapi <- HIDAPI library for libdivecomputer
|
2014-12-31 18:20:28 +00:00
|
|
|
#
|
2017-01-29 20:45:02 +00:00
|
|
|
# ~/src/win32 <- build directory
|
2014-12-31 18:20:28 +00:00
|
|
|
#
|
2017-01-29 20:45:02 +00:00
|
|
|
# then start this script from ~/src/win32
|
2014-12-31 18:20:28 +00:00
|
|
|
#
|
2017-01-29 20:45:02 +00:00
|
|
|
# cd ~/src/win32
|
|
|
|
# bash ../subsurface/packaging/windows/mxe-based-build.sh installer
|
2014-12-31 18:20:28 +00:00
|
|
|
#
|
|
|
|
# this should create the latest daily installer
|
2015-09-22 04:38:26 +00:00
|
|
|
#
|
|
|
|
# in order not to keep recompiling everything this script only compiles
|
|
|
|
# the other components if their directories are missing or if a "magic
|
|
|
|
# file" has been touched.
|
|
|
|
#
|
|
|
|
# so if you update one of the other libs do
|
|
|
|
#
|
2017-01-29 20:45:02 +00:00
|
|
|
# cd ~/src/win32
|
2015-09-22 04:38:26 +00:00
|
|
|
# touch build.<component>
|
2017-01-29 20:45:02 +00:00
|
|
|
# bash ../subsurface/packaging/windows/mxe-based-build.sh installer
|
2015-09-22 04:38:26 +00:00
|
|
|
#
|
|
|
|
# and that component gets rebuilt as well. E.g.
|
|
|
|
# touch build.libdivecomputer
|
|
|
|
# to rebuild libdivecomputer before you build Subsurface
|
|
|
|
#
|
2017-03-26 17:51:53 +00:00
|
|
|
# If you want to create a installer for the debug build call
|
|
|
|
#
|
|
|
|
# bash ../subsurface/packaging/windows/mxe-based-build.sh debug installer
|
|
|
|
#
|
|
|
|
# please be aware of the fact that this installer will be a few 100MB large
|
|
|
|
#
|
|
|
|
#
|
2015-09-22 04:38:26 +00:00
|
|
|
# please send patches / additions to this file!
|
|
|
|
#
|
2014-12-31 18:20:28 +00:00
|
|
|
|
2015-09-22 04:38:26 +00:00
|
|
|
exec 1> >(tee ./winbuild.log) 2>&1
|
2014-12-31 18:20:28 +00:00
|
|
|
|
2015-09-22 04:38:26 +00:00
|
|
|
# for debugging
|
|
|
|
#trap "set +x; sleep 1; set -x" DEBUG
|
|
|
|
|
2018-10-07 05:38:29 +00:00
|
|
|
if [[ "$1" == "-noftdi" ]] ; then
|
|
|
|
shift
|
|
|
|
FTDI="OFF"
|
|
|
|
else
|
|
|
|
FTDI="ON"
|
|
|
|
fi
|
|
|
|
|
2015-09-22 04:38:26 +00:00
|
|
|
# this is run on a rather powerful machine - if you want less
|
|
|
|
# build parallelism, please change this variable
|
2015-12-16 16:14:59 +00:00
|
|
|
JOBS="-j4"
|
|
|
|
|
|
|
|
EXECDIR=`pwd`
|
|
|
|
BASEDIR=$(cd "$EXECDIR/.."; pwd)
|
|
|
|
BUILDDIR=$(cd "$EXECDIR"; pwd)
|
2017-07-03 01:55:16 +00:00
|
|
|
MXEDIR=${MXEDIR:-mxe}
|
2020-10-28 17:55:02 +00:00
|
|
|
MXEBUILDTYPE=${MXEBUILDTYPE:-x86_64-w64-mingw32.shared}
|
2015-12-16 16:14:59 +00:00
|
|
|
|
|
|
|
echo $BUILDDIR
|
2014-12-31 18:20:28 +00:00
|
|
|
|
2017-07-03 01:55:16 +00:00
|
|
|
if [[ ! -d "$BASEDIR"/"$MXEDIR" ]] ; then
|
2015-09-22 04:38:26 +00:00
|
|
|
echo "Please start this from the right directory "
|
|
|
|
echo "usually a winbuild directory parallel to the mxe directory"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "Building in $BUILDDIR ..."
|
2014-12-31 18:20:28 +00:00
|
|
|
|
2018-11-14 04:42:52 +00:00
|
|
|
export PATH="$BASEDIR"/"$MXEDIR"/usr/bin:$PATH:"$BASEDIR"/"$MXEDIR"/usr/"$MXEBUILDTYPE"/qt5/bin/
|
2020-10-17 22:08:38 +00:00
|
|
|
export CXXFLAGS=-std=c++17
|
2014-12-31 18:20:28 +00:00
|
|
|
|
2015-09-23 19:25:14 +00:00
|
|
|
if [[ "$1" == "debug" ]] ; then
|
|
|
|
RELEASE="Debug"
|
2017-11-13 23:07:17 +00:00
|
|
|
RELEASE_MAIN="Debug"
|
2018-03-23 18:55:00 +00:00
|
|
|
RELEASE_GM="debug"
|
2017-03-26 17:51:53 +00:00
|
|
|
DLL_SUFFIX="d"
|
2015-09-23 19:25:14 +00:00
|
|
|
shift
|
2017-04-01 14:40:50 +00:00
|
|
|
if [[ -f Release ]] ; then
|
|
|
|
rm -rf *
|
|
|
|
fi
|
|
|
|
touch Debug
|
2015-09-23 19:25:14 +00:00
|
|
|
else
|
|
|
|
RELEASE="Release"
|
2017-11-13 23:07:17 +00:00
|
|
|
RELEASE_MAIN="RelWithDebInfo"
|
2018-03-23 18:55:00 +00:00
|
|
|
RELEASE_GM="release"
|
2017-03-26 17:51:53 +00:00
|
|
|
DLL_SUFFIX=""
|
2017-04-01 14:40:50 +00:00
|
|
|
if [[ -f Debug ]] ; then
|
|
|
|
rm -rf *
|
|
|
|
fi
|
|
|
|
touch Release
|
2015-09-23 19:25:14 +00:00
|
|
|
fi
|
2014-12-31 18:20:28 +00:00
|
|
|
|
2019-10-14 14:31:05 +00:00
|
|
|
|
|
|
|
|
2015-09-22 04:38:26 +00:00
|
|
|
# libdivecomputer
|
2017-12-04 23:07:23 +00:00
|
|
|
# ensure the git submodule is present and the autotools are set up
|
2017-12-03 20:53:56 +00:00
|
|
|
|
|
|
|
cd "$BASEDIR"/subsurface
|
|
|
|
if [ ! -d libdivecomputer/src ] ; then
|
2017-12-04 23:07:23 +00:00
|
|
|
git submodule init
|
2017-12-03 20:53:56 +00:00
|
|
|
git submodule update --recursive
|
|
|
|
fi
|
2017-12-04 23:07:23 +00:00
|
|
|
if [ ! -f libdivecomputer/configure ] ; then
|
|
|
|
cd libdivecomputer
|
|
|
|
autoreconf --install
|
|
|
|
autoreconf --install
|
|
|
|
fi
|
2014-12-31 18:20:28 +00:00
|
|
|
|
2020-10-30 21:14:28 +00:00
|
|
|
# if this is a 64bit build then build libmtp as that isn't available via MXE
|
|
|
|
# for 32bit builds the library currently fails to build, so support for
|
|
|
|
# MTP devices (right now just the Garmin Descent Mk2/Mk2i) is not available on 32bit Windows
|
|
|
|
if [ "$MXEBUILDTYPE" = "x86_64-w64-mingw32.shared" ] ; then
|
2020-10-28 14:15:20 +00:00
|
|
|
cd "$BUILDDIR"
|
2020-10-30 21:14:28 +00:00
|
|
|
if [[ ! -d libmtp || -f build.libmtp ]] ; then
|
|
|
|
rm -f build.libmtp
|
|
|
|
cd "$BASEDIR/libmtp"
|
|
|
|
export NOCONFIGURE=1
|
2020-10-31 23:08:02 +00:00
|
|
|
echo 'N' | bash autogen.sh
|
2020-10-30 21:14:28 +00:00
|
|
|
cd "$BUILDDIR"
|
|
|
|
mkdir -p libmtp
|
|
|
|
cd libmtp
|
|
|
|
"$BASEDIR"/libmtp/configure \
|
|
|
|
CC="$MXEBUILDTYPE"-gcc \
|
|
|
|
--host="$MXEBUILDTYPE" \
|
|
|
|
--enable-shared \
|
|
|
|
--prefix="$BASEDIR"/"$MXEDIR"/usr/"$MXEBUILDTYPE"
|
|
|
|
make $JOBS
|
|
|
|
make install
|
|
|
|
fi
|
2020-10-28 14:15:20 +00:00
|
|
|
fi
|
|
|
|
|
2015-09-23 19:25:14 +00:00
|
|
|
cd "$BUILDDIR"
|
2018-06-25 07:06:11 +00:00
|
|
|
CURRENT_SHA=$(cd "$BASEDIR"/subsurface/libdivecomputer ; git describe)
|
|
|
|
PREVIOUS_SHA=$(cat "libdivecomputer.SHA" 2>/dev/null || echo)
|
|
|
|
if [ ! "$CURRENT_SHA" = "$PREVIOUS_SHA" ] || [ ! -d libdivecomputer ] || [ -f build.libdivecomputer ] ; then
|
2017-01-29 20:45:02 +00:00
|
|
|
rm -f build.libdivecomputer
|
2015-09-22 04:38:26 +00:00
|
|
|
mkdir -p libdivecomputer
|
|
|
|
cd libdivecomputer
|
2014-12-31 18:20:28 +00:00
|
|
|
|
2017-12-03 20:53:56 +00:00
|
|
|
"$BASEDIR"/subsurface/libdivecomputer/configure \
|
2018-11-14 04:42:52 +00:00
|
|
|
CC="$MXEBUILDTYPE"-gcc \
|
|
|
|
--host="$MXEBUILDTYPE" \
|
2015-10-26 21:27:16 +00:00
|
|
|
--enable-shared \
|
2018-11-14 04:42:52 +00:00
|
|
|
--prefix="$BASEDIR"/"$MXEDIR"/usr/"$MXEBUILDTYPE"
|
2015-09-22 04:38:26 +00:00
|
|
|
make $JOBS
|
|
|
|
make install
|
|
|
|
else
|
|
|
|
echo ""
|
|
|
|
echo ""
|
|
|
|
echo "WARNING!!!!"
|
|
|
|
echo ""
|
|
|
|
echo "libdivecoputer not rebuilt!!"
|
|
|
|
echo ""
|
|
|
|
echo ""
|
|
|
|
fi
|
2014-12-31 18:20:28 +00:00
|
|
|
|
2017-08-03 05:42:20 +00:00
|
|
|
cd "$BUILDDIR"
|
|
|
|
if [[ ! -d googlemaps || -f build.googlemaps ]] ; then
|
|
|
|
rm -f build.googlemaps
|
|
|
|
cd "$BASEDIR"/googlemaps
|
|
|
|
git pull
|
|
|
|
cd "$BUILDDIR"
|
|
|
|
mkdir -p googlemaps
|
|
|
|
cd googlemaps
|
2018-11-14 04:42:52 +00:00
|
|
|
"$BASEDIR"/"$MXEDIR"/usr/"$MXEBUILDTYPE"/qt5/bin/qmake PREFIX=$"$BASEDIR"/"$MXEDIR"/usr/"$MXEBUILDTYPE" "$BASEDIR"/googlemaps/googlemaps.pro
|
2018-03-23 18:55:00 +00:00
|
|
|
make $JOBS $RELEASE_GM
|
|
|
|
make "$RELEASE_GM"-install
|
2017-08-03 05:42:20 +00:00
|
|
|
fi
|
|
|
|
|
2014-12-31 18:20:28 +00:00
|
|
|
###############
|
2015-09-22 04:38:26 +00:00
|
|
|
# finally, Subsurface
|
|
|
|
|
2015-09-23 19:25:14 +00:00
|
|
|
cd "$BUILDDIR"
|
2015-12-16 16:14:59 +00:00
|
|
|
echo "Starting Subsurface Build"
|
2015-09-23 19:25:14 +00:00
|
|
|
|
|
|
|
# things go weird if we don't create a new build directory... Subsurface
|
|
|
|
# suddenly gets linked against Qt5Guid.a etc...
|
|
|
|
rm -rf subsurface
|
2015-09-22 16:28:36 +00:00
|
|
|
|
|
|
|
# first copy the Qt plugins in place
|
2018-11-14 04:42:52 +00:00
|
|
|
QT_PLUGIN_DIRECTORIES="$BASEDIR/"$MXEDIR"/usr/"$MXEBUILDTYPE"/qt5/plugins/iconengines \
|
|
|
|
$BASEDIR/"$MXEDIR"/usr/"$MXEBUILDTYPE"/qt5/plugins/imageformats \
|
|
|
|
$BASEDIR/"$MXEDIR"/usr/"$MXEBUILDTYPE"/qt5/plugins/platforms \
|
|
|
|
$BASEDIR/"$MXEDIR"/usr/"$MXEBUILDTYPE"/qt5/plugins/geoservices \
|
2020-10-09 11:29:30 +00:00
|
|
|
$BASEDIR/"$MXEDIR"/usr/"$MXEBUILDTYPE"/qt5/plugins/styles \
|
2018-11-14 04:42:52 +00:00
|
|
|
$BASEDIR/"$MXEDIR"/usr/"$MXEBUILDTYPE"/qt5/plugins/printsupport"
|
2015-09-22 04:38:26 +00:00
|
|
|
|
2017-03-11 05:06:22 +00:00
|
|
|
STAGING_DIR=$BUILDDIR/subsurface/staging
|
|
|
|
STAGING_TESTS_DIR=$BUILDDIR/subsurface/staging_tests
|
|
|
|
|
|
|
|
mkdir -p $STAGING_DIR/plugins
|
|
|
|
mkdir -p $STAGING_TESTS_DIR
|
|
|
|
|
|
|
|
for d in $QT_PLUGIN_DIRECTORIES
|
|
|
|
do
|
2017-03-31 20:34:57 +00:00
|
|
|
mkdir -p $STAGING_DIR/plugins/$(basename $d)
|
|
|
|
mkdir -p $STAGING_TESTS_DIR/$(basename $d)
|
|
|
|
for f in $d/*
|
|
|
|
do
|
2017-08-02 20:37:00 +00:00
|
|
|
if [[ "$d" =~ geoservice ]] && [[ ! "$f" =~ googlemaps ]] ; then
|
2017-07-29 20:11:47 +00:00
|
|
|
continue
|
|
|
|
fi
|
2017-03-31 20:34:57 +00:00
|
|
|
if [[ "$RELEASE" == "Release" ]] && ([[ ! -f ${f//d.dll/.dll} || "$f" == "${f//d.dll/.dll}" ]]) ; then
|
|
|
|
cp $f $STAGING_DIR/plugins/$(basename $d)
|
|
|
|
cp $f $STAGING_TESTS_DIR/$(basename $d)
|
|
|
|
elif [[ "$RELEASE" == "Debug" && ! -f ${f//.dll/d.dll} ]] ; then
|
|
|
|
cp $f $STAGING_DIR/plugins/$(basename $d)
|
|
|
|
cp $f $STAGING_TESTS_DIR/$(basename $d)
|
|
|
|
fi
|
|
|
|
done
|
2017-03-11 05:06:22 +00:00
|
|
|
done
|
|
|
|
|
2017-07-29 20:42:06 +00:00
|
|
|
# next we need the QML modules
|
2018-11-14 04:42:52 +00:00
|
|
|
QT_QML_MODULES="$BASEDIR/"$MXEDIR"/usr/"$MXEBUILDTYPE"/qt5/qml/QtQuick.2 \
|
|
|
|
$BASEDIR/"$MXEDIR"/usr/"$MXEBUILDTYPE"/qt5/qml/QtLocation \
|
|
|
|
$BASEDIR/"$MXEDIR"/usr/"$MXEBUILDTYPE"/qt5/qml/QtPositioning"
|
2017-07-29 20:42:06 +00:00
|
|
|
|
|
|
|
mkdir -p $STAGING_DIR/qml
|
|
|
|
|
|
|
|
for d in $QT_QML_MODULES
|
|
|
|
do
|
|
|
|
cp -a $d $STAGING_DIR/qml
|
|
|
|
done
|
|
|
|
|
2017-07-29 20:41:35 +00:00
|
|
|
# for some reason we aren't installing Qt5Xml.dll and Qt5Location.dll
|
|
|
|
# I need to figure out why and fix that, but for now just manually copy that as well
|
2018-11-14 04:42:52 +00:00
|
|
|
EXTRA_MANUAL_DEPENDENCIES="$BASEDIR/"$MXEDIR"/usr/"$MXEBUILDTYPE"/qt5/bin/Qt5Xml$DLL_SUFFIX.dll \
|
2020-05-30 11:21:22 +00:00
|
|
|
$BASEDIR/"$MXEDIR"/usr/"$MXEBUILDTYPE"/qt5/bin/Qt5Location$DLL_SUFFIX.dll \
|
|
|
|
$BASEDIR/"$MXEDIR"/usr/"$MXEBUILDTYPE"/qt5/bin/Qt5QmlWorkerScript$DLL_SUFFIX.dll"
|
2017-07-29 20:41:35 +00:00
|
|
|
|
2017-03-11 05:06:22 +00:00
|
|
|
for f in $EXTRA_MANUAL_DEPENDENCIES
|
|
|
|
do
|
|
|
|
cp $f $STAGING_DIR
|
|
|
|
cp $f $STAGING_TESTS_DIR
|
|
|
|
done
|
2015-09-22 16:28:36 +00:00
|
|
|
|
2015-09-23 19:25:14 +00:00
|
|
|
cd "$BUILDDIR"/subsurface
|
2014-12-31 18:20:28 +00:00
|
|
|
|
2018-11-14 04:42:52 +00:00
|
|
|
"$MXEBUILDTYPE"-cmake \
|
|
|
|
-DCMAKE_PREFIX_PATH="$BASEDIR"/"$MXEDIR"/usr/"$MXEBUILDTYPE"/qt5 \
|
2017-11-13 23:07:17 +00:00
|
|
|
-DCMAKE_BUILD_TYPE=$RELEASE_MAIN \
|
2018-11-14 04:42:52 +00:00
|
|
|
-DQT_TRANSLATION_DIR="$BASEDIR"/"$MXEDIR"/usr/"$MXEBUILDTYPE"/qt5/translations \
|
|
|
|
-DMAKENSIS="$MXEBUILDTYPE"-makensis \
|
|
|
|
-DLIBDIVECOMPUTER_INCLUDE_DIR="$BASEDIR"/"$MXEDIR"/usr/"$MXEBUILDTYPE"/include \
|
|
|
|
-DLIBDIVECOMPUTER_LIBRARIES="$BASEDIR"/"$MXEDIR"/usr/"$MXEBUILDTYPE"/lib/libdivecomputer.dll.a \
|
2017-09-02 11:39:37 +00:00
|
|
|
-DMAKE_TESTS=OFF \
|
2018-09-30 15:24:55 +00:00
|
|
|
-DBTSUPPORT=ON -DBLESUPPORT=ON \
|
2018-10-07 05:38:29 +00:00
|
|
|
-DFTDISUPPORT=$FTDI \
|
2018-10-07 05:37:35 +00:00
|
|
|
-DLIBGIT2_FROM_PKGCONFIG=ON \
|
2015-12-16 16:14:59 +00:00
|
|
|
"$BASEDIR"/subsurface
|
2015-09-22 04:38:26 +00:00
|
|
|
|
2015-09-23 19:25:14 +00:00
|
|
|
make $JOBS "$@"
|