diff options
author | Dylan Baker <dylan@pnwbakers.com> | 2022-03-10 10:43:07 -0800 |
---|---|---|
committer | Eli Schwartz <eschwartz93@gmail.com> | 2022-05-25 22:41:03 -0400 |
commit | bd68e8c61343b3fd108a2f5cacaa7d931b0209d0 (patch) | |
tree | b42084da0b669ec6e189fc3c30a7abc89d0a52ee /mesonbuild/build.py | |
parent | 702030a9cccf78b2ebdf2a6c85ea558163160dbc (diff) | |
download | meson-bd68e8c61343b3fd108a2f5cacaa7d931b0209d0.zip meson-bd68e8c61343b3fd108a2f5cacaa7d931b0209d0.tar.gz meson-bd68e8c61343b3fd108a2f5cacaa7d931b0209d0.tar.bz2 |
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.
Diffstat (limited to 'mesonbuild/build.py')
-rw-r--r-- | mesonbuild/build.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/mesonbuild/build.py b/mesonbuild/build.py index 51419d1..550b5e4 100644 --- a/mesonbuild/build.py +++ b/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() |