Merge pull request #388 from nirbheek/extprog.path

Add path() method to ExternalProgramHolder types
pull/401/head
Jussi Pakkanen 9 years ago
commit 2cbe876f71
  1. 2
      mesonbuild/build.py
  2. 6
      mesonbuild/interpreter.py
  3. 11
      test cases/common/105 find program path/meson.build
  4. 3
      test cases/common/105 find program path/program.py

@ -808,6 +808,8 @@ class CustomTarget:
if not isinstance(s, str):
raise InvalidArguments('Array as argument %d contains a non-string.' % i)
final_cmd.append(s)
elif isinstance(c, File):
final_cmd.append(os.path.join(c.subdir, c.fname))
else:
raise InvalidArguments('Argument %s in "command" is invalid.' % i)
self.command = final_cmd

@ -242,11 +242,15 @@ class ExternalProgramHolder(InterpreterObject):
def __init__(self, ep):
InterpreterObject.__init__(self)
self.held_object = ep
self.methods.update({'found': self.found_method})
self.methods.update({'found': self.found_method,
'path': self.path_method})
def found_method(self, args, kwargs):
return self.found()
def path_method(self, args, kwargs):
return self.get_command()
def found(self):
return self.held_object.found()

@ -0,0 +1,11 @@
project('find program', 'c')
prog = find_program('program.py')
# Use either Python3 or 2 to run this
python = find_program('python3', required : false)
if not python.found()
python = find_program('python')
endif
run_command(python, prog.path())

@ -0,0 +1,3 @@
#!/usr/bin/env python3
print("Found")
Loading…
Cancel
Save