From a67d1e56e626a3a2a680892afbf12d8f7c5e2cf4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20=22sp1rit=22=E2=80=8B?= Date: Thu, 28 Nov 2024 14:26:30 +0100 Subject: [PATCH] build: Introduce introspection flags for Target Using .add_introspection_flag high level concepts can mark a specific target in the introspection data. --- mesonbuild/build.py | 7 +++++++ mesonbuild/mintro.py | 3 +++ mesonbuild/modules/gnome.py | 1 + 3 files changed, 11 insertions(+) diff --git a/mesonbuild/build.py b/mesonbuild/build.py index e6979efd71f6..0500cc0f2633 100644 --- a/mesonbuild/build.py +++ b/mesonbuild/build.py @@ -525,6 +525,7 @@ class Target(HoldableObject, metaclass=abc.ABCMeta): build_always_stale: bool = False extra_files: T.List[File] = field(default_factory=list) override_options: InitVar[T.Optional[T.Dict[OptionKey, str]]] = None + introspection_flags: T.Optional[T.List[str]] = None @abc.abstractproperty def typename(self) -> str: @@ -637,6 +638,12 @@ def construct_id_from_path(subdir: str, name: str, type_suffix: str) -> str: return subdir_part + '@@' + my_id return my_id + def add_introspection_flag(self, flag: str) -> None: + if self.introspection_flags is None: + self.introspection_flags = [flag] + else: + self.introspection_flags.append(flag) + def get_id(self) -> str: name = self.name if getattr(self, 'name_suffix_set', False): diff --git a/mesonbuild/mintro.py b/mesonbuild/mintro.py index 810a2b674b40..eb438ef6f12b 100644 --- a/mesonbuild/mintro.py +++ b/mesonbuild/mintro.py @@ -263,6 +263,9 @@ def list_targets(builddata: build.Build, installdata: backends.InstallData, back 'depends': [lib.get_id() for lib in getattr(target, 'dependencies', [])] } + if target.introspection_flags: + t['flags'] = target.introspection_flags + vs_module_defs = getattr(target, 'vs_module_defs', None) if vs_module_defs is not None: t['vs_module_defs'] = vs_module_defs.relative_name() diff --git a/mesonbuild/modules/gnome.py b/mesonbuild/modules/gnome.py index e8c432c4de52..e2c86611fa08 100644 --- a/mesonbuild/modules/gnome.py +++ b/mesonbuild/modules/gnome.py @@ -2222,6 +2222,7 @@ def executable(self, state: 'ModuleState', args: T.Tuple[str, SourcesVarargsType target = state.add_target(args, kwargs, build.SharedLibrary) glue = state.dependency('gtk4-android-glue') target.add_deps([glue]) + target.add_introspection_flag('gnome:has-android-glue') else: target = state.add_target(args, kwargs, build.Executable) return ModuleReturnValue(target, [])