Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide a separate build argument to set plugin search path #1307

Closed
bbhtt opened this issue Sep 12, 2024 · 6 comments
Closed

Provide a separate build argument to set plugin search path #1307

bbhtt opened this issue Sep 12, 2024 · 6 comments

Comments

@bbhtt
Copy link

bbhtt commented Sep 12, 2024

At the moment both the install and search path are tied to the same build argument PLUGIN_DIRECTORY. It'd be useful to have a separate build argument for the search path for sandboxed applications.

Something like this potentially:

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 041f3b8e..ffd96174 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -67,6 +67,7 @@ LIST (APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/modules")
 
 option(ENABLE_PLUGIN_LOADING "Support loading of plugins" ON)
 set(PLUGIN_DIRECTORY "${CMAKE_INSTALL_FULL_LIBDIR}/libheif" CACHE STRING "Plugin install directory")
+set(PLUGIN_SEARCH_DIRECTORY "${CMAKE_INSTALL_FULL_LIBDIR}/libheif" CACHE STRING "Plugin search directory")
 
 if (ENABLE_PLUGIN_LOADING)
     set(PLUGIN_LOADING_SUPPORTED_AND_ENABLED TRUE)
diff --git a/libheif/api/libheif/heif_version.h.in b/libheif/api/libheif/heif_version.h.in
index fae2cb81..ddc112d0 100644
--- a/libheif/api/libheif/heif_version.h.in
+++ b/libheif/api/libheif/heif_version.h.in
@@ -33,6 +33,6 @@
 /* Version string */
 #define LIBHEIF_VERSION "@PROJECT_VERSION_MAJOR@.@PROJECT_VERSION_MINOR@.@PROJECT_VERSION_PATCH@"
 
-#define LIBHEIF_PLUGIN_DIRECTORY "@PLUGIN_DIRECTORY@"
+#define LIBHEIF_PLUGIN_DIRECTORY "@PLUGIN_SEARCH_DIRECTORY@"
 
 #endif  // LIBHEIF_HEIF_VERSION_H

The use case is that when building Flatpak runtimes, libheif is built with the plugin path /usr/lib/x86_64-linux-gnu/extension/libheif as we want the plugins to be installed in /usr/lib/x86_64-linux-gnu/extension/libheif. It cannot be set to /app/... as that is a special prefix not used outside Flatpak.

Then the contents of /usr/lib/x86_64-linux-gnu/extension/ is copied into the Flatpak extension and mounted at /app/lib/extension/libheif.

But libheif.so now wants the plugins to be in /usr/lib/x86_64-linux-gnu/extension/libheif while they are actually mounted at /app/lib/extension/libheif.

@bbhtt
Copy link
Author

bbhtt commented Sep 12, 2024

Setting the environment variable LIBHEIF_PLUGIN_PATH=/app/lib/extension/libheif solves the issue but ideally it'd be embedded into libheif.so itself so that it works by default.

@bradh
Copy link
Contributor

bradh commented Sep 12, 2024

This feels like a breaking change for any existing packaging that sets PLUGIN_DIRECTORY .

@farindk
Copy link
Contributor

farindk commented Sep 12, 2024

Yes, we would have to set PLUGIN_SEARCH_DIRECTORY to an empty string by default, in which case cmake will use PLUGIN_DIRECTORY. Or maybe even better: instead of adding a PLUGIN_SEARCH_DIRECTORY, add a PLUGIN_INSTALL_DIRECTORY that is used for installation if not empty.

@farindk
Copy link
Contributor

farindk commented Sep 12, 2024

@bbhtt Does that patch work for you? (Set the install path explicitly with PLUGIN_INSTALL_DIRECTORY.)

@bbhtt
Copy link
Author

bbhtt commented Sep 13, 2024

Thank you! It seems to work, I set it like this:

-DPLUGIN_INSTALL_DIRECTORY="/usr/lib/%{gcc_triplet}/extension/libheif"
-DPLUGIN_DIRECTORY="/app/lib/extension/libheif"

Mine was a quick hack to get something working.

@farindk
Copy link
Contributor

farindk commented Sep 13, 2024

@bbhtt Thanks for reporting this and testing the fix.

@farindk farindk closed this as completed Sep 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants