aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mesonbuild/build.py21
-rw-r--r--test cases/common/62 exe static shared/meson.build6
-rw-r--r--test cases/common/62 exe static shared/shlib2.c3
-rw-r--r--test cases/common/62 exe static shared/stat2.c3
-rw-r--r--test cases/frameworks/7 gnome/mkenums/meson.build2
5 files changed, 24 insertions, 11 deletions
diff --git a/mesonbuild/build.py b/mesonbuild/build.py
index 6170f84..f212fe4 100644
--- a/mesonbuild/build.py
+++ b/mesonbuild/build.py
@@ -510,18 +510,18 @@ class BuildTarget():
name_prefix = kwargs['name_prefix']
if isinstance(name_prefix, list):
if len(name_prefix) != 0:
- raise InvalidArguments('Array must be empty to signify null.')
+ raise InvalidArguments('name_prefix array must be empty to signify null.')
elif not isinstance(name_prefix, str):
- raise InvalidArguments('Name prefix must be a string.')
+ raise InvalidArguments('name_prefix must be a string.')
self.prefix = name_prefix
if 'name_suffix' in kwargs:
name_suffix = kwargs['name_suffix']
if isinstance(name_suffix, list):
if len(name_suffix) != 0:
- raise InvalidArguments('Array must be empty to signify null.')
+ raise InvalidArguments('name_suffix array must be empty to signify null.')
else:
if not isinstance(name_suffix, str):
- raise InvalidArguments('Name suffix must be a string.')
+ raise InvalidArguments('name_suffix must be a string.')
self.suffix = name_suffix
if isinstance(self, StaticLibrary):
# You can't disable PIC on OS X. The compiler ignores -fno-PIC.
@@ -529,10 +529,13 @@ class BuildTarget():
# since library loading is done differently)
if for_darwin(self.is_cross, self.environment) or for_windows(self.is_cross, self.environment):
self.pic = True
+ elif '-fPIC' in clist + cpplist:
+ mlog.log(mlog.red('WARNING:'), "Use the 'pic' kwarg instead of passing -fPIC manually to static library {!r}".format(self.name))
+ self.pic = True
else:
self.pic = kwargs.get('pic', False)
if not isinstance(self.pic, bool):
- raise InvalidArguments('Argument pic must be boolean')
+ raise InvalidArguments('Argument pic to static library {!r} must be boolean'.format(self.name))
def get_subdir(self):
return self.subdir
@@ -634,11 +637,13 @@ by calling get_variable() on the subproject object.''')
if hasattr(t, 'held_object'):
t = t.held_object
if not isinstance(t, (StaticLibrary, SharedLibrary)):
- raise InvalidArguments('Link target is not library.')
+ raise InvalidArguments('Link target {!r} is not library.'.format(t.name))
if isinstance(self, SharedLibrary) and isinstance(t, StaticLibrary) and not t.pic:
- raise InvalidArguments("Can't link a non-PIC static library into a shared library")
+ msg = "Can't link non-PIC static library {!r} into shared library {!r}. ".format(t.name, self.name)
+ msg += "Use the 'pic' option to static_library to build with PIC."
+ raise InvalidArguments(msg)
if self.is_cross != t.is_cross:
- raise InvalidArguments('Tried to mix cross built and native libraries in target %s.' % self.name)
+ raise InvalidArguments('Tried to mix cross built and native libraries in target {!r}'.format(self.name))
self.link_targets.append(t)
def set_generated(self, genlist):
diff --git a/test cases/common/62 exe static shared/meson.build b/test cases/common/62 exe static shared/meson.build
index 8631e68..2888882 100644
--- a/test cases/common/62 exe static shared/meson.build
+++ b/test cases/common/62 exe static shared/meson.build
@@ -1,7 +1,11 @@
project('statchain', 'c')
subdir('subdir')
-statlib = static_library('stat', 'stat.c', link_with : shlib, pic : true)
+# Test that -fPIC in c_args is also accepted
+statlib2 = static_library('stat2', 'stat2.c', c_args : '-fPIC', pic : false)
+# Test that pic is needed for both direct and indirect static library
+# dependencies of shared libraries (on Linux and BSD)
+statlib = static_library('stat', 'stat.c', link_with : [shlib, statlib2], pic : true)
shlib2 = shared_library('shr2', 'shlib2.c', link_with : statlib)
exe = executable('prog', 'prog.c', link_with : shlib2)
test('runtest', exe)
diff --git a/test cases/common/62 exe static shared/shlib2.c b/test cases/common/62 exe static shared/shlib2.c
index e26d11c..12bc913 100644
--- a/test cases/common/62 exe static shared/shlib2.c
+++ b/test cases/common/62 exe static shared/shlib2.c
@@ -1,7 +1,8 @@
#include "subdir/exports.h"
int statlibfunc(void);
+int statlibfunc2(void);
int DLL_PUBLIC shlibfunc2(void) {
- return statlibfunc() - 18;
+ return statlibfunc() - statlibfunc2();
}
diff --git a/test cases/common/62 exe static shared/stat2.c b/test cases/common/62 exe static shared/stat2.c
new file mode 100644
index 0000000..4ae3775
--- /dev/null
+++ b/test cases/common/62 exe static shared/stat2.c
@@ -0,0 +1,3 @@
+int statlibfunc2() {
+ return 18;
+}
diff --git a/test cases/frameworks/7 gnome/mkenums/meson.build b/test cases/frameworks/7 gnome/mkenums/meson.build
index efd6b04..e01e9eb 100644
--- a/test cases/frameworks/7 gnome/mkenums/meson.build
+++ b/test cases/frameworks/7 gnome/mkenums/meson.build
@@ -32,7 +32,7 @@ enums_h2 = gnome.mkenums('abc2',
enums_c2 = gnome.mkenums('abc2',
sources : 'meson-sample.h',
- depends : enums_h2,
+ depends : [enums_h1, enums_h2],
c_template : 'enums2.c.in',
ftail : '/* trailing source file info */',
install_header : true,