From 64fbd0f41f4eb175b772a2eddba8bfccb66e016a Mon Sep 17 00:00:00 2001 From: Marius Vlad Date: Sat, 15 Dec 2018 15:51:57 +0200 Subject: [PATCH] compositor: Add some handy wrappers for wet_get_binary_path() This allows to possibility to specify where to look for the executable but also simplifies the need of having to pass either BINDIR/LIBEXECDIR for retrieving full-path of the executable. Signed-off-by: Marius Vlad --- compositor/main.c | 18 +++++++++++++++--- compositor/text-backend.c | 2 +- compositor/weston-screenshooter.c | 2 +- compositor/weston.h | 5 ++++- desktop-shell/shell.c | 2 +- ivi-shell/hmi-controller.c | 2 +- 6 files changed, 23 insertions(+), 8 deletions(-) diff --git a/compositor/main.c b/compositor/main.c index 383a88b9..3400ffa4 100644 --- a/compositor/main.c +++ b/compositor/main.c @@ -903,8 +903,8 @@ wet_load_shell(struct weston_compositor *compositor, return 0; } -WL_EXPORT char * -wet_get_binary_path(const char *name) +static char * +wet_get_binary_path(const char *name, const char *dir) { char path[PATH_MAX]; size_t len; @@ -913,13 +913,25 @@ wet_get_binary_path(const char *name) if (len > 0) return strdup(path); - len = snprintf(path, sizeof path, "%s/%s", LIBEXECDIR, name); + len = snprintf(path, sizeof path, "%s/%s", dir, name); if (len >= sizeof path) return NULL; return strdup(path); } +WL_EXPORT char * +wet_get_libexec_path(const char *name) +{ + return wet_get_binary_path(name, LIBEXECDIR); +} + +WL_EXPORT char * +wet_get_bindir_path(const char *name) +{ + return wet_get_binary_path(name, BINDIR); +} + static int load_modules(struct weston_compositor *ec, const char *modules, int *argc, char *argv[], int32_t *xwayland) diff --git a/compositor/text-backend.c b/compositor/text-backend.c index 664c36f7..03019584 100644 --- a/compositor/text-backend.c +++ b/compositor/text-backend.c @@ -1049,7 +1049,7 @@ text_backend_configuration(struct text_backend *text_backend) section = weston_config_get_section(config, "input-method", NULL, NULL); - client = wet_get_binary_path("weston-keyboard"); + client = wet_get_libexec_path("weston-keyboard"); weston_config_section_get_string(section, "path", &text_backend->input_method.path, client); diff --git a/compositor/weston-screenshooter.c b/compositor/weston-screenshooter.c index dfe5cc85..c23a6944 100644 --- a/compositor/weston-screenshooter.c +++ b/compositor/weston-screenshooter.c @@ -127,7 +127,7 @@ screenshooter_binding(struct weston_keyboard *keyboard, char *screenshooter_exe; - screenshooter_exe = wet_get_binary_path("weston-screenshooter"); + screenshooter_exe = wet_get_libexec_path("weston-screenshooter"); if (!screenshooter_exe) { weston_log("Could not construct screenshooter path.\n"); return; diff --git a/compositor/weston.h b/compositor/weston.h index 8e1d2602..5a2225d1 100644 --- a/compositor/weston.h +++ b/compositor/weston.h @@ -78,7 +78,10 @@ module_init(struct weston_compositor *compositor, int *argc, char *argv[]); char * -wet_get_binary_path(const char *name); +wet_get_libexec_path(const char *name); + +char * +wet_get_bindir_path(const char *name); int wet_load_xwayland(struct weston_compositor *comp); diff --git a/desktop-shell/shell.c b/desktop-shell/shell.c index 9a447159..a72f7391 100644 --- a/desktop-shell/shell.c +++ b/desktop-shell/shell.c @@ -468,7 +468,7 @@ shell_configuration(struct desktop_shell *shell) section = weston_config_get_section(wet_get_config(shell->compositor), "shell", NULL, NULL); - client = wet_get_binary_path(WESTON_SHELL_CLIENT); + client = wet_get_libexec_path(WESTON_SHELL_CLIENT); weston_config_section_get_string(section, "client", &s, client); free(client); shell->client = s; diff --git a/ivi-shell/hmi-controller.c b/ivi-shell/hmi-controller.c index 773f2dd5..41284413 100644 --- a/ivi-shell/hmi-controller.c +++ b/ivi-shell/hmi-controller.c @@ -709,7 +709,7 @@ hmi_server_setting_create(struct weston_compositor *ec) "ivi-shell-user-interface", &ivi_ui_config, NULL); if (ivi_ui_config && ivi_ui_config[0] != '/') { - setting->ivi_homescreen = wet_get_binary_path(ivi_ui_config); + setting->ivi_homescreen = wet_get_libexec_path(ivi_ui_config); if (setting->ivi_homescreen) free(ivi_ui_config); else