aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/interpreter
diff options
context:
space:
mode:
authorDudemanguy <random342@airmail.cc>2022-01-10 19:02:12 -0600
committerEli Schwartz <eschwartz93@gmail.com>2022-05-03 23:03:56 -0400
commit557680f7d6b2a2e7c3d0f04fb0d6529ac7a6d475 (patch)
treededf300cdb4b39a83e7bfa9eb7720f7fb43f0352 /mesonbuild/interpreter
parent8b3a54e5085933b78a8509103a76bed7ca8cdde4 (diff)
downloadmeson-557680f7d6b2a2e7c3d0f04fb0d6529ac7a6d475.zip
meson-557680f7d6b2a2e7c3d0f04fb0d6529ac7a6d475.tar.gz
meson-557680f7d6b2a2e7c3d0f04fb0d6529ac7a6d475.tar.bz2
add prefer_static built-in option
By default, meson will try to look for shared libraries first before static ones. In the meson.build itself, one can use the static keyword to control if a static library will be tried first but there's no simple way for an end user performing a build to switch back and forth at will. Let's cover this usecase by adding an option that allows a user to specify if they want dependency lookups to try static or shared libraries first. The writer of the meson.build can manually specify the static keyword where appropriate which will override the value of this option.
Diffstat (limited to 'mesonbuild/interpreter')
-rw-r--r--mesonbuild/interpreter/compiler.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/mesonbuild/interpreter/compiler.py b/mesonbuild/interpreter/compiler.py
index 185d151..c5db6aa 100644
--- a/mesonbuild/interpreter/compiler.py
+++ b/mesonbuild/interpreter/compiler.py
@@ -17,6 +17,7 @@ from ..interpreterbase import (ObjectHolder, noPosargs, noKwargs,
FeatureNew, disablerIfNotFound,
InterpreterException)
from ..interpreterbase.decorators import ContainerTypeInfo, typed_kwargs, KwargInfo, typed_pos_args
+from ..mesonlib import OptionKey
from .interpreterobjects import (extract_required_kwarg, extract_search_dirs)
from .type_checking import REQUIRED_KW, in_set_validator, NoneType
@@ -592,10 +593,13 @@ class CompilerHolder(ObjectHolder['Compiler']):
search_dirs = extract_search_dirs(kwargs)
+ prefer_static = self.environment.coredata.get_option(OptionKey('prefer_static'))
if kwargs['static'] is True:
libtype = mesonlib.LibType.STATIC
elif kwargs['static'] is False:
libtype = mesonlib.LibType.SHARED
+ elif prefer_static:
+ libtype = mesonlib.LibType.PREFER_STATIC
else:
libtype = mesonlib.LibType.PREFER_SHARED
linkargs = self.compiler.find_library(libname, self.environment, search_dirs, libtype)