aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild
diff options
context:
space:
mode:
authorJussi Pakkanen <jpakkane@gmail.com>2017-11-27 00:32:34 +0200
committerJussi Pakkanen <jpakkane@gmail.com>2017-11-27 23:22:47 +0200
commit5bc1009109431ad6f72d1ddfcf46ea718123a48b (patch)
treeafd03287883455c8bc8277b493c4a1999dab8897 /mesonbuild
parentdad5779d3c71d2d7474d481a4c4c2e48a1770c64 (diff)
downloadmeson-5bc1009109431ad6f72d1ddfcf46ea718123a48b.zip
meson-5bc1009109431ad6f72d1ddfcf46ea718123a48b.tar.gz
meson-5bc1009109431ad6f72d1ddfcf46ea718123a48b.tar.bz2
Add if_found kwarg to subdir().
Diffstat (limited to 'mesonbuild')
-rw-r--r--mesonbuild/interpreter.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py
index fbf9a21..77f3105 100644
--- a/mesonbuild/interpreter.py
+++ b/mesonbuild/interpreter.py
@@ -1374,6 +1374,7 @@ permitted_kwargs = {'add_global_arguments': {'language'},
'shared_library': shlib_kwargs,
'shared_module': shmod_kwargs,
'static_library': stlib_kwargs,
+ 'subdir': {'if_found'},
'subproject': {'version', 'default_options'},
'test': {'args', 'env', 'is_parallel', 'should_fail', 'timeout', 'workdir', 'suite'},
'vcs_tag': {'input', 'output', 'fallback', 'command', 'replace_string'},
@@ -2477,7 +2478,7 @@ to directly access options of other subprojects.''')
self.build.man.append(m)
return m
- @noKwargs
+ @permittedKwargs(permitted_kwargs['subdir'])
def func_subdir(self, node, args, kwargs):
self.validate_arguments(args, 1, [str])
if '..' in args[0]:
@@ -2486,6 +2487,11 @@ to directly access options of other subprojects.''')
raise InvalidArguments('Must not go into subprojects dir with subdir(), use subproject() instead.')
if self.subdir == '' and args[0].startswith('meson-'):
raise InvalidArguments('The "meson-" prefix is reserved and cannot be used for top-level subdir().')
+ for i in mesonlib.extract_as_list(kwargs, 'if_found'):
+ if not hasattr(i, 'found_method'):
+ raise InterpreterException('Object used in if_found does not have a found method.')
+ if not i.found_method([], {}):
+ return
prev_subdir = self.subdir
subdir = os.path.join(prev_subdir, args[0])
if os.path.isabs(subdir):