Merge pull request #1735 from dcbaker/list-of-files

Allow passing a list of Files to CustomTarget. Closes #1720
pull/1768/merge
Jussi Pakkanen 8 years ago committed by GitHub
commit 1e14438a38
  1. 6
      docs/markdown/Reference-manual.md
  2. 15
      mesonbuild/build.py
  3. 2
      mesonbuild/mesonlib.py
  4. 8
      test cases/common/150 nested links/meson.build
  5. 3
      test cases/common/150 nested links/xephyr.c
  6. 1
      test cases/common/151 list of file sources/foo
  7. 7
      test cases/common/151 list of file sources/gen.py
  8. 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
@ -228,8 +228,8 @@ With the Ninja backend, Meson will create a build-time [order-only dependency](h
Executable supports the following keyword arguments. Note that just like the positional arguments above, these keyword arguments can also be passed to [shared and static libraries](#library).
- `link_with`, one or more shared or static libraries (built by this project) that this target should be linked with
- `link_whole` links all contents of the given static libraries whether they are used by not, equivalent to the `-Wl,--whole-archive` argument flag of GCC, available since 0.40.0
- `link_with`, one or more shared or static libraries (built by this project) that this target should be linked with, If passed a list this list will be flattened as of 0.41.0.
- `link_whole` links all contents of the given static libraries whether they are used by not, equivalent to the `-Wl,--whole-archive` argument flag of GCC, available since 0.40.0. As of 0.41.0 if passed a list that list will be flattened.
- `<languagename>_pch` precompiled header file to use for the given language
- `<languagename>_args` compiler flags to use for the given language; eg: `cpp_args` for C++
- `link_args` flags to use during linking. You can use UNIX-style flags here for all platforms.

@ -638,9 +638,7 @@ class BuildTarget(Target):
self.vala_gir = kwargs.get('vala_gir', None)
dlist = stringlistify(kwargs.get('d_args', []))
self.add_compiler_args('d', dlist)
self.link_args = kwargs.get('link_args', [])
if not isinstance(self.link_args, list):
self.link_args = [self.link_args]
self.link_args = flatten(kwargs.get('link_args', []))
for i in self.link_args:
if not isinstance(i, str):
raise InvalidArguments('Link_args arguments must be strings.')
@ -813,9 +811,7 @@ You probably should put it in link_with instead.''')
return self.external_deps
def link(self, target):
if not isinstance(target, list):
target = [target]
for t in target:
for t in flatten(target):
if hasattr(t, 'held_object'):
t = t.held_object
if not isinstance(t, (StaticLibrary, SharedLibrary)):
@ -829,9 +825,7 @@ You probably should put it in link_with instead.''')
self.link_targets.append(t)
def link_whole(self, target):
if not isinstance(target, list):
target = [target]
for t in target:
for t in flatten(target):
if hasattr(t, 'held_object'):
t = t.held_object
if not isinstance(t, StaticLibrary):
@ -1443,8 +1437,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']

@ -203,7 +203,7 @@ def classify_unity_sources(compilers, sources):
def flatten(item):
if not isinstance(item, list):
return item
return [item]
result = []
for i in item:
if isinstance(i, list):

@ -0,0 +1,8 @@
project('test', 'c')
libxserver_dri3 = []
libxserver = [ libxserver_dri3 ]
executable('Xephyr', 'xephyr.c', link_with: [ libxserver ])
executable('Zephyr', 'xephyr.c', link_args: [[], []])

@ -0,0 +1,3 @@
int main() {
return 0;
}

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