aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/interpreter.py
diff options
context:
space:
mode:
authorNirbheek Chauhan <nirbheek@centricular.com>2018-06-29 19:33:17 +0530
committerNirbheek Chauhan <nirbheek.chauhan@gmail.com>2018-07-01 13:59:48 +0000
commitec29f19c1274d72e3a2639e47caf4a7f17ffa436 (patch)
tree70ffad6c031159508e92b05ff69acbc052262480 /mesonbuild/interpreter.py
parentae8d044cb6dca20c1d6504a27660bcbed16db438 (diff)
downloadmeson-ec29f19c1274d72e3a2639e47caf4a7f17ffa436.zip
meson-ec29f19c1274d72e3a2639e47caf4a7f17ffa436.tar.gz
meson-ec29f19c1274d72e3a2639e47caf4a7f17ffa436.tar.bz2
Add a helper for fetching of binaries from cross files
A number of cases have to be taken care of while doing this, so refactor it into a helper on ExternalProgram and use it everywhere. 1. Command is a list of len > 1, use it as-is 2. Command is a list of len == 1 (or a string), use as a string 3. If command is an absolute path, use it as-is 4. If command is not an absolute path, search for it
Diffstat (limited to 'mesonbuild/interpreter.py')
-rw-r--r--mesonbuild/interpreter.py17
1 files changed, 6 insertions, 11 deletions
diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py
index 8f6f79d..5a9cc22 100644
--- a/mesonbuild/interpreter.py
+++ b/mesonbuild/interpreter.py
@@ -2618,23 +2618,18 @@ external dependencies (including libraries) must go to "dependencies".''')
self.emit_base_options_warnings(enabled_opts)
def program_from_cross_file(self, prognames, silent=False):
- bins = self.environment.cross_info.config['binaries']
+ cross_info = self.environment.cross_info
for p in prognames:
if hasattr(p, 'held_object'):
p = p.held_object
if isinstance(p, mesonlib.File):
continue # Always points to a local (i.e. self generated) file.
if not isinstance(p, str):
- raise InterpreterException('Executable name must be a string.')
- if p in bins:
- command = bins[p]
- if isinstance(command, (list, str)):
- extprog = dependencies.ExternalProgram(p, command=command, silent=silent)
- else:
- raise InterpreterException('Invalid type {!r} for binary {!r} in cross file'
- ''.format(command, p))
- progobj = ExternalProgramHolder(extprog)
- return progobj
+ raise InterpreterException('Executable name must be a string')
+ prog = ExternalProgram.from_cross_info(cross_info, p)
+ if prog.found():
+ return ExternalProgramHolder(prog)
+ return None
def program_from_system(self, args, silent=False):
# Search for scripts relative to current subdir.