From 013172f9251bd59a7bfba69073e4a7a0750fbdd3 Mon Sep 17 00:00:00 2001 From: 4gray Date: Fri, 10 Jul 2026 23:01:06 +0200 Subject: [PATCH] spike(embedded-mpv): support MacPorts libmpv and legacy-macOS bundles MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Makefile and collect-results.sh now detect libmpv in the Homebrew prefix or MacPorts /opt/local (Homebrew is unsupported on legacy macOS like High Sierra; 'sudo port install mpv +libmpv' provides libmpv there). make-bundle takes ELECTRON_VERSION/BUNDLE_SUFFIX overrides — Electron 27+ needs macOS 10.15, so High Sierra bundles ship Electron 26.6.10 (LSMinimumSystemVersion 10.13). Co-Authored-By: Claude Fable 5 --- spikes/mpv-frame-copy/Makefile | 10 +++++++++- spikes/mpv-frame-copy/collect-results.sh | 13 ++++++++++--- spikes/mpv-frame-copy/make-bundle.sh | 16 +++++++++++++--- 3 files changed, 32 insertions(+), 7 deletions(-) diff --git a/spikes/mpv-frame-copy/Makefile b/spikes/mpv-frame-copy/Makefile index 5069afcea..71f53bd92 100644 --- a/spikes/mpv-frame-copy/Makefile +++ b/spikes/mpv-frame-copy/Makefile @@ -5,7 +5,15 @@ # if detection picks the wrong one. Works on Apple Silicon (/opt/homebrew) # and Intel (/usr/local) Homebrew layouts. -BREW_PREFIX ?= $(shell brew --prefix 2>/dev/null || echo /opt/homebrew) +# libmpv prefix: Homebrew (Apple Silicon /opt/homebrew or Intel /usr/local) +# or MacPorts (/opt/local, needed on legacy macOS like High Sierra where +# Homebrew is unsupported — install with: sudo port install mpv +libmpv). +MPV_PREFIX ?= $(shell \ + brew_p="$$(brew --prefix 2>/dev/null)"; \ + if [ -n "$$brew_p" ] && ls "$$brew_p"/lib/libmpv*.dylib >/dev/null 2>&1; then echo "$$brew_p"; \ + elif ls /opt/local/lib/libmpv*.dylib >/dev/null 2>&1; then echo /opt/local; \ + else echo /opt/homebrew; fi) +BREW_PREFIX ?= $(MPV_PREFIX) # Self-contained bundles vendor the four N-API headers so no Node install # is needed; otherwise take headers from the PATH node. ifneq (,$(wildcard vendor/node-headers/node_api.h)) diff --git a/spikes/mpv-frame-copy/collect-results.sh b/spikes/mpv-frame-copy/collect-results.sh index 72479d653..cf4a42470 100755 --- a/spikes/mpv-frame-copy/collect-results.sh +++ b/spikes/mpv-frame-copy/collect-results.sh @@ -22,9 +22,16 @@ if ! xcode-select -p >/dev/null 2>&1; then echo "Xcode Command Line Tools required: run 'xcode-select --install'" >&2 exit 1 fi -BREW_PREFIX="$(brew --prefix 2>/dev/null || true)" -if [[ -z "$BREW_PREFIX" || (! -e "$BREW_PREFIX/lib/libmpv.dylib" && ! -e "$BREW_PREFIX/lib/libmpv.2.dylib") ]]; then - echo "Homebrew libmpv required: run 'brew install mpv'" >&2 +MPV_PREFIX="" +for prefix in "$(brew --prefix 2>/dev/null || true)" /opt/local; do + if [[ -n "$prefix" ]] && ls "$prefix"/lib/libmpv*.dylib >/dev/null 2>&1; then + MPV_PREFIX="$prefix" + break + fi +done +if [[ -z "$MPV_PREFIX" ]]; then + echo "libmpv not found. Install it with Homebrew ('brew install mpv') or," >&2 + echo "on legacy macOS (e.g. High Sierra), MacPorts: 'sudo port install mpv +libmpv'" >&2 exit 1 fi diff --git a/spikes/mpv-frame-copy/make-bundle.sh b/spikes/mpv-frame-copy/make-bundle.sh index 5e92ed467..dbfa8c461 100755 --- a/spikes/mpv-frame-copy/make-bundle.sh +++ b/spikes/mpv-frame-copy/make-bundle.sh @@ -6,15 +6,20 @@ # Command Line Tools and `brew install mpv`. # # ./make-bundle.sh [x64|arm64] # Electron arch of the TARGET machine +# +# For legacy macOS targets override the Electron version — Electron 27+ +# requires macOS 10.15, Electron 26.6.10 is the last for 10.13/10.14: +# ELECTRON_VERSION=26.6.10 BUNDLE_SUFFIX=highsierra-x64 ./make-bundle.sh x64 set -euo pipefail DIR="$(cd "$(dirname "$0")" && pwd)" cd "$DIR" ARCH="${1:-x64}" -ELECTRON_VERSION="41.7.2" +ELECTRON_VERSION="${ELECTRON_VERSION:-41.7.2}" +BUNDLE_SUFFIX="${BUNDLE_SUFFIX:-$ARCH}" BUNDLE_ROOT="build/bundle/mpv-frame-copy-spike" -TARBALL="build/mpv-frame-copy-spike-macos-$ARCH.tar.gz" +TARBALL="build/mpv-frame-copy-spike-macos-$BUNDLE_SUFFIX.tar.gz" rm -rf build/bundle mkdir -p "$BUNDLE_ROOT" @@ -69,7 +74,12 @@ cat > "$BUNDLE_ROOT/START-HERE.md" <<'EOF' Target-machine prerequisites (no Node/pnpm needed): 1. Xcode Command Line Tools: `xcode-select --install` -2. Homebrew mpv: `brew install mpv` +2. libmpv, either via: + - Homebrew (macOS 13+): `brew install mpv` + - MacPorts (legacy macOS, e.g. High Sierra — install the MacPorts pkg + for your macOS from macports.org first): + `sudo port install mpv +libmpv` (compiles from source; can take + an hour or more on old hardware) Then: