From 67a4075925cf7b51ba4af7c7c2e6601c64717c3c Mon Sep 17 00:00:00 2001 From: lingyicute <160479206+lingyicute@users.noreply.github.com> Date: Sat, 12 Sep 2026 03:38:44 +0000 Subject: [PATCH] Add Windows ARM64 support [initial] - build.yml: add native windows-11-arm jobs (Qt 6.8/6.10, the only versions with ARM64 binaries), install Qt win64_msvc2022_arm64, use the arm64 VS environment, and upload/publish -arm64 artifacts - PackagingWindows.cmake: only ship the OpenSSL DLLs for x64 builds; ARM64 uses Qt's Schannel TLS backend - installer.nsi: only embed the OpenSSL DLLs when present in the package No C++ changes are required: as far as I know, the code and all thirdparty dependencies are architecture-neutral. --- .github/workflows/build.yml | 34 +++++++++++++++++++++++++++++++--- cmake/PackagingWindows.cmake | 32 ++++++++++++++++++++++++-------- installer/installer.nsi | 5 ++++- src/dialogs/MainWindow.cpp | 9 +++++++++ 4 files changed, 68 insertions(+), 12 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f94b3aecb..0a4babcd6 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -29,6 +29,20 @@ jobs: platform: windows qt_version: "6.10" + # ─── Windows (ARM) ───────────────────────────────────────── + - os: windows-11-arm + platform: windows + qt_version: "6.8" + qt_arch: win64_msvc2022_arm64 + vs_arch: arm64 + artifact_suffix: -arm64 + - os: windows-11-arm + platform: windows + qt_version: "6.10" + qt_arch: win64_msvc2022_arm64 + vs_arch: arm64 + artifact_suffix: -arm64 + # ─── Linux ───────────────────────────────────────────────── - os: ubuntu-24.04 platform: linux @@ -100,6 +114,7 @@ jobs: version: ${{ matrix.qt_version }} modules: 'qt5compat' cache: true + arch: ${{ matrix.qt_arch }} # ─── Install Qt (macOS via jdpurcell for arch support) ───── - name: Install Qt (mac) @@ -117,7 +132,7 @@ jobs: if: matrix.platform == 'windows' uses: egor-tensin/vs-shell@v2 with: - arch: x64 + arch: ${{ matrix.vs_arch || 'x64' }} - name: Install NSIS if: matrix.platform == 'windows' @@ -171,14 +186,14 @@ jobs: uses: actions/upload-artifact@v7 if: matrix.platform == 'windows' with: - name: NotepadNext-Windows-Qt${{ matrix.qt_version }}-Zip + name: NotepadNext-Windows-Qt${{ matrix.qt_version }}${{ matrix.artifact_suffix }}-Zip path: ${{ github.workspace }}/build/package/ - name: Upload Windows Installer uses: actions/upload-artifact@v7 if: matrix.platform == 'windows' with: - name: NotepadNext-Windows-Qt${{ matrix.qt_version }}-Installer + name: NotepadNext-Windows-Qt${{ matrix.qt_version }}${{ matrix.artifact_suffix }}-Installer path: ${{ github.workspace }}/installer/NotepadNext*.exe - name: Upload MacOS dmg @@ -202,6 +217,7 @@ jobs: if: github.repository == 'dail8859/NotepadNext' && github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + QT_ARM64_RELEASE_VER: 6.8 steps: - name: Checkout Repository @@ -225,6 +241,18 @@ jobs: cd .. gh release upload ${{ github.ref_name }} NotepadNext-${{ github.ref_name }}-win64.zip + - name: Upload Windows arm64 Installer + run: | + mv NotepadNext-Windows-Qt$QT_ARM64_RELEASE_VER-arm64-Installer/NotepadNext-${{ github.ref_name }}-Installer.exe NotepadNext-${{ github.ref_name }}-Installer-arm64.exe + gh release upload ${{ github.ref_name }} NotepadNext-${{ github.ref_name }}-Installer-arm64.exe + + - name: Upload Windows arm64 Zip + run: | + cd NotepadNext-Windows-Qt$QT_ARM64_RELEASE_VER-arm64-Zip/ + zip -r ../NotepadNext-${{ github.ref_name }}-win64-arm64.zip . + cd .. + gh release upload ${{ github.ref_name }} NotepadNext-${{ github.ref_name }}-win64-arm64.zip + - name: Upload Linux AppImage run: | gh release upload ${{ github.ref_name }} NotepadNext-Linux-Qt$QT_RELEASE_VER-AppImage/NotepadNext-${{ github.ref_name }}-x86_64.AppImage diff --git a/cmake/PackagingWindows.cmake b/cmake/PackagingWindows.cmake index e089b6927..e713a1219 100644 --- a/cmake/PackagingWindows.cmake +++ b/cmake/PackagingWindows.cmake @@ -24,6 +24,28 @@ list(APPEND WINDEPLOYQT_ARGS "${PACKAGE_DIR}/NotepadNext.exe") file(GLOB EXTRA_DLLS "${EXTRA_DLL_DIR}/*.dll") +# Determine the target architecture. The extra OpenSSL DLLs used by the +# auto updater are only shipped for x64; ARM64 builds use Qt's Schannel +# TLS backend instead, so no OpenSSL DLLs are needed. +if(CMAKE_CXX_COMPILER_ARCHITECTURE_ID MATCHES "ARM64" OR CMAKE_SYSTEM_PROCESSOR MATCHES "ARM64|aarch64") + set(TARGET_ARCH "arm64") +else() + set(TARGET_ARCH "x64") +endif() + +set(OPENSSL_DLL_COMMANDS "") +if(TARGET_ARCH STREQUAL "x64") + list(APPEND OPENSSL_DLL_COMMANDS + COMMAND ${CMAKE_COMMAND} -E copy_if_different + "${CMAKE_SOURCE_DIR}/deploy/windows/libcrypto-1_1-x64.dll" + "${PACKAGE_DIR}/libcrypto-1_1-x64.dll" + + COMMAND ${CMAKE_COMMAND} -E copy_if_different + "${CMAKE_SOURCE_DIR}/deploy/windows/libssl-1_1-x64.dll" + "${PACKAGE_DIR}/libssl-1_1-x64.dll" + ) +endif() + # Define the package target add_custom_target(package COMMENT "Packaging NotepadNext for distribution" @@ -39,14 +61,8 @@ add_custom_target(package "${CMAKE_SOURCE_DIR}/LICENSE" "${PACKAGE_DIR}/LICENSE" - # Copy the two extra DLLs - COMMAND ${CMAKE_COMMAND} -E copy_if_different - "${CMAKE_SOURCE_DIR}/deploy/windows/libcrypto-1_1-x64.dll" - "${PACKAGE_DIR}/libcrypto-1_1-x64.dll" - - COMMAND ${CMAKE_COMMAND} -E copy_if_different - "${CMAKE_SOURCE_DIR}/deploy/windows/libssl-1_1-x64.dll" - "${PACKAGE_DIR}/libssl-1_1-x64.dll" + # Copy the two extra DLLs (x64 only, see TARGET_ARCH above) + ${OPENSSL_DLL_COMMANDS} # Run windeployqt with correct flags COMMAND windeployqt ${WINDEPLOYQT_ARGS} diff --git a/installer/installer.nsi b/installer/installer.nsi index 6f9a286d2..2cb5a77ff 100644 --- a/installer/installer.nsi +++ b/installer/installer.nsi @@ -243,7 +243,10 @@ ${MementoSection} "Auto Updater" SEC_AUTO_UPDATER SetRegView 64 SetOutPath $INSTDIR - File ..\build\package\libcrypto-1_1-x64.dll ..\build\package\libssl-1_1-x64.dll + # The OpenSSL DLLs are only shipped with x64 builds; ARM64 builds use Qt's Schannel TLS backend + !if /FILEEXISTS "..\build\package\libcrypto-1_1-x64.dll" + File ..\build\package\libcrypto-1_1-x64.dll ..\build\package\libssl-1_1-x64.dll + !endif WriteRegDWORD SHCTX "Software\NotepadNext\NotepadNext\" "AutoUpdate" 1 ${MementoSectionEnd} diff --git a/src/dialogs/MainWindow.cpp b/src/dialogs/MainWindow.cpp index d689984a0..71c7682d0 100644 --- a/src/dialogs/MainWindow.cpp +++ b/src/dialogs/MainWindow.cpp @@ -2187,6 +2187,15 @@ void MainWindow::checkForUpdates(bool silent) qInfo(Q_FUNC_INFO); QString url = "https://github.com/dail8859/NotepadNext/raw/master/updates.json"; + +#if defined(_M_ARM64) || defined(__aarch64__) + // updates.json only points to the x64 installer, so ARM64 builds check + // the "windows-arm64" key instead. Until that key is added to the json, + // the updater will never report an available update which effectively + // disables the auto updater rather than downloading a useless x64 installer. + QSimpleUpdater::getInstance()->setPlatformKey(url, "windows-arm64"); +#endif + QSimpleUpdater::getInstance()->checkForUpdates(url); if (!silent) {