build: Add a `links_dynamically` method to CustomTarget[Index]

This is useful for cases where we treat CustomTargets as linkable
targets, and need to know whether they're going to link statically or
dynamically.
pull/10432/head
Dylan Baker 3 years ago committed by Eli Schwartz
parent 702030a9cc
commit bd68e8c613
  1. 20
      mesonbuild/build.py

@ -2545,6 +2545,16 @@ class CustomTarget(Target, CommandBase):
suf = os.path.splitext(self.outputs[0])[-1]
return suf in {'.a', '.dll', '.lib', '.so', '.dylib'}
def links_dynamically(self) -> bool:
"""Whether this target links dynamically or statically
Does not assert the target is linkable, just that it is not shared
:return: True if is dynamically linked, otherwise False
"""
suf = os.path.splitext(self.outputs[0])[-1]
return suf not in {'.a', '.lib'}
def get_link_deps_mapping(self, prefix: str) -> T.Mapping[str, str]:
return {}
@ -2744,6 +2754,16 @@ class CustomTargetIndex(HoldableObject):
suf = os.path.splitext(self.output)[-1]
return suf in {'.a', '.dll', '.lib', '.so'}
def links_dynamically(self) -> bool:
"""Whether this target links dynamically or statically
Does not assert the target is linkable, just that it is not shared
:return: True if is dynamically linked, otherwise False
"""
suf = os.path.splitext(self.output)[-1]
return suf not in {'.a', '.lib'}
def should_install(self) -> bool:
return self.target.should_install()

Loading…
Cancel
Save