aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild
diff options
context:
space:
mode:
Diffstat (limited to 'mesonbuild')
-rw-r--r--mesonbuild/build.py2
-rw-r--r--mesonbuild/compilers.py13
-rw-r--r--mesonbuild/interpreter.py2
3 files changed, 11 insertions, 6 deletions
diff --git a/mesonbuild/build.py b/mesonbuild/build.py
index 3d41cda..6170f84 100644
--- a/mesonbuild/build.py
+++ b/mesonbuild/build.py
@@ -823,6 +823,8 @@ class Executable(BuildTarget):
class StaticLibrary(BuildTarget):
def __init__(self, name, subdir, subproject, is_cross, sources, objects, environment, kwargs):
+ if 'pic' not in kwargs and 'b_staticpic' in environment.coredata.base_options:
+ kwargs['pic'] = environment.coredata.base_options['b_staticpic'].value
super().__init__(name, subdir, subproject, is_cross, sources, objects, environment, kwargs)
if 'cs' in self.compilers:
raise InvalidArguments('Static libraries not supported for C#.')
diff --git a/mesonbuild/compilers.py b/mesonbuild/compilers.py
index 3cf761a..bb733a7 100644
--- a/mesonbuild/compilers.py
+++ b/mesonbuild/compilers.py
@@ -190,7 +190,10 @@ base_options = {
'always'),
'b_ndebug' : coredata.UserBooleanOption('b_ndebug',
'Disable asserts',
- False)
+ False),
+ 'b_staticpic' : coredata.UserBooleanOption('b_staticpic',
+ 'Build static libraries as position independent',
+ True),
}
def sanitizer_compile_args(value):
@@ -1521,7 +1524,7 @@ class GnuDCompiler(DCompiler):
self.warn_args = {'1': ['-Wall', '-Wdeprecated'],
'2': ['-Wall', '-Wextra', '-Wdeprecated'],
'3': ['-Wall', '-Wextra', '-Wdeprecated', '-Wpedantic']}
- self.base_options = ['b_colorout', 'b_sanitize']
+ self.base_options = ['b_colorout', 'b_sanitize', 'b_staticpic']
def get_colorout_args(self, colortype):
if mesonlib.version_compare(self.version, '>=4.9.0'):
@@ -1909,7 +1912,7 @@ class GnuCompiler:
self.gcc_type = gcc_type
self.defines = defines or {}
self.base_options = ['b_pch', 'b_lto', 'b_pgo', 'b_sanitize', 'b_coverage',
- 'b_colorout', 'b_ndebug']
+ 'b_colorout', 'b_ndebug', 'b_staticpic']
if self.gcc_type != GCC_OSX:
self.base_options.append('b_lundef')
self.base_options.append('b_asneeded')
@@ -2055,7 +2058,7 @@ class ClangCompiler():
self.id = 'clang'
self.clang_type = clang_type
self.base_options = ['b_pch', 'b_lto', 'b_pgo', 'b_sanitize', 'b_coverage',
- 'b_ndebug']
+ 'b_ndebug', 'b_staticpic']
if self.clang_type != CLANG_OSX:
self.base_options.append('b_lundef')
self.base_options.append('b_asneeded')
@@ -2285,7 +2288,7 @@ class GnuFortranCompiler(FortranCompiler):
def get_define(self, define):
if define in self.defines:
- return defines[define]
+ return self.defines[define]
def get_always_args(self):
return ['-pipe']
diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py
index be19bab..92b997a 100644
--- a/mesonbuild/interpreter.py
+++ b/mesonbuild/interpreter.py
@@ -1117,7 +1117,7 @@ class Interpreter():
if not os.path.isfile(mesonfile):
raise InvalidArguments('Missing Meson file in %s' % mesonfile)
with open(mesonfile, encoding='utf8') as mf:
- code = mf.read()
+ code = mf.read()
if len(code.strip()) == 0:
raise InvalidCode('Builder file is empty.')
assert(isinstance(code, str))