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>
dev
Marius Vlad 6 years ago
parent 6bc37259e6
commit 64fbd0f41f
  1. 18
      compositor/main.c
  2. 2
      compositor/text-backend.c
  3. 2
      compositor/weston-screenshooter.c
  4. 5
      compositor/weston.h
  5. 2
      desktop-shell/shell.c
  6. 2
      ivi-shell/hmi-controller.c

@ -903,8 +903,8 @@ wet_load_shell(struct weston_compositor *compositor,
return 0; return 0;
} }
WL_EXPORT char * static char *
wet_get_binary_path(const char *name) wet_get_binary_path(const char *name, const char *dir)
{ {
char path[PATH_MAX]; char path[PATH_MAX];
size_t len; size_t len;
@ -913,13 +913,25 @@ wet_get_binary_path(const char *name)
if (len > 0) if (len > 0)
return strdup(path); 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) if (len >= sizeof path)
return NULL; return NULL;
return strdup(path); 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 static int
load_modules(struct weston_compositor *ec, const char *modules, load_modules(struct weston_compositor *ec, const char *modules,
int *argc, char *argv[], int32_t *xwayland) 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, section = weston_config_get_section(config,
"input-method", NULL, NULL); "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", weston_config_section_get_string(section, "path",
&text_backend->input_method.path, &text_backend->input_method.path,
client); client);

@ -127,7 +127,7 @@ screenshooter_binding(struct weston_keyboard *keyboard,
char *screenshooter_exe; char *screenshooter_exe;
screenshooter_exe = wet_get_binary_path("weston-screenshooter"); screenshooter_exe = wet_get_libexec_path("weston-screenshooter");
if (!screenshooter_exe) { if (!screenshooter_exe) {
weston_log("Could not construct screenshooter path.\n"); weston_log("Could not construct screenshooter path.\n");
return; return;

@ -78,7 +78,10 @@ module_init(struct weston_compositor *compositor,
int *argc, char *argv[]); int *argc, char *argv[]);
char * char *
wet_get_binary_path(const char *name); wet_get_libexec_path(const char *name);
char *
wet_get_bindir_path(const char *name);
int int
wet_load_xwayland(struct weston_compositor *comp); 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), section = weston_config_get_section(wet_get_config(shell->compositor),
"shell", NULL, NULL); "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); weston_config_section_get_string(section, "client", &s, client);
free(client); free(client);
shell->client = s; shell->client = s;

@ -709,7 +709,7 @@ hmi_server_setting_create(struct weston_compositor *ec)
"ivi-shell-user-interface", "ivi-shell-user-interface",
&ivi_ui_config, NULL); &ivi_ui_config, NULL);
if (ivi_ui_config && ivi_ui_config[0] != '/') { 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) if (setting->ivi_homescreen)
free(ivi_ui_config); free(ivi_ui_config);
else else

Loading…
Cancel
Save