From 00f911d5dae85451f5226fe8a047b7431301afee Mon Sep 17 00:00:00 2001 From: Cyano Hao Date: Fri, 17 May 2024 09:04:44 +0800 Subject: [PATCH 1/2] require UTF-8 code page to build with MSVC toolchain (#427) --- docs/detailed-build-win-cn.md | 11 +++----- docs/detailed-build-win.md | 11 +++----- packages/windows/vcpkg-win7-2023.08.09.patch | 29 -------------------- 3 files changed, 8 insertions(+), 43 deletions(-) delete mode 100644 packages/windows/vcpkg-win7-2023.08.09.patch diff --git a/docs/detailed-build-win-cn.md b/docs/detailed-build-win-cn.md index 6751fcca..dd0115bf 100644 --- a/docs/detailed-build-win-cn.md +++ b/docs/detailed-build-win-cn.md @@ -56,7 +56,8 @@ qmake 变量: 前置条件: -0. Windows 7 x64 或更高版本。不支持 ARM64。 +0. Windows 10 x64 或更高版本。不支持 ARM64。 + - 对于 MSVC 工具链,Windows 必须使用 Unicode UTF-8 提供全球语言支持。 1. 用 [Qt.io](https://www.qt.io/download-qt-installer-oss) 或[镜像站](https://mirrors.sjtug.sjtu.edu.cn/docs/qt)的在线安装器安装 Qt。 - 选中 Qt 库(“Qt” 组下的 “Qt 5.15.2” 小组,勾选 “MinGW 8.1.0 32-bit” “MinGW 8.1.0 64-bit” “MSVC 2019 32-bit” “MSVC 2019 64-bit” 中的至少一个)。 - 对于 MinGW 工具链,选中相应的工具链(“Qt” 组下的 “Developer and Designer Tools” 小组,“MinGW 8.1.0 32-bit” 或 “MinGW 8.1.0 64-bit”,匹配库的版本)。 @@ -113,15 +114,11 @@ qmake 变量: 前置条件: -0. Windows 7 x64 或更高版本。不支持 ARM64。 - - 在全新安装的 Windows 7 上,依次安装以下组件: - 1. SHA-2 代码签名支持(.NET Framework 4.8 的前置条件), - 2. .NET Framework 4.8(Windows 管理框架 5.1 和 Visual Studio 的前置条件,也是 Git for Windows 的可选依赖), - 3. Windows 管理框架 5.1(vcpkg 自举的前置条件)。 +0. Windows 10 x64 或更高版本。不支持 ARM64。 + - Windows 必须使用 Unicode UTF-8 提供全球语言支持。 1. 安装 Visual Studio 2017 或更高版本,或 “Visual Studio 构建工具 2017” 或更高版本,带有 “使用 C++ 的桌面开发” 工作负载。 - 在 “安装详细信息” 面板,“使用 C++ 的桌面开发” 之下,至少选择一个 “MSVC x86/x64 生成工具” 和一个 Windows SDK。 2. 安装 [vcpkg 的独立版本](https://github.com/microsoft/vcpkg/blob/master/README_zh_CN.md#快速开始-windows)。 - - 截至 2023.08.09,Windows 7 需要[一个补丁](./packages/windows/vcpkg-win7-2023.08.09.patch)以使用兼容的 Python 版本。受影响的文件可能会被修改,所以最好手动修改这些文件。 3. 用 vcpkg 安装 Qt。 ```ps1 $TARGET = "x64-windows-static" # 或 "x86-windows-static" diff --git a/docs/detailed-build-win.md b/docs/detailed-build-win.md index c3d90281..e2c0ebb9 100644 --- a/docs/detailed-build-win.md +++ b/docs/detailed-build-win.md @@ -58,7 +58,8 @@ To build: Prerequisites: -0. Windows 7 x64 or later. ARM64 is not supported. +0. Windows 10 x64 or later. ARM64 is not supported. + - For MSVC toolchain, Windows has to use Unicode UTF-8 for worldwide language support. 1. Install Qt with online installer from [Qt.io](https://www.qt.io/download-qt-installer-oss). - Select the library (in _Qt_ group, _Qt 5.15.2_ subgroup, check at lease one of _MinGW 8.1.0 32-bit_, _MinGW 8.1.0 64-bit_, _MSVC 2019 32-bit_ or _MSVC 2019 64-bit_). - For MinGW toolchain, select the toolchain (in _Qt_ group, _Developer and Designer Tools_ subgroup, check _MinGW 8.1.0 32-bit_ or _MinGW 8.1.0 64-bit_, matching the library). @@ -115,15 +116,11 @@ To build: Prerequisites: -0. Windows 7 x64 or later. ARM64 is not supported. - - For a fresh installation of Windows 7, install following components in order: - 1. SHA-2 code signing support (prerequisite of .NET Framework 4.8), - 2. .NET Framework 4.8 (prerequisite of Windows Management Framework 5.1 and Visual Studio; also optional dependency of Git for Windows), - 3. Windows Management Framework 5.1 (prerequisite of vcpkg bootstrapping). +0. Windows 10 x64 or later. ARM64 is not supported. + - For MSVC toolchain, Windows has to use Unicode UTF-8 for worldwide language support. 1. Install Visual Studio 2017 or later, or Visual Studio Build Tools 2017 or later, with _Desktop Development with C++_ workload. - In _Installation Details_ panel, under the _Desktop Development with C++_ workload, select at least one _MSVC x86/x64 build tools_ and one _Windows SDK_. 2. Install [standalone vcpkg](https://vcpkg.io/en/getting-started). - - As of 2023.08.09, [a patch](./packages/windows/vcpkg-win7-2023.08.09.patch) is required for Windows 7 to use compatible version of Python. Affected files will change over time, so manually edit them to apply the patch. 3. Install Qt with vcpkg. ```ps1 $TARGET = "x64-windows-static" # or "x86-windows-static" diff --git a/packages/windows/vcpkg-win7-2023.08.09.patch b/packages/windows/vcpkg-win7-2023.08.09.patch deleted file mode 100644 index cd9fa37f..00000000 --- a/packages/windows/vcpkg-win7-2023.08.09.patch +++ /dev/null @@ -1,29 +0,0 @@ -diff --git a/scripts/cmake/vcpkg_find_acquire_program(PYTHON3).cmake b/scripts/cmake/vcpkg_find_acquire_program(PYTHON3).cmake -index 6734b0bb6..2900ddf9e 100644 ---- a/scripts/cmake/vcpkg_find_acquire_program(PYTHON3).cmake -+++ b/scripts/cmake/vcpkg_find_acquire_program(PYTHON3).cmake -@@ -1,20 +1,20 @@ - if(CMAKE_HOST_WIN32) - set(program_name python) -- set(program_version 3.11.4) -+ set(program_version 3.8.10) - if(VCPKG_TARGET_ARCHITECTURE STREQUAL "x86") - set(tool_subdirectory "python-${program_version}-x86") - set(download_urls "https://www.python.org/ftp/python/${program_version}/python-${program_version}-embed-win32.zip") - set(download_filename "python-${program_version}-embed-win32.zip") -- set(download_sha512 4cdbb2efdc7764a87edfb7370716c1caf660d38bce37a280ec59b7aecab5672c5798aabe19a8ae395224bea7dfe644bd92656f0bbc44348717981b45a909c024) -+ set(download_sha512 a6f0c35ba37c07c6e8815fb43c20095541117f3b6cc034b8ef0acfc908de8951bdffa38706bac802f820290b39ae84f934f27a8e32f548735f470277f7a70550) - else() - set(tool_subdirectory "python-${program_version}-x64") - set(download_urls "https://www.python.org/ftp/python/${program_version}/python-${program_version}-embed-amd64.zip") - set(download_filename "python-${program_version}-embed-amd64.zip") -- set(download_sha512 3f93c2a16764b9ea6343315b70c0c6319aac8edaefbf4e21206fb30eff365e8fe37264a9133bebe12e664ea5d8fd232d587a5603a51fd96e1252a2fc01a2e550) -+ set(download_sha512 86e55911be78205a61f886feff2195c78a6f158a760cc1697ce4340dcb5ca118360251de2f707b6d2a78b7469d92c87b045b7326d6f194bfa92e665af1cd55a5) - endif() - - set(paths_to_search "${DOWNLOADS}/tools/python/${tool_subdirectory}") -- vcpkg_list(SET post_install_command "${CMAKE_COMMAND}" -E rm python311._pth) -+ vcpkg_list(SET post_install_command "${CMAKE_COMMAND}" -E rm python38._pth) - else() - set(program_name python3) - set(brew_package_name "python") From 01dffbe72efe43207123a783a74f827f2061fb14 Mon Sep 17 00:00:00 2001 From: Cyano Hao Date: Fri, 17 May 2024 15:52:36 +0800 Subject: [PATCH 2/2] update nt5 toolchain (#428) --- .github/workflows/build.yml | 53 +++++++++++++++++-------------------- BUILD.md | 16 +++++++---- BUILD_cn.md | 16 +++++++---- packages/msys/build-xp.sh | 17 ++++-------- 4 files changed, 52 insertions(+), 50 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c25a6240..5d4a2f3b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -50,59 +50,56 @@ jobs: path: pkg/ windows_legacy: - name: Windows NT 5.1–6.0 MinGW + name: Windows NT 5.x strategy: fail-fast: false matrix: - arch: [32, 64] + profile: + - 64-ucrt + - 32-ucrt + - 64-msvcrt + - 32-msvcrt + - 32-win2000 include: - - arch: 32 - vcArch: x86 - - arch: 64 - vcArch: x64 + - isUcrt: 0 + - profile: 64-ucrt + isUcrt: 1 + - profile: 32-ucrt + isUcrt: 1 runs-on: windows-2019 defaults: run: - shell: bash + shell: msys2 {0} env: - _QT_VERSION: "5.15.13" - _QT_NAME: mingw132_${{ matrix.arch }}-redpanda - _REDPANDA_QT_BUILD: "20240428.0" - _MINGW_LITE_RELEASE: "13.2.0-r4" + _REDPANDA_QT_BUILD: "5.15.13+redpanda1" + _QT_NAME: mingw141_${{ matrix.profile }} steps: - uses: actions/checkout@v2 with: fetch-depth: 0 - - name: Setup toolchain - run: | - curl -LO https://github.com/redpanda-cpp/mingw-lite/releases/download/$_MINGW_LITE_RELEASE/mingw${{ matrix.arch }}-ucrt-$_MINGW_LITE_RELEASE.7z - 7z x mingw${{ matrix.arch }}-ucrt-$_MINGW_LITE_RELEASE.7z + - name: Setup + uses: msys2/setup-msys2@v2 + with: + msystem: UCRT64 + update: true + install: mingw-w64-x86_64-7zip mingw-w64-x86_64-cmake mingw-w64-i686-nsis curl git - name: Setup Qt run: | curl -LO https://github.com/redpanda-cpp/qtbase-xp/releases/download/$_REDPANDA_QT_BUILD/$_QT_NAME.7z - 7z x $_QT_NAME.7z -oC:/Qt + /mingw64/bin/7z x $_QT_NAME.7z -oC:/Qt - name: Build run: | - export PATH="/c/Qt/$_QT_VERSION/$_QT_NAME/bin:$PWD/mingw${{ matrix.arch }}/bin:$PATH" - - mkdir build && pushd build - { - qmake PREFIX=$GITHUB_WORKSPACE/pkg $GITHUB_WORKSPACE/Red_Panda_CPP.pro - mingw32-make -j$(nproc) - mingw32-make install - cp "/c/Program Files (x86)/Windows Kits/10/Redist/10.0.22621.0/ucrt/DLLs/${{ matrix.vcArch }}"/*.dll $GITHUB_WORKSPACE/pkg/ - } - popd + ./packages/msys/build-xp.sh -p ${{ matrix.profile }} $( [[ ${{ matrix.isUcrt }} -eq 1 ]] && echo --ucrt 22621 ) - name: Upload uses: actions/upload-artifact@v2 with: - name: Windows NT 5.1–6.0 MinGW - arch=${{ matrix.arch }} - path: pkg/ + name: Windows NT 5.x - profile=${{ matrix.profile }} + path: dist/* windows_msvc_x64: name: Windows MSVC x64 diff --git a/BUILD.md b/BUILD.md index 9726affe..0a636b01 100644 --- a/BUILD.md +++ b/BUILD.md @@ -79,7 +79,7 @@ Extra arguments for `build-mingw.sh`: ## Windows NT 5.x Qt Library with MinGW Lite Toolchain -The script `build-xp.sh` is alike `build-mingw.sh`, but it will download a standalone MinGW Lite toolchain to build Red Panda C++ for Windows NT 5.x. +The script `build-xp.sh` is alike `build-mingw.sh`, but the toolchain is provided by Qt library. Prerequisites: @@ -97,21 +97,27 @@ Prerequisites: ``` C: └─ Qt - └─ 5.15.13 - ├─ mingw141_32-msvcrt-redpanda + └─ 5.15.13+redpanda1 + ├─ mingw141_32-msvcrt │ ├─ bin + │ │ ├─ gcc.exe + │ │ ├─ mingw32-make.exe + │ │ └─ qmake.exe │ ├─ include │ ├─ lib │ └─ ... - └─ mingw141_64-msvcrt-redpanda + └─ mingw141_64-msvcrt ├─ bin + │ ├─ gcc.exe + │ ├─ mingw32-make.exe + │ └─ qmake.exe ├─ include ├─ lib └─ ... ``` - Or you can build from source and specify the path with `--qt` argument. -To build, launch selected MSYS2 environment, run: +To build, launch MSYS2 environment, run: ```bash ./packages/msys/build-xp.sh -p 32-msvcrt ``` diff --git a/BUILD_cn.md b/BUILD_cn.md index 37c896b8..8897bb01 100644 --- a/BUILD_cn.md +++ b/BUILD_cn.md @@ -79,7 +79,7 @@ ## 用于 Windows NT 5.x 的 Qt 库 + MinGW Lite 工具链 -`build-xp.sh` 脚本和 `build-mingw.sh` 类似,但是会下载独立的 MinGW Lite 工具链来构建用于 Windows NT 5.x 的小熊猫C++。 +`build-xp.sh` 脚本和 `build-mingw.sh` 类似,但是工具链由 Qt 库提供。 前置条件: @@ -97,21 +97,27 @@ ``` C: └─ Qt - └─ 5.15.13 - ├─ mingw141_32-msvcrt-redpanda + └─ 5.15.13+redpanda1 + ├─ mingw141_32-msvcrt │ ├─ bin + │ │ ├─ gcc.exe + │ │ ├─ mingw32-make.exe + │ │ └─ qmake.exe │ ├─ include │ ├─ lib │ └─ ... - └─ mingw141_64-msvcrt-redpanda + └─ mingw141_64-msvcrt ├─ bin + │ ├─ gcc.exe + │ ├─ mingw32-make.exe + │ └─ qmake.exe ├─ include ├─ lib └─ ... ``` - 也可以从源代码自行构建 Qt 并在构建时指定 `--qt` 参数。 -要构建此项目,启动所选的 MSYS2 环境,然后运行 +要构建此项目,启动 MSYS2 环境,然后运行 ```bash ./packages/msys/build-xp.sh -p 32-msvcrt ``` diff --git a/packages/msys/build-xp.sh b/packages/msys/build-xp.sh index 8e1b4b98..006314cb 100644 --- a/packages/msys/build-xp.sh +++ b/packages/msys/build-xp.sh @@ -39,8 +39,8 @@ fi PROFILE=$2 shift 2 -QT_VERSION="5.15.13" -QT_NAME="mingw141_${PROFILE}-redpanda" +QT_VERSION="5.15.13+redpanda1" +QT_NAME="mingw141_${PROFILE}" case "${PROFILE}" in 64-ucrt|64-msvcrt) NSIS_ARCH=x64 @@ -161,10 +161,6 @@ 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}" -MINGW_LITE_RELEASE="14.1.0-r1" -HOST_MINGW_ARCHIVE="mingw${PROFILE}-${MINGW_LITE_RELEASE}.7z" -HOST_MINGW_BIT="${PROFILE%%-*}" - REDPANDA_MINGW_RELEASE="11.4.0-r0" MINGW32_ARCHIVE="mingw32-${REDPANDA_MINGW_RELEASE}.7z" MINGW32_COMPILER_NAME="MinGW-w64 i686 GCC" @@ -174,6 +170,7 @@ MINGW64_ARCHIVE="mingw64-${REDPANDA_MINGW_RELEASE}.7z" MINGW64_COMPILER_NAME="MinGW-w64 x86_64 GCC" MINGW64_PACKAGE_SUFFIX="mingw64" +MINGW_LITE_RELEASE="14.1.0-r2" MINGW32_WIN2000_ARCHIVE="mingw32-win2000-${MINGW_LITE_RELEASE}.7z" if [[ ${#compilers[@]} -eq 0 ]]; then @@ -213,6 +210,8 @@ if [[ -n "${UCRT}" && ! -f "${UCRT_DIR}/ucrtbase.dll" ]]; then exit 1 fi +export PATH="${QT_DIR}/bin:${PATH}" + ## prepare dirs if [[ ${CLEAN} -eq 1 ]]; then @@ -243,12 +242,6 @@ if [[ ${COMPILER_MINGW32_WIN2000} -eq 1 && ! -f "${ASSETS_DIR}/${MINGW32_WIN2000 curl -L "https://github.com/redpanda-cpp/mingw-lite/releases/download/${MINGW_LITE_RELEASE}/${MINGW32_WIN2000_ARCHIVE}" -o "${ASSETS_DIR}/${MINGW32_WIN2000_ARCHIVE}" fi -## prepare host compiler - -[[ -f "${ASSETS_DIR}/${HOST_MINGW_ARCHIVE}" ]] || curl -L "https://github.com/redpanda-cpp/mingw-lite/releases/download/${MINGW_LITE_RELEASE}/${HOST_MINGW_ARCHIVE}" -o "${ASSETS_DIR}/${HOST_MINGW_ARCHIVE}" -[[ -x "${BUILD_DIR}/mingw${HOST_MINGW_BIT}/bin/gcc.exe" ]] || "${_7Z}" x "${ASSETS_DIR}/${HOST_MINGW_ARCHIVE}" -o"${BUILD_DIR}" -export PATH="${BUILD_DIR}/mingw${HOST_MINGW_BIT}/bin:${PATH}" - ## build fn_print_progress "Building astyle..." pushd "${ASSETS_DIR}/astyle"