vapoursynth: fix darwin build (#359263)

This commit is contained in:
Michele Guerini Rocco 2024-11-29 10:41:56 +01:00 committed by GitHub
commit a5fb96baf0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 119 additions and 97 deletions

View File

@ -2,6 +2,7 @@
lib,
stdenv,
fetchFromGitHub,
fetchpatch,
autoreconfHook,
pkg-config,
vapoursynth,
@ -19,6 +20,14 @@ stdenv.mkDerivation (finalAttrs: {
hash = "sha256-jd/PCXhbCZGMsoXjekbeqMSRVBJAy4INdpkTbZFjVO0=";
};
patches = [
(fetchpatch {
name = "build-fixes-for-aarch64-apple-silicon.patch";
url = "https://github.com/dubhater/vapoursynth-nnedi3/commit/15c15080ed4406929aa0d2d6a3f83ca3e26bc979.patch";
hash = "sha256-8gNj4LixfrGq0MaIYdZuwSK/2iyh1E9s/uuSBJHZwx8=";
})
];
nativeBuildInputs = [
autoreconfHook
pkg-config

View File

@ -34,7 +34,7 @@ stdenv.mkDerivation {
installPhase = ''
runHook preInstall
install -D -t $out/lib/vapoursynth vsznedi3${stdenv.hostPlatform.extensions.sharedLibrary}
install -D -t $out/lib/vapoursynth vsznedi3.so
install -D -m644 -t $out/share/nnedi3 nnedi3_weights.bin
runHook postInstall

View File

@ -1,5 +1,6 @@
{
lib,
stdenv,
mkDerivation,
fetchFromGitHub,
makeWrapper,
@ -23,6 +24,11 @@ let
hash = "sha256-+/9j9DJDGXbuTvE8ZXIu6wjcof39SyatS36Q6y9hLPg=";
};
postPatch = ''
substituteInPlace pro/vsedit/vsedit.pro \
--replace-fail "TARGET = vsedit-32bit" "TARGET = vsedit"
'';
nativeBuildInputs = [ qmake ];
buildInputs = [
qtbase
@ -34,14 +40,25 @@ let
preConfigure = "cd pro";
preFixup = ''
cd ../build/release*
mkdir -p $out/bin
for bin in vsedit{,-job-server{,-watcher}}; do
mv $bin $out/bin
wrapQtApp $out/bin/$bin
done
'';
preFixup =
''
cd ../build/release*
mkdir -p $out/bin
''
+ lib.optionalString stdenv.hostPlatform.isDarwin ''
mkdir -p $out/Applications
for bin in vsedit{,-job-server{,-watcher}}; do
mv $bin.app $out/Applications
makeQtWrapper $out/Applications/$bin.app/Contents/MacOS/$bin $out/bin/$bin
wrapQtApp $out/Applications/$bin.app/Contents/MacOS/$bin
done
''
+ lib.optionalString (!stdenv.hostPlatform.isDarwin) ''
for bin in vsedit{,-job-server{,-watcher}}; do
mv $bin $out/bin
wrapQtApp $out/bin/$bin
done
'';
passthru = {
inherit withPlugins;

View File

@ -12,9 +12,7 @@
zimg,
libass,
python3,
libiconv,
testers,
ApplicationServices,
}:
stdenv.mkDerivation rec {
@ -33,24 +31,19 @@ stdenv.mkDerivation rec {
autoreconfHook
makeWrapper
];
buildInputs =
[
zimg
libass
(python3.withPackages (
ps: with ps; [
sphinx
cython
]
))
]
++ lib.optionals stdenv.hostPlatform.isDarwin [
libiconv
ApplicationServices
];
buildInputs = [
zimg
libass
(python3.withPackages (
ps: with ps; [
sphinx
cython
]
))
];
enableParallelBuilding = true;
doInstallCheck = true;
doInstallCheck = !stdenv.hostPlatform.isDarwin;
passthru = rec {
# If vapoursynth is added to the build inputs of mpv and then
@ -80,7 +73,7 @@ stdenv.mkDerivation rec {
};
};
postPatch = ''
postPatch = lib.optionalString (!stdenv.hostPlatform.isDarwin) ''
# Export weak symbol nixPluginDir to permit override of default plugin path
sed -E -i \
-e 's/(VS_PATH_PLUGINDIR)/(nixPluginDir ? nixPluginDir : \1)/g' \
@ -110,11 +103,10 @@ stdenv.mkDerivation rec {
'';
meta = with lib; {
broken = stdenv.hostPlatform.isDarwin; # see https://github.com/NixOS/nixpkgs/pull/189446 for partial fix
description = "Video processing framework with the future in mind";
homepage = "http://www.vapoursynth.com/";
license = licenses.lgpl21;
platforms = platforms.x86_64;
platforms = platforms.all;
maintainers = with maintainers; [
rnhmjoj
sbruder

View File

@ -51,77 +51,85 @@ let
ext = stdenv.hostPlatform.extensions.sharedLibrary;
in
runCommand "${vapoursynth.name}-with-plugins"
{
nativeBuildInputs = [ makeWrapper ];
passthru = {
inherit python3;
inherit (vapoursynth) src version;
withPlugins = plugins': withPlugins (plugins ++ plugins');
};
}
''
mkdir -p \
$out/bin \
$out/lib/pkgconfig \
$out/lib/vapoursynth \
$out/${python3.sitePackages}
if stdenv.hostPlatform.isDarwin then
vapoursynth.overrideAttrs (previousAttrs: {
pname = "vapoursynth-with-plugins";
configureFlags = (previousAttrs.configureFlags or [ ]) ++ [
"--with-plugindir=${pluginsEnv}/lib/vapoursynth"
];
})
else
runCommand "${vapoursynth.name}-with-plugins"
{
nativeBuildInputs = [ makeWrapper ];
passthru = {
inherit python3;
inherit (vapoursynth) src version;
withPlugins = plugins': withPlugins (plugins ++ plugins');
};
}
''
mkdir -p \
$out/bin \
$out/lib/pkgconfig \
$out/lib/vapoursynth \
$out/${python3.sitePackages}
for textFile in \
lib/pkgconfig/vapoursynth{,-script}.pc \
lib/libvapoursynth.la \
lib/libvapoursynth-script.la \
${python3.sitePackages}/vapoursynth.la
do
substitute ${vapoursynth}/$textFile $out/$textFile \
--replace "${vapoursynth}" "$out"
done
for textFile in \
lib/pkgconfig/vapoursynth{,-script}.pc \
lib/libvapoursynth.la \
lib/libvapoursynth-script.la \
${python3.sitePackages}/vapoursynth.la
do
substitute ${vapoursynth}/$textFile $out/$textFile \
--replace "${vapoursynth}" "$out"
done
for binaryPlugin in ${pluginsEnv}/lib/vapoursynth/*; do
ln -s $binaryPlugin $out/''${binaryPlugin#"${pluginsEnv}/"}
done
for binaryPlugin in ${pluginsEnv}/lib/vapoursynth/*; do
ln -s $binaryPlugin $out/''${binaryPlugin#"${pluginsEnv}/"}
done
for pythonPlugin in ${pythonEnvironment}/${python3.sitePackages}/*; do
ln -s $pythonPlugin $out/''${pythonPlugin#"${pythonEnvironment}/"}
done
for pythonPlugin in ${pythonEnvironment}/${python3.sitePackages}/*; do
ln -s $pythonPlugin $out/''${pythonPlugin#"${pythonEnvironment}/"}
done
for binaryFile in \
lib/libvapoursynth${ext} \
lib/libvapoursynth-script${ext}.0.0.0
do
old_rpath=$(patchelf --print-rpath ${vapoursynth}/$binaryFile)
new_rpath="$old_rpath:$out/lib"
patchelf \
--set-rpath "$new_rpath" \
--output $out/$binaryFile \
${vapoursynth}/$binaryFile
patchelf \
--add-needed libvapoursynth-nix-plugins${ext} \
$out/$binaryFile
done
for binaryFile in \
${python3.sitePackages}/vapoursynth${ext} \
bin/.vspipe-wrapped
do
for binaryFile in \
lib/libvapoursynth${ext} \
lib/libvapoursynth-script${ext}.0.0.0
do
old_rpath=$(patchelf --print-rpath ${vapoursynth}/$binaryFile)
new_rpath="''${old_rpath//"${vapoursynth}"/"$out"}"
new_rpath="$old_rpath:$out/lib"
patchelf \
--set-rpath "$new_rpath" \
--output $out/$binaryFile \
${vapoursynth}/$binaryFile
done
patchelf \
--add-needed libvapoursynth-nix-plugins${ext} \
$out/$binaryFile
done
ln -s ${nixPlugins} $out/lib/libvapoursynth-nix-plugins${ext}
ln -s ${vapoursynth}/include $out/include
ln -s ${vapoursynth}/lib/vapoursynth/* $out/lib/vapoursynth
ln -s \
libvapoursynth-script${ext}.0.0.0 \
$out/lib/libvapoursynth-script${ext}
ln -s \
libvapoursynth-script${ext}.0.0.0 \
$out/lib/libvapoursynth-script${ext}.0
for binaryFile in \
${python3.sitePackages}/vapoursynth${ext} \
bin/.vspipe-wrapped
do
old_rpath=$(patchelf --print-rpath ${vapoursynth}/$binaryFile)
new_rpath="''${old_rpath//"${vapoursynth}"/"$out"}"
patchelf \
--set-rpath "$new_rpath" \
--output $out/$binaryFile \
${vapoursynth}/$binaryFile
done
makeWrapper $out/bin/.vspipe-wrapped $out/bin/vspipe \
--prefix PYTHONPATH : $out/${python3.sitePackages}
''
ln -s ${nixPlugins} $out/lib/libvapoursynth-nix-plugins${ext}
ln -s ${vapoursynth}/include $out/include
ln -s ${vapoursynth}/lib/vapoursynth/* $out/lib/vapoursynth
ln -s \
libvapoursynth-script${ext}.0.0.0 \
$out/lib/libvapoursynth-script${ext}
ln -s \
libvapoursynth-script${ext}.0.0.0 \
$out/lib/libvapoursynth-script${ext}.0
makeWrapper $out/bin/.vspipe-wrapped $out/bin/vspipe \
--prefix PYTHONPATH : $out/${python3.sitePackages}
''

View File

@ -9033,10 +9033,6 @@ with pkgs;
eigen2 = callPackage ../development/libraries/eigen/2.0.nix { };
vapoursynth = callPackage ../by-name/va/vapoursynth/package.nix {
inherit (darwin.apple_sdk.frameworks) ApplicationServices;
};
vapoursynth-editor = libsForQt5.callPackage ../by-name/va/vapoursynth/editor.nix { };
vmmlib = callPackage ../development/libraries/vmmlib {