diff options
author | Xavier Claessens <xavier.claessens@collabora.com> | 2023-08-27 11:02:09 -0400 |
---|---|---|
committer | Xavier Claessens <xclaesse@gmail.com> | 2023-08-29 13:34:23 -0400 |
commit | 494bdbd3345d1c2d20cf2520249962bd32fc61e6 (patch) | |
tree | 9c543fe1c84c8d2b58f97f39f847ed8c53a9be63 /mesonbuild | |
parent | 4eb9c84cf97427a11af7ec928c849e4289862202 (diff) | |
download | meson-494bdbd3345d1c2d20cf2520249962bd32fc61e6.zip meson-494bdbd3345d1c2d20cf2520249962bd32fc61e6.tar.gz meson-494bdbd3345d1c2d20cf2520249962bd32fc61e6.tar.bz2 |
gnome: Fix crash in gtkdoc and generate_gir in C++ projects
gtkdoc() and generate_gir() methods assumes there is a C compiler, but
pure C++ projects might not add it explicitly.
Fixes: #12162
Diffstat (limited to 'mesonbuild')
-rw-r--r-- | mesonbuild/modules/__init__.py | 2 | ||||
-rw-r--r-- | mesonbuild/modules/gnome.py | 6 |
2 files changed, 8 insertions, 0 deletions
diff --git a/mesonbuild/modules/__init__.py b/mesonbuild/modules/__init__.py index 57c169d..eef67a1 100644 --- a/mesonbuild/modules/__init__.py +++ b/mesonbuild/modules/__init__.py @@ -167,6 +167,8 @@ class ModuleState: else: yield self._interpreter.build_incdir_object([d]) + def add_language(self, lang: str, for_machine: MachineChoice) -> None: + self._interpreter.add_languages([lang], True, for_machine) class ModuleObject(HoldableObject): """Base class for all objects returned by modules diff --git a/mesonbuild/modules/gnome.py b/mesonbuild/modules/gnome.py index 6bd0436..039e122 100644 --- a/mesonbuild/modules/gnome.py +++ b/mesonbuild/modules/gnome.py @@ -1113,6 +1113,9 @@ class GnomeModule(ExtensionModule): ) def generate_gir(self, state: 'ModuleState', args: T.Tuple[T.List[T.Union[Executable, build.SharedLibrary, build.StaticLibrary]]], kwargs: 'GenerateGir') -> ModuleReturnValue: + # Ensure we have a C compiler even in C++ projects. + state.add_language('c', MachineChoice.HOST) + girtargets = [self._unwrap_gir_target(arg, state) for arg in args[0]] if len(girtargets) > 1 and any(isinstance(el, Executable) for el in girtargets): raise MesonException('generate_gir only accepts a single argument when one of the arguments is an executable') @@ -1430,6 +1433,9 @@ class GnomeModule(ExtensionModule): namespace = kwargs['namespace'] + # Ensure we have a C compiler even in C++ projects. + state.add_language('c', MachineChoice.HOST) + def abs_filenames(files: T.Iterable['FileOrString']) -> T.Iterator[str]: for f in files: if isinstance(f, mesonlib.File): |