Skip to content

Commit ae397bf

Browse files
authoredOct 13, 2018
Merge pull request #8176 from elpaso/mxe-reborn-docker
mxe: couldn't be easier now
2 parents 0816a29 + a2ec75c commit ae397bf

File tree

6 files changed

+118
-48
lines changed

6 files changed

+118
-48
lines changed
 

‎doc/mxe.t2t

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,40 @@
11

22
== Building on Linux with mxe ==
33

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

77
For now, Python buildings cannot be built with mxe.
88

9-
=== Initial setup ===
9+
=== Building with Docker ===
10+
11+
This is the simplest way, but you need to have Docker installed
12+
on your system.
13+
14+
You can use a Docker image to cross build QGIS by calling
15+
the script ms-windows/mxe/build.sh from the root directory of QGIS repository.
16+
17+
=== Building without Docker ====
18+
19+
This requires to install mxe toolchain on your system and build
20+
all dependencies by yourself.
21+
22+
==== Initial setup ====
1023

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

14-
=== Building the dependencies ===
27+
==== Building the dependencies ====
1528

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

19-
=== Cross-Building QGIS ===
32+
==== Cross-Building QGIS ====
2033

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

2437
=== Testing QGIS ===
2538

26-
Copy and unzip the release package on a Windows machine and launch it!
39+
Copy and unzip on the Windows machine package produced by the build and launch the qgis binary: no installation
40+
is required.

‎ms-windows/mxe/README

Lines changed: 0 additions & 30 deletions
This file was deleted.

‎ms-windows/mxe/README.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# MXE cross build
2+
3+
Scripts to cross build a windows QGIS binary from Linux using MXE:
4+
(M cross environment) http://mxe.cc/
5+
6+
The product is a zip file that contains a Windows build of QGIS,
7+
ready to be unzipped on a Windows machine, it does not require
8+
installation, just run the `qgis` binary.
9+
10+
Unfortunately it has some...
11+
12+
## Limitations
13+
14+
- No Python support
15+
- No OpenCL support
16+
- No support for the new native Windows overrides (notifications etc.)
17+
18+
## The easy way (requires docker)
19+
20+
From the main directory of QGIS repo issue the following command:
21+
22+
```
23+
ms-windows/mxe/build.sh
24+
```
25+
26+
## The hard way
27+
28+
Follow the instructions on the website to prepare the mxe environment, you
29+
will need to build all required dependencies for QGIS (or see `mxe.Dockerfile` to get an idea).
30+
31+
The following command will select the posix threads enabled target and install
32+
the dependencies required by QGIS:
33+
34+
```
35+
make MXE_TARGETS=i686-w64-mingw32.shared.posix -j 16 \
36+
qca \
37+
qtlocation \
38+
qscintilla2 \
39+
qwt \
40+
gdal \
41+
qtkeychain \
42+
qtserialport \
43+
qtwebkit \
44+
qtwinextras \
45+
libzip \
46+
gsl \
47+
libspatialindex
48+
```
49+
50+
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.
51+

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

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,10 @@ set -e
1919

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

2527
COMMAND=$1
2628

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

3436
# Location of mxe install dir
35-
MXE=${HOME}/dev/mxe/
37+
MXE=${MXE:-/mxe/}
3638

3739
# Directory for build
3840
BUILD_DIR=$(pwd)/build-mxe
3941
# Directory where the artifact will be saved
40-
RELEASE_DIR=$(pwd)/release-mxe
42+
RELEASE_DIR=$(pwd)/qgis-mxe-release
4143

4244
# End configuration
4345

@@ -49,10 +51,8 @@ if [[ "$COMMAND" != *"package"* ]]; then
4951
[ -d ${BUILD_DIR} ] && rm -rf ${BUILD_DIR}
5052
[ -d ${RELEASE_DIR} ] && rm -rf ${RELEASE_DIR}
5153
# Make sure dirs exist
52-
5354
[ -d ${BUILD_DIR} ] || mkdir ${BUILD_DIR}
5455
[ -d ${RELEASE_DIR} ] || mkdir ${RELEASE_DIR}
55-
5656
fi
5757

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

86-
8786
make -j16 install
8887

8988
fi
@@ -105,9 +104,11 @@ __TXT__
105104
# Make the zip
106105

107106
cd ${RELEASE_DIR}/..
108-
ZIP_NAME=mxe-release-$(date +%Y-%m-%d-%H-%I-%S).zip
107+
ZIP_NAME=qgis-mxe-release-$(date +%Y-%m-%d-%H-%I-%S).zip
109108
zip -r ${ZIP_NAME} $(basename ${RELEASE_DIR})
110-
mv ${ZIP_NAME} ${DIR}
109+
110+
# Cleanup
111+
rm -rf ${RELEASE_DIR}
111112

112113
popd
113114

‎ms-windows/mxe/build.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/bash
2+
3+
# Location of current script
4+
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
5+
6+
docker run \
7+
-v $(pwd):$(pwd) \
8+
-w $(pwd) --rm \
9+
--user $(id -u):$(id -g) \
10+
-it elpaso/mxe-qt5-builder \
11+
${DIR}/build-mxe.sh

‎ms-windows/mxe/mxe.Dockerfile

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
FROM buildpack-deps:stretch
2+
3+
RUN apt-get update
4+
RUN apt-get install -y --no-install-recommends autopoint bison flex gperf libtool ruby scons unzip p7zip-full intltool libtool libtool-bin nsis zip
5+
6+
WORKDIR /mxe
7+
8+
RUN git clone https://github.com/mxe/mxe . || git pull origin master
9+
RUN make MXE_TARGETS=i686-w64-mingw32.shared.posix -j 16 \
10+
qca \
11+
qtlocation \
12+
qscintilla2 \
13+
qwt \
14+
gdal \
15+
qtkeychain \
16+
qtserialport \
17+
qtwebkit \
18+
qtwinextras \
19+
libzip \
20+
gsl \
21+
libspatialindex
22+
23+
RUN chmod -R a+rw /mxe/usr/i686-w64-mingw32.shared.posix

0 commit comments

Comments
 (0)
Please sign in to comment.