diff options
author | Jussi Pakkanen <jpakkane@gmail.com> | 2016-02-20 14:33:42 +0200 |
---|---|---|
committer | Jussi Pakkanen <jpakkane@gmail.com> | 2016-02-20 14:33:42 +0200 |
commit | 2cbe876f714f2c6fc66a5bcb0dfe9118752f850d (patch) | |
tree | 69d90849ab4eb5176154764787a20fdd80bac806 | |
parent | a15e784851dee647aeaf96f180f4947cd4775bd6 (diff) | |
parent | fabb49773e522a68e10c4be80067d28abecc4017 (diff) | |
download | meson-2cbe876f714f2c6fc66a5bcb0dfe9118752f850d.zip meson-2cbe876f714f2c6fc66a5bcb0dfe9118752f850d.tar.gz meson-2cbe876f714f2c6fc66a5bcb0dfe9118752f850d.tar.bz2 |
Merge pull request #388 from nirbheek/extprog.path
Add path() method to ExternalProgramHolder types
-rw-r--r-- | mesonbuild/build.py | 2 | ||||
-rw-r--r-- | mesonbuild/interpreter.py | 6 | ||||
-rw-r--r-- | test cases/common/105 find program path/meson.build | 11 | ||||
-rw-r--r-- | test cases/common/105 find program path/program.py | 3 |
4 files changed, 21 insertions, 1 deletions
diff --git a/mesonbuild/build.py b/mesonbuild/build.py index c0ba895..f9e628d 100644 --- a/mesonbuild/build.py +++ b/mesonbuild/build.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 diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py index a633917..4d41f1a 100644 --- a/mesonbuild/interpreter.py +++ b/mesonbuild/interpreter.py @@ -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() diff --git a/test cases/common/105 find program path/meson.build b/test cases/common/105 find program path/meson.build new file mode 100644 index 0000000..b21d659 --- /dev/null +++ b/test cases/common/105 find program path/meson.build @@ -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()) diff --git a/test cases/common/105 find program path/program.py b/test cases/common/105 find program path/program.py new file mode 100644 index 0000000..2ebc564 --- /dev/null +++ b/test cases/common/105 find program path/program.py @@ -0,0 +1,3 @@ +#!/usr/bin/env python3 + +print("Found") |