From ccda88821b5bd9a7eb82aafc59823709f453c091 Mon Sep 17 00:00:00 2001 From: Marius Vlad Date: Tue, 20 Apr 2021 13:31:18 +0300 Subject: [PATCH] main: Teach agl-compositor to load additional modules Passing modules arguments to the compositor instance would be useful when using the testing framework/harness because that way the test itself can start-up. The idea here is that we would need to load-up a testing plug-in (either one from weston) or one written specifically for this. Bug-AGL: SPEC-3888 Signed-off-by: Marius Vlad Change-Id: Ia5e688901fe11b1ab10feb3f5e2631a0f31707be --- src/main.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/src/main.c b/src/main.c index 340d0e0..5605841 100644 --- a/src/main.c +++ b/src/main.c @@ -1153,6 +1153,46 @@ load_backend(struct ivi_compositor *ivi, const char *backend, return -1; } +static int +load_modules(struct ivi_compositor *ivi, const char *modules, + int *argc, char *argv[], bool *xwayland) +{ + const char *p, *end; + char buffer[256]; + int (*module_init)(struct weston_compositor *wc, int argc, char *argv[]); + + if (modules == NULL) + return 0; + + p = modules; + while (*p) { + end = strchrnul(p, ','); + snprintf(buffer, sizeof buffer, "%.*s", (int) (end - p), p); + + if (strstr(buffer, "xwayland.so")) { + weston_log("Xwayland plug-in not supported!\n"); + p = end; + while (*p == ',') + p++; + continue; + } + + module_init = weston_load_module(buffer, "wet_module_init"); + if (!module_init) + return -1; + + if (module_init(ivi->compositor, *argc, argv) < 0) + return -1; + + p = end; + while (*p == ',') + p++; + } + + return 0; +} + + static char * choose_default_backend(void) { @@ -1512,6 +1552,8 @@ int main(int argc, char *argv[]) char *backend = NULL; char *socket_name = NULL; char *log = NULL; + char *modules = NULL; + char *option_modules = NULL; int help = 0; int version = 0; int no_config = 0; @@ -1520,6 +1562,7 @@ int main(int argc, char *argv[]) struct weston_log_context *log_ctx = NULL; struct weston_log_subscriber *logger; int ret = EXIT_FAILURE; + bool xwayland = false; const struct weston_option core_options[] = { { WESTON_OPTION_STRING, "backend", 'B', &backend }, @@ -1530,6 +1573,7 @@ int main(int argc, char *argv[]) { WESTON_OPTION_BOOLEAN, "no-config", 0, &no_config }, { WESTON_OPTION_BOOLEAN, "debug", 0, &debug }, { WESTON_OPTION_STRING, "config", 'c', &config_file }, + { WESTON_OPTION_STRING, "modules", 0, &option_modules }, }; wl_list_init(&ivi.outputs); @@ -1625,6 +1669,14 @@ int main(int argc, char *argv[]) ivi_seat_init(&ivi); + /* load additional modules */ + weston_config_section_get_string(section, "modules", &modules, ""); + if (load_modules(&ivi, modules, &argc, argv, &xwayland) < 0) + goto error_compositor; + + if (load_modules(&ivi, option_modules, &argc, argv, &xwayland) < 0) + goto error_compositor; + if (ivi_policy_init(&ivi) < 0) goto error_compositor; -- 2.16.6