diff options
author | Jussi Pakkanen <jpakkane@gmail.com> | 2014-09-02 23:06:07 +0300 |
---|---|---|
committer | Jussi Pakkanen <jpakkane@gmail.com> | 2014-09-02 23:06:07 +0300 |
commit | 1c0a735e00e12140817432f5b1218f388f59b287 (patch) | |
tree | 7025dc3312b3f3458da20f2ea247cb356d0e49f7 | |
parent | 8d45972ee3fedf5dc82be5d6801b4c61367acac9 (diff) | |
download | meson-1c0a735e00e12140817432f5b1218f388f59b287.zip meson-1c0a735e00e12140817432f5b1218f388f59b287.tar.gz meson-1c0a735e00e12140817432f5b1218f388f59b287.tar.bz2 |
Use static library dependencies not when the library is built but when it is used.
-rw-r--r-- | build.py | 8 | ||||
-rw-r--r-- | environment.py | 1 | ||||
-rw-r--r-- | ninjabackend.py | 8 | ||||
-rw-r--r-- | test cases/common/62 exe static shared/meson.build | 6 | ||||
-rw-r--r-- | test cases/common/62 exe static shared/prog.c | 5 | ||||
-rw-r--r-- | test cases/common/62 exe static shared/stat.c | 5 | ||||
-rw-r--r-- | test cases/common/62 exe static shared/subdir/meson.build | 1 | ||||
-rw-r--r-- | test cases/common/62 exe static shared/subdir/shlib.c | 3 |
8 files changed, 35 insertions, 2 deletions
@@ -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 diff --git a/environment.py b/environment.py index 018bb17..6a56ac9 100644 --- a/environment.py +++ b/environment.py @@ -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 [] diff --git a/ninjabackend.py b/ninjabackend.py index 8659729..fecdbf3 100644 --- a/ninjabackend.py +++ b/ninjabackend.py @@ -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. diff --git a/test cases/common/62 exe static shared/meson.build b/test cases/common/62 exe static shared/meson.build new file mode 100644 index 0000000..3c75391 --- /dev/null +++ b/test cases/common/62 exe static shared/meson.build @@ -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) diff --git a/test cases/common/62 exe static shared/prog.c b/test cases/common/62 exe static shared/prog.c new file mode 100644 index 0000000..4f82a6b --- /dev/null +++ b/test cases/common/62 exe static shared/prog.c @@ -0,0 +1,5 @@ +int statlibfunc(); + +int main(int argc, char **argv) { + return statlibfunc() == 42 ? 0 : 1; +} diff --git a/test cases/common/62 exe static shared/stat.c b/test cases/common/62 exe static shared/stat.c new file mode 100644 index 0000000..4eceb30 --- /dev/null +++ b/test cases/common/62 exe static shared/stat.c @@ -0,0 +1,5 @@ +int shlibfunc(); + +int statlibfunc() { + return shlibfunc(); +} diff --git a/test cases/common/62 exe static shared/subdir/meson.build b/test cases/common/62 exe static shared/subdir/meson.build new file mode 100644 index 0000000..2b7393b --- /dev/null +++ b/test cases/common/62 exe static shared/subdir/meson.build @@ -0,0 +1 @@ +shlib = shared_library('shar', 'shlib.c') diff --git a/test cases/common/62 exe static shared/subdir/shlib.c b/test cases/common/62 exe static shared/subdir/shlib.c new file mode 100644 index 0000000..b513e13 --- /dev/null +++ b/test cases/common/62 exe static shared/subdir/shlib.c @@ -0,0 +1,3 @@ +int shlibfunc() { + return 42; +} |