diff options
author | Michele Guerini Rocco | 2024-10-24 10:39:26 +0200 |
---|---|---|
committer | GitHub | 2024-10-24 10:39:26 +0200 |
commit | a1071d00556d8b7615c30bd2435be6a36ccb8eda (patch) | |
tree | 9ba2e2cd71ed398dddd39dcf9b573c3b6fb2a429 /pkgs/by-name/va | |
parent | 1dd9d10b455f5b591c1607fbcff9c1740b1133df (diff) | |
parent | 1a66c5bf282b9e6435b9e136c1d0cf2988bbbfdf (diff) |
vapoursynth: Simplify plugin loading (#332800)
Diffstat (limited to 'pkgs/by-name/va')
-rw-r--r-- | pkgs/by-name/va/vapoursynth/nix-plugin-loader.patch | 28 | ||||
-rw-r--r-- | pkgs/by-name/va/vapoursynth/package.nix | 25 | ||||
-rw-r--r-- | pkgs/by-name/va/vapoursynth/plugin-interface.nix | 29 |
3 files changed, 29 insertions, 53 deletions
diff --git a/pkgs/by-name/va/vapoursynth/nix-plugin-loader.patch b/pkgs/by-name/va/vapoursynth/nix-plugin-loader.patch deleted file mode 100644 index e06c9a6cf6b8..000000000000 --- a/pkgs/by-name/va/vapoursynth/nix-plugin-loader.patch +++ /dev/null @@ -1,28 +0,0 @@ -diff --git a/src/core/vscore.cpp b/src/core/vscore.cpp -index 73e2eafc..66a01326 100644 ---- a/src/core/vscore.cpp -+++ b/src/core/vscore.cpp -@@ -1779,6 +1779,12 @@ void VSCore::isPortableInit() { - } - #endif - -+void __attribute__((weak)) VSLoadPluginsNix(void (*load)(VSCore *core, const std::filesystem::path &), VSCore *); -+ -+static void VSLoadPluginsNixCallback(VSCore *core, const std::filesystem::path &path) { -+ core->loadAllPluginsInPath(path); -+} -+ - VSCore::VSCore(int flags) : - numFilterInstances(1), - numFunctionInstances(0), -@@ -1890,6 +1896,10 @@ VSCore::VSCore(int flags) : - #endif - } - -+ if (VSLoadPluginsNix != nullptr) { -+ VSLoadPluginsNix(VSLoadPluginsNixCallback, this); -+ }; -+ - VSMap *settings = readSettings(configFile); - const char *error = vs_internal_vsapi.mapGetError(settings); - if (error) { diff --git a/pkgs/by-name/va/vapoursynth/package.nix b/pkgs/by-name/va/vapoursynth/package.nix index 7a40f1eba1c2..3fdbfd1cc445 100644 --- a/pkgs/by-name/va/vapoursynth/package.nix +++ b/pkgs/by-name/va/vapoursynth/package.nix @@ -8,7 +8,6 @@ runCommandCC, runCommand, vapoursynth, - writeText, buildEnv, zimg, libass, @@ -29,8 +28,6 @@ stdenv.mkDerivation rec { hash = "sha256-T2bCVNH0dLM9lFYChXzvD6AJM3xEtOVCb2tI10tIXJs="; }; - patches = [ ./nix-plugin-loader.patch ]; - nativeBuildInputs = [ pkg-config autoreconfHook @@ -53,6 +50,7 @@ stdenv.mkDerivation rec { ]; enableParallelBuilding = true; + doInstallCheck = true; passthru = rec { # If vapoursynth is added to the build inputs of mpv and then @@ -66,7 +64,6 @@ stdenv.mkDerivation rec { lib python3 buildEnv - writeText runCommandCC stdenv runCommand @@ -83,6 +80,14 @@ stdenv.mkDerivation rec { }; }; + postPatch = '' + # Export weak symbol nixPluginDir to permit override of default plugin path + sed -E -i \ + -e 's/(VS_PATH_PLUGINDIR)/(nixPluginDir ? nixPluginDir : \1)/g' \ + -e '1i\extern char const __attribute__((weak)) nixPluginDir[];' \ + src/core/vscore.cpp + ''; + postInstall = '' wrapProgram $out/bin/vspipe \ --prefix PYTHONPATH : $out/${python3.sitePackages} @@ -92,6 +97,18 @@ stdenv.mkDerivation rec { mkdir $out/lib/vapoursynth ''; + installCheckPhase = '' + runHook preInstallCheck + + libv="$out/lib/libvapoursynth${stdenv.hostPlatform.extensions.sharedLibrary}" + if ! $NM -g -P "$libv" | grep -q '^nixPluginDir w'; then + echo "Weak symbol nixPluginDir is missing from $libv." >&2 + exit 1 + fi + + runHook postInstallCheck + ''; + 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"; diff --git a/pkgs/by-name/va/vapoursynth/plugin-interface.nix b/pkgs/by-name/va/vapoursynth/plugin-interface.nix index c240b205ac1c..2716c27225cf 100644 --- a/pkgs/by-name/va/vapoursynth/plugin-interface.nix +++ b/pkgs/by-name/va/vapoursynth/plugin-interface.nix @@ -2,7 +2,6 @@ lib, python3, buildEnv, - writeText, runCommandCC, stdenv, runCommand, @@ -35,29 +34,19 @@ let paths = deepPlugins; }; - pluginLoader = - let - source = writeText "vapoursynth-nix-plugins.cpp" '' - #include <filesystem> - - struct VSCore; - - void VSLoadPluginsNix(void (*load)(VSCore *, const std::filesystem::path &), VSCore *core) { - ${lib.concatMapStrings ( - path: ''load(core, std::filesystem::u8path("${path}/lib/vapoursynth"));'' - ) deepPlugins} - } - ''; - in - runCommandCC "vapoursynth-plugin-loader" + # Override default plugin path through nixPluginDir symbol + nixPlugins = + runCommandCC "libvapoursynth-nix-plugins${ext}" { executable = true; preferLocalBuild = true; allowSubstitutes = false; + src = '' + char const nixPluginDir[] = "${pluginsEnv}/lib/vapoursynth"; + ''; } '' - mkdir -p $out/lib - $CXX -std=c++17 -shared -fPIC ${source} -o "$out/lib/libvapoursynth-nix-plugins${ext}" + $CC -x c -shared -fPIC - -o "$out" <<<"$src" ''; ext = stdenv.hostPlatform.extensions.sharedLibrary; @@ -123,9 +112,7 @@ runCommand "${vapoursynth.name}-with-plugins" ${vapoursynth}/$binaryFile done - ln -s \ - ${pluginLoader}/lib/libvapoursynth-nix-plugins${ext} \ - $out/lib/libvapoursynth-nix-plugins${ext} + 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 \ |