Skip to content
Snippets Groups Projects

Create Qt5 runtime archive for GR CI MinGW cross compiling jobs

  • Clone with SSH
  • Clone with HTTPS
  • Embed
  • Share
    The snippet can be accessed without any authentication.
    Authored by Ingo Meyer
    Edited
    create_qt5_runtime_for_windows.sh 2.48 KiB
    #!/bin/bash
    
    
    ########################################################################################################################
    #
    # Script which creates a `qt5-runtime-Windows-i686.tar.gz` or `qt5-runtime-Windows-x86_64.tar.gz` for GR CI jobs
    # (Windows Cross compiling with MinGW).
    #
    ########################################################################################################################
    
    
    DLL_LIST=( \
        "Qt5Core.dll" \
        "Qt5Gui.dll" \
        "Qt5Network.dll" \
        "Qt5Widgets.dll" \
        "d3dcompiler_47.dll" \
        "libGLESv2.dll" \
        "libstdc++-6.dll" \
        "libwinpthread-1.dll" \
    )
    
    LIBGCC_32="libgcc_s_dw2-1.dll"
    LIBGCC_64="libgcc_s_seh-1.dll"
    
    INCLUDE_DIRECTORIES=( \
        "QtCore" \
        "QtGui" \
        "QtNetwork" \
        "QtWidgets" \
    )
    
    PLATFORM_DLL_LIST=( \
        "qwindows.dll" \
    )
    
    
    main () {
        local qt_dir target_dir arch dll_name include_dir_name platform_dll_name
    
        qt_dir="$1"
        target_dir="$2"
        if [[ -z "${qt_dir}" || -z "${target_dir}" ]]; then
            >&2 echo "Usage: $0 qt_dir target_dir"
            return 1
        fi
    
        if [[ -d "${target_dir}" ]]; then
            >&2 echo "The target_dir must not exist yet!"
            return 1
        fi
    
        # Check if `qt_dir` ends with `32`
        if [[ "${qt_dir%32}" != "${qt_dir}" ]]; then
            arch="i686"
        else
            arch="x86_64"
        fi
    
        mkdir "${target_dir}" && \
        for dll_name in "${DLL_LIST[@]}"; do
            cp -v "${qt_dir}/bin/${dll_name}" "${target_dir}/" || return
        done
        if [[ "${arch}" == "i686" ]]; then
            cp -v "${qt_dir}/bin/${LIBGCC_32}" "${target_dir}/" || return
        else
            cp -v "${qt_dir}/bin/${LIBGCC_64}" "${target_dir}/" || return
        fi
    
        mkdir "${target_dir}/include" && \
        for include_dir_name in "${INCLUDE_DIRECTORIES[@]}"; do
            cp -rv "${qt_dir}/include/${include_dir_name}" "${target_dir}/include/" || return
        done
    
        mkdir "${target_dir}/cmake" && \
        curl -fL "https://gr-framework.org/downloads/3rdparty/qt5-runtime-Windows-i686.tar.gz" | \
            tar -Oxzf - "./cmake/FindQt5.cmake" > "${target_dir}/cmake/FindQt5.cmake" || return
    
        mkdir "${target_dir}/platforms" && \
        for platform_dll_name in "${PLATFORM_DLL_LIST[@]}"; do
            cp -v "${qt_dir}/plugins/platforms/${platform_dll_name}" "${target_dir}/platforms/" || return
        done
    
        tar -C"${target_dir}" -czf "${target_dir}/qt5-runtime-Windows-${arch}.tar.gz" \
            $(cd "${target_dir}" && find . -name "*.dll") \
            "cmake" \
            "include" \
            "platforms" || return
    }
    
    main "$@"
    0% Loading or .
    You are about to add 0 people to the discussion. Proceed with caution.
    Finish editing this message first!
    Please register or to comment