summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGiulio Camuffo <giuliocamuffo@gmail.com>2016-06-02 21:48:14 +0300
committerPekka Paalanen <pekka.paalanen@collabora.co.uk>2016-06-03 13:17:18 +0300
commit179fcda31f6b95f7bfb270574a597ef25dbd503b (patch)
treeeae010e9361d3bff421d287b4906ae6192bea9e9 /src
parentbe2b11a7c01e5fd8cd5b17729d4eae76217d8280 (diff)
downloadweston-179fcda31f6b95f7bfb270574a597ef25dbd503b.tar.gz
Split the modules and include files between weston and libweston
The backends are now installed in lib/libweston-0, and the include files that will be used by libweston in include/libweston-0. The other modules and weston-specific include files are kept in the old paths. A new wet_load_module() is added to load plugins in the old path, which is not part of libweston, but weston only and defined in main.c. To allow that to be used by out of tree weston plugins, the function is declared in a new weston.h, installed in include/weston. The -0 in the paths is the abi version of libweston, and it will also be used by the libweston .so. If the abi changes the number will need to be increased. Signed-off-by: Giulio Camuffo <giuliocamuffo@gmail.com> Reviewed-by: Quentin Glidic <sardemff7+git@sardemff7.net> Acked-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Diffstat (limited to 'src')
-rw-r--r--src/compositor.c2
-rw-r--r--src/main.c47
-rw-r--r--src/weston.h5
-rw-r--r--src/weston.pc.in2
4 files changed, 52 insertions, 4 deletions
diff --git a/src/compositor.c b/src/compositor.c
index 2ec2f183..3904ef00 100644
--- a/src/compositor.c
+++ b/src/compositor.c
@@ -4791,7 +4791,7 @@ weston_load_module(const char *name, const char *entrypoint)
if (builddir)
snprintf(path, sizeof path, "%s/.libs/%s", builddir, name);
else
- snprintf(path, sizeof path, "%s/%s", MODULEDIR, name);
+ snprintf(path, sizeof path, "%s/%s", LIBWESTON_MODULEDIR, name);
} else {
snprintf(path, sizeof path, "%s", name);
}
diff --git a/src/main.c b/src/main.c
index e34f8f57..733bf099 100644
--- a/src/main.c
+++ b/src/main.c
@@ -40,12 +40,14 @@
#include <sys/socket.h>
#include <libinput.h>
#include <sys/time.h>
+#include <linux/limits.h>
#ifdef HAVE_LIBUNWIND
#define UNW_LOCAL_ONLY
#include <libunwind.h>
#endif
+#include "weston.h"
#include "compositor.h"
#include "../shared/os-compatibility.h"
#include "../shared/helpers.h"
@@ -690,6 +692,49 @@ weston_create_listening_socket(struct wl_display *display, const char *socket_na
return 0;
}
+WL_EXPORT void *
+wet_load_module(const char *name, const char *entrypoint)
+{
+ const char *builddir = getenv("WESTON_BUILD_DIR");
+ char path[PATH_MAX];
+ void *module, *init;
+
+ if (name == NULL)
+ return NULL;
+
+ if (name[0] != '/') {
+ if (builddir)
+ snprintf(path, sizeof path, "%s/.libs/%s", builddir, name);
+ else
+ snprintf(path, sizeof path, "%s/%s", MODULEDIR, name);
+ } else {
+ snprintf(path, sizeof path, "%s", name);
+ }
+
+ module = dlopen(path, RTLD_NOW | RTLD_NOLOAD);
+ if (module) {
+ weston_log("Module '%s' already loaded\n", path);
+ dlclose(module);
+ return NULL;
+ }
+
+ weston_log("Loading module '%s'\n", path);
+ module = dlopen(path, RTLD_NOW);
+ if (!module) {
+ weston_log("Failed to load module: %s\n", dlerror());
+ return NULL;
+ }
+
+ init = dlsym(module, entrypoint);
+ if (!init) {
+ weston_log("Failed to lookup init function: %s\n", dlerror());
+ dlclose(module);
+ return NULL;
+ }
+
+ return init;
+}
+
static int
load_modules(struct weston_compositor *ec, const char *modules,
int *argc, char *argv[])
@@ -706,7 +751,7 @@ load_modules(struct weston_compositor *ec, const char *modules,
while (*p) {
end = strchrnul(p, ',');
snprintf(buffer, sizeof buffer, "%.*s", (int) (end - p), p);
- module_init = weston_load_module(buffer, "module_init");
+ module_init = wet_load_module(buffer, "module_init");
if (!module_init)
return -1;
if (module_init(ec, argc, argv) < 0)
diff --git a/src/weston.h b/src/weston.h
index ea421665..da7c7a9e 100644
--- a/src/weston.h
+++ b/src/weston.h
@@ -30,7 +30,7 @@
extern "C" {
#endif
-#include "compositor.h"
+#include <compositor.h>
void
screenshooter_create(struct weston_compositor *ec);
@@ -60,6 +60,9 @@ weston_watch_process(struct weston_process *process);
struct weston_config *
wet_get_config(struct weston_compositor *compositor);
+void *
+wet_load_module(const char *name, const char *entrypoint);
+
#ifdef __cplusplus
}
#endif
diff --git a/src/weston.pc.in b/src/weston.pc.in
index c560eb37..f2ffc9e7 100644
--- a/src/weston.pc.in
+++ b/src/weston.pc.in
@@ -9,4 +9,4 @@ Name: Weston Plugin API
Description: Header files for Weston plugin development
Version: @WESTON_VERSION@
Requires.private: wayland-server pixman-1 xkbcommon
-Cflags: -I${includedir}
+Cflags: -I${includedir}/weston -I{includedir}/libweston-@LIBWESTON_ABI_VERSION@