tests: Don't rely on build directory layout
Rather than having a hardcoded dependency on the build-directory layout, use an explicit module-map environment variable, which rewrites requests for modules and helper/libexec binaries to specific paths. Pekka: This will help with migration to Meson where setting up the paths according to autotools would be painful and unnecessary. Emre: This should also help setting up the test suite after a cross-compile. Pekka: A caveat here is that this patch makes it slightly easier to load external backends by abusing the module map. External backends are specifically not supported in libweston. Signed-off-by: Daniel Stone <daniels@collabora.com> v2: Fixed ivi_layout-test-plugin.c:wet_module_init(). Do not change the lookup name of ivi-layout.ivi. Improved documentation of weston_module_path_from_env() and made it cope with map strings that a) do not end with a semicolon, and b) have multiple consecutive semicolons. Let WESTON_MODULE_MAP be printed into the test log so that it is easier to run tests manually. Reviewed-by: Daniel Stone <daniels@collabora.com> Reviewed-by: Emre Ucan <eucan@de.adit-jv.com> Suggested by Emil: Use a variable for strlen(name). Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk> Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
This commit is contained in:
committed by
Pekka Paalanen
parent
002f0c56e0
commit
e03c111e4e
+20
-6
@@ -652,7 +652,6 @@ weston_create_listening_socket(struct wl_display *display, const char *socket_na
|
||||
WL_EXPORT void *
|
||||
wet_load_module_entrypoint(const char *name, const char *entrypoint)
|
||||
{
|
||||
const char *builddir = getenv("WESTON_BUILD_DIR");
|
||||
char path[PATH_MAX];
|
||||
void *module, *init;
|
||||
size_t len;
|
||||
@@ -661,10 +660,8 @@ wet_load_module_entrypoint(const char *name, const char *entrypoint)
|
||||
return NULL;
|
||||
|
||||
if (name[0] != '/') {
|
||||
if (builddir)
|
||||
len = snprintf(path, sizeof path, "%s/.libs/%s", builddir,
|
||||
name);
|
||||
else
|
||||
len = weston_module_path_from_env(name, path, sizeof path);
|
||||
if (len == 0)
|
||||
len = snprintf(path, sizeof path, "%s/%s", MODULEDIR,
|
||||
name);
|
||||
} else {
|
||||
@@ -701,7 +698,6 @@ wet_load_module_entrypoint(const char *name, const char *entrypoint)
|
||||
return init;
|
||||
}
|
||||
|
||||
|
||||
WL_EXPORT int
|
||||
wet_load_module(struct weston_compositor *compositor,
|
||||
const char *name, int *argc, char *argv[])
|
||||
@@ -732,6 +728,24 @@ wet_load_shell(struct weston_compositor *compositor,
|
||||
return 0;
|
||||
}
|
||||
|
||||
WL_EXPORT char *
|
||||
wet_get_binary_path(const char *name)
|
||||
{
|
||||
char path[PATH_MAX];
|
||||
size_t len;
|
||||
|
||||
len = weston_module_path_from_env(name, path, sizeof path);
|
||||
if (len > 0)
|
||||
return strdup(path);
|
||||
|
||||
len = snprintf(path, sizeof path, "%s/%s",
|
||||
weston_config_get_libexec_dir(), name);
|
||||
if (len >= sizeof path)
|
||||
return NULL;
|
||||
|
||||
return strdup(path);
|
||||
}
|
||||
|
||||
static int
|
||||
load_modules(struct weston_compositor *ec, const char *modules,
|
||||
int *argc, char *argv[], int32_t *xwayland)
|
||||
|
||||
@@ -1047,14 +1047,10 @@ text_backend_configuration(struct text_backend *text_backend)
|
||||
struct weston_config *config = wet_get_config(text_backend->compositor);
|
||||
struct weston_config_section *section;
|
||||
char *client;
|
||||
int ret;
|
||||
|
||||
section = weston_config_get_section(config,
|
||||
"input-method", NULL, NULL);
|
||||
ret = asprintf(&client, "%s/weston-keyboard",
|
||||
weston_config_get_libexec_dir());
|
||||
if (ret < 0)
|
||||
client = NULL;
|
||||
client = wet_get_binary_path("weston-keyboard");
|
||||
weston_config_section_get_string(section, "path",
|
||||
&text_backend->input_method.path,
|
||||
client);
|
||||
|
||||
@@ -117,12 +117,10 @@ screenshooter_binding(struct weston_keyboard *keyboard,
|
||||
{
|
||||
struct screenshooter *shooter = data;
|
||||
char *screenshooter_exe;
|
||||
int ret;
|
||||
|
||||
ret = asprintf(&screenshooter_exe, "%s/%s",
|
||||
weston_config_get_libexec_dir(),
|
||||
"/weston-screenshooter");
|
||||
if (ret < 0) {
|
||||
|
||||
screenshooter_exe = wet_get_binary_path("weston-screenshooter");
|
||||
if (!screenshooter_exe) {
|
||||
weston_log("Could not construct screenshooter path.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -77,6 +77,9 @@ int
|
||||
module_init(struct weston_compositor *compositor,
|
||||
int *argc, char *argv[]);
|
||||
|
||||
char *
|
||||
wet_get_binary_path(const char *name);
|
||||
|
||||
int
|
||||
wet_load_xwayland(struct weston_compositor *comp);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user