Build sup2vob into the app bundle so it ships and stays fresh

A "Build sup2vob CLI" run-script phase on the Subler target runs the
submodule's Makefile (incremental — a no-op unless the conversion
sources changed) and installs the product to Contents/MacOS/sup2vob.
Every Subler build refreshes the CLI; a terminal sup2vob can be a
symlink into the bundle instead of a copied `make install`.

extractsubs finds that bundle-internal sup2vob automatically: PATH
first, then the script's own ../MacOS/sup2vob sibling, so running the
copy inside Subler.app/Contents/Resources works with no install at all
(verified with sup2vob absent from PATH: same 1920x1080 .sub/.idx).

The phase walks the source tree, so it opts the Subler target out of
ENABLE_USER_SCRIPT_SANDBOXING — a build-time shell-script file-access
setting only, no effect on the app's runtime security posture.

Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
Scott GarrettandClaude Code committed 2026-11-28 23:25:40 -05:00
1 parent 56d843c044
commit 51112947fb
3 files changed
+53 -9

No files matched your search

+26 -7
View File
@@ -37,7 +37,8 @@ then
fi
# --- dependency checks ------------------------------------------------------
# ffprobe, ffmpeg and sup2vob must all be on PATH, and the ffmpeg build must
# ffprobe and ffmpeg must be on PATH (sup2vob too, or it is taken from the
# Subler.app bundle beside this script), and the ffmpeg build must
# include muxers for every extension stage 2 can write ("sup" is the one
# minimal builds strip). Check up front so a missing or broken tool prints a
# clear message and exits 1 instead of failing per track mid-pipeline.
@@ -50,10 +51,26 @@ die()
}
missing=()
for tool in ffprobe ffmpeg sup2vob
for tool in ffprobe ffmpeg
do
command -v "${tool}" >/dev/null 2>&1 || missing+=("${tool}")
done
# sup2vob is looked up on PATH first (a `make install` copy, or a symlink to
# the one bundled with Subler.app), then as this script's bundle sibling:
# the app build compiles sup2vob into Contents/MacOS beside this script's
# Contents/Resources home, so running the bundled script needs no install.
sup2vob_bin=""
if command -v sup2vob >/dev/null 2>&1
then
sup2vob_bin="sup2vob"
else
sibling="$(dirname "$0")/../MacOS/sup2vob"
[ -x "${sibling}" ] && sup2vob_bin="${sibling}"
fi
[ -n "${sup2vob_bin}" ] || missing+=("sup2vob")
if [ "${#missing[@]}" -gt 0 ]
then
printf 'extractsubs: missing dependency on PATH: %s\n' "${missing[*]}" >&2
@@ -67,19 +84,21 @@ then
printf ' e.g. brew install ffmpeg\n' >&2
;;
sup2vob)
printf ' build and install it from sup2vob/: make && sudo make install\n' >&2
printf ' build and install it: cd MP42Foundation/sup2vob && make && sudo make install\n' >&2
printf ' (or run the copy bundled in Subler.app/Contents/Resources — the app\n' >&2
printf ' carries sup2vob at Contents/MacOS/sup2vob and needs no install)\n' >&2
;;
esac
done
exit 1
fi
# Found on PATH is not enough — a broken install (bad arch, half-updated
# Homebrew) must fail here too, so give each tool a cheap smoke run.
# Found is not enough — a broken install (bad arch, half-updated Homebrew)
# must fail here too, so give each tool a cheap smoke run.
ffprobe -version >/dev/null 2>&1 || die "ffprobe is on PATH but does not run (ffprobe -version failed)"
ffmpeg -version >/dev/null 2>&1 || die "ffmpeg is on PATH but does not run (ffmpeg -version failed)"
sup2vob --help >/dev/null 2>&1 || die "sup2vob is on PATH but does not run (sup2vob --help failed)"
"${sup2vob_bin}" --help >/dev/null 2>&1 || die "sup2vob (${sup2vob_bin}) does not run (${sup2vob_bin} --help failed)"
# Feature check: ffmpeg must be able to mux every format stage 2 can write —
# "sup" for pgs, "srt", "ass" and "webvtt" for text. There is no "ssa" muxer
@@ -354,5 +373,5 @@ fi
cat /tmp/extractsubs.$$ | egrep "\.sup$" | cut -f 3- -d ':' | while IFS= read -r supfile
do
[ -z "${supfile}" ] && continue
sup2vob --full "${supfile}"
"${sup2vob_bin}" --full "${supfile}"
done