aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/interpreter.py
diff options
context:
space:
mode:
authorNirbheek Chauhan <nirbheek@centricular.com>2017-02-19 03:00:07 +0530
committerNirbheek Chauhan <nirbheek@centricular.com>2017-02-19 03:01:24 +0530
commit280346da3ac5904ec097afe89ef45ad34bd4a173 (patch)
tree5dafa8f10be2a4474c3958b0fb5521d208bda732 /mesonbuild/interpreter.py
parent18bce476913de4deec18fcd028cb59d378c43812 (diff)
downloadmeson-280346da3ac5904ec097afe89ef45ad34bd4a173.zip
meson-280346da3ac5904ec097afe89ef45ad34bd4a173.tar.gz
meson-280346da3ac5904ec097afe89ef45ad34bd4a173.tar.bz2
find_program: Support passing mesonlib.File objects
This means you can pass files() and the return value of configure_file() to find_program() now.
Diffstat (limited to 'mesonbuild/interpreter.py')
-rw-r--r--mesonbuild/interpreter.py16
1 files changed, 14 insertions, 2 deletions
diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py
index 224f98e..963cc69 100644
--- a/mesonbuild/interpreter.py
+++ b/mesonbuild/interpreter.py
@@ -1759,7 +1759,6 @@ class Interpreter(InterpreterBase):
break
self.coredata.base_options[optname] = oobj
- @stringArgs
def func_find_program(self, node, args, kwargs):
if len(args) == 0:
raise InterpreterException('No program name specified.')
@@ -1769,8 +1768,21 @@ class Interpreter(InterpreterBase):
# Search for scripts relative to current subdir.
# Do not cache found programs because find_program('foobar')
# might give different results when run from different source dirs.
- search_dir = os.path.join(self.environment.get_source_dir(), self.subdir)
+ source_dir = os.path.join(self.environment.get_source_dir(), self.subdir)
for exename in args:
+ if isinstance(exename, mesonlib.File):
+ if exename.is_built:
+ search_dir = os.path.join(self.environment.get_build_dir(),
+ exename.subdir)
+ else:
+ search_dir = os.path.join(self.environment.get_source_dir(),
+ exename.subdir)
+ exename = exename.fname
+ elif isinstance(exename, str):
+ search_dir = source_dir
+ else:
+ raise InvalidArguments('find_program only accepts strings and '
+ 'files, not {!r}'.format(exename))
extprog = dependencies.ExternalProgram(exename, search_dir=search_dir)
progobj = ExternalProgramHolder(extprog)
if progobj.found():