base-dirs: rename ETC & PREFIX* flags to BUILD* and improve documentation

The directories specified by these flags are build-time constants,
so the BUILD* prefix is more appropriate.
This commit is contained in:
George Kiagiadakis
2024-03-01 11:01:19 +02:00
parent 14daab576b
commit e7484c16a3
2 changed files with 29 additions and 23 deletions

View File

@@ -56,14 +56,7 @@ lookup_dirs (guint flags, gboolean is_absolute)
g_autoptr(GPtrArray) dirs = g_ptr_array_new_with_free_func (g_free); g_autoptr(GPtrArray) dirs = g_ptr_array_new_with_free_func (g_free);
const gchar *dir; const gchar *dir;
/* Compile the list of lookup directories in priority order: /* Compile the list of lookup directories in priority order */
* - environment variables
* - XDG config directories
* - /etc/
* - /usr/share/....
*
* Note that wireplumber environment variables *replace* other directories.
*/
if (is_absolute) { if (is_absolute) {
g_ptr_array_add (dirs, NULL); g_ptr_array_add (dirs, NULL);
} }
@@ -104,7 +97,7 @@ lookup_dirs (guint flags, gboolean is_absolute)
NULL)); NULL));
} }
} }
if (flags & WP_BASE_DIRS_ETC) { if (flags & WP_BASE_DIRS_BUILD_SYSCONFDIR) {
g_ptr_array_add (dirs, g_ptr_array_add (dirs,
g_canonicalize_filename (WIREPLUMBER_DEFAULT_CONFIG_DIR, NULL)); g_canonicalize_filename (WIREPLUMBER_DEFAULT_CONFIG_DIR, NULL));
} }
@@ -115,11 +108,11 @@ lookup_dirs (guint flags, gboolean is_absolute)
NULL)); NULL));
} }
} }
if (flags & WP_BASE_DIRS_PREFIX_SHARE) { if (flags & WP_BASE_DIRS_BUILD_DATADIR) {
g_ptr_array_add (dirs, g_ptr_array_add (dirs,
g_canonicalize_filename(WIREPLUMBER_DEFAULT_DATA_DIR, NULL)); g_canonicalize_filename(WIREPLUMBER_DEFAULT_DATA_DIR, NULL));
} }
if (flags & WP_BASE_DIRS_PREFIX_LIB) { if (flags & WP_BASE_DIRS_BUILD_LIBDIR) {
g_ptr_array_add (dirs, g_ptr_array_add (dirs,
g_canonicalize_filename (WIREPLUMBER_DEFAULT_MODULE_DIR, NULL)); g_canonicalize_filename (WIREPLUMBER_DEFAULT_MODULE_DIR, NULL));
} }

View File

@@ -17,41 +17,54 @@ G_BEGIN_DECLS
/*! /*!
* \brief Flags to specify lookup directories * \brief Flags to specify lookup directories
* \ingroup wpbasedirs * \ingroup wpbasedirs
*
* These flags can be used to specify which directories to look for a file in.
* The flags can be combined to search in multiple directories at once. Some
* flags may also used to specify the type of the file being looked up or other
* lookup parameters.
*
* Lookup is performed in the same order as the flags are listed here. Note that
* if a WirePlumber-specific environment variable is set ($WIREPLUMBER_*_DIR)
* and the equivalent WP_BASE_DIRS_ENV_* flag is specified, the lookup in other
* directories is skipped, even if the file is not found in the
* environment-specified directory.
*/ */
typedef enum { /*< flags >*/ typedef enum { /*< flags >*/
WP_BASE_DIRS_ENV_CONFIG = (1 << 0), /*!< $WIREPLUMBER_CONFIG_DIR */ WP_BASE_DIRS_ENV_CONFIG = (1 << 0), /*!< $WIREPLUMBER_CONFIG_DIR */
WP_BASE_DIRS_ENV_DATA = (1 << 1), /*!< $WIREPLUMBER_DATA_DIR */ WP_BASE_DIRS_ENV_DATA = (1 << 1), /*!< $WIREPLUMBER_DATA_DIR */
WP_BASE_DIRS_ENV_MODULE = (1 << 2), /*!< $WIREPLUMBER_MODULE_DIR */ WP_BASE_DIRS_ENV_MODULE = (1 << 2), /*!< $WIREPLUMBER_MODULE_DIR */
WP_BASE_DIRS_XDG_CONFIG_HOME = (1 << 8), /*!< XDG_CONFIG_HOME/wireplumber */ WP_BASE_DIRS_XDG_CONFIG_HOME = (1 << 8), /*!< XDG_CONFIG_HOME */
WP_BASE_DIRS_XDG_DATA_HOME = (1 << 9), /*!< XDG_DATA_HOME/wireplumber */ WP_BASE_DIRS_XDG_DATA_HOME = (1 << 9), /*!< XDG_DATA_HOME */
WP_BASE_DIRS_XDG_CONFIG_DIRS = (1 << 10), /*!< XDG_CONFIG_DIRS/wireplumber */ WP_BASE_DIRS_XDG_CONFIG_DIRS = (1 << 10), /*!< XDG_CONFIG_DIRS */
WP_BASE_DIRS_XDG_DATA_DIRS = (1 << 11), /*!< XDG_DATA_DIRS/wireplumber */ WP_BASE_DIRS_BUILD_SYSCONFDIR = (1 << 11), /*!< compile-time $sysconfdir (/etc) */
WP_BASE_DIRS_ETC = (1 << 16), /*!< ($prefix)/etc/wireplumber */ WP_BASE_DIRS_XDG_DATA_DIRS = (1 << 12), /*!< XDG_DATA_DIRS */
WP_BASE_DIRS_PREFIX_SHARE = (1 << 17), /*!< $prefix/share/wireplumber */ WP_BASE_DIRS_BUILD_DATADIR = (1 << 13), /*!< compile-time $datadir ($prefix/share) */
WP_BASE_DIRS_PREFIX_LIB = (1 << 18), /*!< $prefix/$libdir/wireplumber-$ABI_version */
WP_BASE_DIRS_FLAG_MODULE = (1 << 24), /*!< the file is a loadable module */ WP_BASE_DIRS_BUILD_LIBDIR = (1 << 14), /*!< compile-time $libdir ($prefix/lib) */
/*! the file is a loadable module; prepend "lib" and append ".so" if needed */
WP_BASE_DIRS_FLAG_MODULE = (1 << 24),
WP_BASE_DIRS_CONFIGURATION = WP_BASE_DIRS_CONFIGURATION =
WP_BASE_DIRS_ENV_CONFIG | WP_BASE_DIRS_ENV_CONFIG |
WP_BASE_DIRS_XDG_CONFIG_HOME | WP_BASE_DIRS_XDG_CONFIG_HOME |
WP_BASE_DIRS_XDG_CONFIG_DIRS | WP_BASE_DIRS_XDG_CONFIG_DIRS |
WP_BASE_DIRS_ETC | WP_BASE_DIRS_BUILD_SYSCONFDIR |
WP_BASE_DIRS_XDG_DATA_DIRS | WP_BASE_DIRS_XDG_DATA_DIRS |
WP_BASE_DIRS_PREFIX_SHARE, WP_BASE_DIRS_BUILD_DATADIR,
WP_BASE_DIRS_DATA = WP_BASE_DIRS_DATA =
WP_BASE_DIRS_ENV_DATA | WP_BASE_DIRS_ENV_DATA |
WP_BASE_DIRS_XDG_DATA_HOME | WP_BASE_DIRS_XDG_DATA_HOME |
WP_BASE_DIRS_XDG_DATA_DIRS | WP_BASE_DIRS_XDG_DATA_DIRS |
WP_BASE_DIRS_PREFIX_SHARE, WP_BASE_DIRS_BUILD_DATADIR,
WP_BASE_DIRS_MODULE = WP_BASE_DIRS_MODULE =
WP_BASE_DIRS_ENV_MODULE | WP_BASE_DIRS_ENV_MODULE |
WP_BASE_DIRS_PREFIX_LIB | WP_BASE_DIRS_BUILD_LIBDIR |
WP_BASE_DIRS_FLAG_MODULE, WP_BASE_DIRS_FLAG_MODULE,
} WpBaseDirsFlags; } WpBaseDirsFlags;