Skip to content

CI: build macOS x86_64 by cross-compiling on the arm64 runner #6

CI: build macOS x86_64 by cross-compiling on the arm64 runner

CI: build macOS x86_64 by cross-compiling on the arm64 runner #6

Workflow file for this run

name: build
on:
push:
branches: [master]
pull_request:
workflow_dispatch:
jobs:
build:
name: ${{ matrix.name }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- { os: ubuntu-latest, name: linux }
# Both macOS builds run on the reliable Apple-Silicon runner: one native
# arm64, one cross-compiled to x86_64 (static SDL2 from source), so the
# Intel build no longer depends on scarce Intel-runner capacity.
- { os: macos-14, name: macos-arm64, mac_arch: arm64 }
- { os: macos-14, name: macos-x86_64, mac_arch: x86_64 }
- { os: windows-latest, name: windows }
steps:
- uses: actions/checkout@v4
- name: Install deps (Linux)
if: runner.os == 'Linux'
run: sudo apt-get update && sudo apt-get install -y cmake build-essential libsdl2-dev libgl1-mesa-dev
- name: Install deps (macOS arm64, native)
if: matrix.mac_arch == 'arm64'
run: brew install sdl2
- name: Build x86_64 SDL2 from source (macOS cross)
if: matrix.mac_arch == 'x86_64'
run: |
git clone --depth 1 -b release-2.30.x https://github.com/libsdl-org/SDL SDLsrc
cmake -S SDLsrc -B sdlbuild -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_OSX_ARCHITECTURES=x86_64 -DCMAKE_OSX_DEPLOYMENT_TARGET=10.13 \
-DSDL_SHARED=OFF -DSDL_STATIC=ON -DSDL_TEST=OFF \
-DCMAKE_INSTALL_PREFIX="$PWD/sdlx86"
cmake --build sdlbuild -j3 --target install
- name: Configure
shell: bash
run: |
if [ "${{ matrix.mac_arch }}" = "x86_64" ]; then
cmake -B build -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_OSX_ARCHITECTURES=x86_64 -DCMAKE_OSX_DEPLOYMENT_TARGET=10.13 \
-DCMAKE_PREFIX_PATH="$PWD/sdlx86"
else
cmake -B build -DCMAKE_BUILD_TYPE=Release
fi
- name: Build
shell: bash
run: cmake --build build --config Release -j 3
- name: Verify arch (macOS)
if: runner.os == 'macOS'
run: |
echo "runner arch: $(uname -m) target: ${{ matrix.name }}"
file build/msxforge-gui
lipo -archs build/msxforge-gui || true
- name: Stage artifacts (Unix)
if: runner.os != 'Windows'
run: |
mkdir dist
cp build/msxforge build/msxforge-gui build/dsk2dmk dist/
cp README.md LICENSE dist/
- name: Stage artifacts (Windows)
if: runner.os == 'Windows'
shell: bash
run: |
mkdir dist
cp build/Release/msxforge.exe build/Release/msxforge-gui.exe build/Release/dsk2dmk.exe dist/
cp libs/SDL2/lib/SDL2.dll dist/
cp README.md LICENSE dist/
- uses: actions/upload-artifact@v4
with:
name: msxforge-${{ matrix.name }}
path: dist/
if-no-files-found: error