aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/interpreter/interpreter.py
diff options
context:
space:
mode:
authorNomura <nomura.rh@gmail.com>2023-08-02 22:34:39 +0200
committerXavier Claessens <xclaesse@gmail.com>2023-08-04 14:46:39 -0400
commit50baf3c626267252a2d943a49d8e7c0402e23218 (patch)
tree3b50e104ec4cf1d484693e5ef903b6147ef8b3c2 /mesonbuild/interpreter/interpreter.py
parent183e4b8e903c6c4c057d09549e669d6292478a4e (diff)
downloadmeson-50baf3c626267252a2d943a49d8e7c0402e23218.zip
meson-50baf3c626267252a2d943a49d8e7c0402e23218.tar.gz
meson-50baf3c626267252a2d943a49d8e7c0402e23218.tar.bz2
Add default_options argument to find_program()
Diffstat (limited to 'mesonbuild/interpreter/interpreter.py')
-rw-r--r--mesonbuild/interpreter/interpreter.py15
1 files changed, 10 insertions, 5 deletions
diff --git a/mesonbuild/interpreter/interpreter.py b/mesonbuild/interpreter/interpreter.py
index 4ef78e8..95a6e1d 100644
--- a/mesonbuild/interpreter/interpreter.py
+++ b/mesonbuild/interpreter/interpreter.py
@@ -1619,6 +1619,7 @@ class Interpreter(InterpreterBase, HoldableObject):
# the host machine.
def find_program_impl(self, args: T.List[mesonlib.FileOrString],
for_machine: MachineChoice = MachineChoice.HOST,
+ default_options: T.Optional[T.Dict[OptionKey, T.Union[str, int, bool, T.List[str]]]] = None,
required: bool = True, silent: bool = True,
wanted: T.Union[str, T.List[str]] = '',
search_dirs: T.Optional[T.List[str]] = None,
@@ -1627,7 +1628,7 @@ class Interpreter(InterpreterBase, HoldableObject):
args = mesonlib.listify(args)
extra_info: T.List[mlog.TV_Loggable] = []
- progobj = self.program_lookup(args, for_machine, required, search_dirs, extra_info)
+ progobj = self.program_lookup(args, for_machine, default_options, required, search_dirs, extra_info)
if progobj is None:
progobj = self.notfound_program(args)
@@ -1671,6 +1672,7 @@ class Interpreter(InterpreterBase, HoldableObject):
return progobj
def program_lookup(self, args: T.List[mesonlib.FileOrString], for_machine: MachineChoice,
+ default_options: T.Optional[T.Dict[OptionKey, T.Union[str, int, bool, T.List[str]]]],
required: bool, search_dirs: T.List[str], extra_info: T.List[mlog.TV_Loggable]
) -> T.Optional[T.Union[ExternalProgram, build.Executable, OverrideProgram]]:
progobj = self.program_from_overrides(args, extra_info)
@@ -1686,7 +1688,7 @@ class Interpreter(InterpreterBase, HoldableObject):
if wrap_mode != WrapMode.nofallback and self.environment.wrap_resolver:
fallback = self.environment.wrap_resolver.find_program_provider(args)
if fallback and wrap_mode == WrapMode.forcefallback:
- return self.find_program_fallback(fallback, args, required, extra_info)
+ return self.find_program_fallback(fallback, args, default_options, required, extra_info)
progobj = self.program_from_file_for(for_machine, args)
if progobj is None:
@@ -1695,18 +1697,19 @@ class Interpreter(InterpreterBase, HoldableObject):
prog = ExternalProgram('python3', mesonlib.python_command, silent=True)
progobj = prog if prog.found() else None
if progobj is None and fallback and required:
- progobj = self.find_program_fallback(fallback, args, required, extra_info)
+ progobj = self.find_program_fallback(fallback, args, default_options, required, extra_info)
return progobj
def find_program_fallback(self, fallback: str, args: T.List[mesonlib.FileOrString],
+ default_options: T.Dict[OptionKey, T.Union[str, int, bool, T.List[str]]],
required: bool, extra_info: T.List[mlog.TV_Loggable]
) -> T.Optional[T.Union[ExternalProgram, build.Executable, OverrideProgram]]:
mlog.log('Fallback to subproject', mlog.bold(fallback), 'which provides program',
mlog.bold(' '.join(args)))
sp_kwargs: kwtypes.DoSubproject = {
'required': required,
- 'default_options': {},
+ 'default_options': default_options or {},
'version': [],
'cmake_options': [],
'options': None,
@@ -1722,6 +1725,7 @@ class Interpreter(InterpreterBase, HoldableObject):
REQUIRED_KW,
KwargInfo('dirs', ContainerTypeInfo(list, str), default=[], listify=True, since='0.53.0'),
KwargInfo('version', ContainerTypeInfo(list, str), default=[], listify=True, since='0.52.0'),
+ DEFAULT_OPTIONS.evolve(since='1.3.0')
)
@disablerIfNotFound
def func_find_program(self, node: mparser.BaseNode, args: T.Tuple[T.List[mesonlib.FileOrString]],
@@ -1733,7 +1737,8 @@ class Interpreter(InterpreterBase, HoldableObject):
return self.notfound_program(args[0])
search_dirs = extract_search_dirs(kwargs)
- return self.find_program_impl(args[0], kwargs['native'], required=required,
+ default_options = kwargs['default_options']
+ return self.find_program_impl(args[0], kwargs['native'], default_options=default_options, required=required,
silent=False, wanted=kwargs['version'],
search_dirs=search_dirs)