aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/interpreter.py
diff options
context:
space:
mode:
authorDylan Baker <dylan@pnwbakers.com>2020-10-01 13:02:08 -0700
committerXavier Claessens <xclaesse@gmail.com>2021-03-19 08:47:10 -0400
commit40e3577a65ac688814eff1239fa38b86aad19ee8 (patch)
tree8329ecb3418c58c43ef7ccf1c0f354aab530ed5f /mesonbuild/interpreter.py
parentf7b0238ed67fc0c9e3cef38090983e33b40fa205 (diff)
downloadmeson-40e3577a65ac688814eff1239fa38b86aad19ee8.zip
meson-40e3577a65ac688814eff1239fa38b86aad19ee8.tar.gz
meson-40e3577a65ac688814eff1239fa38b86aad19ee8.tar.bz2
split program related classes and functions out of dependencies
Dependencies is already a large and complicated package without adding programs to the list. This also allows us to untangle a bit of spaghetti that we have.
Diffstat (limited to 'mesonbuild/interpreter.py')
-rw-r--r--mesonbuild/interpreter.py34
1 files changed, 17 insertions, 17 deletions
diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py
index 6a51f3d..f4e296d 100644
--- a/mesonbuild/interpreter.py
+++ b/mesonbuild/interpreter.py
@@ -22,7 +22,7 @@ from . import compilers
from .wrap import wrap, WrapMode
from . import mesonlib
from .mesonlib import FileMode, MachineChoice, OptionKey, Popen_safe, listify, extract_as_list, has_path_sep, unholder
-from .dependencies import ExternalProgram
+from .programs import ExternalProgram, NonExistingExternalProgram
from .dependencies import InternalDependency, Dependency, NotFoundDependency, DependencyException
from .depfile import DepFile
from .interpreterbase import InterpreterBase, typed_pos_args
@@ -72,7 +72,7 @@ def stringifyUserArguments(args, quote=False):
raise InvalidArguments('Function accepts only strings, integers, lists, dictionaries and lists thereof.')
-class OverrideProgram(dependencies.ExternalProgram):
+class OverrideProgram(ExternalProgram):
pass
@@ -1931,9 +1931,9 @@ class MesonMain(InterpreterObject):
found = self._found_source_scripts[key]
elif isinstance(prog, mesonlib.File):
prog = prog.rel_to_builddir(self.interpreter.environment.source_dir)
- found = dependencies.ExternalProgram(prog, search_dir=self.interpreter.environment.build_dir)
+ found = ExternalProgram(prog, search_dir=self.interpreter.environment.build_dir)
else:
- found = dependencies.ExternalProgram(prog, search_dir=search_dir)
+ found = ExternalProgram(prog, search_dir=search_dir)
if found.found():
self._found_source_scripts[key] = found
@@ -1976,7 +1976,7 @@ class MesonMain(InterpreterObject):
elif isinstance(a, build.ConfigureFile):
new = True
script_args.append(os.path.join(a.subdir, a.targetname))
- elif isinstance(a, dependencies.ExternalProgram):
+ elif isinstance(a, ExternalProgram):
script_args.extend(a.command)
new = True
else:
@@ -2163,7 +2163,7 @@ class MesonMain(InterpreterObject):
if not os.path.exists(abspath):
raise InterpreterException('Tried to override %s with a file that does not exist.' % name)
exe = OverrideProgram(name, abspath)
- if not isinstance(exe, (dependencies.ExternalProgram, build.Executable)):
+ if not isinstance(exe, (ExternalProgram, build.Executable)):
raise InterpreterException('Second argument must be an external program or executable.')
self.interpreter.add_find_program_override(name, exe)
@@ -2543,7 +2543,7 @@ class Interpreter(InterpreterBase):
return DataHolder(item)
elif isinstance(item, dependencies.Dependency):
return DependencyHolder(item, self.subproject)
- elif isinstance(item, dependencies.ExternalProgram):
+ elif isinstance(item, ExternalProgram):
return ExternalProgramHolder(item, self.subproject)
elif isinstance(item, ModuleObject):
return ModuleObjectHolder(item, self)
@@ -2576,7 +2576,7 @@ class Interpreter(InterpreterBase):
elif isinstance(v, Test):
self.build.tests.append(v)
elif isinstance(v, (int, str, bool, Disabler, ObjectHolder, build.GeneratedList,
- dependencies.ExternalProgram)):
+ ExternalProgram)):
pass
else:
raise InterpreterException('Module returned a value of unknown type.')
@@ -3424,12 +3424,12 @@ external dependencies (including libraries) must go to "dependencies".''')
else:
raise InvalidArguments('find_program only accepts strings and '
'files, not {!r}'.format(exename))
- extprog = dependencies.ExternalProgram(exename, search_dir=search_dir,
- extra_search_dirs=extra_search_dirs,
- silent=True)
+ extprog = ExternalProgram(exename, search_dir=search_dir,
+ extra_search_dirs=extra_search_dirs,
+ silent=True)
progobj = ExternalProgramHolder(extprog, self.subproject)
if progobj.found():
- extra_info.append('({})'.format(' '.join(progobj.get_command())))
+ extra_info.append(f"({' '.join(progobj.get_command())})")
return progobj
def program_from_overrides(self, command_names, extra_info):
@@ -3457,7 +3457,7 @@ external dependencies (including libraries) must go to "dependencies".''')
self.build.find_overrides[name] = exe
def notfound_program(self, args):
- return ExternalProgramHolder(dependencies.NonExistingExternalProgram(' '.join(args)), self.subproject)
+ return ExternalProgramHolder(NonExistingExternalProgram(' '.join(args)), self.subproject)
# TODO update modules to always pass `for_machine`. It is bad-form to assume
# the host machine.
@@ -3515,7 +3515,7 @@ external dependencies (including libraries) must go to "dependencies".''')
if progobj is None:
progobj = self.program_from_system(args, search_dirs, extra_info)
if progobj is None and args[0].endswith('python3'):
- prog = dependencies.ExternalProgram('python3', mesonlib.python_command, silent=True)
+ prog = ExternalProgram('python3', mesonlib.python_command, silent=True)
progobj = ExternalProgramHolder(prog, self.subproject) if prog.found() else None
if progobj is None and fallback and required:
progobj = self.find_program_fallback(fallback, args, required, extra_info)
@@ -4032,10 +4032,10 @@ This will become a hard error in the future.''' % kwargs['input'], location=self
cleaned_args = []
for i in unholder(listify(all_args)):
- if not isinstance(i, (str, build.BuildTarget, build.CustomTarget, dependencies.ExternalProgram, mesonlib.File)):
+ if not isinstance(i, (str, build.BuildTarget, build.CustomTarget, ExternalProgram, mesonlib.File)):
mlog.debug('Wrong type:', str(i))
raise InterpreterException('Invalid argument to run_target.')
- if isinstance(i, dependencies.ExternalProgram) and not i.found():
+ if isinstance(i, ExternalProgram) and not i.found():
raise InterpreterException(f'Tried to use non-existing executable {i.name!r}')
cleaned_args.append(i)
if isinstance(cleaned_args[0], str):
@@ -4647,7 +4647,7 @@ This warning will become a hard error in a future Meson release.
for i in inp:
if isinstance(i, str):
exe_wrapper.append(i)
- elif isinstance(i, dependencies.ExternalProgram):
+ elif isinstance(i, ExternalProgram):
if not i.found():
raise InterpreterException('Tried to use non-found executable.')
exe_wrapper += i.get_command()