summaryrefslogtreecommitdiff
path: root/plugins/pychrysalide
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2021-04-17 13:56:56 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2021-04-17 13:56:56 (GMT)
commit58afc7858cffe180bafbae306db6be66d313b74b (patch)
tree6ccba3064e1b1d49faf1099d3d6fe3c600192819 /plugins/pychrysalide
parentb25638b8b13ffa833414c6a7c48fffdac12eda61 (diff)
Remove hardcoded run paths from libraries.
Diffstat (limited to 'plugins/pychrysalide')
-rw-r--r--plugins/pychrysalide/Makefile.am13
-rw-r--r--plugins/pychrysalide/core.c30
2 files changed, 41 insertions, 2 deletions
diff --git a/plugins/pychrysalide/Makefile.am b/plugins/pychrysalide/Makefile.am
index b4b20ad..fb3986c 100644
--- a/plugins/pychrysalide/Makefile.am
+++ b/plugins/pychrysalide/Makefile.am
@@ -6,6 +6,13 @@ lib_LTLIBRARIES = pychrysalide.la
libdir = $(pluginslibdir)
+if BUILD_PYTHON_PACKAGE
+
+RUN_PATH = -Wl,-rpath,'$$ORIGIN/chrysalide-libs'
+
+endif
+
+
pychrysalide_la_SOURCES = \
access.h access.c \
core.h core.c \
@@ -28,10 +35,12 @@ pychrysalide_la_LIBADD = \
mangling/libpychrysamangling.la \
plugins/libpychrysaplugins.la
+# -ldl: dladdr(), dlerror()
pychrysalide_la_LDFLAGS = \
- -module -avoid-version \
+ -module -avoid-version -ldl \
$(LIBPYTHON_LIBS) $(LIBPYGOBJECT_LIBS) \
- -L$(top_srcdir)/src/.libs -lchrysacore
+ -L$(top_srcdir)/src/.libs -lchrysacore \
+ $(RUN_PATH)
devdir = $(includedir)/chrysalide/$(subdir)
diff --git a/plugins/pychrysalide/core.c b/plugins/pychrysalide/core.c
index 38e3c7c..98f94b6 100644
--- a/plugins/pychrysalide/core.c
+++ b/plugins/pychrysalide/core.c
@@ -42,6 +42,7 @@
#include <common/environment.h>
#include <common/extstr.h>
#include <core/core.h>
+#include <core/logs.h>
#include <core/paths.h>
#include <plugins/pglist.h>
#include <plugins/self.h>
@@ -399,6 +400,9 @@ PyMODINIT_FUNC PyInit_pychrysalide(void)
PyObject *result; /* Module Python à retourner */
bool status; /* Bilan des inclusions */
int ret; /* Bilan de préparatifs */
+#ifdef PYTHON_PACKAGE
+ Dl_info info; /* Informations dynamiques */
+#endif
GPluginModule *self; /* Représentation interne */
PluginStatusFlags self_flags; /* Fanions à mettre à jour */
@@ -529,6 +533,32 @@ PyMODINIT_FUNC PyInit_pychrysalide(void)
set_batch_mode();
+ /**
+ * Si cette extension pour Python est chargée depuis un dépôt Python,
+ * elle ne se trouve pas dans le répertoire classique des extensions et
+ * n'est donc pas chargée et enregistrée comme attendu.
+ *
+ * Cet enregistrement est donc forcé ici.
+ */
+
+#ifdef PYTHON_PACKAGE
+
+ ret = dladdr(__FUNCTION__, &info);
+ if (ret == 0)
+ {
+ LOG_ERROR_DL_N("dladdr");
+ Py_DECREF(result);
+ result = NULL;
+ goto exit;
+ }
+
+ self = g_plugin_module_new(info.dli_fname);
+ assert(self != NULL);
+
+ register_plugin(self);
+
+#endif
+
init_all_plugins(false);
lock_plugin_list_for_reading();