Skip to content

Commit

Permalink
Merge pull request #8176 from elpaso/mxe-reborn-docker
Browse files Browse the repository at this point in the history
mxe: couldn't be easier now
  • Loading branch information
elpaso committed Oct 13, 2018
2 parents 0816a29 + a2ec75c commit ae397bf
Show file tree
Hide file tree
Showing 6 changed files with 118 additions and 48 deletions.
34 changes: 24 additions & 10 deletions doc/mxe.t2t
@@ -1,26 +1,40 @@

== Building on Linux with mxe ==

With this approach you can build a windows binary on Linux using mxe MXE (M cross environment).
You can find the build script and a README file in the ms-windows/mxe directory.
With this approach you can cross build a Windows binary on Linux using MXE (M cross environment).
You can find the build script and a README.md file in the ms-windows/mxe directory.

For now, Python buildings cannot be built with mxe.

=== Initial setup ===
=== Building with Docker ===

This is the simplest way, but you need to have Docker installed
on your system.

You can use a Docker image to cross build QGIS by calling
the script ms-windows/mxe/build.sh from the root directory of QGIS repository.

=== Building without Docker ====

This requires to install mxe toolchain on your system and build
all dependencies by yourself.

==== Initial setup ====

Please follow the instructions on mxe website to setup your building toolchain http://mxe.cc/,
take note of the path where you have installed mxe.

=== Building the dependencies ===
==== Building the dependencies ====

Please see the README under ms-windows/mxe for a list of the dependencies that need to be
built in mxe before attempting to build QGIS.
Please see README.md under ms-windows/mxe for detailed instructions and for the
list of dependencies that need to be built in mxe before attempting to build QGIS.

=== Cross-Building QGIS ===
==== Cross-Building QGIS ====

Edit the build-mxe.sh script and change the path where your mxe installation is located, you
can also change the build and release directory.
Edit the build-mxe.sh script and optionally adjust the path where your mxe installation is located, you
can also change the build and release directories.

=== Testing QGIS ===

Copy and unzip the release package on a Windows machine and launch it!
Copy and unzip on the Windows machine package produced by the build and launch the qgis binary: no installation
is required.
30 changes: 0 additions & 30 deletions ms-windows/mxe/README

This file was deleted.

51 changes: 51 additions & 0 deletions ms-windows/mxe/README.md
@@ -0,0 +1,51 @@
# MXE cross build

Scripts to cross build a windows QGIS binary from Linux using MXE:
(M cross environment) http://mxe.cc/

The product is a zip file that contains a Windows build of QGIS,
ready to be unzipped on a Windows machine, it does not require
installation, just run the `qgis` binary.

Unfortunately it has some...

## Limitations

- No Python support
- No OpenCL support
- No support for the new native Windows overrides (notifications etc.)

## The easy way (requires docker)

From the main directory of QGIS repo issue the following command:

```
ms-windows/mxe/build.sh
```

## The hard way

Follow the instructions on the website to prepare the mxe environment, you
will need to build all required dependencies for QGIS (or see `mxe.Dockerfile` to get an idea).

The following command will select the posix threads enabled target and install
the dependencies required by QGIS:

```
make MXE_TARGETS=i686-w64-mingw32.shared.posix -j 16 \
qca \
qtlocation \
qscintilla2 \
qwt \
gdal \
qtkeychain \
qtserialport \
qtwebkit \
qtwinextras \
libzip \
gsl \
libspatialindex
```

When done, you can check and edit the `build-mxe.sh` script and set the `MXE` path to your mxe installation directory, `MXE` can also be passed as an environment variable.

17 changes: 9 additions & 8 deletions ms-windows/mxe/build-mxe.sh
Expand Up @@ -19,8 +19,10 @@ set -e

# Usage: you can pass an optional "package" command to skip the build
# and directly go to the packaging
# This script needs to be called from the main QGIS directory, the
# This script needs to be called from the main QGIS directory, the
# one which contains CMakeLists.txt
# The artifact will be saved as a zip package in the directory
# from which this script is launched.

COMMAND=$1

Expand All @@ -32,12 +34,12 @@ PYDEPLOY=${DIR}/deploy.py
# Configuration: change this!

# Location of mxe install dir
MXE=${HOME}/dev/mxe/
MXE=${MXE:-/mxe/}

# Directory for build
BUILD_DIR=$(pwd)/build-mxe
# Directory where the artifact will be saved
RELEASE_DIR=$(pwd)/release-mxe
RELEASE_DIR=$(pwd)/qgis-mxe-release

# End configuration

Expand All @@ -49,10 +51,8 @@ if [[ "$COMMAND" != *"package"* ]]; then
[ -d ${BUILD_DIR} ] && rm -rf ${BUILD_DIR}
[ -d ${RELEASE_DIR} ] && rm -rf ${RELEASE_DIR}
# Make sure dirs exist

[ -d ${BUILD_DIR} ] || mkdir ${BUILD_DIR}
[ -d ${RELEASE_DIR} ] || mkdir ${RELEASE_DIR}

fi

# Patch for 5.11
Expand Down Expand Up @@ -83,7 +83,6 @@ if [[ "$COMMAND" != *"package"* ]]; then
-DQT_LRELEASE_EXECUTABLE=${MXE}/usr/${TARGET}/qt5/bin/lrelease \
$ARGS


make -j16 install

fi
Expand All @@ -105,9 +104,11 @@ __TXT__
# Make the zip

cd ${RELEASE_DIR}/..
ZIP_NAME=mxe-release-$(date +%Y-%m-%d-%H-%I-%S).zip
ZIP_NAME=qgis-mxe-release-$(date +%Y-%m-%d-%H-%I-%S).zip
zip -r ${ZIP_NAME} $(basename ${RELEASE_DIR})
mv ${ZIP_NAME} ${DIR}

# Cleanup
rm -rf ${RELEASE_DIR}

popd

Expand Down
11 changes: 11 additions & 0 deletions ms-windows/mxe/build.sh
@@ -0,0 +1,11 @@
#!/bin/bash

# Location of current script
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

docker run \
-v $(pwd):$(pwd) \
-w $(pwd) --rm \
--user $(id -u):$(id -g) \
-it elpaso/mxe-qt5-builder \
${DIR}/build-mxe.sh
23 changes: 23 additions & 0 deletions ms-windows/mxe/mxe.Dockerfile
@@ -0,0 +1,23 @@
FROM buildpack-deps:stretch

RUN apt-get update
RUN apt-get install -y --no-install-recommends autopoint bison flex gperf libtool ruby scons unzip p7zip-full intltool libtool libtool-bin nsis zip

WORKDIR /mxe

RUN git clone https://github.com/mxe/mxe . || git pull origin master
RUN make MXE_TARGETS=i686-w64-mingw32.shared.posix -j 16 \
qca \
qtlocation \
qscintilla2 \
qwt \
gdal \
qtkeychain \
qtserialport \
qtwebkit \
qtwinextras \
libzip \
gsl \
libspatialindex

RUN chmod -R a+rw /mxe/usr/i686-w64-mingw32.shared.posix

0 comments on commit ae397bf

Please sign in to comment.