diff options
author | Dylan Baker <dylan@pnwbakers.com> | 2017-05-04 12:19:33 -0700 |
---|---|---|
committer | Dylan Baker <dylan@pnwbakers.com> | 2017-05-11 09:57:38 -0700 |
commit | c03744cccb3239a98803debf05b98793a1291aa7 (patch) | |
tree | 9172724c7546c602ac82431d84dde39accd5064a | |
parent | e2567386f108c17704a9b300f56c0f2f2c0b4b54 (diff) | |
download | meson-c03744cccb3239a98803debf05b98793a1291aa7.zip meson-c03744cccb3239a98803debf05b98793a1291aa7.tar.gz meson-c03744cccb3239a98803debf05b98793a1291aa7.tar.bz2 |
Allow passing a list of Files to CustomTarget. Closes #1720
-rw-r--r-- | docs/markdown/Reference-manual.md | 2 | ||||
-rw-r--r-- | mesonbuild/build.py | 3 | ||||
-rw-r--r-- | test cases/common/151 list of file sources/foo | 1 | ||||
-rw-r--r-- | test cases/common/151 list of file sources/gen.py | 7 | ||||
-rw-r--r-- | test cases/common/151 list of file sources/meson.build | 12 |
5 files changed, 22 insertions, 3 deletions
diff --git a/docs/markdown/Reference-manual.md b/docs/markdown/Reference-manual.md index 7e46da1..01f991d 100644 --- a/docs/markdown/Reference-manual.md +++ b/docs/markdown/Reference-manual.md @@ -137,7 +137,7 @@ These are all the supported keyword arguments: Create a custom top level build target. The only positional argument is the name of this target and the keyword arguments are the following. -- `input` list of source files +- `input` list of source files. As of 0.41.0 the list will be flattened. - `output` list of output files - `command` command to run to create outputs from inputs. The command may be strings or the return of `find_program()` or `executable()` (note: always specify commands in array form `['commandname', '-arg1', '-arg2']` rather than as a string `'commandname -arg1 -arg2'` as the latter will *not* work) - `install` when true, this target is installed during the install step diff --git a/mesonbuild/build.py b/mesonbuild/build.py index 41fd8c1..59459bf 100644 --- a/mesonbuild/build.py +++ b/mesonbuild/build.py @@ -1439,8 +1439,7 @@ class CustomTarget(Target): def process_kwargs(self, kwargs): super().process_kwargs(kwargs) self.sources = kwargs.get('input', []) - if not isinstance(self.sources, list): - self.sources = [self.sources] + self.sources = flatten(self.sources) if 'output' not in kwargs: raise InvalidArguments('Missing keyword argument "output".') self.outputs = kwargs['output'] diff --git a/test cases/common/151 list of file sources/foo b/test cases/common/151 list of file sources/foo new file mode 100644 index 0000000..7b57bd2 --- /dev/null +++ b/test cases/common/151 list of file sources/foo @@ -0,0 +1 @@ +some text diff --git a/test cases/common/151 list of file sources/gen.py b/test cases/common/151 list of file sources/gen.py new file mode 100644 index 0000000..2337d3d --- /dev/null +++ b/test cases/common/151 list of file sources/gen.py @@ -0,0 +1,7 @@ +import shutil +import sys + +if __name__ == '__main__': + if len(sys.argv) != 3: + raise Exception('Requires exactly 2 args') + shutil.copy2(sys.argv[1], sys.argv[2]) diff --git a/test cases/common/151 list of file sources/meson.build b/test cases/common/151 list of file sources/meson.build new file mode 100644 index 0000000..819509d --- /dev/null +++ b/test cases/common/151 list of file sources/meson.build @@ -0,0 +1,12 @@ +project('test', 'c') + +mod_py = import('python3') +python = mod_py.find_python() + +test_target = custom_target( + 'test_target', + input : [files('gen.py'), files('foo')], + output : 'bar', + command : [python, '@INPUT0@', '@INPUT1@', '@OUTPUT@'], + build_by_default : true, +) |