summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorQuentin Glidic <sardemff7+git@sardemff7.net>2016-07-04 14:16:59 +0200
committerQuentin Glidic <sardemff7+git@sardemff7.net>2016-12-18 13:34:32 +0100
commit097eab429ae478793cf5c1d00acc48554c5b92f6 (patch)
tree423f9294dd8fbffb03a6b329b73bb7a42f8438a3
parent93d43c35869a913f367c81638c85782aca56c926 (diff)
libweston: Add a generic weston_compositor_load_modulewip/libweston-modules
This way, we can share modules between libweston-based compositors, but they can only be loaded explicitely by the compositor. Signed-off-by: Quentin Glidic <sardemff7+git@sardemff7.net>
-rw-r--r--Makefile.am3
-rw-r--r--compositor/main.c38
-rw-r--r--libweston/compositor.c11
-rw-r--r--libweston/compositor.h4
-rw-r--r--man/weston.ini.man8
-rw-r--r--man/weston.man6
6 files changed, 66 insertions, 4 deletions
diff --git a/Makefile.am b/Makefile.am
index 2219e3d5..10b7e385 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1483,7 +1483,8 @@ endif
MAN_SUBSTS = \
-e 's|__weston_native_backend__|$(WESTON_NATIVE_BACKEND)|g' \
- -e 's|__weston_modules_dir__|$(pkglibdir)|g' \
+ -e 's|__libweston_modules_dir__|$(libweston_moduledir)|g' \
+ -e 's|__weston_modules_dir__|$(moduledir)|g' \
-e 's|__weston_shell_client__|$(WESTON_SHELL_CLIENT)|g' \
-e 's|__version__|$(PACKAGE_VERSION)|g'
diff --git a/compositor/main.c b/compositor/main.c
index f9614f57..e0984c5a 100644
--- a/compositor/main.c
+++ b/compositor/main.c
@@ -844,6 +844,33 @@ wet_load_shell(struct weston_compositor *compositor,
}
static int
+load_cmodules(struct weston_compositor *ec, const char *modules,
+ int *argc, char *argv[])
+{
+ const char *p, *end;
+ char buffer[256];
+
+ if (modules == NULL)
+ return 0;
+
+ p = modules;
+ while (*p) {
+ end = strchrnul(p, ',');
+ snprintf(buffer, sizeof buffer, "%.*s", (int) (end - p), p);
+
+ if (weston_compositor_load_module(ec, buffer) < 0)
+ return -1;
+
+ p = end;
+ while (*p == ',')
+ p++;
+
+ }
+
+ return 0;
+}
+
+static int
load_modules(struct weston_compositor *ec, const char *modules,
int *argc, char *argv[], int32_t *xwayland)
{
@@ -1759,7 +1786,9 @@ int main(int argc, char *argv[])
char *backend = NULL;
char *shell = NULL;
int32_t xwayland = 0;
+ char *cmodules = NULL;
char *modules = NULL;
+ char *option_cmodules = NULL;
char *option_modules = NULL;
char *log = NULL;
char *server_socket = NULL;
@@ -1784,6 +1813,7 @@ int main(int argc, char *argv[])
{ WESTON_OPTION_STRING, "socket", 'S', &socket_name },
{ WESTON_OPTION_INTEGER, "idle-time", 'i', &idle_time },
{ WESTON_OPTION_BOOLEAN, "xwayland", 0, &xwayland },
+ { WESTON_OPTION_STRING, "common-modules", 0, &option_cmodules },
{ WESTON_OPTION_STRING, "modules", 0, &option_modules },
{ WESTON_OPTION_STRING, "log", 0, &log },
{ WESTON_OPTION_BOOLEAN, "help", 'h', &help },
@@ -1917,6 +1947,14 @@ int main(int argc, char *argv[])
if (wet_load_shell(ec, shell, &argc, argv) < 0)
goto out;
+ weston_config_section_get_string(section, "common-modules", &cmodules,
+ "");
+ if (load_cmodules(ec, cmodules, &argc, argv) < 0)
+ goto out;
+
+ if (load_cmodules(ec, option_cmodules, &argc, argv) < 0)
+ goto out;
+
weston_config_section_get_string(section, "modules", &modules, "");
if (load_modules(ec, modules, &argc, argv, &xwayland) < 0)
goto out;
diff --git a/libweston/compositor.c b/libweston/compositor.c
index d00a25ad..0d038c22 100644
--- a/libweston/compositor.c
+++ b/libweston/compositor.c
@@ -5355,14 +5355,21 @@ weston_compositor_load_backend(struct weston_compositor *compositor,
}
WL_EXPORT int
-weston_compositor_load_xwayland(struct weston_compositor *compositor)
+weston_compositor_load_module(struct weston_compositor *compositor,
+ const char *name)
{
int (*module_init)(struct weston_compositor *ec);
- module_init = weston_load_module("xwayland.so", "weston_module_init");
+ module_init = weston_load_module(name, "weston_module_init");
if (!module_init)
return -1;
if (module_init(compositor) < 0)
return -1;
return 0;
}
+
+WL_EXPORT int
+weston_compositor_load_xwayland(struct weston_compositor *compositor)
+{
+ return weston_compositor_load_module(compositor, "xwayland.so");
+}
diff --git a/libweston/compositor.h b/libweston/compositor.h
index d59e622c..6dd01ad5 100644
--- a/libweston/compositor.h
+++ b/libweston/compositor.h
@@ -1798,6 +1798,10 @@ void
weston_seat_set_keyboard_focus(struct weston_seat *seat,
struct weston_surface *surface);
+
+int
+weston_compositor_load_module(struct weston_compositor *compositor, const char *name);
+
int
weston_compositor_load_xwayland(struct weston_compositor *compositor);
diff --git a/man/weston.ini.man b/man/weston.ini.man
index 429dcdd0..66e1cebc 100644
--- a/man/weston.ini.man
+++ b/man/weston.ini.man
@@ -110,6 +110,12 @@ directory are:
ask Weston to load the XWayland module (boolean).
.RE
.TP 7
+.BI "common-modules=" cms-colord.so,screen-share.so
+specifies the modules to load (string). These are shared with other
+libweston-based compositors. The files are searched for in the
+.IR "__libweston_modules_dir__"
+directory.
+.TP 7
.BI "modules=" cms-colord.so,screen-share.so
specifies the modules to load (string). Available modules in the
.IR "__weston_modules_dir__"
@@ -124,7 +130,7 @@ directory are:
.TP 7
.BI "backend=" headless-backend.so
overrides defaults backend. Available backend modules in the
-.IR "__weston_modules_dir__"
+.IR "__libweston_modules_dir__"
directory are:
.PP
.RS 10
diff --git a/man/weston.man b/man/weston.man
index face2298..5338b663 100644
--- a/man/weston.man
+++ b/man/weston.man
@@ -146,6 +146,12 @@ instead of writing them to stderr.
\fB\-\-xwayland\fR
Ask Weston to load the XWayland module.
.TP
+\fB\-\-common-modules\fR=\fImodule1.so,module2.so\fR
+Load the comma-separated list of modules shared with other
+libweston-based compositors. The file is searched for in
+.IR "__libweston_modules_dir__" ,
+or you can pass an absolute path.
+.TP
\fB\-\-modules\fR=\fImodule1.so,module2.so\fR
Load the comma-separated list of modules. Only used by the test
suite. The file is searched for in