mirror of
https://github.com/kirbylink/mpv-natives
synced 2026-11-19 21:24:39 +01:00
Pinning fontconfig's sysconfdir to /etc made the build try to install its own conf files into the real /etc/fonts/conf.d, which fails without root on the runner (PermissionError). Revert to the default prefix: the prefix-baked config paths are harmless because fontconfig falls back to a built-in config that scans /usr/share/fonts and /usr/local/share/fonts when no config file exists at the compiled-in path - so libass's font lookup works on any standard box without env vars. Also tighten the artifact verification: instead of a broad build-path grep (which would false-positive on fontconfig's benign prefix strings), assert the ALSA config dir is the system path and not the build prefix - the specific regression that broke audio.
144 lines
5.3 KiB
YAML
144 lines
5.3 KiB
YAML
name: build-linux
|
|
|
|
# Builds a single self-contained libmpv.so for Linux (x86_64) from mpv source
|
|
# pinned to a release tag. Every dependency is built static and linked into
|
|
# the one .so; only glibc/pthread/dl/m and the system zlib stay external, so
|
|
# the artifact has no runtime dependency closure to ship (unlike mpv's own
|
|
# shared-lib CI build).
|
|
#
|
|
# Linux is the easiest of the three platforms: a single native build on an
|
|
# ubuntu runner, no cross-compile, no lipo. The only Linux-specific work is the
|
|
# font stack: libass (a hard mpv dependency) needs fontconfig (-> expat) where
|
|
# macOS/Windows use CoreText/DirectWrite.
|
|
#
|
|
# 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 (dependency versions, static flags) lives in
|
|
# ci/build-libmpv-linux.sh in this repository.
|
|
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
workflow_dispatch:
|
|
|
|
env:
|
|
MPV_REF: v0.41.0
|
|
TARGET: x86_64-linux
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: ubuntu-24.04
|
|
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%N)" >> $GITHUB_OUTPUT
|
|
|
|
- name: Restore ccache
|
|
uses: actions/cache/restore@v4
|
|
with:
|
|
path: ${{ env.CCACHE_DIR }}
|
|
key: ${{ env.TARGET }}-${{ steps.get_time.outputs.timestamp }}
|
|
restore-keys: ${{ env.TARGET }}-
|
|
|
|
- name: Install dependencies
|
|
run: |
|
|
sudo apt-get update
|
|
sudo apt-get install --no-install-recommends -y \
|
|
ccache nasm ninja-build pkgconf cmake autoconf automake libtool
|
|
python3 -m pip install meson
|
|
|
|
# Run the vendored build script from inside the mpv source tree, so the
|
|
# native build writes linux_prefix/ and the meson build next to mpv's
|
|
# meson.build and produces the self-contained .so in mpv/artifact/.
|
|
- name: Build self-contained libmpv
|
|
working-directory: mpv
|
|
run: bash "${{ github.workspace }}/ci/build-libmpv-linux.sh"
|
|
|
|
- name: Print meson log on failure
|
|
if: failure()
|
|
run: cat mpv/linux_build/meson-logs/meson-log.txt
|
|
|
|
- name: Collect artifact
|
|
run: |
|
|
mkdir -p artifact-libmpv
|
|
cp -pv mpv/artifact/libmpv.so artifact-libmpv/
|
|
echo "=== contents ==="
|
|
ls -l artifact-libmpv
|
|
|
|
# Verify the artifact is self-contained and portable:
|
|
# (1) ldd shows only system libs (no vendored .so to ship),
|
|
# (2) no .debug sections remain (strip worked, artifact stays small),
|
|
# (3) the ALSA config dir is the system path, not the build prefix.
|
|
# (The prefix-baked ALSA_CONFIG_DIR is what broke audio before:
|
|
# snd_pcm_open("default") looked for <prefix>/share/alsa/alsa.conf
|
|
# on the target box. fontconfig also bakes its prefix into the
|
|
# binary, but that is benign - with no config at that path it falls
|
|
# back to a built-in config that scans /usr/share/fonts, so we do
|
|
# NOT fail on fontconfig prefix strings.)
|
|
- name: Verify artifact (ldd, size, alsa config dir)
|
|
run: |
|
|
cd artifact-libmpv
|
|
echo "=== dynamic deps (system libs only) ==="
|
|
ldd libmpv.so
|
|
echo "=== debug sections (expect 0) ==="
|
|
readelf -S libmpv.so | grep -c '\.debug' || true
|
|
echo "=== size ==="
|
|
du -h libmpv.so
|
|
echo "=== ALSA config dir baked into the lib (must be /usr/share/alsa) ==="
|
|
if strings -a libmpv.so | grep -q "linux_prefix/share/alsa\|/share/alsa"; then
|
|
strings -a libmpv.so | grep -o "[^ ]*share/alsa" | sort -u
|
|
else
|
|
echo "ERROR: no ALSA config dir found in libmpv.so (libasound not linked?)"
|
|
exit 1
|
|
fi
|
|
if strings -a libmpv.so | grep -q "linux_prefix/share/alsa"; then
|
|
echo "ERROR: ALSA config dir points at the build prefix (audio will be broken)"
|
|
exit 1
|
|
fi
|
|
echo "OK"
|
|
|
|
- name: Checksums
|
|
run: |
|
|
cd artifact-libmpv
|
|
sha256sum libmpv.so > checksums.txt
|
|
cat checksums.txt
|
|
|
|
- name: Artifact name
|
|
id: artifact
|
|
run: |
|
|
VER=$(cat mpv/MPV_VERSION | tr -d '[:space:]')
|
|
echo "name=mpv-natives-linux-x86_64-mpv-$VER" >> "$GITHUB_OUTPUT"
|
|
echo "version=$VER" >> "$GITHUB_OUTPUT"
|
|
|
|
# upload-artifact zips the directory itself, so handing it the folder
|
|
# (not a pre-zipped file) yields a single-level archive without the
|
|
# double-zip wrapper.
|
|
- name: Upload artifact
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: ${{ steps.artifact.outputs.name }}
|
|
path: artifact-libmpv
|
|
|
|
- name: Save ccache
|
|
uses: actions/cache/save@v4
|
|
if: always()
|
|
with:
|
|
path: ${{ env.CCACHE_DIR }}
|
|
key: ${{ env.TARGET }}-${{ steps.get_time.outputs.timestamp }} |