fix(cpn): tie macOS bundle to its own SDL copies, and verify it (#7653)
Co-authored-by: Peter Feerick <5500713+pfeerick@users.noreply.github.com> Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Peter Feerick
Claude Opus 5
parent
2025ac7274
commit
c562f486d0
@@ -10,8 +10,17 @@ inputs:
|
||||
description: 'Qt architecture'
|
||||
required: runner.os != 'Linux'
|
||||
sdl2-version:
|
||||
description: 'SDL2 version'
|
||||
description: 'Upstream SDL2 version (Windows only)'
|
||||
default: '2.32.8'
|
||||
sdl3-version:
|
||||
description: 'SDL3 version built from source for macOS'
|
||||
default: '3.4.14'
|
||||
sdl2-compat-version:
|
||||
description: 'sdl2-compat version built from source for macOS'
|
||||
default: '2.32.70'
|
||||
macos-deployment-target:
|
||||
description: 'Minimum macOS version the SDL libraries are built for'
|
||||
default: '11.0'
|
||||
|
||||
runs:
|
||||
using: "composite"
|
||||
@@ -29,14 +38,26 @@ runs:
|
||||
cache: true
|
||||
cache-key-prefix: 'install-qt-action-${{ inputs.qt-arch }}'
|
||||
|
||||
- name: Setup SDL2
|
||||
# macOS builds SDL from source (see setup-sdl.sh) - cache it so only the first
|
||||
# run per version pays for it
|
||||
- name: Cache SDL build
|
||||
if: runner.os == 'macOS'
|
||||
uses: actions/cache@v6
|
||||
with:
|
||||
path: ${{ runner.temp }}/sdl
|
||||
key: sdl-${{ runner.os }}-${{ inputs.sdl3-version }}-${{ inputs.sdl2-compat-version }}-${{ inputs.macos-deployment-target }}
|
||||
|
||||
- name: Setup SDL
|
||||
if: runner.os != 'Linux'
|
||||
shell: bash
|
||||
env:
|
||||
ACTION_PATH: ${{ github.action_path }}
|
||||
SDL2_VERSION: ${{ inputs.sdl2-version }}
|
||||
SDL3_VERSION: ${{ inputs.sdl3-version }}
|
||||
SDL2_COMPAT_VERSION: ${{ inputs.sdl2-compat-version }}
|
||||
MACOS_DEPLOYMENT_TARGET: ${{ inputs.macos-deployment-target }}
|
||||
run: |
|
||||
"${ACTION_PATH}/setup-sdl2.sh" ${SDL2_VERSION}
|
||||
"${ACTION_PATH}/setup-sdl.sh"
|
||||
|
||||
- name: Setup MSVC
|
||||
if: runner.os == 'Windows'
|
||||
|
||||
Executable
+108
@@ -0,0 +1,108 @@
|
||||
#!/usr/bin/env bash
|
||||
# setup-sdl.sh
|
||||
# Provisions SDL for Companion builds.
|
||||
#
|
||||
# Windows: upstream SDL2 MSVC development binaries.
|
||||
# macOS: sdl2-compat + SDL3 built from source.
|
||||
# Linux: provided by the Docker container.
|
||||
#
|
||||
# macOS builds against sdl2-compat rather than classic SDL2 because that is what users get
|
||||
# from Homebrew, and it is the configuration that exposed the SDL3 bundling bug - CI needs to
|
||||
# exercise the same code path Companion ships through.
|
||||
#
|
||||
# Homebrew itself cannot be used here: its bottles are single-architecture and target the
|
||||
# runner's macOS version, while Companion ships a universal binary for macOS 11.0+. Building
|
||||
# from source is what keeps both properties.
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
SDL2_VERSION="${SDL2_VERSION:?SDL2_VERSION must be set}"
|
||||
|
||||
build_cmake_project() {
|
||||
local name="$1" url="$2" srcdir="$3"
|
||||
shift 3
|
||||
|
||||
echo "Building ${name} (universal, macOS ${MACOS_DEPLOYMENT_TARGET}+)..."
|
||||
curl -fsSL -o "${RUNNER_TEMP}/${name}.tar.gz" "${url}"
|
||||
mkdir -p "${RUNNER_TEMP}/src"
|
||||
tar -xzf "${RUNNER_TEMP}/${name}.tar.gz" -C "${RUNNER_TEMP}/src"
|
||||
|
||||
cmake -S "${RUNNER_TEMP}/src/${srcdir}" -B "${RUNNER_TEMP}/build-${name}" \
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
-DCMAKE_OSX_ARCHITECTURES="x86_64;arm64" \
|
||||
-DCMAKE_OSX_DEPLOYMENT_TARGET="${MACOS_DEPLOYMENT_TARGET}" \
|
||||
-DCMAKE_INSTALL_PREFIX="${SDL_ROOT}" \
|
||||
-DCMAKE_PREFIX_PATH="${SDL_ROOT}" \
|
||||
"$@"
|
||||
cmake --build "${RUNNER_TEMP}/build-${name}" --parallel
|
||||
cmake --install "${RUNNER_TEMP}/build-${name}"
|
||||
}
|
||||
|
||||
case "$RUNNER_OS" in
|
||||
Windows)
|
||||
ARCHIVE="SDL2-devel-${SDL2_VERSION}-VC.zip"
|
||||
URL="https://github.com/libsdl-org/SDL/releases/download/release-${SDL2_VERSION}/${ARCHIVE}"
|
||||
DEST="${RUNNER_TEMP}/SDL2"
|
||||
|
||||
echo "Downloading SDL2 ${SDL2_VERSION} (Windows/MSVC)..."
|
||||
curl -fsSL -o "${RUNNER_TEMP}/${ARCHIVE}" "${URL}"
|
||||
unzip -q "${RUNNER_TEMP}/${ARCHIVE}" -d "${DEST}"
|
||||
|
||||
SDL2_ROOT="${DEST}/SDL2-${SDL2_VERSION}"
|
||||
echo "SDL2_ROOT=${SDL2_ROOT}" >> "${GITHUB_ENV}"
|
||||
;;
|
||||
|
||||
macOS)
|
||||
SDL3_VERSION="${SDL3_VERSION:?SDL3_VERSION must be set}"
|
||||
SDL2_COMPAT_VERSION="${SDL2_COMPAT_VERSION:?SDL2_COMPAT_VERSION must be set}"
|
||||
MACOS_DEPLOYMENT_TARGET="${MACOS_DEPLOYMENT_TARGET:-11.0}"
|
||||
SDL_ROOT="${RUNNER_TEMP}/sdl"
|
||||
STAMP="${SDL_ROOT}/.stamp-${SDL3_VERSION}-${SDL2_COMPAT_VERSION}-${MACOS_DEPLOYMENT_TARGET}"
|
||||
|
||||
if [[ -f "${STAMP}" ]]; then
|
||||
echo "Reusing cached SDL build in ${SDL_ROOT}"
|
||||
else
|
||||
rm -rf "${SDL_ROOT}"
|
||||
|
||||
# SDL3 first - sdl2-compat needs its headers and CMake package to configure
|
||||
build_cmake_project "SDL3" \
|
||||
"https://github.com/libsdl-org/SDL/releases/download/release-${SDL3_VERSION}/SDL3-${SDL3_VERSION}.tar.gz" \
|
||||
"SDL3-${SDL3_VERSION}" \
|
||||
-DSDL_SHARED=ON -DSDL_STATIC=OFF -DSDL_TESTS=OFF -DSDL_EXAMPLES=OFF
|
||||
|
||||
build_cmake_project "sdl2-compat" \
|
||||
"https://github.com/libsdl-org/sdl2-compat/releases/download/release-${SDL2_COMPAT_VERSION}/sdl2-compat-${SDL2_COMPAT_VERSION}.tar.gz" \
|
||||
"sdl2-compat-${SDL2_COMPAT_VERSION}" \
|
||||
-DSDL2COMPAT_STATIC=OFF -DSDL2COMPAT_TESTS=OFF
|
||||
|
||||
touch "${STAMP}"
|
||||
fi
|
||||
|
||||
# Both live under one prefix, so a single entry on CMAKE_PREFIX_PATH finds
|
||||
# SDL2 (sdl2-compat) and SDL3 alike.
|
||||
echo "SDL2_ROOT=${SDL_ROOT}" >> "${GITHUB_ENV}"
|
||||
|
||||
echo "Verifying universal slices and deployment target..."
|
||||
for lib in "${SDL_ROOT}"/lib/libSDL2-2.0.0.dylib "${SDL_ROOT}"/lib/libSDL3.0.dylib; do
|
||||
[[ -f "${lib}" ]] || { echo "::error::Expected ${lib} to exist"; exit 1; }
|
||||
archs="$(lipo -archs "${lib}")"
|
||||
case "${archs}" in
|
||||
*x86_64*arm64*|*arm64*x86_64*) ;;
|
||||
*) echo "::error::${lib} is not universal (got: ${archs})"; exit 1 ;;
|
||||
esac
|
||||
echo " $(basename "${lib}"): ${archs}"
|
||||
vtool -show-build "${lib}" | grep -E 'minos|platform' || true
|
||||
done
|
||||
;;
|
||||
|
||||
Linux)
|
||||
echo "Skipping — SDL is provided by the Docker container"
|
||||
;;
|
||||
|
||||
*)
|
||||
echo "::error::Unsupported RUNNER_OS: ${RUNNER_OS}"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
echo "SDL setup complete for ${RUNNER_OS}"
|
||||
@@ -1,46 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
# setup-sdl2.sh
|
||||
# Downloads/installs SDL2 for Windows and macOS.
|
||||
# Linux is handled separately via a Docker container.
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
VERSION="${1:?Usage: setup-sdl2.sh <version>}"
|
||||
|
||||
case "$RUNNER_OS" in
|
||||
Windows)
|
||||
ARCHIVE="SDL2-devel-${VERSION}-VC.zip"
|
||||
URL="https://github.com/libsdl-org/SDL/releases/download/release-${VERSION}/${ARCHIVE}"
|
||||
DEST="${RUNNER_TEMP}/SDL2"
|
||||
|
||||
echo "Downloading SDL2 ${VERSION} (Windows/MSVC)..."
|
||||
curl -fsSL -o "${RUNNER_TEMP}/${ARCHIVE}" "${URL}"
|
||||
unzip -q "${RUNNER_TEMP}/${ARCHIVE}" -d "${DEST}"
|
||||
|
||||
SDL2_ROOT="${DEST}/SDL2-${VERSION}"
|
||||
echo "SDL2_ROOT=${SDL2_ROOT}" >> "${GITHUB_ENV}"
|
||||
;;
|
||||
|
||||
macOS)
|
||||
ARCHIVE="SDL2-${VERSION}.dmg"
|
||||
URL="https://github.com/libsdl-org/SDL/releases/download/release-${VERSION}/${ARCHIVE}"
|
||||
|
||||
echo "Downloading SDL2 ${VERSION} (macOS framework)..."
|
||||
curl -fsSL -o "${RUNNER_TEMP}/${ARCHIVE}" "${URL}"
|
||||
|
||||
hdiutil attach "${RUNNER_TEMP}/${ARCHIVE}" -quiet -mountpoint "${RUNNER_TEMP}/sdl2-mnt"
|
||||
sudo cp -R "${RUNNER_TEMP}/sdl2-mnt/SDL2.framework" /Library/Frameworks/
|
||||
hdiutil detach "${RUNNER_TEMP}/sdl2-mnt" -quiet
|
||||
;;
|
||||
|
||||
Linux)
|
||||
echo "Skipping — SDL2 is provided by the Docker container"
|
||||
;;
|
||||
|
||||
*)
|
||||
echo "::error::Unsupported RUNNER_OS: ${RUNNER_OS}"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
echo "SDL2 ${VERSION} setup complete for ${RUNNER_OS}"
|
||||
Reference in New Issue
Block a user