Skip to content

Commit 3ed22fc

Browse files
committed
Use external libs of static libraries when the static library is linked to a final target.
1 parent 1c0a735 commit 3ed22fc

File tree

4 files changed

+27
-0
lines changed

4 files changed

+27
-0
lines changed

ninjabackend.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1252,6 +1252,10 @@ def generate_link(self, target, outfile, outname, obj_list, linker, extra_args=[
12521252
if not(isinstance(target, build.StaticLibrary)):
12531253
for dep in target.get_external_deps():
12541254
commands += dep.get_link_args()
1255+
for d in target.get_dependencies():
1256+
if isinstance(d, build.StaticLibrary):
1257+
for dep in d.get_external_deps():
1258+
commands += dep.get_link_args()
12551259
commands += linker.build_rpath_args(self.environment.get_build_dir(),\
12561260
target.get_rpaths(), target.install_rpath)
12571261
if self.environment.coredata.coverage:
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#include<zlib.h>
2+
3+
int statlibfunc() {
4+
void * something = deflate;
5+
if(something != 0)
6+
return 0;
7+
return 1;
8+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
project('external dependency with static', 'c')
2+
3+
# Zlib is probably on all dev machines.
4+
5+
dep = dependency('zlib')
6+
statlib = static_library('statlib', 'lib.c', dependencies : dep)
7+
exe = executable('prog', 'prog.c', link_with : statlib)
8+
9+
10+
test('zlibtest', exe)
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
int statlibfunc();
2+
3+
int main(int argc, char **argv) {
4+
return statlibfunc();
5+
}

0 commit comments

Comments
 (0)