aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--build.py8
-rw-r--r--environment.py1
-rw-r--r--ninjabackend.py8
-rw-r--r--test cases/common/62 exe static shared/meson.build6
-rw-r--r--test cases/common/62 exe static shared/prog.c5
-rw-r--r--test cases/common/62 exe static shared/stat.c5
-rw-r--r--test cases/common/62 exe static shared/subdir/meson.build1
-rw-r--r--test cases/common/62 exe static shared/subdir/shlib.c3
8 files changed, 35 insertions, 2 deletions
diff --git a/build.py b/build.py
index d747b32..84191c4 100644
--- a/build.py
+++ b/build.py
@@ -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;
+}