Skip to content
This repository has been archived by the owner on Sep 11, 2023. It is now read-only.

Latest commit

 

History

History
137 lines (99 loc) · 4.42 KB

Patcher-mingw.md

File metadata and controls

137 lines (99 loc) · 4.42 KB

Building the Patcher for Windows (with mingw-w64)

Environment Setup

If you have docker installed, follow the directions at Docker.md to set up a docker build environment. It includes all the dependencies needed for building DualBootPatcher. With docker, DualBootPatcher can also be built from Windows and Mac hosts. For building the Qt patcher for Windows, you'll need to use the <version>-mingw image.

If you don't have docker installed, the following packages are needed.

Host packages:

  • Android NDK
  • cmake
  • mingw-w64 toolchain

mingw-w64 packages:

  • gtest
  • libarchive
  • OpenSSL
  • qt5
  • yaml-cpp

DualBootPatcher can be natively compiled on Windows or cross-compiled from Linux using mingw-w64.

If you're using Fedora 25, the mingw packages can be found in the official repos and the DualBootPatcher Copr repo: https://copr.fedorainfracloud.org/coprs/chenxiaolong/mingw/.

If you're using Arch Linux, the mingw packages are available in the AUR.

Build process

  1. If you haven't cloned the repo and its submodules yet, follow the directions at Git-Clone.md.

  2. Set the environment variables for the Android NDK path. If you're using the docker image, this step is not needed as the environment variables are already set in the image.

    export ANDROID_NDK_HOME=/path/to/android-ndk
    export ANDROID_NDK=/path/to/android-ndk
  3. If making a release build, make a copy of cmake/SigningConfig.prop.in and edit it to specify the keystore path, keystore passphrase, key alias, and key passphrase.

  4. If cross-compiling from Linux, copy the cmake/toolchain-mingw.cmake.in toolchain file template and modify it to point to the mingw-w64 installation.

    # Set these appropriately for your distro
    
    # For Fedora
    #export MINGW_TRIPLET=$(rpm -E '%{mingw32_target}')
    #export MINGW_ROOT_PATH=$(rpm -E '%{mingw32_prefix}')
    # For Arch Linux
    #export MINGW_TRIPLET=i686-w64-mingw32
    #export MINGW_ROOT_PATH=/usr/${MINGW_TRIPLET}
    
    sed \
        -e "s,@MINGW_TRIPLET@,${MINGW_TRIPLET},g" \
        -e "s,@MINGW_ROOT_PATH@,${MINGW_ROOT_PATH},g" \
        < cmake/toolchain-mingw.cmake.in \
        > cmake/toolchain-mingw.cmake
  5. Configure the build with CMake.

    mkdir build && cd build
    cmake .. -DMBP_BUILD_TARGET=desktop -DMBP_PORTABLE=ON

    If cross-compiling, pass -DCMAKE_TOOLCHAIN_FILE=../cmake/toolchain-mingw.cmake to cmake.

    It is possible to make a non-portable build, but it doesn't make much sense for Windows.

    If you're making a release build, you'll need to pass the -DMBP_BUILD_TYPE=release and -DMBP_SIGN_CONFIG_PATH=<signing config path> arguments. See CMake.md for a complete listing of CMake options.

  6. Build the system components. This includes things like mbtool and odinupdater. The build can be sped up by running things in parallel. Just pass -j<number of cores> (eg. -j4) to make.

    make
  7. Package the patcher.

    If you're making a portable build, use cpack to generate an archive.

    cpack

    Note that the .dll dependencies have to be manually added to the resulting archive in order to be used on other machines.

    For Fedora 25 (and consequently, the mingw docker image), the following script will copy the needed DLLs.

    unzip DualBootPatcher-<version>-win32.zip
    rm DualBootPatcher-<version>-win32.zip
    
    pushd DualBootPatcher-<version>-win32
    
    dlls=(
        iconv.dll
        libarchive-13.dll
        libbz2-1.dll
        libcrypto-10.dll
        libgcc_s_sjlj-1.dll
        libGLESv2.dll
        libglib-2.0-0.dll
        libharfbuzz-0.dll
        libintl-8.dll
        liblz4.dll
        liblzma-5.dll
        libpcre-1.dll
        libpcre16-0.dll
        libpng16-16.dll
        libstdc++-6.dll
        libwinpthread-1.dll
        libxml2-2.dll
        Qt5Core.dll
        Qt5Gui.dll
        Qt5Widgets.dll
        zlib1.dll
    )
    for dll in "${dlls[@]}"; do
        cp "${MINGW_ROOT_PATH}/bin/${dll}" .
    done
    
    # Qt Windows plugin
    mkdir platforms/
    cp "${MINGW_ROOT_PATH}"/lib/qt5/plugins/platforms/qwindows.dll platforms/
    
    # Strip exe's and dll's
    find -name '*.exe' -o -name '*.dll' -exec strip {} \\+
    
    # Optionally, compress executables and libraries (excluding qwindows plugin)
    upx --lzma *.exe *.dll
    
    popd
    zip -r DualBootPatcher-<version>-win32.zip DualBootPatcher-<version>-win32