From 6359000c85efe5e0d438c32f34d5d97b45a023bd Mon Sep 17 00:00:00 2001 From: Cyano Hao Date: Sun, 28 Apr 2024 16:47:35 +0800 Subject: [PATCH] update docs (#404) --- BUILD.md | 250 ++++++------------- BUILD_cn.md | 250 ++++++------------- docs/detailed-build-win-cn.md | 184 ++++++++++++++ docs/detailed-build-win.md | 186 ++++++++++++++ packages/windows/build-qt5.6-mingw-static.sh | 127 ---------- 5 files changed, 522 insertions(+), 475 deletions(-) create mode 100644 docs/detailed-build-win-cn.md create mode 100644 docs/detailed-build-win.md delete mode 100644 packages/windows/build-qt5.6-mingw-static.sh diff --git a/BUILD.md b/BUILD.md index 1d1800cd..697a3986 100644 --- a/BUILD.md +++ b/BUILD.md @@ -25,40 +25,13 @@ To setup development environment in Visual Studio Code: # Windows -For Windows 7 or later: - | Library + Toolchain \ Target | x86 | x64 | ARM64 | | ---------------------------- | --- | --- | ----- | | MSYS2 + GNU-based MinGW | ✔️ | ✔️ | ❌ | | MSYS2 + LLVM-based MinGW | ✔️ | ✔️ | ✔️ | -| Qt.io + MinGW | ✔️ | ✔️ | ❌ | -| Qt.io + MSVC | ✔️ | ✔️ | ❌ | -| vcpkg + MSVC | ✔️ | ✔️ | ❌ | +| [Windows XP](https://github.com/redpanda-cpp/qtbase-xp) + [MinGW UCRT](https://github.com/redpanda-cpp/mingw-lite) | ✔️ | ✔️ | ❌ | -qmake variables: -- `PREFIX`: where `$MAKE install` installs files to. -- `WINDOWS_PREFER_OPENCONSOLE=ON` (make phase): prefer UTF-8 compatible `OpenConsole.exe`. - - `OpenConsole.exe` is a part of Windows Terminal. UTF-8 input support was added in version 1.18. - - `OpenConsole.exe` requires ConPTY, which was introduced in Windows 10 1809. - -Notes for Windows on ARM: -- Red Panda C++ can be built for ARM64 ABI only on Windows 11 ARM64, while it is supposed (but not tested) to run on Windows 10 ARM64. - - ARM64EC (“emulation compatible”) host is not supported, i.e., Red Panda C++ cannot be built with ARM64EC toolchain. - - ARM64EC target is (theoretically) supported, i.e. Red Panda C++ will build ARM64EC binaries if upstream toolchain supports ARM64EC. -- With the [ARM32 deprecation in Windows 11 Insider Preview Build 25905](https://blogs.windows.com/windows-insider/2023/07/12/announcing-windows-11-insider-preview-build-25905/), ARM32 support will never be added. - -For legacy Windows (NT 5.1 – 6.0): - -| Library + Toolchain \ Target | x86 | x64 | -| ---------------------------- | --- | --- | -| Qt 5.6 from [patched source](https://github.com/redpanda-cpp/qtbase-5.6) + MinGW | ✔️ | ✔️ | - -Notes for legacy Windows: -- Supported Windows versions: - - Windows XP SP3 or later; - - Windows Server 2003 x64 Edition (a.k.a. Windows XP x64 Edition) SP2 or later. -- Windows 7 x64 or later required as build host. -- Here is [a script](packages/windows/build-qt5.6-mingw-static.sh) for building Qt 5.6 from source alongside official Qt installation (with Qt.io MinGW GCC 8.1.0). +See also [more build instructions for Windows](./docs/detailed-build-win.md). ## MSYS2 Qt Library with MinGW Toolchain (Recommended) @@ -72,163 +45,92 @@ Official distributions of Red Panda C++ are built with MINGW32 GCC and MINGW64 G Prerequisites: -0. Windows 8.1 x64 or later, or Windows 11 ARM64. +0. Windows 10 x64 or later, or Windows 11 ARM64. 1. Install MSYS2. -2. In selected environment, install toolchain and Qt 5 library: +2. In selected environment, install toolchain, Qt 5 library, and required utils: ```bash - pacman -S $MINGW_PACKAGE_PREFIX-toolchain $MINGW_PACKAGE_PREFIX-qt5-static + pacman -S \ + $MINGW_PACKAGE_PREFIX-{toolchain,qt5-static,7zip,cmake} \ + mingw-w64-i686-nsis \ + git curl ``` -To build: +To build, launch selected MSYS2 environment, run: +```bash +./packages/msys/build-mingw.sh +``` +to build Red Panda C++ installer and portable package with MinGW GCC toolchain or without compiler; and +```bash +./packages/msys/build-llvm.sh +``` +to build Red Panda C++ installer with LLVM MinGW toolchain. -1. In selected environment, set related variables: - ```bash - SRC_DIR="/c/src/redpanda-src" # “C:\src\redpanda-src” for example - BUILD_DIR="/c/src/redpanda-build" # “C:\src\redpanda-build” for example - INSTALL_DIR="/c/src/redpanda-pkg" # “C:\src\redpanda-pkg” for example - ``` -2. Navigate to build directory: - ```bash - rm -rf "$BUILD_DIR" # optional for clean build - mkdir -p "$BUILD_DIR" && cd "$BUILD_DIR" - ``` -3. Configure, build and install: - ```bash - $MSYSTEM_PREFIX/qt5-static/bin/qmake PREFIX="$INSTALL_DIR" "$SRC_DIR/Red_Panda_CPP.pro" - mingw32-make -j$(nproc) - mingw32-make install - ``` +Common arguments: +- `-h`, `--help`: show help message. +- `-c`, `--clean`: clean build directory. +- `-nd`, `--no-deps`: do not check dependencies. +- `-t `, `--target-dir `: set target directory for the packages. Default: `dist/`. -## Qt.io Qt Library with MinGW Toolchain or MSVC Toolchain +Extra arguments for `build-mingw.sh`: +- `--mingw32`: add `assets/mingw32.7z` to the package. +- `--mingw64`: add `assets/mingw64.7z` to the package. +- `--mingw`: alias for `--mingw32` (x86 app) or `--mingw64` (x64 app). +- `--ucrt `: add UCRT runtime from Windows SDK to the package. e.g. `--ucrt 22621` for Windows 11 SDK 22H2. + +## Windows XP Qt Library with MinGW UCRT Toolchain + +The script `build-xp.sh` is alike `build-mingw.sh`, but it will download a standalone MinGW UCRT toolchain to build Red Panda C++ for Windows XP, according to current MSYS2 environment: +- MINGW32/CLANG32: build x86 app; +- MINGW64/UCRT64/CLANG64: build x64 app. Prerequisites: -0. Windows 7 x64 or later. ARM64 is not supported. -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). - - Optionally select Qt Creator (in _Qt_ group, _Developer and Designer Tools_ subgroup; recomended for MSVC toolchain for parallel build support). -2. For MSVC toolchain, install Visual Studio 2019 or later, or Visual Studio Build Tools 2019 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_. +0. Windows 10 x64 or later. +1. Install MSYS2. +2. In selected environment, install required utils: + ```bash + pacman -S \ + $MINGW_PACKAGE_PREFIX-{7zip,cmake} \ + mingw-w64-i686-nsis \ + git curl + ``` +3. Download [Windows XP Qt Library](https://github.com/redpanda-cpp/qtbase-xp) and extract to `C:/Qt`. + - The directory structure should be like + ``` + C: + └─ Qt + └─ 5.15.13 + ├─ mingw132_32-redpanda + │ ├─ bin + │ ├─ include + │ ├─ lib + │ └─ ... + └─ mingw132_64-redpanda + ├─ bin + ├─ include + ├─ lib + └─ ... + ``` + - Or you can build from source and specify the path with `--qt` argument. +4. Install Windows 11 SDK 22H2 for UCRT runtime. -To build: +To build, launch selected MSYS2 environment, run: +```bash +./packages/msys/build-xp.sh --ucrt 22621 +``` -1. Launch Qt environment from Start Menu. -2. In Qt environment, set related variables: - ```bat - rem no quotes even if path contains spaces - set SRC_DIR=C:\src\redpanda-src - set BUILD_DIR=C:\src\redpanda-build - set INSTALL_DIR=C:\src\redpanda-pkg - rem for MSVC toolchain - set VS_INSTALL_PATH=C:\Program Files\Microsoft Visual Studio\2022\Community - rem for MSVC toolchain; or x86 - set VC_ARCH=amd64 - rem for MSVC toolchain; keep unset if Qt Creator is not installed - set QT_CREATOR_DIR=C:\Qt\Tools\QtCreator - ``` -3. Navigate to build directory: - ```bat - rem optional for clean build - rmdir /s /q "%BUILD_DIR%" - mkdir "%BUILD_DIR%" && cd /d "%BUILD_DIR%" - ``` -4. Configure, build and install. For MinGW toolchain: - ```bat - qmake PREFIX="%INSTALL_DIR%" "%SRC_DIR%\Red_Panda_CPP.pro" - mingw32-make -j%NUMBER_OF_PROCESSORS% - mingw32-make install - windeployqt "%INSTALL_DIR%\RedPandaIDE.exe" - ``` - For MSVC toolchain: - ```bat - call "%VS_INSTALL_PATH%\Common7\Tools\VsDevCmd.bat" -arch=%VC_ARCH% - qmake PREFIX="%INSTALL_DIR%" "%SRC_DIR%\Red_Panda_CPP.pro" +This script accepts the same arguments as `build-mingw.sh`, plus: +- `--qt `: set Qt directory. e.g. `--qt /d/myqt-32`. - set JOM=%QT_CREATOR_DIR%\bin\jom\jom.exe - if "%QT_CREATOR_DIR%" neq "" ( - "%JOM%" -j%NUMBER_OF_PROCESSORS% - "%JOM%" install - ) else ( - nmake - nmake install - ) - windeployqt "%INSTALL_DIR%\RedPandaIDE.exe" - ``` - -## Advanced Option: vcpkg Qt Static Library with MSVC Toolchain - -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). -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" - vcpkg install qt5-base:$TARGET qt5-svg:$TARGET qt5-tools:$TARGET - ``` - -To build with VS 2019 or later in PowerShell (Core) or Windows PowerShell: - -1. Set related variables: - ```ps1 - $SRC_DIR = "C:\src\redpanda-src" - $BUILD_DIR = "C:\src\redpanda-build" - $INSTALL_DIR = "C:\src\redpanda-pkg" - $VCPKG_ROOT = "C:\src\vcpkg" - $VCPKG_TARGET = "x64-windows-static" # or "x86-windows-static" - $VS_INSTALL_PATH = "C:\Program Files\Microsoft Visual Studio\2022\Community" - $VC_ARCH = "amd64" # or "x86" - $JOM = "$VCPKG_ROOT\downloads\tools\jom\jom-1.1.3\jom.exe" # check the version - ``` -2. Navigate to build directory: - ```ps1 - Remove-Item -Recurse -Force "$BUILD_DIR" # optional for clean build - (New-Item -ItemType Directory -Force "$BUILD_DIR") -and (Set-Location "$BUILD_DIR") - ``` -3. Configure, build and install: - ```ps1 - Import-Module "$VS_INSTALL_PATH\Common7\Tools\Microsoft.VisualStudio.DevShell.dll" - Enter-VsDevShell -VsInstallPath "$VS_INSTALL_PATH" -SkipAutomaticLocation -DevCmdArguments "-arch=$VC_ARCH" - & "$VCPKG_ROOT\installed\$VCPKG_TARGET\tools\qt5\bin\qmake.exe" PREFIX="$INSTALL_DIR" "$SRC_DIR\Red_Panda_CPP.pro" - & "$JOM" "-j${Env:NUMBER_OF_PROCESSORS}" - & "$JOM" install - ``` - -To build with VS 2017 or later in Command Prompt: - -1. Launch proper VC environment from Start Menu. -2. Set related variables: - ```bat - rem no quotes even if path contains spaces - set SRC_DIR=C:\src\redpanda-src - set BUILD_DIR=C:\src\redpanda-build - set INSTALL_DIR=C:\src\redpanda-pkg - set VCPKG_ROOT=C:\src\vcpkg - rem or x86-windows-static - set VCPKG_TARGET=x64-windows-static - rem check the version - set JOM=%VCPKG_ROOT%\downloads\tools\jom\jom-1.1.3\jom.exe - ``` -3. Navigate to build directory: - ```bat - rem optional for clean build - rmdir /s /q "%BUILD_DIR%" - mkdir "%BUILD_DIR%" && cd /d "%BUILD_DIR%" - ``` -4. Configure, build and install: - ```bat - "%VCPKG_ROOT%\installed\%VCPKG_TARGET%\tools\qt5\bin\qmake.exe" PREFIX="%INSTALL_DIR%" "%SRC_DIR%\Red_Panda_CPP.pro" - "%JOM%" -j%NUMBER_OF_PROCESSORS% - "%JOM%" install - ``` + The directory structure should be like + ``` + D: + └─ myqt-32 + ├─ bin + ├─ include + ├─ lib + └─ ... + ``` # Linux diff --git a/BUILD_cn.md b/BUILD_cn.md index e424f218..e795ae85 100644 --- a/BUILD_cn.md +++ b/BUILD_cn.md @@ -25,40 +25,13 @@ # Windows -适用于 Windows 7 或更高版本: - | 库 + 工具链 \ 目标 | x86 | x64 | ARM64 | | ------------------ | --- | --- | ----- | | MSYS2 + 基于 GNU 的 MinGW | ✔️ | ✔️ | ❌ | | MSYS2 + 基于 LLVM 的 MinGW | ✔️ | ✔️ | ✔️ | -| Qt.io + MinGW | ✔️ | ✔️ | ❌ | -| Qt.io + MSVC | ✔️ | ✔️ | ❌ | -| vcpkg + MSVC | ✔️ | ✔️ | ❌ | +| [Windows XP](https://github.com/redpanda-cpp/qtbase-xp) + [MinGW UCRT](https://github.com/redpanda-cpp/mingw-lite) | ✔️ | ✔️ | ❌ | -qmake 变量: -- `PREFIX`:`$MAKE install` 的安装路径。 -- `WINDOWS_PREFER_OPENCONSOLE=ON`(make 阶段):首选兼容 UTF-8 的 `OpenConsole.exe`。 - - `OpenConsole.exe` 是 Windows 终端的组件,在 1.18 版本加入了 UTF-8 输出支持。 - - `OpenConsole.exe` 需要 Windows 10 1809 加入的 ConPTY 接口。 - -关于 ARM 上的 Windows 的注记: -- 小熊猫C++ 只能在 Windows 11 ARM64 上构建 ARM64 版,成品应该能在 Windows 10 ARM64 上运行(但没有测试过)。 - - 不支持 ARM64EC(“仿真兼容”)主机,即不能用 ARM64EC 工具链构建小熊猫 C++。 - - (理论上)支持 ARM64EC 目标,也就是说,如果上游工具链支持 ARM64EC,那么小熊猫C++ 可以构建 ARM64EC 程序和库。 -- 随着 [Windows 11 Insider Preview Build 25905 弃用 ARM32](https://blogs.windows.com/windows-insider/2023/07/12/announcing-windows-11-insider-preview-build-25905/),小熊猫 C++ 今后也不会添加 ARM32 支持了。 - -适用于旧版 Windows(NT 5.1 – 6.0): - -| 库 + 工具链 \ 目标 | x86 | x64 | -| ------------------ | --- | --- | -| 从[打过补丁的源代码](https://github.com/redpanda-cpp/qtbase-5.6)构建的 Qt 5.6 + MinGW | ✔️ | ✔️ | - -关于旧版 Windows 的注记: -- 支持的 Windows 版本: - - Windows XP SP3 或更高版本; - - Windows Server 2003 x64 Edition(也叫 Windows XP x64 Edition)SP2 或更高版本。 -- 构建环境需要 Windows 7 x64 或更高版本。 -- 从源代码构建 Qt 5.6 并与官方 Qt 安装共存可参考[这个脚本](packages/windows/build-qt5.6-mingw-static.sh)(使用 Qt.io MinGW GCC 8.1.0)。 +另请参阅[详细构建指南——Windows](./docs/detailed-build-win-cn.md)。 ## MSYS2 的 Qt 库 + MinGW 工具链(推荐) @@ -72,163 +45,92 @@ qmake 变量: 前置条件: -0. Windows 8.1 x64 或更高版本,或 Windows 11 ARM64。 +0. Windows 10 x64 或更高版本,或 Windows 11 ARM64。 1. 安装 MSYS2。 -2. 在选定的环境中,安装工具链和 Qt 5 库: +2. 在所选环境中安装工具链、Qt 5 库、其他所需工具: ```bash - pacman -S $MINGW_PACKAGE_PREFIX-toolchain $MINGW_PACKAGE_PREFIX-qt5-static + pacman -S \ + $MINGW_PACKAGE_PREFIX-{toolchain,qt5-static,7zip,cmake} \ + mingw-w64-i686-nsis \ + git curl ``` -构建: +要构建此项目,启动所选的 MSYS2 环境,然后运行 +```bash +./packages/msys/build-mingw.sh +``` +以构建带 MinGW GCC 工具链或不带编译器的小熊猫C++ 安装程序和绿色包;或者运行 +```bash +./packages/msys/build-llvm.sh +``` +以构建带 LLVM MinGW 工具链的小熊猫C++ 安装程序。 -1. 在选定的环境中,设置相关变量: - ```bash - SRC_DIR="/c/src/redpanda-src" # 以 “C:\src\redpanda-src” 为例 - BUILD_DIR="/c/src/redpanda-build" # 以 “C:\src\redpanda-build” 为例 - INSTALL_DIR="/c/src/redpanda-pkg" # 以 “C:\src\redpanda-pkg” 为例 - ``` -2. 定位到构建目录: - ```bash - rm -rf "$BUILD_DIR" # 根据需要进行全新构建 - mkdir -p "$BUILD_DIR" && cd "$BUILD_DIR" - ``` -3. 配置、构建、安装: - ```bash - $MSYSTEM_PREFIX/qt5-static/bin/qmake PREFIX="$INSTALL_DIR" "$SRC_DIR/Red_Panda_CPP.pro" - mingw32-make -j$(nproc) - mingw32-make install - ``` +通用参数: +- `-h`、`--help`:显示帮助信息。 +- `-c`、`--clean`:清理构建目录。 +- `-nd`、`--no-deps`:不检查依赖项。 +- `-t `、`--target-dir `:指定输出目录。默认值为 `dist/`。 -## Qt.io 的 Qt 库 + MinGW 工具链或 MSVC 工具链 +`build-mingw.sh` 的额外参数: +- `--mingw32`:把 `assets/mingw32.7z` 添加到包中。 +- `--mingw64`:把 `assets/mingw64.7z` 添加到包中。 +- `--mingw`:`--mingw32`(x86 程序)或 `--mingw64`(x64 程序)的别名。 +- `--ucrt `:把 Windows SDK 附带的 UCRT 运行时添加到包中。例如 `--ucrt 22621` 表示 Windows 11 SDK 22H2。 + +## 用于 Windows XP 的 Qt 库 + MinGW UCRT 工具链 + +`build-xp.sh` 脚本和 `build-mingw.sh` 类似,但是会根据当前 MSYS2 环境下载独立的 MinGW UCRT 工具链来构建用于 Windows XP 的小熊猫C++: +- MINGW32/CLANG32:构建 x86 程序; +- MINGW64/UCRT64/CLANG64:构建 x64 程序。 前置条件: -0. Windows 7 x64 或更高版本。不支持 ARM64。 -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”,匹配库的版本)。 - - 根据需要,选中 Qt Creator(“Qt” 组下的 “Developer and Designer Tools” 小组,推荐在使用 MSVC 工具链时选中以支持并行构建)。 -2. 对于 MSVC 工具链,安装 Visual Studio 2019 或更高版本,或 “Visual Studio 构建工具 2019” 或更高版本,附带 “使用 C++ 的桌面开发” 工作负载。 - - 在 “安装详细信息” 面板,“使用 C++ 的桌面开发” 之下,至少选择一个 “MSVC x86/x64 生成工具” 和一个 Windows SDK。 +0. Windows 10 x64 或更高版本。 +1. 安装 MSYS2。 +2. 在所选环境中安装所需工具: + ```bash + pacman -S \ + $MINGW_PACKAGE_PREFIX-{7zip,cmake} \ + mingw-w64-i686-nsis \ + git curl + ``` +3. 下载 [Windows XP 的 Qt 库](https://github.com/redpanda-cpp/qtbase-xp)并解压到 `C:/Qt`。 + - 目录结构应该如下: + ``` + C: + └─ Qt + └─ 5.15.13 + ├─ mingw132_32-redpanda + │ ├─ bin + │ ├─ include + │ ├─ lib + │ └─ ... + └─ mingw132_64-redpanda + ├─ bin + ├─ include + ├─ lib + └─ ... + ``` + - 也可以从源代码自行构建 Qt 并在构建时指定 `--qt` 参数。 +4. 安装 Windows 11 SDK 22H2 以获取 UCRT 运行时。 -构建: +要构建此项目,启动所选的 MSYS2 环境,然后运行 +```bash +./packages/msys/build-xp.sh --ucrt 22621 +``` -1. 从开始菜单中打开 Qt 环境。 -2. 在 Qt 环境中,设置相关变量: - ```bat - rem 即使路径含空格也不加引号 - set SRC_DIR=C:\src\redpanda-src - set BUILD_DIR=C:\src\redpanda-build - set INSTALL_DIR=C:\src\redpanda-pkg - rem 仅 MSVC 工具链需要设置 - set VS_INSTALL_PATH=C:\Program Files\Microsoft Visual Studio\2022\Community - rem 仅 MSVC 工具链需要设置;或 x86 - set VC_ARCH=amd64 - rem 仅 MSVC 工具链需要;如果未安装 Qt Creator 则不要设置 - set QT_CREATOR_DIR=C:\Qt\Tools\QtCreator - ``` -3. 定位到构建目录: - ```bat - rem 根据需要进行全新构建 - rmdir /s /q "%BUILD_DIR%" - mkdir "%BUILD_DIR%" && cd /d "%BUILD_DIR%" - ``` -4. 配置、构建、安装。对于 MinGW 工具链: - ```bat - qmake PREFIX="%INSTALL_DIR%" "%SRC_DIR%\Red_Panda_CPP.pro" - mingw32-make -j%NUMBER_OF_PROCESSORS% - mingw32-make install - windeployqt "%INSTALL_DIR%\RedPandaIDE.exe" - ``` - 对于 MSVC 工具链: - ```bat - call "%VS_INSTALL_PATH%\Common7\Tools\VsDevCmd.bat" -arch=%VC_ARCH% - qmake PREFIX="%INSTALL_DIR%" "%SRC_DIR%\Red_Panda_CPP.pro" +此脚本除了接受 `build-mingw.sh` 的参数外,还接受以下参数: +- `--qt `:指定 Qt 库目录。例如 `--qt /d/myqt-32`。 - set JOM=%QT_CREATOR_DIR%\bin\jom\jom.exe - if "%QT_CREATOR_DIR%" neq "" ( - "%JOM%" -j%NUMBER_OF_PROCESSORS% - "%JOM%" install - ) else ( - nmake - nmake install - ) - windeployqt "%INSTALL_DIR%\RedPandaIDE.exe" - ``` - -## 高级选项:vcpkg 的 Qt 静态库 + MSVC 工具链 - -前置条件: - -0. Windows 7 x64 或更高版本。不支持 ARM64。 - - 在全新安装的 Windows 上,依次安装以下组件: - 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 自举的前置条件)。 -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" - vcpkg install qt5-base:$TARGET qt5-svg:$TARGET qt5-tools:$TARGET - ``` - -在 PowerShell (Core) 或 Windows PowerShell 中用 VS 2019 或更高版本构建: - -1. 设置相关变量: - ```ps1 - $SRC_DIR = "C:\src\redpanda-src" - $BUILD_DIR = "C:\src\redpanda-build" - $INSTALL_DIR = "C:\src\redpanda-pkg" - $VCPKG_ROOT = "C:\src\vcpkg" - $VCPKG_TARGET = "x64-windows-static" # 或 "x86-windows-static" - $VS_INSTALL_PATH = "C:\Program Files\Microsoft Visual Studio\2022\Community" - $VC_ARCH = "amd64" # 或 "x86" - $JOM = "$VCPKG_ROOT\downloads\tools\jom\jom-1.1.3\jom.exe" # 检查版本号 - ``` -2. 定位到构建目录: - ```ps1 - Remove-Item -Recurse -Force "$BUILD_DIR" # 根据需要进行全新构建 - (New-Item -ItemType Directory -Force "$BUILD_DIR") -and (Set-Location "$BUILD_DIR") - ``` -3. 配置、构建、安装: - ```ps1 - Import-Module "$VS_INSTALL_PATH\Common7\Tools\Microsoft.VisualStudio.DevShell.dll" - Enter-VsDevShell -VsInstallPath "$VS_INSTALL_PATH" -SkipAutomaticLocation -DevCmdArguments "-arch=$VC_ARCH" - & "$VCPKG_ROOT\installed\$VCPKG_TARGET\tools\qt5\bin\qmake.exe" PREFIX="$INSTALL_DIR" "$SRC_DIR\Red_Panda_CPP.pro" - & "$JOM" "-j${Env:NUMBER_OF_PROCESSORS}" - & "$JOM" install - ``` - -在命令提示符中用 VS 2017 或更高版本构建: - -1. 从开始菜单中打开合适的 VC 环境。 -2. 设置相关变量: - ```bat - rem 即使路径含空格也不加引号 - set SRC_DIR=C:\src\redpanda-src - set BUILD_DIR=C:\src\redpanda-build - set INSTALL_DIR=C:\src\redpanda-pkg - set VCPKG_ROOT=C:\src\vcpkg - rem 或 x86-windows-static - set VCPKG_TARGET=x64-windows-static - rem 检查版本号 - set JOM=%VCPKG_ROOT%\downloads\tools\jom\jom-1.1.3\jom.exe - ``` -3. 定位到构建目录: - ```bat - rem 根据需要进行全新构建 - rmdir /s /q "%BUILD_DIR%" - mkdir "%BUILD_DIR%" && cd /d "%BUILD_DIR%" - ``` -4. 配置、构建、安装: - ```bat - "%VCPKG_ROOT%\installed\%VCPKG_TARGET%\tools\qt5\bin\qmake.exe" PREFIX="%INSTALL_DIR%" "%SRC_DIR%\Red_Panda_CPP.pro" - "%JOM%" -j%NUMBER_OF_PROCESSORS% - "%JOM%" install - ``` + 目录结构应该如下: + ``` + D: + └─ myqt-32 + ├─ bin + ├─ include + ├─ lib + └─ ... + ``` # Linux diff --git a/docs/detailed-build-win-cn.md b/docs/detailed-build-win-cn.md new file mode 100644 index 00000000..6751fcca --- /dev/null +++ b/docs/detailed-build-win-cn.md @@ -0,0 +1,184 @@ +# 详细构建指南——Windows + +| 库 + 工具链 \ 目标 | x86 | x64 | ARM64 | +| ------------------ | --- | --- | ----- | +| MSYS2 + 基于 GNU 的 MinGW | ✔️ | ✔️ | ❌ | +| MSYS2 + 基于 LLVM 的 MinGW | ✔️ | ✔️ | ✔️ | +| [Windows XP](https://github.com/redpanda-cpp/qtbase-xp) + [MinGW UCRT](https://github.com/redpanda-cpp/mingw-lite) | ✔️ | ✔️ | ❌ | +| Qt.io + MinGW | ✔️ | ✔️ | ❌ | +| Qt.io + MSVC | ✔️ | ✔️ | ❌ | +| vcpkg + MSVC | ✔️ | ✔️ | ❌ | + +qmake 变量: +- `PREFIX`:`$MAKE install` 的安装路径。 +- `WINDOWS_PREFER_OPENCONSOLE=ON`(make 阶段):首选兼容 UTF-8 的 `OpenConsole.exe`。 + - `OpenConsole.exe` 是 Windows 终端的组件,在 1.18 版本加入了 UTF-8 输出支持。 + - `OpenConsole.exe` 需要 Windows 10 1809 加入的 ConPTY 接口。 + +关于 ARM 上的 Windows 的注记: +- 小熊猫C++ 只能在 Windows 11 ARM64 上构建 ARM64 版,成品应该能在 Windows 10 ARM64 上运行(但没有测试过)。 + - 不支持 ARM64EC(“仿真兼容”)主机,即不能用 ARM64EC 工具链构建小熊猫 C++。 + - (理论上)支持 ARM64EC 目标,也就是说,如果上游工具链支持 ARM64EC,那么小熊猫C++ 可以构建 ARM64EC 程序和库。 +- 随着 [Windows 11 Insider Preview Build 25905 弃用 ARM32](https://blogs.windows.com/windows-insider/2023/07/12/announcing-windows-11-insider-preview-build-25905/),小熊猫 C++ 今后也不会添加 ARM32 支持了。 + +## 在 MSYS2 环境中手动构建 + +前置条件: + +0. Windows 8.1 x64 或更高版本,或 Windows 11 ARM64。 +1. 安装 MSYS2。 +2. 在选定的环境中,安装工具链和 Qt 5 库: + ```bash + pacman -S $MINGW_PACKAGE_PREFIX-toolchain $MINGW_PACKAGE_PREFIX-qt5-static + ``` + +构建: + +1. 在选定的环境中,设置相关变量: + ```bash + SRC_DIR="/c/src/redpanda-src" # 以 “C:\src\redpanda-src” 为例 + BUILD_DIR="/c/src/redpanda-build" # 以 “C:\src\redpanda-build” 为例 + INSTALL_DIR="/c/src/redpanda-pkg" # 以 “C:\src\redpanda-pkg” 为例 + ``` +2. 定位到构建目录: + ```bash + rm -rf "$BUILD_DIR" # 根据需要进行全新构建 + mkdir -p "$BUILD_DIR" && cd "$BUILD_DIR" + ``` +3. 配置、构建、安装: + ```bash + $MSYSTEM_PREFIX/qt5-static/bin/qmake PREFIX="$INSTALL_DIR" "$SRC_DIR/Red_Panda_CPP.pro" + mingw32-make -j$(nproc) + mingw32-make install + ``` + +## Qt.io 的 Qt 库 + MinGW 工具链或 MSVC 工具链 + +前置条件: + +0. Windows 7 x64 或更高版本。不支持 ARM64。 +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”,匹配库的版本)。 + - 根据需要,选中 Qt Creator(“Qt” 组下的 “Developer and Designer Tools” 小组,推荐在使用 MSVC 工具链时选中以支持并行构建)。 +2. 对于 MSVC 工具链,安装 Visual Studio 2019 或更高版本,或 “Visual Studio 构建工具 2019” 或更高版本,附带 “使用 C++ 的桌面开发” 工作负载。 + - 在 “安装详细信息” 面板,“使用 C++ 的桌面开发” 之下,至少选择一个 “MSVC x86/x64 生成工具” 和一个 Windows SDK。 + +构建: + +1. 从开始菜单中打开 Qt 环境。 +2. 在 Qt 环境中,设置相关变量: + ```bat + rem 即使路径含空格也不加引号 + set SRC_DIR=C:\src\redpanda-src + set BUILD_DIR=C:\src\redpanda-build + set INSTALL_DIR=C:\src\redpanda-pkg + rem 仅 MSVC 工具链需要设置 + set VS_INSTALL_PATH=C:\Program Files\Microsoft Visual Studio\2022\Community + rem 仅 MSVC 工具链需要设置;或 x86 + set VC_ARCH=amd64 + rem 仅 MSVC 工具链需要;如果未安装 Qt Creator 则不要设置 + set QT_CREATOR_DIR=C:\Qt\Tools\QtCreator + ``` +3. 定位到构建目录: + ```bat + rem 根据需要进行全新构建 + rmdir /s /q "%BUILD_DIR%" + mkdir "%BUILD_DIR%" && cd /d "%BUILD_DIR%" + ``` +4. 配置、构建、安装。对于 MinGW 工具链: + ```bat + qmake PREFIX="%INSTALL_DIR%" "%SRC_DIR%\Red_Panda_CPP.pro" + mingw32-make -j%NUMBER_OF_PROCESSORS% + mingw32-make install + windeployqt "%INSTALL_DIR%\RedPandaIDE.exe" + ``` + 对于 MSVC 工具链: + ```bat + call "%VS_INSTALL_PATH%\Common7\Tools\VsDevCmd.bat" -arch=%VC_ARCH% + qmake PREFIX="%INSTALL_DIR%" "%SRC_DIR%\Red_Panda_CPP.pro" + + set JOM=%QT_CREATOR_DIR%\bin\jom\jom.exe + if "%QT_CREATOR_DIR%" neq "" ( + "%JOM%" -j%NUMBER_OF_PROCESSORS% + "%JOM%" install + ) else ( + nmake + nmake install + ) + windeployqt "%INSTALL_DIR%\RedPandaIDE.exe" + ``` + +## 高级选项:vcpkg 的 Qt 静态库 + MSVC 工具链 + +前置条件: + +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 自举的前置条件)。 +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" + vcpkg install qt5-base:$TARGET qt5-svg:$TARGET qt5-tools:$TARGET + ``` + +在 PowerShell (Core) 或 Windows PowerShell 中用 VS 2019 或更高版本构建: + +1. 设置相关变量: + ```ps1 + $SRC_DIR = "C:\src\redpanda-src" + $BUILD_DIR = "C:\src\redpanda-build" + $INSTALL_DIR = "C:\src\redpanda-pkg" + $VCPKG_ROOT = "C:\src\vcpkg" + $VCPKG_TARGET = "x64-windows-static" # 或 "x86-windows-static" + $VS_INSTALL_PATH = "C:\Program Files\Microsoft Visual Studio\2022\Community" + $VC_ARCH = "amd64" # 或 "x86" + $JOM = "$VCPKG_ROOT\downloads\tools\jom\jom-1.1.3\jom.exe" # 检查版本号 + ``` +2. 定位到构建目录: + ```ps1 + Remove-Item -Recurse -Force "$BUILD_DIR" # 根据需要进行全新构建 + (New-Item -ItemType Directory -Force "$BUILD_DIR") -and (Set-Location "$BUILD_DIR") + ``` +3. 配置、构建、安装: + ```ps1 + Import-Module "$VS_INSTALL_PATH\Common7\Tools\Microsoft.VisualStudio.DevShell.dll" + Enter-VsDevShell -VsInstallPath "$VS_INSTALL_PATH" -SkipAutomaticLocation -DevCmdArguments "-arch=$VC_ARCH" + & "$VCPKG_ROOT\installed\$VCPKG_TARGET\tools\qt5\bin\qmake.exe" PREFIX="$INSTALL_DIR" "$SRC_DIR\Red_Panda_CPP.pro" + & "$JOM" "-j${Env:NUMBER_OF_PROCESSORS}" + & "$JOM" install + ``` + +在命令提示符中用 VS 2017 或更高版本构建: + +1. 从开始菜单中打开合适的 VC 环境。 +2. 设置相关变量: + ```bat + rem 即使路径含空格也不加引号 + set SRC_DIR=C:\src\redpanda-src + set BUILD_DIR=C:\src\redpanda-build + set INSTALL_DIR=C:\src\redpanda-pkg + set VCPKG_ROOT=C:\src\vcpkg + rem 或 x86-windows-static + set VCPKG_TARGET=x64-windows-static + rem 检查版本号 + set JOM=%VCPKG_ROOT%\downloads\tools\jom\jom-1.1.3\jom.exe + ``` +3. 定位到构建目录: + ```bat + rem 根据需要进行全新构建 + rmdir /s /q "%BUILD_DIR%" + mkdir "%BUILD_DIR%" && cd /d "%BUILD_DIR%" + ``` +4. 配置、构建、安装: + ```bat + "%VCPKG_ROOT%\installed\%VCPKG_TARGET%\tools\qt5\bin\qmake.exe" PREFIX="%INSTALL_DIR%" "%SRC_DIR%\Red_Panda_CPP.pro" + "%JOM%" -j%NUMBER_OF_PROCESSORS% + "%JOM%" install + ``` diff --git a/docs/detailed-build-win.md b/docs/detailed-build-win.md new file mode 100644 index 00000000..c3d90281 --- /dev/null +++ b/docs/detailed-build-win.md @@ -0,0 +1,186 @@ +# More Build Instructions for Windows + +| Library + Toolchain \ Target | x86 | x64 | ARM64 | +| ---------------------------- | --- | --- | ----- | +| MSYS2 + GNU-based MinGW | ✔️ | ✔️ | ❌ | +| MSYS2 + LLVM-based MinGW | ✔️ | ✔️ | ✔️ | +| [Windows XP](https://github.com/redpanda-cpp/qtbase-xp) + [MinGW UCRT](https://github.com/redpanda-cpp/mingw-lite) | ✔️ | ✔️ | ❌ | +| Qt.io + MinGW | ✔️ | ✔️ | ❌ | +| Qt.io + MSVC | ✔️ | ✔️ | ❌ | +| vcpkg + MSVC | ✔️ | ✔️ | ❌ | + +qmake variables: +- `PREFIX`: where `$MAKE install` installs files to. +- `WINDOWS_PREFER_OPENCONSOLE=ON` (make phase): prefer UTF-8 compatible `OpenConsole.exe`. + - `OpenConsole.exe` is a part of Windows Terminal. UTF-8 input support was added in version 1.18. + - `OpenConsole.exe` requires ConPTY, which was introduced in Windows 10 1809. + +Notes for Windows on ARM: +- Red Panda C++ can be built for ARM64 ABI only on Windows 11 ARM64, while it is supposed (but not tested) to run on Windows 10 ARM64. + - ARM64EC (“emulation compatible”) host is not supported, i.e., Red Panda C++ cannot be built with ARM64EC toolchain. + - ARM64EC target is (theoretically) supported, i.e. Red Panda C++ will build ARM64EC binaries if upstream toolchain supports ARM64EC. +- With the [ARM32 deprecation in Windows 11 Insider Preview Build 25905](https://blogs.windows.com/windows-insider/2023/07/12/announcing-windows-11-insider-preview-build-25905/), ARM32 support will never be added. + +## Maunally Build in MSYS2 + +Prerequisites: + +0. Windows 8.1 x64 or later, or Windows 11 ARM64. +1. Install MSYS2. +2. In selected environment, install toolchain and Qt 5 library: + ```bash + pacman -S \ + $MINGW_PACKAGE_PREFIX-{toolchain,qt5-static} \ + git + ``` + +To build: + +1. In selected environment, set related variables: + ```bash + SRC_DIR="/c/src/redpanda-src" # “C:\src\redpanda-src” for example + BUILD_DIR="/c/src/redpanda-build" # “C:\src\redpanda-build” for example + INSTALL_DIR="/c/src/redpanda-pkg" # “C:\src\redpanda-pkg” for example + ``` +2. Navigate to build directory: + ```bash + rm -rf "$BUILD_DIR" # optional for clean build + mkdir -p "$BUILD_DIR" && cd "$BUILD_DIR" + ``` +3. Configure, build and install: + ```bash + $MSYSTEM_PREFIX/qt5-static/bin/qmake PREFIX="$INSTALL_DIR" "$SRC_DIR/Red_Panda_CPP.pro" + mingw32-make -j$(nproc) + mingw32-make install + ``` + +## Qt.io Qt Library with MinGW Toolchain or MSVC Toolchain + +Prerequisites: + +0. Windows 7 x64 or later. ARM64 is not supported. +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). + - Optionally select Qt Creator (in _Qt_ group, _Developer and Designer Tools_ subgroup; recomended for MSVC toolchain for parallel build support). +2. For MSVC toolchain, install Visual Studio 2019 or later, or Visual Studio Build Tools 2019 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_. + +To build: + +1. Launch Qt environment from Start Menu. +2. In Qt environment, set related variables: + ```bat + rem no quotes even if path contains spaces + set SRC_DIR=C:\src\redpanda-src + set BUILD_DIR=C:\src\redpanda-build + set INSTALL_DIR=C:\src\redpanda-pkg + rem for MSVC toolchain + set VS_INSTALL_PATH=C:\Program Files\Microsoft Visual Studio\2022\Community + rem for MSVC toolchain; or x86 + set VC_ARCH=amd64 + rem for MSVC toolchain; keep unset if Qt Creator is not installed + set QT_CREATOR_DIR=C:\Qt\Tools\QtCreator + ``` +3. Navigate to build directory: + ```bat + rem optional for clean build + rmdir /s /q "%BUILD_DIR%" + mkdir "%BUILD_DIR%" && cd /d "%BUILD_DIR%" + ``` +4. Configure, build and install. For MinGW toolchain: + ```bat + qmake PREFIX="%INSTALL_DIR%" "%SRC_DIR%\Red_Panda_CPP.pro" + mingw32-make -j%NUMBER_OF_PROCESSORS% + mingw32-make install + windeployqt "%INSTALL_DIR%\RedPandaIDE.exe" + ``` + For MSVC toolchain: + ```bat + call "%VS_INSTALL_PATH%\Common7\Tools\VsDevCmd.bat" -arch=%VC_ARCH% + qmake PREFIX="%INSTALL_DIR%" "%SRC_DIR%\Red_Panda_CPP.pro" + + set JOM=%QT_CREATOR_DIR%\bin\jom\jom.exe + if "%QT_CREATOR_DIR%" neq "" ( + "%JOM%" -j%NUMBER_OF_PROCESSORS% + "%JOM%" install + ) else ( + nmake + nmake install + ) + windeployqt "%INSTALL_DIR%\RedPandaIDE.exe" + ``` + +## Advanced Option: vcpkg Qt Static Library with MSVC Toolchain + +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). +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" + vcpkg install qt5-base:$TARGET qt5-svg:$TARGET qt5-tools:$TARGET + ``` + +To build with VS 2019 or later in PowerShell (Core) or Windows PowerShell: + +1. Set related variables: + ```ps1 + $SRC_DIR = "C:\src\redpanda-src" + $BUILD_DIR = "C:\src\redpanda-build" + $INSTALL_DIR = "C:\src\redpanda-pkg" + $VCPKG_ROOT = "C:\src\vcpkg" + $VCPKG_TARGET = "x64-windows-static" # or "x86-windows-static" + $VS_INSTALL_PATH = "C:\Program Files\Microsoft Visual Studio\2022\Community" + $VC_ARCH = "amd64" # or "x86" + $JOM = "$VCPKG_ROOT\downloads\tools\jom\jom-1.1.3\jom.exe" # check the version + ``` +2. Navigate to build directory: + ```ps1 + Remove-Item -Recurse -Force "$BUILD_DIR" # optional for clean build + (New-Item -ItemType Directory -Force "$BUILD_DIR") -and (Set-Location "$BUILD_DIR") + ``` +3. Configure, build and install: + ```ps1 + Import-Module "$VS_INSTALL_PATH\Common7\Tools\Microsoft.VisualStudio.DevShell.dll" + Enter-VsDevShell -VsInstallPath "$VS_INSTALL_PATH" -SkipAutomaticLocation -DevCmdArguments "-arch=$VC_ARCH" + & "$VCPKG_ROOT\installed\$VCPKG_TARGET\tools\qt5\bin\qmake.exe" PREFIX="$INSTALL_DIR" "$SRC_DIR\Red_Panda_CPP.pro" + & "$JOM" "-j${Env:NUMBER_OF_PROCESSORS}" + & "$JOM" install + ``` + +To build with VS 2017 or later in Command Prompt: + +1. Launch proper VC environment from Start Menu. +2. Set related variables: + ```bat + rem no quotes even if path contains spaces + set SRC_DIR=C:\src\redpanda-src + set BUILD_DIR=C:\src\redpanda-build + set INSTALL_DIR=C:\src\redpanda-pkg + set VCPKG_ROOT=C:\src\vcpkg + rem or x86-windows-static + set VCPKG_TARGET=x64-windows-static + rem check the version + set JOM=%VCPKG_ROOT%\downloads\tools\jom\jom-1.1.3\jom.exe + ``` +3. Navigate to build directory: + ```bat + rem optional for clean build + rmdir /s /q "%BUILD_DIR%" + mkdir "%BUILD_DIR%" && cd /d "%BUILD_DIR%" + ``` +4. Configure, build and install: + ```bat + "%VCPKG_ROOT%\installed\%VCPKG_TARGET%\tools\qt5\bin\qmake.exe" PREFIX="%INSTALL_DIR%" "%SRC_DIR%\Red_Panda_CPP.pro" + "%JOM%" -j%NUMBER_OF_PROCESSORS% + "%JOM%" install + ``` diff --git a/packages/windows/build-qt5.6-mingw-static.sh b/packages/windows/build-qt5.6-mingw-static.sh deleted file mode 100644 index 72094517..00000000 --- a/packages/windows/build-qt5.6-mingw-static.sh +++ /dev/null @@ -1,127 +0,0 @@ -# for Git Bash - -# Usage: -# ./build-qt5.6-mingw-static.sh --arch <32|64> [--debug] [--official-qt-dir ] - -set -euo pipefail - -_ARCH="" -_CLEAN=0 -_DEBUG=0 -_OFFICIAL_QT_DIR="/c/Qt" -while [[ $# -gt 0 ]] ; do - case "$1" in - --arch) - _ARCH="$2" - shift - shift - ;; - --clean) - _CLEAN=1 - shift - ;; - --debug) - _DEBUG=1 - shift - ;; - --official-qt-dir) - _OFFICIAL_QT_DIR="$2" - shift - shift - ;; - *) - echo "Unknown option: $1" - exit 1 - ;; - esac -done - -case "$_ARCH" in - 32|64) - _MINGW_TOOLCHAIN="$_OFFICIAL_QT_DIR/Tools/mingw810_$_ARCH" - _QT_INSTALL_PREFIX="$_OFFICIAL_QT_DIR/5.6.4/mingw81_$_ARCH-redpanda" - ;; - *) - echo "Please specify --arch 32 or --arch 64" - exit 1 - ;; -esac - -if [[ $_DEBUG -eq 1 ]] ; then - _QT_CONFIGURE_DEBUG_OR_RELEASE=-debug-and-release -else - _QT_CONFIGURE_DEBUG_OR_RELEASE=-release -fi - -clean() { - rm -rf build-qt{base,svg,tools}-"$_ARCH" || true - rm -rf "$_QT_INSTALL_PREFIX" || true -} - -check-toolchain() { - if ! [[ -x "$_MINGW_TOOLCHAIN/bin/g++.exe" ]] ; then - echo "Please install MinGW 8.1 from Qt Maintenance Tool or download from https://download.qt.io/online/qtsdkrepository/windows_x86/desktop/tools_mingw/ or https://mirrors.ustc.edu.cn/qtproject/online/qtsdkrepository/windows_x86/desktop/tools_mingw/ and extract to $_OFFICAL_QT_DIR." - exit 1 - fi -} - -check-qt-sources() { - while ! [[ -d qtbase ]] ; do - echo "Please clone or link qtbase into this directory. e.g." - echo " git clone https://github.com/redpanda-cpp/qtbase-5.6.git --branch=5.6-redpanda --depth=1 qtbase" - echo " MSYS=winsymlinks:nativestrict ln -s /path/to/qtbase-5.6 qtbase" - echo "Press enter to continue..." - read - done - while ! [[ -d qtsvg ]] ; do - echo "Please clone or link qtsvg into this directory. e.g." - echo " git clone https://github.com/qt/qtsvg.git --branch=5.6 --depth=1" - echo "Press enter to continue..." - read - done - while ! [[ -d qttools ]] ; do - echo "Please clone or link qttools into this directory. e.g." - echo " git clone https://github.com/qt/qttools.git --branch=5.6 --depth=1" - echo "Press enter to continue..." - read - done -} - -build-qt-base() { - local build_dir="build-qtbase-$_ARCH" - mkdir -p "$build_dir" - pushd "$build_dir" - { - "../qtbase/configure.bat" \ - -prefix "$_QT_INSTALL_PREFIX" "$_QT_CONFIGURE_DEBUG_OR_RELEASE" \ - -opensource -confirm-license \ - -no-use-gold-linker -static -static-runtime -platform win32-g++ -target xp \ - -opengl desktop -no-angle -iconv -gnu-iconv -no-icu -qt-zlib -qt-pcre -qt-libpng -qt-libjpeg -qt-freetype -no-fontconfig -qt-harfbuzz -no-ssl -no-openssl \ - -nomake examples -nomake tests -nomake tools - mingw32-make "-j$(nproc)" - mingw32-make install - } - popd -} - -build-qt-module() { - local module_name="$1" - local build_dir="build-qt$module_name-$_ARCH" - mkdir -p "$build_dir" - pushd "$build_dir" - { - qmake "../qt$module_name" - mingw32-make "-j$(nproc)" - mingw32-make install - } - popd -} - -export PATH="$_QT_INSTALL_PREFIX/bin:$_MINGW_TOOLCHAIN/bin:$PATH" - -[[ $_CLEAN -eq 1 ]] && clean -check-toolchain -check-qt-sources -build-qt-base -build-qt-module svg -build-qt-module tools