Allow passing a list of Files to CustomTarget. Closes #1720

pull/1735/head
Dylan Baker 8 years ago
parent e2567386f1
commit c03744cccb
  1. 2
      docs/markdown/Reference-manual.md
  2. 3
      mesonbuild/build.py
  3. 1
      test cases/common/151 list of file sources/foo
  4. 7
      test cases/common/151 list of file sources/gen.py
  5. 12
      test cases/common/151 list of file sources/meson.build

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

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

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

@ -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,
)
Loading…
Cancel
Save