diff options
author | Xavier Claessens <xavier.claessens@collabora.com> | 2023-11-08 14:30:11 -0500 |
---|---|---|
committer | Xavier Claessens <xavier.claessens@collabora.com> | 2023-11-09 14:03:18 -0500 |
commit | d0a7a203a6edb570c36a9fb5f04a3541df2be687 (patch) | |
tree | e1e7c0af20a1d52f9fe771e174fe968793a862e3 /mesonbuild/build.py | |
parent | 21bf18afa159bbfae8f4e5c88e174f4fbc5ffc2b (diff) | |
download | meson-d0a7a203a6edb570c36a9fb5f04a3541df2be687.zip meson-d0a7a203a6edb570c36a9fb5f04a3541df2be687.tar.gz meson-d0a7a203a6edb570c36a9fb5f04a3541df2be687.tar.bz2 |
build: Add dummy base class for CustomTarget and CustomTargetIndex
CustomTarget and CustomTargetIndex often have to be special cased
because they are not subclass of BuildTarget. It's easier to introduce a
dummy base class.
This fix recursive functions over link targets that might encouters
libraries built as CustomTarget.
Diffstat (limited to 'mesonbuild/build.py')
-rw-r--r-- | mesonbuild/build.py | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/mesonbuild/build.py b/mesonbuild/build.py index 0cb21cf..651f614 100644 --- a/mesonbuild/build.py +++ b/mesonbuild/build.py @@ -1299,7 +1299,7 @@ class BuildTarget(Target): for t in self.link_targets: if t in result: continue - if isinstance(t, SharedLibrary) and t.rust_crate_type == 'proc-macro': + if t.rust_crate_type == 'proc-macro': continue if include_internals or not t.is_internal(): result.add(t) @@ -2523,7 +2523,26 @@ class CommandBase: raise InvalidArguments(f'Argument {c!r} in "command" is invalid') return final_cmd -class CustomTarget(Target, CommandBase): +class CustomTargetBase: + ''' Base class for CustomTarget and CustomTargetIndex + + This base class can be used to provide a dummy implementation of some + private methods to avoid repeating `isinstance(t, BuildTarget)` when dealing + with custom targets. + ''' + + rust_crate_type = '' + + def get_dependencies_recurse(self, result: OrderedSet[BuildTargetTypes], include_internals: bool = True) -> None: + pass + + def get_internal_static_libraries(self) -> OrderedSet[BuildTargetTypes]: + return OrderedSet() + + def get_internal_static_libraries_recurse(self, result: OrderedSet[BuildTargetTypes]) -> None: + pass + +class CustomTarget(Target, CustomTargetBase, CommandBase): typename = 'custom' @@ -2900,7 +2919,7 @@ class Jar(BuildTarget): return self.environment.get_jar_dir(), '{jardir}' @dataclass(eq=False) -class CustomTargetIndex(HoldableObject): +class CustomTargetIndex(CustomTargetBase, HoldableObject): """A special opaque object returned by indexing a CustomTarget. This object exists in Meson, but acts as a proxy in the backends, making targets depend |