summaryrefslogtreecommitdiff
path: root/mesonbuild/backend/backends.py
diff options
context:
space:
mode:
authorFlorian "sp1rit"​ <sp1rit@disroot.org>2025-06-11 19:10:12 +0200
committerJussi Pakkanen <jussi.pakkanen@mailbox.org>2025-06-23 19:59:53 +0300
commitfea9f6918a6647430f4e22ca908f074b3e93e489 (patch)
tree102087d670e2f9b5145bccdf7ac84f1c3c10f838 /mesonbuild/backend/backends.py
parent19d3e4dc30bd3210eb85e29a538ad1606adef1bc (diff)
downloadmeson-fea9f6918a6647430f4e22ca908f074b3e93e489.tar.gz
vala: Also add --target-glib if glib is built as subproject
Previously, meson would only check if glib was part of target.external_dependencies and add --target-glib appropriately. This however had the downside of meson not adding --target-glib if glib was included as a subproject, potentially breaking otherwise builds. Instead of checking external_dependencies, check target.added_deps for an occurrence of 'glib-2.0' and then pick the appropriate codepath (either from the external dependency based on version_reqs or for the internal dependency based on the actual version, potentially downgraded to the latest release version) Related-to: #14694
Diffstat (limited to 'mesonbuild/backend/backends.py')
-rw-r--r--mesonbuild/backend/backends.py31
1 files changed, 26 insertions, 5 deletions
diff --git a/mesonbuild/backend/backends.py b/mesonbuild/backend/backends.py
index 28a92d28e..ed57a4c1b 100644
--- a/mesonbuild/backend/backends.py
+++ b/mesonbuild/backend/backends.py
@@ -1085,11 +1085,6 @@ class Backend:
if compiler.language == 'vala':
if dep.type_name == 'pkgconfig':
assert isinstance(dep, dependencies.ExternalDependency)
- if dep.name == 'glib-2.0' and dep.version_reqs is not None:
- for req in dep.version_reqs:
- if req.startswith(('>=', '==')):
- commands += ['--target-glib', req[2:]]
- break
commands += ['--pkg', dep.name]
elif isinstance(dep, dependencies.ExternalLibrary):
commands += dep.get_link_args('vala')
@@ -1101,6 +1096,32 @@ class Backend:
commands += dep.get_exe_args(compiler)
# For 'automagic' deps: Boost and GTest. Also dependency('threads').
# pkg-config puts the thread flags itself via `Cflags:`
+ if compiler.language == 'vala':
+ # Vala wants to know the minimum glib version
+ for dep in target.added_deps:
+ if dep.name == 'glib-2.0':
+ if dep.type_name == 'pkgconfig':
+ assert isinstance(dep, dependencies.ExternalDependency)
+ if dep.version_reqs is not None:
+ for req in dep.version_reqs:
+ if req.startswith(('>=', '==')):
+ commands += ['--target-glib', req[2:]]
+ break
+ elif isinstance(dep, dependencies.InternalDependency) and dep.version is not None:
+ glib_version = dep.version.split('.')
+ if len(glib_version) != 3:
+ mlog.warning(f'GLib version has unexpected format: {dep.version}')
+ break
+ try:
+ # If GLib version is a development version, downgrade
+ # --target-glib to the previous version, as valac will
+ # complain about non-even minor versions
+ glib_version[1] = str((int(glib_version[1]) // 2) * 2)
+ except ValueError:
+ mlog.warning(f'GLib version has unexpected format: {dep.version}')
+ break
+ commands += ['--target-glib', f'{glib_version[0]}.{glib_version[1]}']
+
# Fortran requires extra include directives.
if compiler.language == 'fortran':
for lt in chain(target.link_targets, target.link_whole_targets):