dependencies: make the preferred LibType available to any ExternalDependency

Just like we automatically provide some reusable glue for self.static,
provide it here too. It seems plausibly like something people would
commonly want.
pull/8989/head
Eli Schwartz 3 years ago
parent 23ea9feee3
commit 276fe408af
No known key found for this signature in database
GPG Key ID: CEB167EFB5722BD6
  1. 3
      mesonbuild/dependencies/base.py
  2. 5
      mesonbuild/dependencies/pkgconfig.py

@ -22,7 +22,7 @@ from enum import Enum
from .. import mlog
from ..compilers import clib_langs
from ..mesonlib import MachineChoice, MesonException, HoldableObject
from ..mesonlib import LibType, MachineChoice, MesonException, HoldableObject
from ..mesonlib import version_compare_many
from ..interpreterbase import FeatureDeprecated
@ -319,6 +319,7 @@ class ExternalDependency(Dependency, HasNativeKwarg):
self.required = kwargs.get('required', True)
self.silent = kwargs.get('silent', False)
self.static = kwargs.get('static', False)
self.libtype = LibType.STATIC if self.static else LibType.PREFER_SHARED
if not isinstance(self.static, bool):
raise DependencyException('Static keyword must be boolean')
# Is this dependency to be run on the build platform?

@ -13,7 +13,7 @@
# limitations under the License.
from .base import ExternalDependency, DependencyException, sort_libpaths, DependencyTypeName
from ..mesonlib import LibType, MachineChoice, OptionKey, OrderedSet, PerMachine, Popen_safe
from ..mesonlib import MachineChoice, OptionKey, OrderedSet, PerMachine, Popen_safe
from ..programs import find_external_program, ExternalProgram
from .. import mlog
from pathlib import PurePath
@ -267,7 +267,6 @@ class PkgConfigDependency(ExternalDependency):
libs_found: OrderedSet[str] = OrderedSet()
# Track not-found libraries to know whether to add library paths
libs_notfound = []
libtype = LibType.STATIC if self.static else LibType.PREFER_SHARED
# Generate link arguments for this library
link_args = []
for lib in full_args:
@ -283,7 +282,7 @@ class PkgConfigDependency(ExternalDependency):
continue
if self.clib_compiler:
args = self.clib_compiler.find_library(lib[2:], self.env,
libpaths, libtype)
libpaths, self.libtype)
# If the project only uses a non-clib language such as D, Rust,
# C#, Python, etc, all we can do is limp along by adding the
# arguments as-is and then adding the libpaths at the end.

Loading…
Cancel
Save