From 47230ae1b4189c3238a0b19f9f41b563ebc82a2e Mon Sep 17 00:00:00 2001 From: Mugunthan Selvanayagam Date: Mon, 2 Mar 2026 15:56:50 +0530 Subject: [PATCH] Add support for building Texworks on Windows ARM64 --- .../actions/msvc-dependencies/CMakeLists.txt | 26 ++++-- .github/actions/package-windows/action.yml | 38 ++++++-- .github/workflows/cd.yml | 87 ++++++++++++++++++- .github/workflows/ci.yml | 39 +++++++++ 4 files changed, 173 insertions(+), 17 deletions(-) diff --git a/.github/actions/msvc-dependencies/CMakeLists.txt b/.github/actions/msvc-dependencies/CMakeLists.txt index 159a7f96c..db5a04b5c 100644 --- a/.github/actions/msvc-dependencies/CMakeLists.txt +++ b/.github/actions/msvc-dependencies/CMakeLists.txt @@ -1,30 +1,38 @@ -cmake_minimum_required(VERSION 3.1) +cmake_minimum_required(VERSION 3.5...4.0) project(tw-deps) include(ExternalProject) include(GNUInstallDirs) +# Set target platform for compiling MSVC dependencies +if(CMAKE_GENERATOR_PLATFORM) + set(PLATFORM ${CMAKE_GENERATOR_PLATFORM}) +else() + set(PLATFORM x64) +endif() + set(CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX} -DCMAKE_BUILD_TYPE=RELEASE -DBUILD_SHARED_LIBS=TRUE) -set(MSBUILD_ARGS /t:rebuild /p:Configuration=Release /p:Platform=$(Platform) /p:PlatformToolset=$(PlatformToolset) /p:WindowsTargetPlatformVersion=$(WindowsTargetPlatformVersion)) +set(MSBUILD_ARGS /t:rebuild /p:Configuration=Release /p:Platform=$(PLATFORM) /p:PlatformToolset=$(PlatformToolset) /p:WindowsTargetPlatformVersion=$(WindowsTargetPlatformVersion)) ExternalProject_Add(lua URL "https://www.lua.org/ftp/lua-5.5.0.tar.gz" URL_HASH SHA256=57ccc32bbbd005cab75bcc52444052535af691789dba2b9016d5c50640d68b3d PATCH_COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_LIST_DIR}/lua.cmake /CMakeLists.txt - CMAKE_ARGS ${CMAKE_ARGS} + CMAKE_ARGS ${CMAKE_ARGS} -DCMAKE_POLICY_VERSION_MINIMUM=3.5 ) + ExternalProject_Add(hunspell - URL "https://github.com/hunspell/hunspell/archive/refs/tags/v1.7.2.tar.gz" - URL_HASH SHA256=69fa312d3586c988789266eaf7ffc9861d9f6396c31fc930a014d551b59bbd6e - CONFIGURE_COMMAND "" + GIT_REPOSITORY https://github.com/hunspell/hunspell.git + GIT_TAG 8b6c2e12f9c0e33e2fa2e00e9697cfb1ebd616ce + CONFIGURE_COMMAND "" BUILD_COMMAND msbuild msvc\\libhunspell.vcxproj ${MSBUILD_ARGS} /p:Configuration=Release_dll BUILD_IN_SOURCE TRUE INSTALL_COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_INSTALL_FULL_LIBDIR} - COMMAND ${CMAKE_COMMAND} -E copy_if_different msvc/x64/Release_dll/libhunspell.lib ${CMAKE_INSTALL_FULL_LIBDIR}/hunspell.lib + COMMAND ${CMAKE_COMMAND} -E copy_if_different msvc/${PLATFORM}/Release_dll/libhunspell.lib ${CMAKE_INSTALL_FULL_LIBDIR}/hunspell.lib COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_INSTALL_FULL_BINDIR} - COMMAND ${CMAKE_COMMAND} -E copy_if_different msvc/x64/Release_dll/libhunspell.dll ${CMAKE_INSTALL_FULL_BINDIR}/ + COMMAND ${CMAKE_COMMAND} -E copy_if_different msvc/${PLATFORM}/Release_dll/libhunspell.dll ${CMAKE_INSTALL_FULL_BINDIR}/ COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_INSTALL_FULL_INCLUDEDIR} COMMAND ${CMAKE_COMMAND} -E copy_if_different src/hunspell/atypes.hxx ${CMAKE_INSTALL_FULL_INCLUDEDIR}/ COMMAND ${CMAKE_COMMAND} -E copy_if_different src/hunspell/hunspell.h ${CMAKE_INSTALL_FULL_INCLUDEDIR}/ @@ -52,7 +60,7 @@ ExternalProject_Add(libjpeg CONFIGURE_COMMAND NMAKE /f makefile.vs setupcopy-v16 BUILD_COMMAND MSBUILD jpeg.sln ${MSBUILD_ARGS} INSTALL_COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_INSTALL_FULL_LIBDIR} - COMMAND ${CMAKE_COMMAND} -E copy_if_different Release/x64/jpeg.lib ${CMAKE_INSTALL_FULL_LIBDIR}/ + COMMAND ${CMAKE_COMMAND} -E copy_if_different Release/${PLATFORM}/jpeg.lib ${CMAKE_INSTALL_FULL_LIBDIR}/ COMMAND ${CMAKE_COMMAND} -E copy_if_different jpeglib.h jerror.h jconfig.h jmorecfg.h ${CMAKE_INSTALL_FULL_INCLUDEDIR}/ BUILD_IN_SOURCE TRUE ) diff --git a/.github/actions/package-windows/action.yml b/.github/actions/package-windows/action.yml index 501dfabb9..822adcc19 100644 --- a/.github/actions/package-windows/action.yml +++ b/.github/actions/package-windows/action.yml @@ -11,25 +11,32 @@ inputs: outputs: file: description: 'The filename of the packaged artifact (relative to builddir)' - value: ${{ steps.info.outputs.file }} + value: ${{ steps.info-x64.outputs.file || steps.info-arm64.outputs.file }} version: description: 'The version of the packaged artifact (e.g., 0.7)' - value: ${{ steps.info.outputs.version }} + value: ${{ steps.info-x64.outputs.version || steps.info-arm64.outputs.version }} fullversion: description: 'The full version of the packaged artifact (e.g., 0.7-202011160643-git_14dcc2c)' - value: ${{ steps.info.outputs.fullversion }} - + value: ${{ steps.info-x64.outputs.fullversion || steps.info-arm64.outputs.fullversion }} runs: using: composite steps: - - name: Assemble package + - name: Assemble package (WSL x64) + if: env.arch != 'ARM64' shell: wsl-bash {0} run: cpack --verbose working-directory: ${{ inputs.builddir }} - - name: Info + - name: Assemble package (ARM64) + if: env.arch == 'ARM64' + shell: bash + run: cpack --verbose + working-directory: ${{ inputs.builddir }} + + - name: Info WSL-x64 + if: env.arch != 'ARM64' shell: wsl-bash {0} - id: info + id: info-x64 run: | GITHUB_OUTPUT=$(echo "${{ github.output }}" | tr '\\' '/' | sed -e 's!\([A-Za-z]\):/!/mnt/\L\1/!') FILENAME=$(find ${{ inputs.builddir }} -maxdepth 1 -name 'TeXworks-win-*.zip') @@ -42,3 +49,20 @@ runs: echo "version=${VERSION}" >> "${GITHUB_OUTPUT}" echo "fullversion=${FULLVERSION}" >> "${GITHUB_OUTPUT}" echo "file=${FILENAME}" >> "${GITHUB_OUTPUT}" + + - name: Info Windows ARM64 + if: env.arch == 'ARM64' + shell: bash + id: info-arm64 + working-directory: ${{ inputs.builddir }} + run: | + FILENAME=$(find . -maxdepth 1 -name 'TeXworks-win-*.zip' | sed 's|^\./||') + VERSION=$(basename "$FILENAME" | sed -e 's/^TeXworks-win-\([^-]*\)-.*\.zip$/\1/') + FULLVERSION=$(basename "$FILENAME" | sed -e 's/^TeXworks-win-\(.*\)\.zip$/\1/') + echo "MD5" + md5sum "$FILENAME" + echo "SHA256" + sha256sum "$FILENAME" + echo "version=${VERSION}" >> "$GITHUB_OUTPUT" + echo "fullversion=${FULLVERSION}" >> "$GITHUB_OUTPUT" + echo "file=${{ inputs.builddir }}/${FILENAME}" >> "$GITHUB_OUTPUT" diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index da3ee89dd..35e8adf37 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -52,7 +52,7 @@ jobs: ################################################################################ - win: + win-x64: name: Windows runs-on: windows-latest strategy: @@ -129,6 +129,8 @@ jobs: - name: Package uses: ./.github/actions/package-windows id: package + env: + arch: x64 - name: Upload artifact uses: actions/upload-artifact@v4 @@ -161,6 +163,89 @@ jobs: # username: st.loeffler@gmail.com # key: ${{ secrets.jfrog_key }} +################################################################################ + + win-arm64: + name: Windows (MSVC ARM64) + runs-on: windows-11-arm + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Install Qt + uses: jurplel/install-qt-action@v4 + with: + version: 6.8.* + modules: qt5compat + + - name: Install dependencies + run: | + cmake -A ARM64 -B "${{ runner.workspace }}/tw-deps-build" -S "${{ github.workspace }}/.github/actions/msvc-dependencies" -DCMAKE_INSTALL_PREFIX="${{ runner.workspace }}/tw-deps" + cmake --build "${{ runner.workspace }}/tw-deps-build" --config Release + + - name: Configure + run: | + cmake -A ARM64 -B build -DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake -DTW_BUILD_ID='github' -DCMAKE_PREFIX_PATH="${{ runner.workspace }}/tw-deps" -Dgp_tool='none' -DQT_DEFAULT_MAJOR_VERSION=6 + + - name: Build & Install + run: | + cmake --build build --config Release + cmake --install build --config Release + + - name: Prepare dependencies for testing + shell: cmd + run: | + set PATH=${{ env.QT_ROOT_DIR }}\bin;%PATH% + windeployqt --release --compiler-runtime build\Release\texworks.exe + cmake -E copy_directory build/share build/Release/share + cd "${{ runner.workspace }}/tw-deps/bin" + cmake -E copy freetype.dll lcms2.dll libhunspell.dll libpng16.dll lua.dll openjp2.dll poppler.dll poppler-qt6.dll tiff.dll zlib1.dll "${{ github.workspace }}/build/Release/" + + - name: Run Test suite + run: ctest -V -C Release + working-directory: build + env: + QT_FORCE_STDERR_LOGGING: 1 + + - name: Package + uses: ./.github/actions/package-windows + id: package + env: + arch: ARM64 + + - name: Upload artifact + uses: actions/upload-artifact@v4 + with: + name: TeXworks-WindowsARM64 + path: ${{ steps.package.outputs.file }} + + - name: Install InnoSetup + run: choco install innosetup + + - name: Prepare installer files + run: cmake -E copy_directory build/Release win32/../release + + - name: Build installer + run: ISCC texworks-setup-script.iss + working-directory: win32 + + - name: Upload installer artifact + uses: actions/upload-artifact@v4 + with: + name: TeXworks-WindowsARM64-Setup + path: win32/Output/*.exe + +# - name: Deploy to Artifactory +# if: github.event_name == 'push' +# uses: ./.github/actions/deploy-artifactory +# with: +# file: ${{ steps.package.outputs.file }} +# baseurl: https://texworks.jfrog.io +# repo: windows-11-arm +# remotePath: ${{ steps.package.outputs.version }} +# username: st.loeffler@gmail.com +# key: ${{ secrets.jfrog_key }} + ################################################################################ macosx: diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e59eb538f..bd2f96f0b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -167,6 +167,45 @@ jobs: ################################################################################ + build-win-arm64-msvc: + name: Windows ARM64(MSVC) + runs-on: windows-11-arm + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Install Qt + uses: jurplel/install-qt-action@v4 + with: + version: 6.8.* + modules: qt5compat + + - name: Install dependencies + run: | + cmake -A ARM64 -B "${{ runner.workspace }}/tw-deps-build" -S "${{ github.workspace }}/.github/actions/msvc-dependencies" -DCMAKE_INSTALL_PREFIX="${{ runner.workspace }}/tw-deps" + cmake --build "${{ runner.workspace }}/tw-deps-build" --config Release + + - name: Configure + run: cmake -A ARM64 -B build -DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake -DTW_BUILD_ID='github' -DCMAKE_PREFIX_PATH="${{ runner.workspace }}/tw-deps" -Dgp_tool='none' -DQT_DEFAULT_MAJOR_VERSION=6 + + - name: Build + run: cmake --build build --config Release + + - name: Prepare for testing + run: | + cmake -E copy_directory build/share build/Release/share + cd "${{ runner.workspace }}/tw-deps/bin" + cmake -E copy freetype.dll lcms2.dll libhunspell.dll libpng16.dll lua.dll openjp2.dll poppler.dll poppler-qt6.dll tiff.dll zlib1.dll "${{ github.workspace }}/build/Release/" + + - name: Test + run: ctest -V -C Release + working-directory: build + env: + QT_FORCE_STDERR_LOGGING: 1 + +# ################################################################################ + macosx-homebrew: name: Mac OS X (Homebrew) runs-on: macos-latest