From 6240920c213fb76b4e4be8b6b59ae3346cbbcf77 Mon Sep 17 00:00:00 2001 From: Eli Schwartz Date: Fri, 11 Feb 2022 14:48:30 -0500 Subject: pkgconfig module: allow custom variables to reference builtin directories Automatically generate additional variables and write them into the generated pkg-config file. This means projects no longer need to manually define the ones they use, which is annoying for dataonly usages (it used to forbid setting the base library-relevant "reserved" ones, and now allows it only for dataonly. But it's bloat to manualy list them anyway). It also fixes a regression in commit 248e6cf4736ef9ec636228da66c28f9be03aa74f which caused libdir to not be set, and to be unsettable, if the pkg-config file has no libraries but uses the ${libdir} expansion in a custom variable. This could be considered likely a case for dataonly, but it's not guaranteed. --- .../snippets/pkgconfig_directory_variables.md | 31 ++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 docs/markdown/snippets/pkgconfig_directory_variables.md (limited to 'docs/markdown') diff --git a/docs/markdown/snippets/pkgconfig_directory_variables.md b/docs/markdown/snippets/pkgconfig_directory_variables.md new file mode 100644 index 0000000..27a4069 --- /dev/null +++ b/docs/markdown/snippets/pkgconfig_directory_variables.md @@ -0,0 +1,31 @@ +## pkgconfig.generate will now include variables for builtin directories when referenced + +When using the `variables:` family of kwargs to `pkgconfig.generate` to refer +to installed paths, traditionally only `prefix`, `includedir`, and `libdir` +were available by default, and generating a correct (relocatable) pkg-config +file required manually constructing variables for e.g. `datadir`. + +Meson now checks each variable to see if it begins with a reference to a +standard directory, and if so, adds it to the list of directories for which a +builtin variable is created. + +For example, before it was necessary to do this: +```meson +pkgconfig.generate( + name: 'bash-completion', + description: 'programmable completion for the bash shell', + dataonly: true, + variables: { + 'prefix': get_option('prefix'), + 'datadir': join_paths('${prefix}', get_option('datadir')), + 'sysconfdir': join_paths('${prefix}', get_option('sysconfdir')), + + 'compatdir': '${sysconfdir}/bash_completion.d', + 'completionsdir': '${datadir}/bash-completion/completions', + 'helpersdir': '${datadir}/bash-completion/helpers', + }, + install_dir: join_paths(get_option('datadir'), 'pkgconfig'), +) +``` + +Now the first three variables are not needed. -- cgit v1.1