mirror of
https://gitlab.freedesktop.org/pipewire/wireplumber.git
synced 2026-05-02 05:08:01 +02:00
WpLookupDirs: remove the flag for looking into G_TEST_SRCDIR
Instead, make it so that WIREPLUMBER_*_DIR environment variables can contain a list of directories to look into. This is safer and, as a bonus, allows for more control over the lookup directories. Using the G_TEST_SRCDIR variable can cause problems for tests of other projects that use libwireplumber and may also lead to unexpected behavior by not being obvious that this causes wireplumber to skip looking in its standard directories... This also brings back WIREPLUMBER_CONFIG_DIR, which is going to be needed again for the upcoming WpConf changes.
This commit is contained in:
parent
770028aad5
commit
3dc837c370
5 changed files with 29 additions and 24 deletions
47
lib/wp/wp.c
47
lib/wp/wp.c
|
|
@ -120,31 +120,36 @@ lookup_dirs (guint flags)
|
|||
* - XDG config directories
|
||||
* - /etc/
|
||||
* - /usr/share/....
|
||||
*
|
||||
* Note that wireplumber environment variables *replace* other directories.
|
||||
*/
|
||||
if (flags & (WP_LOOKUP_DIR_ENV_DATA | WP_LOOKUP_DIR_ENV_TEST_SRCDIR)) {
|
||||
if ((flags & WP_LOOKUP_DIR_ENV_DATA) &&
|
||||
(dir = g_getenv ("WIREPLUMBER_DATA_DIR")))
|
||||
g_ptr_array_add (dirs, g_canonicalize_filename (dir, NULL));
|
||||
|
||||
if ((flags & WP_LOOKUP_DIR_ENV_TEST_SRCDIR) &&
|
||||
(dir = g_getenv ("G_TEST_SRCDIR")))
|
||||
g_ptr_array_add (dirs, g_canonicalize_filename (dir, NULL));
|
||||
|
||||
if (dirs->len)
|
||||
goto done;
|
||||
if ((flags & WP_LOOKUP_DIR_ENV_CONFIG) &&
|
||||
(dir = g_getenv ("WIREPLUMBER_CONFIG_DIR"))) {
|
||||
g_auto (GStrv) env_dirs = g_strsplit (dir, G_SEARCHPATH_SEPARATOR_S, 0);
|
||||
for (guint i = 0; env_dirs[i]; i++) {
|
||||
g_ptr_array_add (dirs, g_canonicalize_filename (env_dirs[i], NULL));
|
||||
}
|
||||
}
|
||||
if (flags & WP_LOOKUP_DIR_XDG_CONFIG_HOME) {
|
||||
dir = g_get_user_config_dir ();
|
||||
g_ptr_array_add (dirs, g_build_filename (dir, "wireplumber", NULL));
|
||||
else if ((flags & WP_LOOKUP_DIR_ENV_DATA) &&
|
||||
(dir = g_getenv ("WIREPLUMBER_DATA_DIR"))) {
|
||||
g_auto (GStrv) env_dirs = g_strsplit (dir, G_SEARCHPATH_SEPARATOR_S, 0);
|
||||
for (guint i = 0; env_dirs[i]; i++) {
|
||||
g_ptr_array_add (dirs, g_canonicalize_filename (env_dirs[i], NULL));
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (flags & WP_LOOKUP_DIR_XDG_CONFIG_HOME) {
|
||||
dir = g_get_user_config_dir ();
|
||||
g_ptr_array_add (dirs, g_build_filename (dir, "wireplumber", NULL));
|
||||
}
|
||||
if (flags & WP_LOOKUP_DIR_ETC)
|
||||
g_ptr_array_add (dirs,
|
||||
g_canonicalize_filename (WIREPLUMBER_DEFAULT_CONFIG_DIR, NULL));
|
||||
if (flags & WP_LOOKUP_DIR_PREFIX_SHARE)
|
||||
g_ptr_array_add (dirs,
|
||||
g_canonicalize_filename(WIREPLUMBER_DEFAULT_DATA_DIR, NULL));
|
||||
}
|
||||
if (flags & WP_LOOKUP_DIR_ETC)
|
||||
g_ptr_array_add (dirs,
|
||||
g_canonicalize_filename (WIREPLUMBER_DEFAULT_CONFIG_DIR, NULL));
|
||||
if (flags & WP_LOOKUP_DIR_PREFIX_SHARE)
|
||||
g_ptr_array_add (dirs,
|
||||
g_canonicalize_filename(WIREPLUMBER_DEFAULT_DATA_DIR, NULL));
|
||||
|
||||
done:
|
||||
return g_steal_pointer (&dirs);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -83,8 +83,8 @@ const gchar * wp_get_module_dir (void);
|
|||
* \ingroup wp
|
||||
*/
|
||||
typedef enum { /*< flags >*/
|
||||
WP_LOOKUP_DIR_ENV_CONFIG = (1 << 0), /*!< $WIREPLUMBER_CONFIG_DIR */
|
||||
WP_LOOKUP_DIR_ENV_DATA = (1 << 1), /*!< $WIREPLUMBER_DATA_DIR */
|
||||
WP_LOOKUP_DIR_ENV_TEST_SRCDIR = (1 << 2), /*!< $G_TEST_SRCDIR */
|
||||
|
||||
WP_LOOKUP_DIR_XDG_CONFIG_HOME = (1 << 10), /*!< XDG_CONFIG_HOME/wireplumber */
|
||||
WP_LOOKUP_DIR_ETC = (1 << 11), /*!< ($prefix)/etc/wireplumber */
|
||||
|
|
|
|||
|
|
@ -40,7 +40,6 @@ wp_lua_scripting_package_searcher (lua_State *L)
|
|||
g_autoptr (GError) error = NULL;
|
||||
g_autofree gchar *filename = g_strdup_printf ("%s.lua", name);
|
||||
g_autofree gchar *script = wp_find_file (
|
||||
WP_LOOKUP_DIR_ENV_TEST_SRCDIR |
|
||||
WP_LOOKUP_DIR_ENV_DATA |
|
||||
WP_LOOKUP_DIR_XDG_CONFIG_HOME |
|
||||
WP_LOOKUP_DIR_ETC |
|
||||
|
|
@ -144,7 +143,6 @@ find_script (const gchar * script, WpCore *core)
|
|||
return g_strdup (script);
|
||||
|
||||
return wp_find_file (WP_LOOKUP_DIR_ENV_DATA |
|
||||
WP_LOOKUP_DIR_ENV_TEST_SRCDIR |
|
||||
WP_LOOKUP_DIR_XDG_CONFIG_HOME |
|
||||
WP_LOOKUP_DIR_ETC |
|
||||
WP_LOOKUP_DIR_PREFIX_SHARE,
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
common_deps = [wplua_dep, pipewire_dep, wp_dep]
|
||||
common_env = common_test_env
|
||||
common_env.prepend('WIREPLUMBER_DATA_DIR', meson.current_source_dir())
|
||||
common_env.set('G_TEST_SRCDIR', meson.current_source_dir())
|
||||
common_env.set('G_TEST_BUILDDIR', meson.current_build_dir())
|
||||
common_args = [
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
common_deps = [wplua_dep, pipewire_dep, wp_dep]
|
||||
common_env = common_test_env
|
||||
common_env.prepend('WIREPLUMBER_DATA_DIR', meson.current_source_dir())
|
||||
common_env.set('G_TEST_SRCDIR', meson.current_source_dir())
|
||||
common_env.set('G_TEST_BUILDDIR', meson.current_build_dir())
|
||||
common_args = [
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue