diff options
-rw-r--r-- | docs/markdown/Reference-manual.md | 6 | ||||
-rw-r--r-- | mesonbuild/build.py | 15 | ||||
-rw-r--r-- | mesonbuild/mesonlib.py | 2 | ||||
-rw-r--r-- | test cases/common/150 nested links/meson.build | 8 | ||||
-rw-r--r-- | test cases/common/150 nested links/xephyr.c | 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 |
8 files changed, 39 insertions, 15 deletions
diff --git a/docs/markdown/Reference-manual.md b/docs/markdown/Reference-manual.md index b20c14a..6f34e5e 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 @@ -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. diff --git a/mesonbuild/build.py b/mesonbuild/build.py index 0d58394..c2d4583 100644 --- a/mesonbuild/build.py +++ b/mesonbuild/build.py @@ -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'] diff --git a/mesonbuild/mesonlib.py b/mesonbuild/mesonlib.py index 54e8016..6937502 100644 --- a/mesonbuild/mesonlib.py +++ b/mesonbuild/mesonlib.py @@ -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): diff --git a/test cases/common/150 nested links/meson.build b/test cases/common/150 nested links/meson.build new file mode 100644 index 0000000..0821b03 --- /dev/null +++ b/test cases/common/150 nested links/meson.build @@ -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: [[], []]) diff --git a/test cases/common/150 nested links/xephyr.c b/test cases/common/150 nested links/xephyr.c new file mode 100644 index 0000000..33c14ce --- /dev/null +++ b/test cases/common/150 nested links/xephyr.c @@ -0,0 +1,3 @@ +int main() { + return 0; +} 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, +) |