From 3ed22fcc56877ca974e31b7fd80343b126f866aa Mon Sep 17 00:00:00 2001 From: Jussi Pakkanen Date: Wed, 3 Sep 2014 22:13:14 +0300 Subject: Use external libs of static libraries when the static library is linked to a final target. --- ninjabackend.py | 4 ++++ test cases/linuxlike/4 extdep static lib/lib.c | 8 ++++++++ test cases/linuxlike/4 extdep static lib/meson.build | 10 ++++++++++ test cases/linuxlike/4 extdep static lib/prog.c | 5 +++++ 4 files changed, 27 insertions(+) create mode 100644 test cases/linuxlike/4 extdep static lib/lib.c create mode 100644 test cases/linuxlike/4 extdep static lib/meson.build create mode 100644 test cases/linuxlike/4 extdep static lib/prog.c diff --git a/ninjabackend.py b/ninjabackend.py index fecdbf35c..08e43b44a 100644 --- a/ninjabackend.py +++ b/ninjabackend.py @@ -1252,6 +1252,10 @@ rule FORTRAN_DEP_HACK if not(isinstance(target, build.StaticLibrary)): for dep in target.get_external_deps(): commands += dep.get_link_args() + for d in target.get_dependencies(): + if isinstance(d, build.StaticLibrary): + for dep in d.get_external_deps(): + commands += dep.get_link_args() commands += linker.build_rpath_args(self.environment.get_build_dir(),\ target.get_rpaths(), target.install_rpath) if self.environment.coredata.coverage: diff --git a/test cases/linuxlike/4 extdep static lib/lib.c b/test cases/linuxlike/4 extdep static lib/lib.c new file mode 100644 index 000000000..2f3b3c9a5 --- /dev/null +++ b/test cases/linuxlike/4 extdep static lib/lib.c @@ -0,0 +1,8 @@ +#include + +int statlibfunc() { + void * something = deflate; + if(something != 0) + return 0; + return 1; +} diff --git a/test cases/linuxlike/4 extdep static lib/meson.build b/test cases/linuxlike/4 extdep static lib/meson.build new file mode 100644 index 000000000..1a73e494e --- /dev/null +++ b/test cases/linuxlike/4 extdep static lib/meson.build @@ -0,0 +1,10 @@ +project('external dependency with static', 'c') + +# Zlib is probably on all dev machines. + +dep = dependency('zlib') +statlib = static_library('statlib', 'lib.c', dependencies : dep) +exe = executable('prog', 'prog.c', link_with : statlib) + + +test('zlibtest', exe) diff --git a/test cases/linuxlike/4 extdep static lib/prog.c b/test cases/linuxlike/4 extdep static lib/prog.c new file mode 100644 index 000000000..843c6284f --- /dev/null +++ b/test cases/linuxlike/4 extdep static lib/prog.c @@ -0,0 +1,5 @@ +int statlibfunc(); + +int main(int argc, char **argv) { + return statlibfunc(); +} -- cgit v1.2.3