diff options
author | Dylan Baker <dylan@pnwbakers.com> | 2022-03-10 10:35:47 -0800 |
---|---|---|
committer | Eli Schwartz <eschwartz93@gmail.com> | 2022-05-25 22:41:03 -0400 |
commit | 702030a9cccf78b2ebdf2a6c85ea558163160dbc (patch) | |
tree | ca4af589e596575d91058d2b9880b401529766ee /mesonbuild/dependencies | |
parent | 5926190cbb2c5970f35d31b65c40f2da4e4e9254 (diff) | |
download | meson-702030a9cccf78b2ebdf2a6c85ea558163160dbc.zip meson-702030a9cccf78b2ebdf2a6c85ea558163160dbc.tar.gz meson-702030a9cccf78b2ebdf2a6c85ea558163160dbc.tar.bz2 |
dependencies: Don't allow as_link_whole to complete with SharedLibraries
Since a SharedLibrary can't be statically linked in, we shouldn't allow
the method to complete.
Diffstat (limited to 'mesonbuild/dependencies')
-rw-r--r-- | mesonbuild/dependencies/base.py | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/mesonbuild/dependencies/base.py b/mesonbuild/dependencies/base.py index 6f7cd2a..e239d66 100644 --- a/mesonbuild/dependencies/base.py +++ b/mesonbuild/dependencies/base.py @@ -317,8 +317,19 @@ class InternalDependency(Dependency): raise DependencyException(f'Could not get an internal variable and no default provided for {self!r}') def generate_link_whole_dependency(self) -> Dependency: + from ..build import SharedLibrary, CustomTarget, CustomTargetIndex new_dep = copy.deepcopy(self) - new_dep.whole_libraries += new_dep.libraries + for x in new_dep.libraries: + if isinstance(x, SharedLibrary): + raise MesonException('Cannot convert a dependency to link_whole when it contains a ' + 'SharedLibrary') + elif isinstance(x, (CustomTarget, CustomTargetIndex)) and x.links_dynamically(): + raise MesonException('Cannot convert a dependency to link_whole when it contains a ' + 'CustomTarget or CustomTargetIndex which is a shared library') + + # Mypy doesn't understand that the above is a TypeGuard + new_dep.whole_libraries += T.cast('T.List[T.Union[StaticLibrary, CustomTarget, CustomTargetIndex]]', + new_dep.libraries) new_dep.libraries = [] return new_dep |