aboutsummaryrefslogtreecommitdiff
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
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.
-rw-r--r--mesonbuild/interpreter.py16
-rw-r--r--test cases/common/105 find program path/meson.build8
2 files changed, 22 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():
diff --git a/test cases/common/105 find program path/meson.build b/test cases/common/105 find program path/meson.build
index ba6030b..8040bb3 100644
--- a/test cases/common/105 find program path/meson.build
+++ b/test cases/common/105 find program path/meson.build
@@ -8,3 +8,11 @@ if not python.found()
endif
run_command(python, prog.path())
+
+progf = files('program.py')
+py = configure_file(input : 'program.py',
+ output : 'builtprogram.py',
+ configuration : configuration_data())
+
+find_program(py)
+find_program(progf)