diff options
author | Nirbheek Chauhan <nirbheek@centricular.com> | 2018-04-05 16:46:22 +0530 |
---|---|---|
committer | Nirbheek Chauhan <nirbheek@centricular.com> | 2018-04-15 13:32:38 +0530 |
commit | 87c166db954591372bd2d34ab59d3a2d8c2b0bd7 (patch) | |
tree | 9e61bf56b1e0d32ee2f6a65556a2318dbf811672 | |
parent | 998892ed2962fdabcb3ef882375501fd849d56f8 (diff) | |
download | meson-87c166db954591372bd2d34ab59d3a2d8c2b0bd7.zip meson-87c166db954591372bd2d34ab59d3a2d8c2b0bd7.tar.gz meson-87c166db954591372bd2d34ab59d3a2d8c2b0bd7.tar.bz2 |
find_program: Only store successful lookups
Otherwise we can't do the following workflow:
if not find_program('foo', required : false).found()
subproject('provides-foo')
endif
Where 'provides-foo' has a meson.override_find_program() on
a configure_file() or similar.
-rw-r--r-- | mesonbuild/interpreter.py | 3 | ||||
-rw-r--r-- | test cases/common/182 find override/meson.build | 10 |
2 files changed, 11 insertions, 2 deletions
diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py index 0d4c37d..e2f0f88 100644 --- a/mesonbuild/interpreter.py +++ b/mesonbuild/interpreter.py @@ -2324,7 +2324,6 @@ to directly access options of other subprojects.''') required = kwargs.get('required', True) if not isinstance(required, bool): raise InvalidArguments('"required" argument must be a boolean.') - self.store_name_lookups(args) progobj = self.program_from_overrides(args) if progobj is None and self.build.environment.is_cross_build(): use_native = kwargs.get('native', False) @@ -2338,6 +2337,8 @@ to directly access options of other subprojects.''') raise InvalidArguments('Program(s) {!r} not found or not executable'.format(args)) if progobj is None: return ExternalProgramHolder(dependencies.NonExistingExternalProgram()) + # Only store successful lookups + self.store_name_lookups(args) return progobj def func_find_library(self, node, args, kwargs): diff --git a/test cases/common/182 find override/meson.build b/test cases/common/182 find override/meson.build index ebf3a05..3b8af80 100644 --- a/test cases/common/182 find override/meson.build +++ b/test cases/common/182 find override/meson.build @@ -1,4 +1,12 @@ project('find program override', 'c') -subdir('subdir') +gencodegen = find_program('gencodegen', required : false) + +assert(not gencodegen.found(), 'gencodegen is an internal program, should not be found') + +# Test the check-if-found-else-override workflow +if not gencodegen.found() + subdir('subdir') +endif + subdir('otherdir') |