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.
pull/3218/head
Nirbheek Chauhan 7 years ago
parent 998892ed29
commit 87c166db95
  1. 3
      mesonbuild/interpreter.py
  2. 10
      test cases/common/182 find override/meson.build

@ -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):

@ -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')

Loading…
Cancel
Save