diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 09c31c41..2567d227 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -10,14 +10,21 @@ jobs: matrix: msystem: [MINGW32, MINGW64, UCRT64, CLANG64] include: + - isUcrt: false - msystem: MINGW32 packagePrefix: mingw-w64-i686 + _7zPackagePrefix: mingw-w64-x86_64 - msystem: MINGW64 packagePrefix: mingw-w64-x86_64 + _7zPackagePrefix: mingw-w64-x86_64 - msystem: UCRT64 + isUcrt: true packagePrefix: mingw-w64-ucrt-x86_64 + _7zPackagePrefix: mingw-w64-ucrt-x86_64 - msystem: CLANG64 + isUcrt: true packagePrefix: mingw-w64-clang-x86_64 + _7zPackagePrefix: mingw-w64-clang-x86_64 runs-on: windows-latest defaults: run: @@ -33,21 +40,33 @@ jobs: with: msystem: ${{ matrix.msystem }} update: true - install: ${{ matrix.packagePrefix }}-toolchain ${{ matrix.packagePrefix }}-qt5-static + install: | + ${{ matrix.packagePrefix }}-cc + ${{ matrix.packagePrefix }}-make + ${{ matrix.packagePrefix }}-qt5-static + ${{ matrix.packagePrefix }}-cmake + mingw-w64-i686-nsis + ${{ matrix._7zPackagePrefix }}-7zip + git + + - name: Download MinGW toolchain + run: | + mkdir -p assets + curl -L https://github.com/redpanda-cpp/toolchain-win32-mingw-xp/releases/download/11.4.0-r0/mingw32-11.4.0-r0.7z -o assets/mingw32.7z + curl -L https://github.com/redpanda-cpp/toolchain-win32-mingw-xp/releases/download/11.4.0-r0/mingw64-11.4.0-r0.7z -o assets/mingw64.7z - name: Build run: | - mkdir build && pushd build - $MSYSTEM_PREFIX/qt5-static/bin/qmake PREFIX=$GITHUB_WORKSPACE/pkg $GITHUB_WORKSPACE/Red_Panda_CPP.pro - mingw32-make -j$(nproc) - mingw32-make install - popd + ./packages/msys/build-mingw.sh \ + $( [[ ${{ matrix.isUcrt }} -eq 1 ]] && echo --ucrt 22621 ) + ./packages/msys/build-mingw.sh --mingw \ + $( [[ ${{ matrix.isUcrt }} -eq 1 ]] && echo --ucrt 22621 ) - name: Upload uses: actions/upload-artifact@v4 with: name: Windows MSYS2 - msystem=${{ matrix.msystem }} - path: pkg/ + path: dist/ windows_legacy: name: Windows NT 5.x diff --git a/BUILD.md b/BUILD.md index 7f3b155b..61e373be 100644 --- a/BUILD.md +++ b/BUILD.md @@ -35,7 +35,7 @@ See also [more build instructions for Windows](./docs/detailed-build-win.md). ## MSYS2 Qt Library with MinGW Toolchain (Recommended) -Red Panda C++ should work with any MinGW toolchain from MSYS2, including GCCs and Clangs in three GNU-based environments (MINGW32, MINGW64 and UCRT64), and Clangs in three LLVM-based environments (CLANG32, CLANG64 and CLANGARM64; see also [MSYS2’s document](https://www.msys2.org/docs/environments/)), while the following toolchains are frequently tested: +Red Panda C++ should work with any MinGW toolchain from MSYS2, including GCCs and Clangs in three GNU-based environments (MINGW32, MINGW64 and UCRT64), and Clangs in 64-bit LLVM-based environments (CLANG64 and CLANGARM64; see also [MSYS2’s document](https://www.msys2.org/docs/environments/)), while the following toolchains are frequently tested: - MINGW32 GCC, - MINGW64 GCC, - UCRT64 GCC (recommended for x64) @@ -47,13 +47,21 @@ Prerequisites: 0. Windows 10 x64 or later, or Windows 11 ARM64. 1. Install MSYS2. -2. In selected environment, install toolchain, Qt 5 library, and required utils: +2. In selected environment, install toolchain, Qt 5 library, and required utils. For 64-bit: ```bash pacman -S \ - $MINGW_PACKAGE_PREFIX-{toolchain,qt5-static,7zip,cmake} \ + $MINGW_PACKAGE_PREFIX-{cc,make,qt5-static,7zip,cmake} \ mingw-w64-i686-nsis \ git curl ``` + And for 32-bit: + ```bash + pacman -S \ + $MINGW_PACKAGE_PREFIX-{cc,make,qt5-static,cmake} \ + mingw-w64-i686-nsis \ + mingw-w64-x86_64-7zip \ + git curl + ``` To build, launch selected MSYS2 environment, run: ```bash diff --git a/BUILD_cn.md b/BUILD_cn.md index 7f74e53e..25fb6ef3 100644 --- a/BUILD_cn.md +++ b/BUILD_cn.md @@ -35,7 +35,7 @@ ## MSYS2 的 Qt 库 + MinGW 工具链(推荐) -小熊猫C++ 应该能在 MSYS2 的 MinGW 工具链上构建,包括 3 个基于 GNU 的环境(MINGW32、MINGW64、UCRT64)中的 GCC 和 Clang,以及 3 个基于 LLVM 的环境(CLANG32、CLANG64、CLANGARM64)中的 Clang,关于环境的详情可参考 [MSYS2 的文档](https://www.msys2.org/docs/environments/)。以下几个工具链测试较充分: +小熊猫C++ 应该能在 MSYS2 的 MinGW 工具链上构建,包括 3 个基于 GNU 的环境(MINGW32、MINGW64、UCRT64)中的 GCC 和 Clang,以及基于 LLVM 的 64 位环境(CLANG64、CLANGARM64)中的 Clang,关于环境的详情可参考 [MSYS2 的文档](https://www.msys2.org/docs/environments/)。以下几个工具链测试较充分: - MINGW32 GCC, - MINGW64 GCC, - UCRT64 GCC(x64 推荐), @@ -47,13 +47,21 @@ 0. Windows 10 x64 或更高版本,或 Windows 11 ARM64。 1. 安装 MSYS2。 -2. 在所选环境中安装工具链、Qt 5 库、其他所需工具: +2. 在所选环境中安装工具链、Qt 5 库、其他所需工具,64 位: ```bash pacman -S \ - $MINGW_PACKAGE_PREFIX-{toolchain,qt5-static,7zip,cmake} \ + $MINGW_PACKAGE_PREFIX-{cc,make,qt5-static,7zip,cmake} \ mingw-w64-i686-nsis \ git curl ``` + 32 位: + ```bash + pacman -S \ + $MINGW_PACKAGE_PREFIX-{cc,make,qt5-static,cmake} \ + mingw-w64-i686-nsis \ + mingw-w64-x86_64-7zip \ + git curl + ``` 要构建此项目,启动所选的 MSYS2 环境,然后运行 ```bash diff --git a/packages/msys/build-llvm.sh b/packages/msys/build-llvm.sh index dfbb751c..8ae656fd 100644 --- a/packages/msys/build-llvm.sh +++ b/packages/msys/build-llvm.sh @@ -9,7 +9,7 @@ Usage: Options: -h, --help Display this information. -m, --msystem Switch to other MSYS2 environment. - (MINGW32, MINGW64, UCRT64, CLANG32, CLANG64, CLANGARM64) + (MINGW32, MINGW64, UCRT64, CLANG64, CLANGARM64) MUST be used before other options. -c, --clean Clean build and package directories. -nd, --no-deps Skip dependency check. @@ -29,7 +29,7 @@ if [[ $# -gt 1 && ($1 == "-m" || $1 == "--msystem") ]]; then msystem=$2 shift 2 case "${msystem}" in - MINGW32|MINGW64|UCRT64|CLANG32|CLANG64|CLANGARM64) + MINGW32|MINGW64|UCRT64|CLANG64|CLANGARM64) export MSYSTEM="${msystem}" exec /bin/bash --login "$0" "$@" ;; @@ -41,7 +41,10 @@ if [[ $# -gt 1 && ($1 == "-m" || $1 == "--msystem") ]]; then fi case $MSYSTEM in - MINGW32|CLANG32) + MINGW32) + # there is no UCRT32 + # CLANG32 qt5-static removed since 5.15.15 + # https://github.com/msys2/MINGW-packages/commit/ab062c6e5d6e9fff86ee8f88c1d8e9601ea9ab5b _NATIVE_ARCH=i686 _DISPLAY_ARCH=x86 ;; @@ -55,7 +58,7 @@ case $MSYSTEM in ;; *) echo "This script must be run from one of following MSYS2 shells:" - echo " - MINGW32/CLANG32" + echo " - MINGW32" echo " - MINGW64/UCRT64/CLANG64" echo " - CLANGARM64" exit 1 @@ -113,16 +116,9 @@ done function check-deps() { # MSYS2’s `pacman -Q` is 100x slower than Arch Linux. Allow skipping the check. [[ $_SKIP_DEPS_CHECK -eq 1 ]] && return - case $MSYSTEM in - MINGW32|MINGW64|UCRT64) - local compiler=gcc - ;; - CLANG32|CLANG64|CLANGARM64) - local compiler=clang - ;; - esac local deps=( - $MINGW_PACKAGE_PREFIX-{$compiler,make,qt5-static} + $MINGW_PACKAGE_PREFIX-{cc,make,qt5-static} + # always use x86 NSIS to display error message of mismatched architecture mingw-w64-i686-nsis git ) diff --git a/packages/msys/build-mingw.sh b/packages/msys/build-mingw.sh index 380f6e59..5a5291d8 100644 --- a/packages/msys/build-mingw.sh +++ b/packages/msys/build-mingw.sh @@ -10,7 +10,7 @@ function fn_print_help() { Options: -h, --help Display this information. -m, --msystem Switch to other MSYS2 environment. - (MINGW32, MINGW64, UCRT64, CLANG32, CLANG64, CLANGARM64) + (MINGW32, MINGW64, UCRT64, CLANG64, CLANGARM64) MUST be used before other options. -c, --clean Clean build and package directories. --mingw Alias for --mingw32 (x86 app) or --mingw64 (x64 app). @@ -33,7 +33,7 @@ if [[ $# -gt 1 && ($1 == "-m" || $1 == "--msystem") ]]; then msystem=$2 shift 2 case "${msystem}" in - MINGW32|MINGW64|UCRT64|CLANG32|CLANG64|CLANGARM64) + MINGW32|MINGW64|UCRT64|CLANG64|CLANGARM64) export MSYSTEM="${msystem}" exec /bin/bash --login "$0" "$@" ;; @@ -45,7 +45,10 @@ if [[ $# -gt 1 && ($1 == "-m" || $1 == "--msystem") ]]; then fi case "${MSYSTEM}" in - MINGW32|CLANG32) # there is no UCRT32 + MINGW32) + # there is no UCRT32 + # CLANG32 qt5-static removed since 5.15.15 + # https://github.com/msys2/MINGW-packages/commit/ab062c6e5d6e9fff86ee8f88c1d8e9601ea9ab5b NSIS_ARCH=x86 PACKAGE_BASENAME="RedPanda.C++.${APP_VERSION}.win32" ;; @@ -59,7 +62,7 @@ case "${MSYSTEM}" in ;; *) echo "This script must be run in one of the following MSYS2 shells:" - echo " - MINGW32 / CLANG32" + echo " - MINGW32" echo " - MINGW64 / UCRT64 / CLANG64" echo " - CLANGARM64" exit 1 @@ -113,7 +116,7 @@ while [[ $# -gt 0 ]]; do ;; --ucrt) case "${MSYSTEM}" in - CLANG32|UCRT64|CLANG64) + UCRT64|CLANG64) UCRT="$2" shift 2 ;; @@ -151,6 +154,19 @@ SOURCE_DIR="$(pwd)" ASSETS_DIR="${SOURCE_DIR}/assets" UCRT_DIR="/c/Program Files (x86)/Windows Kits/10/Redist/10.0.${UCRT}.0/ucrt/DLLs/${NSIS_ARCH}" +case "${MSYSTEM}" in + MINGW32) + # 32-bit 7zip removed since 24.05 + # https://github.com/msys2/MINGW-packages/commit/de4ea25ca787035cbed50a158bdc200a3776254b + _7Z="/mingw64/bin/7z" + _7Z_PACKAGE_PREFIX="mingw-w64-x86_64" + ;; + MINGW64|UCRT64|CLANG64|CLANGARM64) + _7Z="7z" + _7Z_PACKAGE_PREFIX="${MINGW_PACKAGE_PREFIX}" + ;; +esac + MINGW32_FOLDER="mingw32" MINGW32_ARCHIVE="mingw32.7z" MINGW32_COMPILER_NAME="MinGW-w64 i686 GCC 11.2" @@ -175,19 +191,14 @@ function fn_print_progress() { ## check deps if [[ ${CHECK_DEPS} -eq 1 ]]; then - case "${MSYSTEM}" in - MINGW32|MINGW64|UCRT64) - compiler=gcc - ;; - CLANG32|CLANG64|CLANGARM64) - compiler=clang - ;; - esac deps=( - ${MINGW_PACKAGE_PREFIX}-{$compiler,make,qt5-static,7zip,cmake} + ${MINGW_PACKAGE_PREFIX}-{cc,make,qt5-static,cmake} + # always use x86 NSIS to display error message of mismatched architecture mingw-w64-i686-nsis + ${_7Z_PACKAGE_PREFIX}-7zip git ) + for dep in ${deps[@]}; do pacman -Q ${dep} &>/dev/null || { echo "Missing dependency: ${dep}" @@ -286,14 +297,14 @@ nsis_flags=( if [[ ${COMPILER_MINGW32} -eq 1 ]]; then nsis_flags+=(-DHAVE_MINGW32) if [[ ! -d "mingw32" ]]; then - [[ -f "${SOURCE_DIR}/assets/${MINGW32_ARCHIVE}" ]] && 7z x "${SOURCE_DIR}/assets/${MINGW32_ARCHIVE}" -o"${PACKAGE_DIR}" + [[ -f "${SOURCE_DIR}/assets/${MINGW32_ARCHIVE}" ]] && "${_7Z}" x "${SOURCE_DIR}/assets/${MINGW32_ARCHIVE}" -o"${PACKAGE_DIR}" [[ -d "${SOURCE_DIR}/assets/${MINGW32_FOLDER}" ]] && cp -a --dereference "${SOURCE_DIR}/assets/${MINGW32_FOLDER}" "${PACKAGE_DIR}" fi fi if [[ ${COMPILER_MINGW64} -eq 1 ]]; then nsis_flags+=(-DHAVE_MINGW64) if [[ ! -d "mingw64" ]]; then - [[ -f "${SOURCE_DIR}/assets/${MINGW64_ARCHIVE}" ]] && 7z x "${SOURCE_DIR}/assets/${MINGW64_ARCHIVE}" -o"${PACKAGE_DIR}" + [[ -f "${SOURCE_DIR}/assets/${MINGW64_ARCHIVE}" ]] && "${_7Z}" x "${SOURCE_DIR}/assets/${MINGW64_ARCHIVE}" -o"${PACKAGE_DIR}" [[ -d "${SOURCE_DIR}/assets/${MINGW64_FOLDER}" ]] && cp -a --dereference "${SOURCE_DIR}/assets/${MINGW64_FOLDER}" "${PACKAGE_DIR}" fi fi @@ -307,8 +318,8 @@ fi "${NSIS}" "${nsis_flags[@]}" redpanda.nsi fn_print_progress "Making Portable Package..." -7z x "${SETUP_NAME}" -o"RedPanda-CPP" -xr'!$PLUGINSDIR' -x"!uninstall.exe" -7z a -mmt -mx9 -ms=on -mqs=on -mf=BCJ2 "${PORTABLE_NAME}" "RedPanda-CPP" +"${_7Z}" x "${SETUP_NAME}" -o"RedPanda-CPP" -xr'!$PLUGINSDIR' -x"!uninstall.exe" +"${_7Z}" a -mmt -mx9 -ms=on -mqs=on -mf=BCJ2 "${PORTABLE_NAME}" "RedPanda-CPP" rm -rf "RedPanda-CPP" mv "${SETUP_NAME}" "${TARGET_DIR}"