Skip to content

Commit

Permalink
pkgconfig: Allow setting both pkgconfig and pkg-config
Browse files Browse the repository at this point in the history
This was previously allowed for different usage. Keep allowing it, but
with non fatal deprecation notice, and ignore the value from legacy
pkgconfig.
  • Loading branch information
xclaesse committed Oct 19, 2023
1 parent 7b7d2e0 commit bf9314e
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 deletions.
10 changes: 10 additions & 0 deletions docs/markdown/snippets/pkgconfig_deprecated_machine_file.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
## Machine files: `pkgconfig` field deprecated and replaced by `pkg-config`

Meson used to allow both `pkgconfig` and `pkg-config` entries in machine files,
the former was used for `dependency()` lookup and the latter was used as return
value for `find_program('pkg-config')`.

This inconsistency is now fixed by deprecating `pkgconfig` in favor of
`pkg-config` which matches the name of the binary. For backward compatibility
it is still allowed to define both with the same value, in that case no
deprecation warning is printed.
19 changes: 14 additions & 5 deletions mesonbuild/envconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -404,12 +404,21 @@ def __init__(
if not isinstance(command, (list, str)):
raise mesonlib.MesonException(
f'Invalid type {command!r} for entry {name!r} in cross file')
if name == 'pkgconfig':
if 'pkg-config' in binaries:
raise mesonlib.MesonException('Both pkgconfig and pkg-config entries in machine file.')
mlog.deprecation('"pkgconfig" entry is deprecated and should be replaced by "pkg-config"')
name = 'pkg-config'
self.binaries[name] = mesonlib.listify(command)
if 'pkgconfig' in self.binaries:
if 'pkg-config' not in self.binaries:
mlog.deprecation('"pkgconfig" entry is deprecated and should be replaced by "pkg-config"', fatal=False)
self.binaries['pkg-config'] = self.binaries['pkgconfig']
elif self.binaries['pkgconfig'] != self.binaries['pkg-config']:
raise mesonlib.MesonException('Mismatched pkgconfig and pkg-config binaries in the machine file.')
else:
# Both are defined with the same value, this is allowed
# for backward compatibility.
# FIXME: We should still print deprecation warning if the
# project targets Meson >= 1.3.0, but we have no way to know
# that here.
pass
del self.binaries['pkgconfig']

@staticmethod
def detect_ccache() -> T.List[str]:
Expand Down

0 comments on commit bf9314e

Please sign in to comment.