|
| 1 | +name: Build for Windows ARM64 |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + push: |
| 6 | + tags: |
| 7 | + - 'v*' |
| 8 | + |
| 9 | +permissions: |
| 10 | + contents: write |
| 11 | + |
| 12 | +jobs: |
| 13 | + build-windows-arm64: |
| 14 | + name: Build |
| 15 | + runs-on: windows-latest |
| 16 | + env: |
| 17 | + boost_path: "${{ github.workspace }}/../boost" |
| 18 | + libtorrent_path: "${{ github.workspace }}/libtorrent-msvc-arm64" |
| 19 | + qt_path: "${{ github.workspace }}/../qt-msvc-arm64" |
| 20 | + boost_version: "1.91.0" |
| 21 | + libt_version: "2.0.13" |
| 22 | + qbt_version: "5.2.3" |
| 23 | + qt_version: "6.10.3" |
| 24 | + qbt_url_base: "https://github.com/qbittorrent/qBittorrent/archive/refs/tags" |
| 25 | + qbt_url_prefix: "release-" |
| 26 | + qbt_url_suffix: ".tar.gz" |
| 27 | + boost_url: "https://archives.boost.io/release/{version}/source/boost_{version_underscored}.7z" |
| 28 | + |
| 29 | + |
| 30 | + |
| 31 | + steps: |
| 32 | + - name: Checkout repository |
| 33 | + uses: actions/checkout@v3 |
| 34 | + |
| 35 | + - name: Setup devcmd |
| 36 | + uses: ilammy/msvc-dev-cmd@v1 |
| 37 | + with: |
| 38 | + arch: amd64_arm64 |
| 39 | + |
| 40 | + - name: Install build tools |
| 41 | + run: | |
| 42 | + choco install ninja |
| 43 | +
|
| 44 | + # use the preinstalled vcpkg from image |
| 45 | + # https://github.com/actions/virtual-environments/blob/main/images/win/Windows2019-Readme.md#package-management |
| 46 | + - name: Setup vcpkg |
| 47 | + uses: lukka/run-vcpkg@v10 |
| 48 | + with: |
| 49 | + vcpkgDirectory: C:/vcpkg |
| 50 | + doNotUpdateVcpkg: true # the preinstalled vcpkg is updated regularly |
| 51 | + |
| 52 | + # Fix backslashes for CMake strings to prevent '\v' escape errors |
| 53 | + - name: Sanitize vcpkg path for CMake |
| 54 | + shell: pwsh |
| 55 | + run: | |
| 56 | + $clean_path = "${{ env.RUNVCPKG_VCPKG_ROOT }}".Replace('\', '/') |
| 57 | + echo "VCPKG_CMAKE_ROOT=$clean_path" >> $env:GITHUB_ENV |
| 58 | + |
| 59 | + |
| 60 | + - name: Install dependencies from vcpkg |
| 61 | + run: | |
| 62 | + # clear buildtrees after each package installation to reduce disk space requirements |
| 63 | + $packages = ` |
| 64 | + "openssl:arm64-windows-static-release", |
| 65 | + "zlib:arm64-windows-static-release" |
| 66 | + ${{ env.RUNVCPKG_VCPKG_ROOT }}/vcpkg.exe upgrade ` |
| 67 | + --no-dry-run |
| 68 | + ${{ env.RUNVCPKG_VCPKG_ROOT }}/vcpkg.exe install ` |
| 69 | + --clean-after-build ` |
| 70 | + $packages |
| 71 | +
|
| 72 | + # added to build url based on version and server |
| 73 | + - name: Build Boost URL |
| 74 | + shell: pwsh |
| 75 | + run: | |
| 76 | + function Build-Url { |
| 77 | + param( |
| 78 | + [string]$version, |
| 79 | + [string]$template |
| 80 | + ) |
| 81 | +
|
| 82 | + # Convert dotted to underscored |
| 83 | + $v_u = $version -replace '\.', '_' |
| 84 | +
|
| 85 | + # Replace placeholders |
| 86 | + $url = $template ` |
| 87 | + -replace '\{version\}', $version ` |
| 88 | + -replace '\{version_underscored\}', $v_u |
| 89 | +
|
| 90 | + return $url |
| 91 | + } |
| 92 | + $url = Build-Url "${{ env.boost_version }}" "${{ env.boost_url }}" |
| 93 | + echo "boost_url=$url" >> $env:GITHUB_ENV |
| 94 | +
|
| 95 | + - name: Install boost |
| 96 | + run: | |
| 97 | + aria2c ` |
| 98 | + "${{ env.boost_url }}" ` |
| 99 | + -d "${{ runner.temp }}" ` |
| 100 | + -o "boost.7z" |
| 101 | + 7z x "${{ runner.temp }}/boost.7z" -o"${{ github.workspace }}/.." |
| 102 | + move "${{ github.workspace }}/../boost_*" "${{ env.boost_path }}" |
| 103 | +
|
| 104 | + # added to build url based on version and server |
| 105 | + - name: Build qBittorrent URL |
| 106 | + shell: pwsh |
| 107 | + run: | |
| 108 | + $url = "${{ env.qbt_url_base }}/${{ env.qbt_url_prefix }}${{ env.qbt_version }}${{ env.qbt_url_suffix }}" |
| 109 | + echo "qbt_url=$url" >> $env:GITHUB_ENV |
| 110 | +
|
| 111 | + - name: Install Qt (host x64) |
| 112 | + uses: jurplel/install-qt-action@v4 |
| 113 | + with: |
| 114 | + aqtversion: '==3.3.*' |
| 115 | + version: "${{ env.qt_version }}" |
| 116 | + archives: 'qtbase qttools' |
| 117 | + set-env: 'false' |
| 118 | + dir: 'C:' |
| 119 | + |
| 120 | + - name: Verify Environment and CMake |
| 121 | + run: | |
| 122 | + echo "Target Version: ${{ env.qt_version }}" |
| 123 | + cmake --version |
| 124 | + ninja --version 2>&1 || echo "Ninja not found" |
| 125 | +
|
| 126 | + - name: Install Qt (target arm64) |
| 127 | + run: | |
| 128 | + $env:Path = "C:\Qt\${{ env.qt_version }}\msvc2022_64\bin;" + $env:Path |
| 129 | + git clone https://github.com/qt/qt5.git qt6 |
| 130 | + cd qt6 |
| 131 | + git checkout "v${{ env.qt_version }}" |
| 132 | + ./configure -init-submodules -submodules qtbase,qtsvg |
| 133 | + rm CMakeCache.txt |
| 134 | + ./configure -opensource -confirm-license -nomake tests -nomake examples ` |
| 135 | + -static -static-runtime -release -xplatform win32-arm64-msvc ` |
| 136 | + -prefix "${{ env.qt_path }}" ` |
| 137 | + -qt-host-path "C:/Qt/${{ env.qt_version }}/msvc2022_64" ` |
| 138 | + -system-zlib -schannel -qt-sqlite -sql-sqlite -no-sql-mysql -no-sql-odbc -no-sql-psql -c++std c++20 -- ` |
| 139 | + -DCMAKE_PREFIX_PATH="${{ env.VCPKG_CMAKE_ROOT }}/installed/arm64-windows-static-release" ` |
| 140 | + -DCMAKE_TOOLCHAIN_FILE="${{ env.VCPKG_CMAKE_ROOT }}/scripts/buildsystems/vcpkg.cmake" ` |
| 141 | + -DVCPKG_TARGET_TRIPLET=arm64-windows-static-release |
| 142 | + |
| 143 | + cmake --build . |
| 144 | + cmake --install . |
| 145 | +
|
| 146 | + - name: Install libtorrent |
| 147 | + run: | |
| 148 | + git clone ` |
| 149 | + --branch v${{ env.libt_version }} ` |
| 150 | + --depth 1 ` |
| 151 | + --recurse-submodules ` |
| 152 | + https://github.com/arvidn/libtorrent.git |
| 153 | + cd libtorrent |
| 154 | + cmake ` |
| 155 | + -B build ` |
| 156 | + -G "Ninja" ` |
| 157 | + -DCMAKE_BUILD_TYPE=Release ` |
| 158 | + -DCMAKE_INSTALL_PREFIX="${{ env.libtorrent_path }}" ` |
| 159 | + -DCMAKE_TOOLCHAIN_FILE="${{ env.RUNVCPKG_VCPKG_ROOT }}/scripts/buildsystems/vcpkg.cmake" ` |
| 160 | + -DBOOST_ROOT="${{ env.boost_path }}" ` |
| 161 | + -DBUILD_SHARED_LIBS=OFF ` |
| 162 | + -Ddeprecated-functions=OFF ` |
| 163 | + -Dstatic_runtime=ON ` |
| 164 | + -DVCPKG_TARGET_TRIPLET=arm64-windows-static-release |
| 165 | + cmake --build build |
| 166 | + cmake --install build |
| 167 | + |
| 168 | + - name: Build qBittorrent |
| 169 | + run: | |
| 170 | + # Resolve your custom ARM64 Qt path cleanly |
| 171 | + $AbsoluteQtPath = (Get-Item "${{ env.qt_path }}").FullName.Replace('\', '/') |
| 172 | + $HostQtPath = "C:/Qt/${{ env.qt_version }}/msvc2022_64" |
| 173 | + $VcpkgInstalledPath = "C:/vcpkg/installed/arm64-windows-static-release" |
| 174 | + |
| 175 | + $env:path = "$AbsoluteQtPath/bin;$env:path" |
| 176 | + $env:LDFLAGS+=" /FORCE:MULTIPLE" |
| 177 | + aria2c "${{ env.qbt_url }}" |
| 178 | + tar -xf qbittorrent-release-${{ env.qbt_version }}.tar.gz |
| 179 | + cd qbittorrent-release-${{ env.qbt_version }} |
| 180 | +
|
| 181 | + # --- HOTFIX: Force Global Visibility for ZLIB & OpenSSL --- |
| 182 | + $FixCode = @" |
| 183 | + # Forced Global Promotion Hotfix |
| 184 | + find_package(ZLIB REQUIRED) |
| 185 | + if(TARGET ZLIB::ZLIB) |
| 186 | + set_property(TARGET ZLIB::ZLIB PROPERTY IMPORTED_GLOBAL TRUE) |
| 187 | + endif() |
| 188 | + find_package(OpenSSL REQUIRED) |
| 189 | + if(TARGET OpenSSL::SSL) |
| 190 | + set_property(TARGET OpenSSL::SSL PROPERTY IMPORTED_GLOBAL TRUE) |
| 191 | + endif() |
| 192 | + if(TARGET OpenSSL::Crypto) |
| 193 | + set_property(TARGET OpenSSL::Crypto PROPERTY IMPORTED_GLOBAL TRUE) |
| 194 | + endif() |
| 195 | + "@ |
| 196 | + |
| 197 | + $Path = "cmake/Modules/CheckPackages.cmake" |
| 198 | + $OriginalContent = Get-Content $Path -Raw |
| 199 | + Set-Content $Path -Value ($FixCode + "`n" + $OriginalContent) |
| 200 | + Write-Host "Successfully injected global target promotion hotfix into $Path" |
| 201 | + # --- END HOTFIX --- |
| 202 | + |
| 203 | + cmake ` |
| 204 | + -B build ` |
| 205 | + -G "Ninja" ` |
| 206 | + -DCMAKE_BUILD_TYPE=Release ` |
| 207 | + -DCMAKE_PREFIX_PATH="$AbsoluteQtPath;$HostQtPath;$VcpkgInstalledPath" ` |
| 208 | + -DQT_HOST_PATH="$HostQtPath" ` |
| 209 | + -DCMAKE_TOOLCHAIN_FILE="${{ env.VCPKG_CMAKE_ROOT }}/scripts/buildsystems/vcpkg.cmake" ` |
| 210 | + -DVCPKG_MANIFEST_MODE=OFF ` |
| 211 | + -DBOOST_ROOT="${{ env.boost_path }}" ` |
| 212 | + -DLibtorrentRasterbar_DIR="${{ env.libtorrent_path }}/lib/cmake/LibtorrentRasterbar" ` |
| 213 | + -DMSVC_RUNTIME_DYNAMIC=OFF ` |
| 214 | + -DSTACKTRACE=OFF ` |
| 215 | + -DQT_NO_PRIVATE_MODULE_WARNING=ON ` |
| 216 | + -DVCPKG_TARGET_TRIPLET=arm64-windows-static-release |
| 217 | + cmake --build build |
| 218 | +
|
| 219 | + - name: Prepare build artifacts |
| 220 | + run: | |
| 221 | + mkdir upload |
| 222 | + copy qbittorrent-release-${{ env.qbt_version }}/build/qbittorrent.exe upload |
| 223 | + copy qbittorrent-release-${{ env.qbt_version }}/dist/windows/qt.conf upload |
| 224 | + cd upload |
| 225 | + 7z a qbittorrent_${{ env.qbt_version }}_arm64.zip * |
| 226 | + mv qbittorrent_${{ env.qbt_version }}_arm64.zip .. |
| 227 | +
|
| 228 | + - name: Upload build artifacts |
| 229 | + uses: actions/upload-artifact@v4 |
| 230 | + with: |
| 231 | + name: qBittorrent_${{ env.qbt_version }}_arm64 |
| 232 | + path: upload |
| 233 | + |
| 234 | + - name: Publish to GitHub Releases |
| 235 | + if: startsWith(github.ref, 'refs/tags/') || github.event_name == 'workflow_dispatch' |
| 236 | + uses: softprops/action-gh-release@v2 |
| 237 | + with: |
| 238 | + name: qBittorrent ${{ env.qbt_version }} (Windows ARM64) |
| 239 | + tag_name: v${{ env.qbt_version }} |
| 240 | + files: qbittorrent_${{ env.qbt_version }}_arm64.zip |
| 241 | + draft: false |
| 242 | + prerelease: false |
| 243 | + body: | |
| 244 | + ### Build Dependency Components: |
| 245 | + * **qBittorrent:** ${{ env.qbt_version }} |
| 246 | + * **Libtorrent:** ${{ env.libt_version }} |
| 247 | + * **Boost:** ${{ env.boost_version }} |
| 248 | + * **Qt:** ${{ env.qt_version }} |
| 249 | + env: |
| 250 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments