summaryrefslogtreecommitdiffstats
path: root/packaging/windows/smtk2ssrf-mxe-build.sh
diff options
context:
space:
mode:
authorGravatar Salvador Cuñat <salvador.cunat@gmail.com>2018-02-15 21:45:58 +0100
committerGravatar Dirk Hohndel <dirk@hohndel.org>2018-02-24 13:42:01 -0800
commitf6cee2ca7ebcad011b5109b2679f14d60852b50f (patch)
tree446b25c43e369da8c4ce74bd2b1d0e3d1d650515 /packaging/windows/smtk2ssrf-mxe-build.sh
parentd303a589e682857f83d8c3ec5ea09a35bc00e7dd (diff)
downloadsubsurface-f6cee2ca7ebcad011b5109b2679f14d60852b50f.tar.gz
smtk-import: add windows building to travis-ci
Prepare the building script to suport travis or set other automated builds, while keeping other options to manual builds. In before_install script, create needed directories, and dowload mdbtools sources. Add smtk2ssrf build script to travisbuild.sh Signed-off-by: Salvador Cuñat <salvador.cunat@gmail.com>
Diffstat (limited to 'packaging/windows/smtk2ssrf-mxe-build.sh')
-rwxr-xr-xpackaging/windows/smtk2ssrf-mxe-build.sh105
1 files changed, 57 insertions, 48 deletions
diff --git a/packaging/windows/smtk2ssrf-mxe-build.sh b/packaging/windows/smtk2ssrf-mxe-build.sh
index 126dd1bd2..5253490f7 100755
--- a/packaging/windows/smtk2ssrf-mxe-build.sh
+++ b/packaging/windows/smtk2ssrf-mxe-build.sh
@@ -5,16 +5,25 @@
# the source tree and, please, refer to said script for instructions on how to
# build.
#
-# Subsurface *MUST* have been built before running that script, as the importer
+# Subsurface *MUST* have been built before running this script, as the importer
# links against libsubsurface_corelib.a library.
# Although is possible to build the latest git version of the importer against
# whichever other version of subsurface, this should be avoided, and both
# versions, subsurface and smtk-import should be the same.
#
# Flags and options:
+# -a (--auto): Mark the buils as "automatic". This assumes we are building
+# in a automated environment (e.g. travis-ci) and doesn't try
+# to change the git tag or repo. -t and -r flags are useless
+# if -a has been set. Building in travis-ci is detected and so
+# the flag is not necessary there.
# -i (--installer): Packs a windows installer. This should always be used.
# -t (--tag): Defines which git version we want to build. Defaults to
# latest. E.g. -t v4.6.4
+# -r (--repo): Set the repo you want to target for the build. If you are
+# working on a github fork, you will usually have an "origin"
+# and a "fork" repo, this enables choosing which repo you want
+# to pull from.
# -b (--build): Values: debug or release. Defines the build we want to do.
# -d (--dir): Specify a directory where a copy of the installer will be
# placed. This is a *must* if the script runs in a VM, and
@@ -22,13 +31,18 @@
#
# Examples: (provided Subsurface has been previously cross built)
#
+# For most pourposes, including travis builds, just
+# smtk2ssrf-mxe-build.sh -i
+# should be used.
+#
# smtk2ssrf-mxe-build.sh -i -t master
-# This will build an release installer of smtk2ssrf placed in a directory under
+# This will build a release installer of smtk2ssrf placed in a directory under
# the win-build directory where it has been launched, named smtk-import. It will
# build git latest master regardless of subsurface's cross built version.
#
# smtk2ssrf-mxe-build.sh -b debug
# This will build *just* a windows binary (no packing) of the latest master.
+# Use with care, this flag *must* match subsurface's build one.
#
# smtk2ssrf-mxe-build.sh -i -t v4.6.4 -b relase -d /mnt/data
# As I'm building in a fedora-25 docker VM, this should bring up a release
@@ -49,6 +63,7 @@ DEFAULT="\033[0m"
SSRF_TAG=""
RELEASE="Release"
+AUTO="${TRAVIS:-false}"
# this is important, if we are building in a VM or if we want to get a copy
# of the installer elsewhere out of the building tree.
@@ -84,10 +99,12 @@ echo -e "$BLUE---> Building in$LIGHT_GRAY $BUILDDIR ...$DEFAULT"
# check for arguments and set options
if [ $# -eq 0 ]; then
echo -e "$BLUE---> No arguments given."
- echo -e "---> Building actual git commit and Release type without installer $DEFAULT"
+ echo -e "---> Building current git commit and Release type without installer $DEFAULT"
else
while [ $# -gt 0 ]; do
case $1 in
+ -a|--auto) AUTO="true"
+ ;;
-t|--tag) SSRF_TAG="$2"
shift;;
-i|--installer) INSTALLER="installer"
@@ -101,7 +118,7 @@ else
esac
shift
done
- echo -e "$BLUE---> Subsurface tagged to:$LIGHT_GRAY $SSRF_TAG"
+ echo -e "$BLUE---> Subsurface tagged to:$LIGHT_GRAY ${SSRF_TAG:-latest}"
echo -e "$BLUE---> Building type:$LIGHT_GRAY $RELEASE"
echo -e "$BLUE---> Installer set to:$LIGHT_GRAY $INSTALLER $DEFAULT"
fi
@@ -126,44 +143,44 @@ export PKG_CONFIG_PATH="$PKG_CONFIG_PATH_i686_w64_mingw32_static":"$PKG_CONFIG_P
#
# mdbtools
+# build from sources. If build fails, fallback to prebuilt mxe binaries.
#
-if [ ! -f "$BASEDIR"/mxe/usr/i686-w64-mingw32.static/lib/libmdb.a ]; then
- echo -e "$BLUE---> Building mdbtools ... $DEFAULT "
- mkdir -p --verbose "$BASEDIR"/mxe/usr/i686-w64-mingw32.static/include
- mkdir -p --verbose "$BASEDIR"/mxe/usr/i686-w64-mingw32.static/lib
- cd "$BUILDDIR"
- [[ -d mdbtools ]] && rm -rf mdbtools
- mkdir -p mdbtools
- cd mdbtools
- if [ ! -f "$BASEDIR"/mdbtools/configure ] ; then
- ( cd "$BASEDIR"/mdbtools
- autoreconf -v -f -i )
- fi
- "$BASEDIR"/mdbtools/configure --host=i686-w64-mingw32.static \
- --srcdir="$BASEDIR"/mdbtools \
- --prefix="$BASEDIR"/mxe/usr/i686-w64-mingw32.static \
- --enable-shared \
- --disable-man \
- --disable-gmdb2
- make $JOBS >/dev/null || aborting "Building mdbtools failed."
- make install
-else
- echo -e "$BLUE---> Prebuilt mxe mdbtools ... $DEFAULT"
+echo -e "$BLUE---> Building mdbtools ... $DEFAULT "
+mkdir -p --verbose "$BASEDIR"/mxe/usr/i686-w64-mingw32.static/include
+mkdir -p --verbose "$BASEDIR"/mxe/usr/i686-w64-mingw32.static/lib
+cd "$BUILDDIR"
+[[ -d mdbtools ]] && rm -rf mdbtools
+mkdir -p mdbtools
+cd mdbtools
+if [ ! -f "$BASEDIR"/mdbtools/configure ] ; then
+ ( cd "$BASEDIR"/mdbtools
+ autoreconf -v -f -i )
fi
+"$BASEDIR"/mdbtools/configure CC=i686-w64-mingw32.static-gcc \
+ --host=i686-w64-mingw32.static \
+ --prefix="$BASEDIR"/mxe/usr/i686-w64-mingw32.static \
+ --enable-shared=no \
+ --disable-man \
+ --disable-gmdb2
+make $JOBS >/dev/null && make install || \
+ echo -e "$RED---> Building mdbtools failed ...$LIGHT_GRAY Trying to build with precompiled mxe binaries$DEFAULT"
# Subsurface
#
-cd "$BASEDIR/subsurface"
-git reset --hard master && echo -e "$BLUE---> Uncommited changes to Subsurface (if any) dropped$DEFAULT"
-if [ ! -z "$GITREPO" ]; then
- git pull --rebase "$GITREPO" master || aborting "git pull failed, Subsurface not updated"
-else
- git pull --rebase || aborting "git pull failed, Subsurface not updated"
-fi
-echo -e "$BLUE---> Subsurface updated$DEFAULT"
+if [ "$AUTO" = "false" ]; then
+ cd "$BASEDIR/subsurface"
+ git reset --hard master && echo -e "$BLUE---> Uncommited changes to Subsurface (if any) dropped$DEFAULT"
+ git checkout master
+ if [ ! -z "$GITREPO" ]; then
+ git pull --rebase "$GITREPO" master || aborting "git pull failed, Subsurface not updated"
+ else
+ git pull --rebase || aborting "git pull failed, Subsurface not updated"
+ fi
+ echo -e "$BLUE---> Subsurface updated$DEFAULT"
-if [ "$SSRF_TAG" != "" ]; then
- git checkout "$SSRF_TAG" || aborting "Failed to checkout Subsurface's $SSRF_TAG."
+ if [ "$SSRF_TAG" != "" ]; then
+ git checkout "$SSRF_TAG" || aborting "Failed to checkout Subsurface's $SSRF_TAG."
+ fi
fi
# Every thing is ok. Go on.
@@ -188,24 +205,20 @@ mkdir -p "$STAGING_DIR"/plugins
for d in $QT_PLUGIN_DIRECTORIES
do
- cp -a "$d" "$STAGING_DIR"/plugins
+ [[ -d $d ]] && cp -a "$d" "$STAGING_DIR"/plugins
done
for f in $EXTRA_MANUAL_DEPENDENCIES
do
- cp "$f" "$STAGING_DIR"
+ [[ -f $f ]] && cp "$f" "$STAGING_DIR"
done
-# this is absolutely hackish, but necessary. Libmdb (built or prebuilt) is linked against
-# shared glib-2.0, but once and again we are trying to link against static lib.
-mv -vf "$BASEDIR"/mxe/usr/i686-w64-mingw32.static/lib/libglib-2.0.a "$BASEDIR"/mxe/usr/i686-w64-mingw32.static/lib/libglib-2.0.a.bak || \
- echo -e "$BLUE------> libglib-2.0.a had been moved in a previous run$DEFAULT"
-
cd "$BUILDDIR"/smtk-import
mkdir -p staging
echo -e "$BLUE---> Building CMakeCache.txt$DEFAULT"
-cmake -DCMAKE_TOOLCHAIN_FILE="$BASEDIR"/mxe/usr/i686-w64-mingw32.shared/share/cmake/mxe-conf.cmake \
+i686-w64-mingw32.shared-cmake \
+ -DCMAKE_TOOLCHAIN_FILE="$BASEDIR"/mxe/usr/i686-w64-mingw32.shared/share/cmake/mxe-conf.cmake \
-DPKG_CONFIG_EXECUTABLE="/usr/bin/pkg-config" \
-DCMAKE_PREFIX_PATH="$BASEDIR"/mxe/usr/i686-w64-mingw32.shared/qt5 \
-DCMAKE_BUILD_TYPE=$RELEASE \
@@ -220,10 +233,6 @@ else
make "$JOBS"
fi
-# Undo previous hackery
-echo -e "$BLUE---> Restoring system to initial state$DEFAULT"
-mv -vf "$BASEDIR"/mxe/usr/i686-w64-mingw32.static/lib/libglib-2.0.a.bak "$BASEDIR"/mxe/usr/i686-w64-mingw32.static/lib/libglib-2.0.a
-
if [ ! -z "$DATADIR" ]; then
echo -e "$BLUE---> Copying Smtk2ssrf installer to data folder$DEFAULT"
cp -vf "$BUILDDIR"/smtk-import/smtk2ssrf-*.exe "$DATADIR"