Use static library dependencies not when the library is built but when it is used.

pull/15/head
Jussi Pakkanen 11 years ago
parent 8d45972ee3
commit 1c0a735e00
  1. 8
      build.py
  2. 1
      environment.py
  3. 8
      ninjabackend.py
  4. 6
      test cases/common/62 exe static shared/meson.build
  5. 5
      test cases/common/62 exe static shared/prog.c
  6. 5
      test cases/common/62 exe static shared/stat.c
  7. 1
      test cases/common/62 exe static shared/subdir/meson.build
  8. 3
      test cases/common/62 exe static shared/subdir/shlib.c

@ -131,6 +131,7 @@ class BuildTarget():
'cs_args' : True,
'link_args' : True,
'link_depends': True,
'link_with' : True,
'include_directories': True,
'dependencies' : True,
'install_dir' : True,
@ -362,7 +363,12 @@ class BuildTarget():
return self.extra_args.get(language, [])
def get_dependencies(self):
return self.link_targets
transitive_deps = []
for t in self.link_targets:
transitive_deps.append(t)
if isinstance(t, StaticLibrary):
transitive_deps += t.get_dependencies()
return transitive_deps
def get_basename(self):
return self.name

@ -1302,6 +1302,7 @@ class ArLinker():
def __init__(self, exelist):
self.exelist = exelist
self.id = 'ar'
def build_rpath_args(self, build_dir, rpath_paths, install_rpath):
return []

@ -1239,7 +1239,13 @@ rule FORTRAN_DEP_HACK
commands += linker.get_std_link_args()
else:
raise RuntimeError('Unknown build target type.')
dependencies = target.get_dependencies()
# Link arguments of static libraries are not put in the command line of
# the library. They are instead appended to the command line where
# the static library is used.
if linker_base == 'STATIC':
dependencies = []
else:
dependencies = target.get_dependencies()
commands += self.build_target_link_arguments(linker, dependencies)
commands += target.link_args
# External deps must be last because target link libraries may depend on them.

@ -0,0 +1,6 @@
project('statchain', 'c')
subdir('subdir')
statlib = static_library('stat', 'stat.c', link_with : shlib)
exe = executable('prog', 'prog.c', link_with : statlib)
test('runtest', exe)

@ -0,0 +1,5 @@
int statlibfunc();
int main(int argc, char **argv) {
return statlibfunc() == 42 ? 0 : 1;
}

@ -0,0 +1,5 @@
int shlibfunc();
int statlibfunc() {
return shlibfunc();
}

@ -0,0 +1 @@
shlib = shared_library('shar', 'shlib.c')

@ -0,0 +1,3 @@
int shlibfunc() {
return 42;
}
Loading…
Cancel
Save