aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/compilers
diff options
context:
space:
mode:
authorXavier Claessens <xavier.claessens@collabora.com>2018-05-13 10:36:58 -0400
committerNirbheek Chauhan <nirbheek.chauhan@gmail.com>2018-06-06 20:02:37 +0000
commitb7d442150dd8575f0756e3bc9e953d0f198e16c6 (patch)
treeea286310111e3e1103db39908cdb8295a3b337f0 /mesonbuild/compilers
parent58a9555ddf49d851a7eb56874df1d0b3f498e53e (diff)
downloadmeson-b7d442150dd8575f0756e3bc9e953d0f198e16c6.zip
meson-b7d442150dd8575f0756e3bc9e953d0f198e16c6.tar.gz
meson-b7d442150dd8575f0756e3bc9e953d0f198e16c6.tar.bz2
Move <lang>_args to coredata.compiler_options
Diffstat (limited to 'mesonbuild/compilers')
-rw-r--r--mesonbuild/compilers/c.py6
-rw-r--r--mesonbuild/compilers/compilers.py31
-rw-r--r--mesonbuild/compilers/d.py4
3 files changed, 30 insertions, 11 deletions
diff --git a/mesonbuild/compilers/c.py b/mesonbuild/compilers/c.py
index 09ac99c..e14d3d8 100644
--- a/mesonbuild/compilers/c.py
+++ b/mesonbuild/compilers/c.py
@@ -351,13 +351,13 @@ class CCompiler(Compiler):
if not self.is_cross:
if mode == 'preprocess':
# Add CPPFLAGS from the env.
- args += env.coredata.external_preprocess_args[self.language]
+ args += env.coredata.get_external_preprocess_args(self.language)
elif mode == 'compile':
# Add CFLAGS/CXXFLAGS/OBJCFLAGS/OBJCXXFLAGS from the env
- args += env.coredata.external_args[self.language]
+ args += env.coredata.get_external_args(self.language)
elif mode == 'link':
# Add LDFLAGS from the env
- args += env.coredata.external_link_args[self.language]
+ args += env.coredata.get_external_link_args(self.language)
args += self.get_compiler_check_args()
# extra_args must override all other arguments, so we add them last
args += extra_args
diff --git a/mesonbuild/compilers/compilers.py b/mesonbuild/compilers/compilers.py
index 7ac0753..fcb658b 100644
--- a/mesonbuild/compilers/compilers.py
+++ b/mesonbuild/compilers/compilers.py
@@ -725,6 +725,11 @@ class Compiler:
"""
return []
+ def get_preproc_flags(self):
+ if self.get_language() in ('c', 'cpp', 'objc', 'objcpp'):
+ return os.environ.get('CPPFLAGS', '')
+ return ''
+
def get_args_from_envvars(self):
"""
Returns a tuple of (compile_flags, link_flags) for the specified language
@@ -740,7 +745,7 @@ class Compiler:
compiler_is_linker = (self.get_exelist() == self.get_linker_exelist())
if lang not in cflags_mapping:
- return [], [], []
+ return [], []
compile_flags = os.environ.get(cflags_mapping[lang], '')
log_var(cflags_mapping[lang], compile_flags)
@@ -758,17 +763,31 @@ class Compiler:
link_flags = compile_flags + link_flags
# Pre-processor flags (not for fortran or D)
- preproc_flags = ''
- if lang in ('c', 'cpp', 'objc', 'objcpp'):
- preproc_flags = os.environ.get('CPPFLAGS', '')
+ preproc_flags = self.get_preproc_flags()
log_var('CPPFLAGS', preproc_flags)
preproc_flags = shlex.split(preproc_flags)
compile_flags += preproc_flags
- return preproc_flags, compile_flags, link_flags
+ return compile_flags, link_flags
def get_options(self):
- return {} # build afresh every time
+ opts = {} # build afresh every time
+
+ # Take default values from env variables.
+ compile_args, link_args = self.get_args_from_envvars()
+ description = 'Extra arguments passed to the {}'.format(self.get_display_language())
+ opts.update({
+ self.language + '_args': coredata.UserArrayOption(
+ self.language + '_args',
+ description + ' compiler',
+ compile_args, shlex_split=True, user_input=True),
+ self.language + '_link_args': coredata.UserArrayOption(
+ self.language + '_link_args',
+ description + ' linker',
+ link_args, shlex_split=True, user_input=True),
+ })
+
+ return opts
def get_option_compile_args(self, options):
return []
diff --git a/mesonbuild/compilers/d.py b/mesonbuild/compilers/d.py
index 474e1bd..5cb3659 100644
--- a/mesonbuild/compilers/d.py
+++ b/mesonbuild/compilers/d.py
@@ -180,10 +180,10 @@ class DCompiler(Compiler):
if mode == 'compile':
# Add DFLAGS from the env
- args += env.coredata.external_args[self.language]
+ args += env.coredata.get_external_args(self.language)
elif mode == 'link':
# Add LDFLAGS from the env
- args += env.coredata.external_link_args[self.language]
+ args += env.coredata.get_external_link_args(self.language)
# extra_args must override all other arguments, so we add them last
args += extra_args
return args