From 2502165f050bb9338f22350889a21e825d8da879 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 25 Nov 2026 07:13:38 +0000 Subject: [PATCH] Build the Windows app on macOS for Intel Macs (x86_64) winport/CMakeLists.txt takes the architecture of libwinport from CMAKE_OSX_ARCHITECTURES (one architecture). CI builds the app on macOS for arm64 and x86_64, and the nightly release adds dmodem-win32-macos-x86_64.tar.gz. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01B82eRVR36R8PgTTMQiuWkQ --- .github/workflows/build.yml | 24 ++++++++++++++++++++---- .github/workflows/nightly.yml | 4 +++- docs/building.md | 5 +++++ docs/design.md | 2 +- docs/download.md | 3 ++- docs/embedded-modem.md | 2 +- winport/CMakeLists.txt | 17 +++++++++++++++-- 7 files changed, 47 insertions(+), 10 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5ac2f3c..d3e7fe5 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -208,9 +208,20 @@ jobs: name: dmodem-win32-linux path: dmodem-win32-linux-x86_64.tar.gz + # arm64 for a Mac with Apple silicon, and x86_64 for an Intel Mac. The + # runner has Apple silicon: it builds the x86_64 app with + # CMAKE_OSX_ARCHITECTURES=x86_64 (winport/CMakeLists.txt). winport-macos: - name: Windows app on macOS, the modem built in (clang-retro MFC's Win32 layer) + name: Windows app on macOS (${{ matrix.arch }}), the modem built in (clang-retro MFC's Win32 layer) runs-on: macos-15 + strategy: + fail-fast: false + matrix: + include: + - arch: arm64 + artifact: dmodem-win32-macos + - arch: x86_64 + artifact: dmodem-win32-macos-x86_64 steps: - uses: actions/checkout@v4 with: @@ -225,16 +236,21 @@ jobs: run: | cmake -S . -B build -DCMAKE_BUILD_TYPE=RelWithDebInfo \ -DDMODEM_GUI_WINPORT=ON -DCLANG_RETRO_MFC="$PWD/mfc" \ + -DCMAKE_OSX_ARCHITECTURES=${{ matrix.arch }} \ -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ cmake --build build --target dmodem-win32 -j"$(sysctl -n hw.ncpu)" + - name: The app is for ${{ matrix.arch }} only + run: | + lipo -archs build/winport/dmodem-win32 + test "$(lipo -archs build/winport/dmodem-win32)" = "${{ matrix.arch }}" - name: The built-in modem is in the app run: nm build/winport/dmodem-win32 | grep -q dmodem_embed_start - name: Package - run: tar -C build/winport -czf dmodem-win32-macos-arm64.tar.gz dmodem-win32 + run: tar -C build/winport -czf dmodem-win32-macos-${{ matrix.arch }}.tar.gz dmodem-win32 - uses: actions/upload-artifact@v4 with: - name: dmodem-win32-macos - path: dmodem-win32-macos-arm64.tar.gz + name: ${{ matrix.artifact }} + path: dmodem-win32-macos-${{ matrix.arch }}.tar.gz # The built-in modem (external/D-Modem) is built by CMake, which # writes build/macos-embed.xcconfig for the Xcode project diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index c1edaff..04d82e8 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -74,6 +74,7 @@ jobs: take dmodem-macos D-Modem-macos.zip take dmodem-win32-linux dmodem-win32-linux-x86_64.tar.gz take dmodem-win32-macos dmodem-win32-macos-arm64.tar.gz + take dmodem-win32-macos-x86_64 dmodem-win32-macos-x86_64.tar.gz (cd out && sha256sum * > SHA256SUMS) ls -l out { @@ -88,7 +89,8 @@ jobs: echo "| \`dmodem-gui-linux-x86_64.tar.gz\` | The Linux app (GTK 4), x86_64. It needs GTK 4, libadwaita, PulseAudio and libsndfile. Its files are in \`usr/\`: extract it into \`/\`, for example with \`sudo tar -xzf dmodem-gui-linux-x86_64.tar.gz -C /\` |" echo "| \`D-Modem-macos.zip\` | The macOS app (SwiftUI) with the modem built in, arm64 and x86_64, macOS 13 and later. Not notarized: right-click the app and select Open |" echo "| \`dmodem-win32-linux-x86_64.tar.gz\` | The Windows app on Linux (X11) with the modem built in, x86_64 |" - echo "| \`dmodem-win32-macos-arm64.tar.gz\` | The Windows app on macOS with the modem built in, arm64 |" + echo "| \`dmodem-win32-macos-arm64.tar.gz\` | The Windows app on macOS with the modem built in, arm64 (Apple silicon) |" + echo "| \`dmodem-win32-macos-x86_64.tar.gz\` | The Windows app on macOS with the modem built in, x86_64 (Intel Mac) |" echo "| \`SHA256SUMS\` | The SHA-256 of each file |" if [ -f missing ]; then echo diff --git a/docs/building.md b/docs/building.md index d38c939..f88686a 100644 --- a/docs/building.md +++ b/docs/building.md @@ -52,6 +52,11 @@ Linux, also install `libusb-1.0-0-dev` and `libasound2-dev`. Then: -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ cmake --build build --target dmodem-win32 && ./build/winport/dmodem-win32 +On macOS, the app is for the architecture of the Mac. To build the app +for an Intel Mac on a Mac with Apple silicon, add +`-DCMAKE_OSX_ARCHITECTURES=x86_64` to the first command. Set one +architecture only. The app cannot be a universal binary. + The first CMake build downloads libssh and mbedTLS for SSH. This always occurs on Windows and macOS. Use `-DDMODEM_GUI_SSH=OFF` for a build with no SSH. On Linux, it occurs if the libssh of the system diff --git a/docs/design.md b/docs/design.md index a42b2b2..71e45c2 100644 --- a/docs/design.md +++ b/docs/design.md @@ -566,7 +566,7 @@ code is the same as on Windows. - SSH uses `~/.ssh` and `/` in paths, because libssh uses POSIX paths on these systems. - The layer changes a COM port name to a device: `COM1` is `/dev/ttyS0`. -- CI builds the app on Linux and macOS. On Linux, `winport/test/smoke.sh` +- CI builds the app on Linux, and on macOS for arm64 and x86_64. On Linux, `winport/test/smoke.sh` starts the app in Xvfb three times: with a TCP line, with a dmodemd that the app starts (`winport/test/dmodemd`, a test dmodemd), and with the built-in modem on a SIP line with no account. For the first two, diff --git a/docs/download.md b/docs/download.md index 38f6831..bfc3fda 100644 --- a/docs/download.md +++ b/docs/download.md @@ -19,7 +19,8 @@ When `main` has no new commits, the release does not change. | macOS 13 and later | [`D-Modem-macos.zip`](https://github.com/D-Modem/gui/releases/download/nightly/D-Modem-macos.zip) | The macOS app (SwiftUI) with the built-in modem, for arm64 and x86_64. | | Linux, x86_64 | [`dmodem-gui-linux-x86_64.tar.gz`](https://github.com/D-Modem/gui/releases/download/nightly/dmodem-gui-linux-x86_64.tar.gz) | The Linux app (GTK 4). | | Linux, x86_64 (X11) | [`dmodem-win32-linux-x86_64.tar.gz`](https://github.com/D-Modem/gui/releases/download/nightly/dmodem-win32-linux-x86_64.tar.gz) | The Windows app on Linux, with the built-in modem. | -| macOS, arm64 | [`dmodem-win32-macos-arm64.tar.gz`](https://github.com/D-Modem/gui/releases/download/nightly/dmodem-win32-macos-arm64.tar.gz) | The Windows app on macOS, with the built-in modem. | +| macOS, arm64 (Apple silicon) | [`dmodem-win32-macos-arm64.tar.gz`](https://github.com/D-Modem/gui/releases/download/nightly/dmodem-win32-macos-arm64.tar.gz) | The Windows app on macOS, with the built-in modem. | +| macOS, x86_64 (Intel Mac) | [`dmodem-win32-macos-x86_64.tar.gz`](https://github.com/D-Modem/gui/releases/download/nightly/dmodem-win32-macos-x86_64.tar.gz) | The Windows app on macOS, with the built-in modem. | | All | [`SHA256SUMS`](https://github.com/D-Modem/gui/releases/download/nightly/SHA256SUMS) | The SHA-256 of each file. | If a file is not in the release, the newest build did not make it. The diff --git a/docs/embedded-modem.md b/docs/embedded-modem.md index eeb47be..d1e90a6 100644 --- a/docs/embedded-modem.md +++ b/docs/embedded-modem.md @@ -101,7 +101,7 @@ Windows and macOS, the build links libusb (LGPL-2.1) statically, as | Windows 95, NT 4.0 and later | Done (`win32-picolibc` build). It builds, and its imports agree with Windows 95 and NT 4.0. It is not tested on Windows or Wine yet. Refer to "Windows 95" below. | | macOS | Done. CI builds it for arm64 and x86_64, and checks that the library is in the app for each architecture. It is not tested on a Mac yet. | | The Windows app on Linux | Done. CI builds it, checks that the library is in the app, and starts the built-in modem in Xvfb (`winport/test/smoke.sh`). | -| The Windows app on macOS | Done (arm64). CI builds it and checks that the library is in the app. It is not tested on a Mac yet. | +| The Windows app on macOS | Done (arm64 and x86_64). CI builds it for each architecture, and checks that the library is in the app. It is not tested on a Mac yet. | ### Windows 95 diff --git a/winport/CMakeLists.txt b/winport/CMakeLists.txt index 26085f6..b9aa7c3 100644 --- a/winport/CMakeLists.txt +++ b/winport/CMakeLists.txt @@ -16,8 +16,21 @@ find_package(Python3 REQUIRED COMPONENTS Interpreter) find_program(DMODEM_LLVM_RC NAMES llvm-rc llvm-rc-20 llvm-rc-19 llvm-rc-18 HINTS /opt/homebrew/opt/llvm/bin /usr/local/opt/llvm/bin REQUIRED) -# The target triple of the layer's Makefile -if(CMAKE_SYSTEM_PROCESSOR MATCHES "^(arm64|aarch64)$") +# The target triple of the layer's Makefile. On macOS, the +# architecture is CMAKE_OSX_ARCHITECTURES when it is set, else the +# architecture of this Mac. Thus a Mac with Apple silicon can build the +# app for an Intel Mac: -DCMAKE_OSX_ARCHITECTURES=x86_64. The layer +# builds for one architecture only. +set(_winport_arch "${CMAKE_SYSTEM_PROCESSOR}") +if(APPLE AND CMAKE_OSX_ARCHITECTURES) + list(LENGTH CMAKE_OSX_ARCHITECTURES _n_archs) + if(NOT _n_archs EQUAL 1) + message(FATAL_ERROR "DMODEM_GUI_WINPORT: set one architecture in " + "CMAKE_OSX_ARCHITECTURES (arm64 or x86_64), not \"${CMAKE_OSX_ARCHITECTURES}\"") + endif() + set(_winport_arch "${CMAKE_OSX_ARCHITECTURES}") +endif() +if(_winport_arch MATCHES "^(arm64|aarch64)$") set(_arch_linux aarch64) set(_arch_apple arm64) else()