mpv: clean‐ups and Darwin improvements (#350674)

This commit is contained in:
Franz Pletz 2024-10-24 13:24:46 +02:00 committed by GitHub
commit f4f88f9dbc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 37 additions and 106 deletions

View File

@ -7,7 +7,6 @@
buildPackages, buildPackages,
callPackage, callPackage,
config, config,
darwin,
docutils, docutils,
fetchFromGitHub, fetchFromGitHub,
ffmpeg, ffmpeg,
@ -15,15 +14,11 @@
freetype, freetype,
lcms2, lcms2,
libGL, libGL,
libGLU,
libX11, libX11,
libXScrnSaver, libXScrnSaver,
libXext, libXext,
libXinerama,
libXpresent, libXpresent,
libXrandr, libXrandr,
libXv,
libXxf86vm,
libarchive, libarchive,
libass, libass,
libbluray, libbluray,
@ -33,19 +28,17 @@
libcdio-paranoia, libcdio-paranoia,
libdrm, libdrm,
libdvdnav, libdvdnav,
libiconv,
libjack2, libjack2,
libplacebo, libplacebo,
libpng,
libpthreadstubs, libpthreadstubs,
libpulseaudio, libpulseaudio,
libsixel, libsixel,
libtheora,
libuchardet, libuchardet,
libva, libva,
libvdpau, libvdpau,
libxkbcommon, libxkbcommon,
lua, lua,
makeWrapper,
mesa, mesa,
meson, meson,
mujs, mujs,
@ -58,7 +51,6 @@
python3, python3,
rubberband, rubberband,
shaderc, # instead of spirv-cross shaderc, # instead of spirv-cross
speex,
stdenv, stdenv,
swift, swift,
testers, testers,
@ -68,7 +60,6 @@
wayland, wayland,
wayland-protocols, wayland-protocols,
wayland-scanner, wayland-scanner,
xcbuild,
zimg, zimg,
# Boolean # Boolean
@ -81,59 +72,28 @@
cmsSupport ? true, cmsSupport ? true,
drmSupport ? stdenv.hostPlatform.isLinux, drmSupport ? stdenv.hostPlatform.isLinux,
dvbinSupport ? stdenv.hostPlatform.isLinux, dvbinSupport ? stdenv.hostPlatform.isLinux,
dvdnavSupport ? stdenv.hostPlatform.isLinux, dvdnavSupport ? true,
jackaudioSupport ? false, jackaudioSupport ? false,
javascriptSupport ? true, javascriptSupport ? true,
libpngSupport ? true,
openalSupport ? true, openalSupport ? true,
pipewireSupport ? stdenv.hostPlatform.isLinux, pipewireSupport ? !stdenv.hostPlatform.isDarwin,
pulseSupport ? config.pulseaudio or stdenv.hostPlatform.isLinux, pulseSupport ? config.pulseaudio or (!stdenv.hostPlatform.isDarwin),
rubberbandSupport ? true, rubberbandSupport ? true,
screenSaverSupport ? true, sdl2Support ? false,
sdl2Support ? !stdenv.hostPlatform.isDarwin,
sixelSupport ? false, sixelSupport ? false,
speexSupport ? true, vaapiSupport ? !stdenv.hostPlatform.isDarwin && (x11Support || waylandSupport),
swiftSupport ? stdenv.hostPlatform.isDarwin,
theoraSupport ? true,
vaapiSupport ? x11Support || waylandSupport,
vapoursynthSupport ? false, vapoursynthSupport ? false,
vdpauSupport ? true, vdpauSupport ? true,
vulkanSupport ? stdenv.hostPlatform.isLinux, vulkanSupport ? true,
waylandSupport ? stdenv.hostPlatform.isLinux, waylandSupport ? !stdenv.hostPlatform.isDarwin,
x11Support ? stdenv.hostPlatform.isLinux, x11Support ? !stdenv.hostPlatform.isDarwin,
xineramaSupport ? stdenv.hostPlatform.isLinux,
xvSupport ? stdenv.hostPlatform.isLinux,
zimgSupport ? true, zimgSupport ? true,
}: }:
let let
inherit (darwin.apple_sdk_11_0.frameworks)
AVFoundation
Accelerate
Cocoa
CoreAudio
CoreFoundation
CoreMedia
MediaPlayer
VideoToolbox
;
luaEnv = lua.withPackages (ps: with ps; [ luasocket ]); luaEnv = lua.withPackages (ps: with ps; [ luasocket ]);
overrideSDK =
platform: version:
platform // lib.optionalAttrs (platform ? darwinMinVersion) { darwinMinVersion = version; };
stdenv' =
if swiftSupport && stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isx86_64 then
stdenv.override (old: {
buildPlatform = overrideSDK old.buildPlatform "11.0";
hostPlatform = overrideSDK old.hostPlatform "11.0";
targetPlatform = overrideSDK old.targetPlatform "11.0";
})
else
stdenv;
in in
stdenv'.mkDerivation (finalAttrs: { stdenv.mkDerivation (finalAttrs: {
pname = "mpv"; pname = "mpv";
version = "0.39.0"; version = "0.39.0";
@ -151,18 +111,13 @@ stdenv'.mkDerivation (finalAttrs: {
hash = "sha256-BOGh+QBTO7hrHohh+RqjSF8eHQH8jVBPjG/k4eyFaaM="; hash = "sha256-BOGh+QBTO7hrHohh+RqjSF8eHQH8jVBPjG/k4eyFaaM=";
}; };
patches = [
# Fix build with Darwin SDK 11
./0001-fix-darwin-build.patch
];
postPatch = lib.concatStringsSep "\n" [ postPatch = lib.concatStringsSep "\n" [
# Don't reference compile time dependencies or create a build outputs cycle # Don't reference compile time dependencies or create a build outputs cycle
# between out and dev # between out and dev
'' ''
substituteInPlace meson.build \ substituteInPlace meson.build \
--replace-fail "conf_data.set_quoted('CONFIGURATION', configuration)" \ --replace-fail "conf_data.set_quoted('CONFIGURATION', configuration)" \
"conf_data.set_quoted('CONFIGURATION', '<ommited>')" "conf_data.set_quoted('CONFIGURATION', '<omitted>')"
'' ''
# A trick to patchShebang everything except mpv_identify.sh # A trick to patchShebang everything except mpv_identify.sh
'' ''
@ -174,30 +129,16 @@ stdenv'.mkDerivation (finalAttrs: {
'' ''
]; ];
# Ensure we reference 'lib' (not 'out') of Swift. mesonFlags = [
preConfigure = lib.optionalString swiftSupport '' (lib.mesonOption "default_library" "shared")
export SWIFT_LIB_DYNAMIC="${lib.getLib swift.swift}/lib/swift/macosx" (lib.mesonBool "libmpv" true)
''; (lib.mesonEnable "manpage-build" true)
(lib.mesonEnable "cdda" cddaSupport)
mesonFlags = (lib.mesonEnable "dvbin" dvbinSupport)
[ (lib.mesonEnable "dvdnav" dvdnavSupport)
(lib.mesonOption "default_library" "shared") (lib.mesonEnable "openal" openalSupport)
(lib.mesonBool "libmpv" true) (lib.mesonEnable "sdl2" sdl2Support)
(lib.mesonEnable "libarchive" archiveSupport) ];
(lib.mesonEnable "manpage-build" true)
(lib.mesonEnable "cdda" cddaSupport)
(lib.mesonEnable "dvbin" dvbinSupport)
(lib.mesonEnable "dvdnav" dvdnavSupport)
(lib.mesonEnable "openal" openalSupport)
(lib.mesonEnable "sdl2" sdl2Support)
# Disable whilst Swift isn't supported
(lib.mesonEnable "swift-build" swiftSupport)
(lib.mesonEnable "macos-cocoa-cb" swiftSupport)
]
++ lib.optionals stdenv.hostPlatform.isDarwin [
# Toggle explicitly because it fails on darwin
(lib.mesonEnable "videotoolbox-pl" vulkanSupport)
];
mesonAutoFeatures = "auto"; mesonAutoFeatures = "auto";
@ -211,9 +152,9 @@ stdenv'.mkDerivation (finalAttrs: {
] ]
++ lib.optionals stdenv.hostPlatform.isDarwin [ ++ lib.optionals stdenv.hostPlatform.isDarwin [
buildPackages.darwin.sigtool buildPackages.darwin.sigtool
xcbuild.xcrun swift
makeWrapper
] ]
++ lib.optionals swiftSupport [ swift ]
++ lib.optionals waylandSupport [ wayland-scanner ]; ++ lib.optionals waylandSupport [ wayland-scanner ];
buildInputs = buildInputs =
@ -248,16 +189,12 @@ stdenv'.mkDerivation (finalAttrs: {
] ]
++ lib.optionals jackaudioSupport [ libjack2 ] ++ lib.optionals jackaudioSupport [ libjack2 ]
++ lib.optionals javascriptSupport [ mujs ] ++ lib.optionals javascriptSupport [ mujs ]
++ lib.optionals libpngSupport [ libpng ]
++ lib.optionals openalSupport [ openalSoft ] ++ lib.optionals openalSupport [ openalSoft ]
++ lib.optionals pipewireSupport [ pipewire ] ++ lib.optionals pipewireSupport [ pipewire ]
++ lib.optionals pulseSupport [ libpulseaudio ] ++ lib.optionals pulseSupport [ libpulseaudio ]
++ lib.optionals rubberbandSupport [ rubberband ] ++ lib.optionals rubberbandSupport [ rubberband ]
++ lib.optionals screenSaverSupport [ libXScrnSaver ]
++ lib.optionals sdl2Support [ SDL2 ] ++ lib.optionals sdl2Support [ SDL2 ]
++ lib.optionals sixelSupport [ libsixel ] ++ lib.optionals sixelSupport [ libsixel ]
++ lib.optionals speexSupport [ speex ]
++ lib.optionals theoraSupport [ libtheora ]
++ lib.optionals vaapiSupport [ libva ] ++ lib.optionals vaapiSupport [ libva ]
++ lib.optionals vapoursynthSupport [ vapoursynth ] ++ lib.optionals vapoursynthSupport [ vapoursynth ]
++ lib.optionals vdpauSupport [ libvdpau ] ++ lib.optionals vdpauSupport [ libvdpau ]
@ -274,29 +211,13 @@ stdenv'.mkDerivation (finalAttrs: {
++ lib.optionals x11Support [ ++ lib.optionals x11Support [
libX11 libX11
libXext libXext
libGLU
libGL libGL
libXxf86vm
libXrandr libXrandr
libXpresent libXpresent
libXScrnSaver
] ]
++ lib.optionals xineramaSupport [ libXinerama ]
++ lib.optionals xvSupport [ libXv ]
++ lib.optionals zimgSupport [ zimg ] ++ lib.optionals zimgSupport [ zimg ]
++ lib.optionals stdenv.hostPlatform.isLinux [ nv-codec-headers-11 ] ++ lib.optionals stdenv.hostPlatform.isLinux [ nv-codec-headers-11 ];
++ lib.optionals stdenv.hostPlatform.isDarwin [ libiconv ]
++ lib.optionals stdenv.hostPlatform.isDarwin [
Accelerate
CoreFoundation
Cocoa
CoreAudio
MediaPlayer
VideoToolbox
]
++ lib.optionals (stdenv.hostPlatform.isDarwin && swiftSupport) [
AVFoundation
CoreMedia
];
postBuild = lib.optionalString stdenv.hostPlatform.isDarwin '' postBuild = lib.optionalString stdenv.hostPlatform.isDarwin ''
pushd .. # Must be run from the source dir because it uses relative paths pushd .. # Must be run from the source dir because it uses relative paths
@ -325,6 +246,13 @@ stdenv'.mkDerivation (finalAttrs: {
+ lib.optionalString stdenv.hostPlatform.isDarwin '' + lib.optionalString stdenv.hostPlatform.isDarwin ''
mkdir -p $out/Applications mkdir -p $out/Applications
cp -r mpv.app $out/Applications cp -r mpv.app $out/Applications
# On macOS, many things wont work properly unless `mpv(1)` is
# executed from the app bundle, such as spatial audio with
# `--ao=avfoundation`. This wrapper ensures that those features
# work reliably and also avoids shipping two copies of the entire
# `mpv` executable.
makeWrapper $out/Applications/mpv.app/Contents/MacOS/mpv $out/bin/mpv
''; '';
# Set RUNPATH so that libcuda in /run/opengl-driver(-32)/lib can be found. # Set RUNPATH so that libcuda in /run/opengl-driver(-32)/lib can be found.

View File

@ -108,6 +108,10 @@ stdenv.mkDerivation (finalAttrs: {
"-isystem ${lib.getDev libcxx}/include/c++/v1" "-isystem ${lib.getDev libcxx}/include/c++/v1"
"-I${lib.getDev spirv-cross}/include/spirv_cross" "-I${lib.getDev spirv-cross}/include/spirv_cross"
"-I${lib.getDev spirv-headers}/include/spirv/unified1" "-I${lib.getDev spirv-headers}/include/spirv/unified1"
# MoltenVK prints a lot of verbose output to the console out of
# the box; we adjust this to match Homebrews default log level.
"-DMVK_CONFIG_LOG_LEVEL=MVK_CONFIG_LOG_LEVEL_NONE"
] ]
++ lib.optional enablePrivateAPIUsage "-DMVK_USE_METAL_PRIVATE_API=1" ++ lib.optional enablePrivateAPIUsage "-DMVK_USE_METAL_PRIVATE_API=1"
); );

View File

@ -31160,9 +31160,8 @@ with pkgs;
libdvdnav = libdvdnav_4_2_1; libdvdnav = libdvdnav_4_2_1;
} // (config.mplayer or {})); } // (config.mplayer or {}));
mpv-unwrapped = darwin.apple_sdk_11_0.callPackage ../applications/video/mpv { mpv-unwrapped = callPackage ../applications/video/mpv {
stdenv = if stdenv.hostPlatform.isDarwin then swiftPackages.stdenv else stdenv; stdenv = if stdenv.hostPlatform.isDarwin then swiftPackages.stdenv else stdenv;
inherit lua;
}; };
# Wrap avoiding rebuild # Wrap avoiding rebuild