From e2567386f108c17704a9b300f56c0f2f2c0b4b54 Mon Sep 17 00:00:00 2001 From: Dylan Baker Date: Tue, 9 May 2017 13:31:16 -0700 Subject: [PATCH] Use flatten for link targets. Fixes #1764 --- docs/markdown/Reference-manual.md | 4 ++-- mesonbuild/build.py | 8 ++------ test cases/common/150 nested links/meson.build | 6 ++++++ test cases/common/150 nested links/xephyr.c | 3 +++ 4 files changed, 13 insertions(+), 8 deletions(-) create mode 100644 test cases/common/150 nested links/meson.build create mode 100644 test cases/common/150 nested links/xephyr.c diff --git a/docs/markdown/Reference-manual.md b/docs/markdown/Reference-manual.md index c64419b8d..7e46da16d 100644 --- a/docs/markdown/Reference-manual.md +++ b/docs/markdown/Reference-manual.md @@ -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. - `_pch` precompiled header file to use for the given language - `_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 0d58394f6..41fd8c16d 100644 --- a/mesonbuild/build.py +++ b/mesonbuild/build.py @@ -813,9 +813,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 +827,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): 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 000000000..32cf66885 --- /dev/null +++ b/test cases/common/150 nested links/meson.build @@ -0,0 +1,6 @@ +project('test', 'c') + +libxserver_dri3 = [] +libxserver = [ libxserver_dri3 ] + +executable('Xephyr', 'xephyr.c', link_with: [ libxserver ]) 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 000000000..33c14ce1d --- /dev/null +++ b/test cases/common/150 nested links/xephyr.c @@ -0,0 +1,3 @@ +int main() { + return 0; +}