aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEli Schwartz <eschwartz@archlinux.org>2021-07-04 15:39:03 -0400
committerEli Schwartz <eschwartz@archlinux.org>2021-07-28 01:33:46 -0400
commit276fe408affa75749aa7ce024738326d659991f6 (patch)
tree1e008de64f9a148da81239e84bea5afb60374159
parent23ea9feee3f94673c0042527dcd7e98013f1651a (diff)
downloadmeson-276fe408affa75749aa7ce024738326d659991f6.zip
meson-276fe408affa75749aa7ce024738326d659991f6.tar.gz
meson-276fe408affa75749aa7ce024738326d659991f6.tar.bz2
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.
-rw-r--r--mesonbuild/dependencies/base.py3
-rw-r--r--mesonbuild/dependencies/pkgconfig.py5
2 files changed, 4 insertions, 4 deletions
diff --git a/mesonbuild/dependencies/base.py b/mesonbuild/dependencies/base.py
index 7d6bf62..fd2b069 100644
--- a/mesonbuild/dependencies/base.py
+++ b/mesonbuild/dependencies/base.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?
diff --git a/mesonbuild/dependencies/pkgconfig.py b/mesonbuild/dependencies/pkgconfig.py
index 28a3f74..9786918 100644
--- a/mesonbuild/dependencies/pkgconfig.py
+++ b/mesonbuild/dependencies/pkgconfig.py
@@ -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.