aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--interpreter.py31
-rw-r--r--test cases/common/94 default options/meson.build18
2 files changed, 36 insertions, 13 deletions
diff --git a/interpreter.py b/interpreter.py
index 402f24e..55168b8 100644
--- a/interpreter.py
+++ b/interpreter.py
@@ -583,6 +583,18 @@ class CompilerHolder(InterpreterObject):
def cmd_array_method(self, args, kwargs):
return self.compiler.exelist
+ def determine_args(self, kwargs):
+ nobuiltins = kwargs.get('no_builtin_args', False)
+ if not isinstance(nobuiltins, bool):
+ raise InterpreterException('Type of no_builtin_args not a boolean.')
+ args = []
+ if not nobuiltins:
+ opts = self.environment.coredata.compiler_options
+ args += self.compiler.get_option_compile_args(opts)
+ args += self.compiler.get_option_link_args(opts)
+ args += mesonlib.stringlistify(kwargs.get('args', []))
+ return args
+
def alignment_method(self, args, kwargs):
if len(args) != 1:
raise InterpreterException('Alignment method takes exactly one positional argument.')
@@ -601,7 +613,7 @@ class CompilerHolder(InterpreterObject):
testname = kwargs.get('name', '')
if not isinstance(testname, str):
raise InterpreterException('Testname argument must be a string.')
- extra_args = mesonlib.stringlistify(kwargs.get('args', []))
+ extra_args = self.determine_args(kwargs)
result = self.compiler.run(code, extra_args)
if len(testname) > 0:
if not result.compiled:
@@ -625,7 +637,7 @@ class CompilerHolder(InterpreterObject):
prefix = kwargs.get('prefix', '')
if not isinstance(prefix, str):
raise InterpreterException('Prefix argument of has_function must be a string.')
- extra_args = mesonlib.stringlistify(kwargs.get('args', []))
+ extra_args = self.determine_args(kwargs)
had = self.compiler.has_member(typename, membername, prefix, extra_args)
if had:
hadtxt = mlog.green('YES')
@@ -643,7 +655,7 @@ class CompilerHolder(InterpreterObject):
prefix = kwargs.get('prefix', '')
if not isinstance(prefix, str):
raise InterpreterException('Prefix argument of has_function must be a string.')
- extra_args = mesonlib.stringlistify(kwargs.get('args', []))
+ extra_args = self.determine_args(kwargs)
had = self.compiler.has_function(funcname, prefix, self.environment, extra_args)
if had:
hadtxt = mlog.green('YES')
@@ -660,7 +672,7 @@ class CompilerHolder(InterpreterObject):
prefix = kwargs.get('prefix', '')
if not isinstance(prefix, str):
raise InterpreterException('Prefix argument of has_type must be a string.')
- extra_args = mesonlib.stringlistify(kwargs.get('args', []))
+ extra_args = self.determine_args(kwargs)
had = self.compiler.has_type(typename, prefix, extra_args)
if had:
hadtxt = mlog.green('YES')
@@ -677,7 +689,7 @@ class CompilerHolder(InterpreterObject):
prefix = kwargs.get('prefix', '')
if not isinstance(prefix, str):
raise InterpreterException('Prefix argument of sizeof must be a string.')
- extra_args = mesonlib.stringlistify(kwargs.get('args', []))
+ extra_args = self.determine_args(kwargs)
esize = self.compiler.sizeof(element, prefix, self.environment, extra_args)
mlog.log('Checking for size of "%s": %d' % (element, esize))
return esize
@@ -690,7 +702,7 @@ class CompilerHolder(InterpreterObject):
testname = kwargs.get('name', '')
if not isinstance(testname, str):
raise InterpreterException('Testname argument must be a string.')
- extra_args = mesonlib.stringlistify(kwargs.get('args', []))
+ extra_args = self.determine_args(kwargs)
result = self.compiler.compiles(code, extra_args)
if len(testname) > 0:
if result:
@@ -708,7 +720,7 @@ class CompilerHolder(InterpreterObject):
testname = kwargs.get('name', '')
if not isinstance(testname, str):
raise InterpreterException('Testname argument must be a string.')
- extra_args = mesonlib.stringlistify(kwargs.get('args', []))
+ extra_args = self.determine_args(kwargs)
result = self.compiler.links(code, extra_args)
if len(testname) > 0:
if result:
@@ -723,7 +735,7 @@ class CompilerHolder(InterpreterObject):
raise InterpreterException('has_header method takes exactly one argument.')
check_stringlist(args)
string = args[0]
- extra_args = mesonlib.stringlistify(kwargs.get('args', []))
+ extra_args = self.determine_args(kwargs)
haz = self.compiler.has_header(string, extra_args)
if haz:
h = mlog.green('YES')
@@ -1329,7 +1341,8 @@ class Interpreter():
setattr(self.coredata, key, value)
# If this was set on the command line, do not override.
else:
- self.environment.cmd_line_options.projectoptions.insert(0, option)
+ newoptions = [option] + self.environment.cmd_line_options.projectoptions
+ self.environment.cmd_line_options.projectoptions = newoptions
@stringArgs
diff --git a/test cases/common/94 default options/meson.build b/test cases/common/94 default options/meson.build
index 9c881bb..e9e885e 100644
--- a/test cases/common/94 default options/meson.build
+++ b/test cases/common/94 default options/meson.build
@@ -1,15 +1,25 @@
-project('default options', 'cpp', default_options : [
+project('default options', 'cpp', 'c', default_options : [
'buildtype=debugoptimized',
'cpp_std=c++03',
- 'cpp_eh=none'
+ 'cpp_eh=none',
+ 'c_std=-crashcompiler',
])
-cc = meson.get_compiler('cpp')
+cpp = meson.get_compiler('cpp')
assert(get_option('buildtype') == 'debugoptimized', 'Build type default value wrong.')
-if cc.get_id() == 'msvc'
+if cpp.get_id() == 'msvc'
assert(get_option('cpp_eh') == 'none', 'MSVC eh value wrong.')
else
assert(get_option('cpp_std') == 'c++03', 'C++ std value wrong.')
endif
+
+# Verify that project args are not used when told not to.
+# MSVC plain C does not have a simple arg to test so skip it.
+if cpp.get_id() != 'msvc'
+ cc = meson.get_compiler('c')
+ assert(not cc.compiles('int foobar;'), 'Default arg not used in test.')
+ assert(cc.compiles('int foobar;', no_builtin_args : true), 'No_builtin did not disable builtins.')
+endif
+