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 <marius.vlad0@gmail.com>
This commit is contained in:
parent
6bc37259e6
commit
64fbd0f41f
@ -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)
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user