Commit 143f4b8a for tesseract

commit 143f4b8a2be67df4709f45f253bfa3954a66053a
Author: Stefan Weil <sw@weilnetz.de>
Date:   Fri Nov 27 09:38:17 2026 +0100

    ci: Add Windows on ARM to the cross build for Windows

    The workflow for the Windows installer now has a single input, the
    MSYS2 environment: CLANG64 (default) or UCRT64 for Windows (64 bit), and
    CLANGARM64 for Windows on ARM, which gives
    tesseract-ocr-arm64-setup-<version>.exe. The input for the target
    operating system is removed. It had only one value, and the MSYS2
    environment already implies the target.

    The title of the workflow run and the name of the job now show the
    MSYS2 environment. Without that, runs for different environments could
    only be told apart in the log of the job.

    The installer for ARM is a 64 bit installer (program directory, registry
    view) with its own file name. nsis/Makefile.am selects the options for
    makensis from the host CPU in the recipe. The installer program itself
    is still the 32 bit x86 program of NSIS, which needs the x86 emulation
    of Windows on ARM.

    Tested by running the steps of the workflow in an Ubuntu 24.04 root
    file system for CLANGARM64 and CLANG64: both give an installer. For ARM
    all 71 programs and DLL files are ARM64 binaries, no imported DLL is
    missing, and NEON is enabled. The ARM programs and the installer were
    not run.

    Assisted-by: Claude Fable 5.2 (Anthropic)
    Signed-off-by: Stefan Weil <sw@weilnetz.de>

diff --git a/.github/workflows/installer-for-windows.yml b/.github/workflows/installer-for-windows.yml
index 1b7b0972..0df6c0b1 100644
--- a/.github/workflows/installer-for-windows.yml
+++ b/.github/workflows/installer-for-windows.yml
@@ -2,28 +2,26 @@

 name: Cross build for Windows

+# Show the MSYS2 environment in the list of workflow runs.
+run-name: Cross build for Windows (${{ inputs.msystem }})
+
 on:
   # Trigger workflow in GitHub web frontend or from API.
   workflow_dispatch:
     inputs:
-      targets:
-        description: 'Target operating system'
-        required: true
-        default: 'Windows (64 bit)'
-        type: choice
-        options:
-          - 'Windows (64 bit)'
       msystem:
-        description: 'MSYS2 environment which provides the libraries'
+        description: 'MSYS2 environment'
         required: true
         default: 'CLANG64'
         type: choice
         options:
           - 'CLANG64'
           - 'UCRT64'
+          - 'CLANGARM64'

 jobs:
   build64:
+    name: Installer (${{ inputs.msystem }})
     runs-on: [ubuntu-24.04]
     steps:
     - uses: actions/checkout@v7
@@ -35,13 +33,13 @@ jobs:
         packages: >-
           curl-winssl giflib icu leptonica libarchive libidn2 openjpeg2
           openssl pango libpng libtiff libwebp
-    - name: Build Tesseract installer (64 bit)
+    - name: Build Tesseract installer
       run: nsis/build.sh "$HOST" "$PREFIX"
       env:
         HOST: ${{ steps.cross.outputs.host }}
         PREFIX: ${{ steps.cross.outputs.prefix }}
     - uses: actions/upload-artifact@v7
       with:
-        name: Tesseract Installer for Windows (64 bit)
-        path: bin/ndebug/x86_64-w64-mingw32/nsis/tesseract-ocr-w*-setup-*.exe
+        name: Tesseract Installer for Windows (${{ inputs.msystem }})
+        path: bin/ndebug/${{ steps.cross.outputs.host }}/nsis/tesseract-ocr-*-setup-*.exe
         archive: false
diff --git a/nsis/Makefile.am b/nsis/Makefile.am
index 41e28d85..5b6b63fc 100644
--- a/nsis/Makefile.am
+++ b/nsis/Makefile.am
@@ -17,6 +17,11 @@ winpath.exe: winpath.cpp
 	$(STRIP) --strip-unneeded $@

 winsetup: Plugins/x86-unicode/INetC.dll winpath.exe
-	makensis -DCROSSBUILD -DSHARED -DSIGNCODE=$(SIGNCODE) -DSRCDIR=$(top_srcdir) -DPREFIX=$(prefix) -DVERSION=${gitrev} $(shell test "$(host_cpu)" = x86_64 && echo "-DW64") -NOCD $(top_srcdir)/nsis/tesseract.nsi
+	case "$(host_cpu)" in \
+	aarch64) arch="-DW64 -DARM64";; \
+	x86_64) arch="-DW64";; \
+	*) arch="";; \
+	esac; \
+	makensis -DCROSSBUILD -DSHARED -DSIGNCODE=$(SIGNCODE) -DSRCDIR=$(top_srcdir) -DPREFIX=$(prefix) -DVERSION=${gitrev} $$arch -NOCD $(top_srcdir)/nsis/tesseract.nsi

 endif
diff --git a/nsis/build.sh b/nsis/build.sh
index 8fd2071a..36f5786c 100755
--- a/nsis/build.sh
+++ b/nsis/build.sh
@@ -17,6 +17,12 @@
 #       openssl pango libpng libtiff libwebp
 #
 # It also shows the directories which must be added to PATH.
+#
+# Supported combinations of HOST and PREFIX:
+#
+#     x86_64-w64-mingw32   /clang64      (default)
+#     x86_64-w64-mingw32   /ucrt64
+#     aarch64-w64-mingw32  /clangarm64   (Windows on ARM)

 set -e
 set -x
diff --git a/nsis/tesseract.nsi b/nsis/tesseract.nsi
index 2eec37ba..88a5f8ad 100644
--- a/nsis/tesseract.nsi
+++ b/nsis/tesseract.nsi
@@ -27,6 +27,7 @@ Unicode true
 ;define CROSSBUILD
 ;define SHARED
 ;define W64
+;define ARM64
 !ifndef COMMENTS
 !define COMMENTS "GitHub CI build"
 !endif
@@ -54,6 +55,11 @@ Unicode true
 !addplugindir Plugins/x86-unicode
 !endif

+!ifdef ARM64
+; Installer for Windows on ARM (64 bit). W64 must be defined, too.
+!define ARCH "aarch64"
+!define SETUP "tesseract-ocr-arm64-setup"
+!else
 !ifdef W64
 !define ARCH "x86_64"
 !define SETUP "tesseract-ocr-w64-setup"
@@ -61,6 +67,7 @@ Unicode true
 !define ARCH "i686"
 !define SETUP "tesseract-ocr-w32-setup"
 !endif
+!endif

 # Name of program and file
 !define OUTFILE "${SETUP}-${VERSION}.exe"