build: add macOS universal libmpv.dylib CI build

Vendor ci/build-libmpv-macos.sh, which builds every dependency statically
for the native runner architecture and links them into a single
self-contained libmpv dylib (coreaudio output, videotoolbox hardware
decode, OpenGL render API; no vulkan/cocoa player). build-macos.yml runs
it on macos-14 (x86_64) and macos-15 (arm64) in parallel and a merge job
combines the two dylibs into one universal libmpv.dylib with lipo, matching
the file name jlibmpv expects on macOS.
This commit is contained in:
david
2026-10-01 00:36:24 +02:00
parent ca0a5de2a9
commit 4b385cd92f
4 changed files with 424 additions and 4 deletions
+94
View File
@@ -0,0 +1,94 @@
name: build-macos-arch
# Builds the self-contained libmpv dylib for one macOS architecture
# (x86_64 on macos-14, arm64 on macos-15) using the vendored build script.
# The merge job in build-macos.yml combines the per-architecture dylibs into
# a universal binary.
on:
workflow_call:
inputs:
arch:
description: Target architecture (x86_64 or arm64)
required: true
type: string
runner:
description: GitHub runner image providing that architecture
required: true
type: string
env:
MPV_REF: v0.41.0
ARCH: ${{ inputs.arch }}
jobs:
build:
runs-on: ${{ inputs.runner }}
env:
CCACHE_BASEDIR: ${{ github.workspace }}
CCACHE_DIR: ${{ github.workspace }}/.ccache
CCACHE_MAXSIZE: 500M
steps:
- name: Check out mpv-natives (build scripts)
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Check out mpv (pinned tag)
uses: actions/checkout@v4
with:
repository: mpv-player/mpv
ref: ${{ env.MPV_REF }}
path: mpv
fetch-depth: 1
- name: Get time
id: get_time
run: echo "timestamp=$(date +%s)" >> $GITHUB_OUTPUT
- name: Restore ccache
uses: actions/cache/restore@v4
with:
path: ${{ env.CCACHE_DIR }}
key: macos-${{ env.ARCH }}-${{ steps.get_time.outputs.timestamp }}
restore-keys: macos-${{ env.ARCH }}-
- name: Install dependencies
run: |
brew install ccache nasm ninja
python3 -m pip install --user meson
export PATH="$HOME/Library/Python/3.12/bin:$PATH"
# export so meson finds pip-installed tools
echo "$HOME/Library/Python/3.12/bin" >> "$GITHUB_PATH"
# Run the vendored build script from inside the mpv source tree, so the
# native build writes macos_prefix/ and the meson build next to mpv's
# meson.build and produces the self-contained dylib in mpv/artifact/.
- name: Build self-contained libmpv
working-directory: mpv
run: bash "${{ github.workspace }}/ci/build-libmpv-macos.sh"
- name: Print meson log on failure
if: failure()
run: cat mpv/macos_build/meson-logs/meson-log.txt
- name: Collect artifact
run: |
mkdir -p "artifact-macos-${{ env.ARCH }}"
cp -pv mpv/artifact/libmpv-2.dylib "artifact-macos-${{ env.ARCH }}/"
cp -pv mpv/artifact/*.h "artifact-macos-${{ env.ARCH }}/" 2>/dev/null || true
echo "=== contents ==="
ls -l "artifact-macos-${{ env.ARCH }}"
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: mpv-natives-macos-${{ env.ARCH }}-mpv-${{ env.MPV_REF }}
path: artifact-macos-${{ env.ARCH }}
- name: Save ccache
uses: actions/cache/save@v4
if: always()
with:
path: ${{ env.CCACHE_DIR }}
key: macos-${{ env.ARCH }}-${{ steps.get_time.outputs.timestamp }}
+78
View File
@@ -0,0 +1,78 @@
name: build-macos
# Builds a universal (arm64 + x86_64) self-contained libmpv.dylib for macOS
# from mpv source pinned to a release tag. Two native builds run in parallel
# (x86_64 on macos-14, arm64 on macos-15); a merge job combines the two dylibs
# with lipo into one universal library and uploads it.
#
# Every dependency is built static and linked into the one dylib (same
# approach as the Windows build). jlibmpv expects the file name
# `libmpv.dylib` (no -2) and one universal binary for both architectures.
#
# Pinned to mpv v0.41.0 — the version whose client API (131077) the jlibmpv
# JNA bindings are validated against. Bump the ref here for a libmpv update.
# The build recipe lives in ci/build-libmpv-macos.sh in this repository.
on:
push:
branches: [main]
workflow_dispatch:
env:
MPV_REF: v0.41.0
jobs:
build-x86_64:
uses: ./.github/workflows/build-macos-arch.yml
with:
arch: x86_64
runner: macos-14
build-arm64:
uses: ./.github/workflows/build-macos-arch.yml
with:
arch: arm64
runner: macos-15
merge:
needs: [build-x86_64, build-arm64]
runs-on: macos-15
steps:
- name: Check out mpv-natives (build scripts)
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Check out mpv (pinned tag)
uses: actions/checkout@v4
with:
repository: mpv-player/mpv
ref: ${{ env.MPV_REF }}
path: mpv
fetch-depth: 1
- name: Download architecture artifacts
uses: actions/download-artifact@v4
with:
pattern: mpv-natives-macos-${{ env.MPV_REF }}-*
path: arch
merge-multiple: true
- name: Create universal dylib
run: |
mkdir -p artifact-libmpv
lipo -create \
"arch/x86_64/libmpv-2.dylib" \
"arch/arm64/libmpv-2.dylib" \
-output artifact-libmpv/libmpv.dylib
lipo -info artifact-libmpv/libmpv.dylib
cp -pv mpv/mpvrender.h mpv/mpv/client.h mpv/ebml_types.h artifact-libmpv/ 2>/dev/null || true
sha256sum artifact-libmpv/libmpv.dylib > artifact-libmpv/checksums.txt
cat artifact-libmpv/checksums.txt
ls -l artifact-libmpv
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: mpv-natives-macos-universal-mpv-${{ env.MPV_REF }}
path: artifact-libmpv