Skip to content

Commit

Permalink
build: Introduce introspection flags for Target
Browse files Browse the repository at this point in the history
Using <target>.add_introspection_flag high level concepts can mark a
specific target in the introspection data.
  • Loading branch information
sp1ritCS committed Nov 28, 2024
1 parent 9f54498 commit a67d1e5
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
7 changes: 7 additions & 0 deletions mesonbuild/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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):
Expand Down
3 changes: 3 additions & 0 deletions mesonbuild/mintro.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
1 change: 1 addition & 0 deletions mesonbuild/modules/gnome.py
Original file line number Diff line number Diff line change
Expand Up @@ -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, [])
Expand Down

0 comments on commit a67d1e5

Please sign in to comment.