2018-05-02 03:50:28 +08:00
|
|
|
# Cross-compile from Linux to Windows
|
2017-07-25 18:55:40 +08:00
|
|
|
|
|
|
|
## Intro
|
|
|
|
|
2018-05-07 18:09:46 +08:00
|
|
|
Following these instructions you will be able to cross-compile qTox for
|
|
|
|
Windows.
|
2017-07-25 18:55:40 +08:00
|
|
|
|
2018-05-07 18:09:46 +08:00
|
|
|
This script can be used by qTox users and devs to compile qTox for Windows
|
|
|
|
themselves.
|
2017-07-25 18:55:40 +08:00
|
|
|
|
2018-05-07 17:06:08 +08:00
|
|
|
Please note that the compilation script doesn't build the updater.
|
2017-07-25 18:55:40 +08:00
|
|
|
|
|
|
|
## Usage
|
|
|
|
|
2018-05-07 18:09:46 +08:00
|
|
|
[Install Docker](https://docs.docker.com/install).
|
2017-07-25 18:55:40 +08:00
|
|
|
|
2018-05-07 18:38:02 +08:00
|
|
|
Create 2 directories:
|
2017-07-25 18:55:40 +08:00
|
|
|
|
2018-05-02 03:50:28 +08:00
|
|
|
* `workspace` -- a directory that will contain a cache of qTox dependencies
|
|
|
|
and the final qTox cross-compilation build. You should create this directory.
|
2017-07-25 18:55:40 +08:00
|
|
|
|
2018-05-07 18:09:46 +08:00
|
|
|
* `qtox` -- the root directory of a qTox repository. This directory must
|
|
|
|
contain the qTox source code that will be cross-compiled.
|
2018-05-02 03:50:28 +08:00
|
|
|
|
2018-05-07 18:38:02 +08:00
|
|
|
These directories will be mounted inside a Docker container at `/workspace` and
|
|
|
|
`/qtox`.
|
2018-05-02 03:50:28 +08:00
|
|
|
|
2018-05-07 18:38:02 +08:00
|
|
|
> Note:
|
|
|
|
> The contents of `qtox` directory are not modified during compilation. The
|
|
|
|
> `build.sh` script makes a temporary copy of the `qtox` directory for the
|
|
|
|
> compilation.
|
2018-05-02 03:50:28 +08:00
|
|
|
|
2018-05-07 18:09:46 +08:00
|
|
|
Once you sort out the directories, you are ready to run the `build.sh` script
|
|
|
|
in a Docker container.
|
2018-05-02 03:50:28 +08:00
|
|
|
|
2018-05-07 18:09:46 +08:00
|
|
|
> Note:
|
|
|
|
> The`build.sh` script takes 2 arguments: architecture and build type.
|
|
|
|
> Valid values for the architecture are `i686` for 32-bit and `x86_64` for
|
|
|
|
> 64-bit. Valid values for the build type are `release` and `debug`. All
|
|
|
|
> case sensitive.
|
2017-07-25 18:55:40 +08:00
|
|
|
|
2018-05-07 18:09:46 +08:00
|
|
|
To start cross-compiling for 32-bit release version of qTox run:
|
2017-07-25 18:55:40 +08:00
|
|
|
|
|
|
|
```sh
|
|
|
|
sudo docker run --rm \
|
2018-05-07 18:09:46 +08:00
|
|
|
-v /absolute/path/to/your/workspace:/workspace \
|
|
|
|
-v /absolute/path/to/your/qtox:/qtox \
|
|
|
|
debian:stretch-slim \
|
2018-05-07 18:38:02 +08:00
|
|
|
/bin/bash /qtox/windows/cross-compile/build.sh i686 release
|
2017-07-25 18:55:40 +08:00
|
|
|
```
|
|
|
|
|
2018-05-07 18:09:46 +08:00
|
|
|
If you want to debug some compilation issue, you might want to instead run:
|
2017-07-25 18:55:40 +08:00
|
|
|
|
|
|
|
```sh
|
2018-05-07 18:09:46 +08:00
|
|
|
# Get shell inside Debian Stretch container so that you can poke around if needed
|
2017-07-25 18:55:40 +08:00
|
|
|
sudo docker run -it \
|
2018-05-07 18:09:46 +08:00
|
|
|
--rm \
|
|
|
|
-v /absolute/path/to/your/workspace:/workspace \
|
|
|
|
-v /absolute/path/to/your/qtox:/qtox \
|
|
|
|
debian:stretch-slim \
|
|
|
|
/bin/bash
|
|
|
|
# Run the script
|
2018-05-07 18:38:02 +08:00
|
|
|
bash /qtox/windows/cross-compile/build.sh i686 release
|
2017-07-25 18:55:40 +08:00
|
|
|
```
|
2018-05-07 18:09:46 +08:00
|
|
|
|
2018-05-02 03:50:28 +08:00
|
|
|
These will cross-compile all of the qTox dependencies and qTox itself, storing
|
2017-07-25 18:55:40 +08:00
|
|
|
them in the `workspace` directory. The first time you run it for each
|
|
|
|
architecture, it will take a long time for the cross-compilation to finish, as
|
2018-05-07 18:09:46 +08:00
|
|
|
qTox has a lot of dependencies that need to be cross-compiled. But once you do
|
|
|
|
it once for each architecture, the dependencies will get cached inside the
|
|
|
|
`workspace` directory, and the next time you build qTox, the `build.sh` script
|
|
|
|
will skip recompiling them, going straight to compiling qTox, which is a lot
|
|
|
|
faster.
|
2018-05-02 03:50:28 +08:00
|
|
|
|
2018-05-07 18:09:46 +08:00
|
|
|
> Note:
|
|
|
|
> On a certain Intel Core i7 processor, a fresh build takes about 125
|
|
|
|
> minutes on a single core, and about 30 minutes using all 8 hyperthreads.
|
|
|
|
> Once built, however, it takes about 8 minutes on a single core and 2
|
|
|
|
> minutes using 8 hyperthreads to rebuild using the cached dependencies.
|
2018-05-02 03:50:28 +08:00
|
|
|
|
2018-05-07 18:09:46 +08:00
|
|
|
After cross-compiling has finished, you should find the comiled qTox in a
|
2018-05-07 18:38:02 +08:00
|
|
|
`workspace/i686/qtox` or `workspace/x86_64/qtox` directory, depending on the
|
2018-05-07 18:09:46 +08:00
|
|
|
architecture.
|
2018-05-02 03:50:28 +08:00
|
|
|
|
2018-05-07 18:38:02 +08:00
|
|
|
You will also find `workspace/dep-cache` directory, where all the
|
2018-05-07 18:09:46 +08:00
|
|
|
cross-compiled qTox dependencies will be cached for the future builds. You can
|
|
|
|
remove any directory inside the `dep-cache`, which will result in the
|
|
|
|
`build.sh` re-compiling the removed dependency only.
|
2018-05-02 03:50:28 +08:00
|
|
|
|
2018-05-07 18:38:02 +08:00
|
|
|
The `workspace` direcory structure for reference:
|
2017-07-25 18:55:40 +08:00
|
|
|
|
|
|
|
```
|
2018-05-07 18:38:02 +08:00
|
|
|
workspace
|
2017-07-25 18:55:40 +08:00
|
|
|
├── i686
|
2018-05-07 18:09:46 +08:00
|
|
|
│ ├── dep-cache
|
|
|
|
│ │ ├── libexif
|
|
|
|
│ │ ├── libffmpeg
|
|
|
|
│ │ ├── libfilteraudio
|
|
|
|
│ │ ├── libopenal
|
|
|
|
│ │ ├── libopenssl
|
|
|
|
│ │ ├── libopus
|
|
|
|
│ │ ├── libqrencode
|
|
|
|
│ │ ├── libqt5
|
|
|
|
│ │ ├── libsodium
|
|
|
|
│ │ ├── libsqlcipher
|
|
|
|
│ │ ├── libtoxcore
|
|
|
|
│ │ ├── libvpx
|
|
|
|
│ │ ├── mingw-w64-debug-scripts
|
|
|
|
│ │ ├── nsis
|
|
|
|
│ │ └── nsis_shellexecuteasuser
|
|
|
|
│ └── qtox
|
|
|
|
│ ├── debug
|
|
|
|
│ └── release
|
2017-07-25 18:55:40 +08:00
|
|
|
└── x86_64
|
|
|
|
├── dep-cache
|
2018-05-07 18:09:46 +08:00
|
|
|
│ ├── libexif
|
|
|
|
│ ├── libffmpeg
|
|
|
|
│ ├── libfilteraudio
|
|
|
|
│ ├── libopenal
|
|
|
|
│ ├── libopenssl
|
|
|
|
│ ├── libopus
|
|
|
|
│ ├── libqrencode
|
|
|
|
│ ├── libqt5
|
|
|
|
│ ├── libsodium
|
|
|
|
│ ├── libsqlcipher
|
|
|
|
│ ├── libtoxcore
|
|
|
|
│ ├── libvpx
|
|
|
|
│ ├── mingw-w64-debug-scripts
|
|
|
|
│ ├── nsis
|
|
|
|
│ └── nsis_shellexecuteasuser
|
2017-07-25 18:55:40 +08:00
|
|
|
└── qtox
|
|
|
|
├── debug
|
|
|
|
└── release
|
|
|
|
```
|