diff options
author | Nirbheek Chauhan <nirbheek@centricular.com> | 2017-02-13 21:11:03 +0530 |
---|---|---|
committer | Nirbheek Chauhan <nirbheek@centricular.com> | 2017-02-20 23:32:03 +0530 |
commit | 73b2ee08a884d6baa7b8e3c35c6da8f17aa9a875 (patch) | |
tree | b4be36679237ecf85b9d6d66fa8a172e889b4570 /mesonbuild/build.py | |
parent | af1b898cc51d11074096cf34fb1410766def3edf (diff) | |
download | meson-73b2ee08a884d6baa7b8e3c35c6da8f17aa9a875.zip meson-73b2ee08a884d6baa7b8e3c35c6da8f17aa9a875.tar.gz meson-73b2ee08a884d6baa7b8e3c35c6da8f17aa9a875.tar.bz2 |
Rewrite custom_target template string substitution
Factor it out into a function in mesonlib.py. This will allow us to
reuse it for generators and for configure_file(). The latter doesn't
implement this at all right now.
Also includes unit tests.
Diffstat (limited to 'mesonbuild/build.py')
-rw-r--r-- | mesonbuild/build.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/mesonbuild/build.py b/mesonbuild/build.py index 5f2de3b..395321c 100644 --- a/mesonbuild/build.py +++ b/mesonbuild/build.py @@ -1530,3 +1530,22 @@ class TestSetup: self.gdb = gdb self.timeout_multiplier = timeout_multiplier self.env = env + +def get_sources_output_names(sources): + ''' + For the specified list of @sources which can be strings, Files, or targets, + get all the output basenames. + ''' + names = [] + for s in sources: + if hasattr(s, 'held_object'): + s = s.held_object + if isinstance(s, str): + names.append(s) + elif isinstance(s, (BuildTarget, CustomTarget, GeneratedList)): + names += s.get_outputs() + elif isinstance(s, File): + names.append(s.fname) + else: + raise AssertionError('Unknown source type: {!r}'.format(s)) + return names |