aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/compilers
diff options
context:
space:
mode:
authorJohn Ericson <John.Ericson@Obsidian.Systems>2019-03-19 17:58:46 -0400
committerNirbheek Chauhan <nirbheek.chauhan@gmail.com>2019-03-27 14:45:42 +0000
commite677704d2149db9ac91c5000633a3fac8f91956f (patch)
treedf27968a4780819eecc56a2b8415e0e1c2476665 /mesonbuild/compilers
parent151961056cc2ebda27244746d4d441b2eb48cf8e (diff)
downloadmeson-e677704d2149db9ac91c5000633a3fac8f91956f.zip
meson-e677704d2149db9ac91c5000633a3fac8f91956f.tar.gz
meson-e677704d2149db9ac91c5000633a3fac8f91956f.tar.bz2
Don't collect preprocssor flags separately from compiler flags
I recall that @jpakkane never wanted this, but @nirbheek did, but then @nirbheek changed his mind. I am fine either way except for the cross inconsistency that exists today: There is no `c_preproc_args` or similar one can put in the cross file, so no way to replicate the effect of CPPFLAGS during cross compilation.
Diffstat (limited to 'mesonbuild/compilers')
-rw-r--r--mesonbuild/compilers/c.py7
-rw-r--r--mesonbuild/compilers/compilers.py20
2 files changed, 13 insertions, 14 deletions
diff --git a/mesonbuild/compilers/c.py b/mesonbuild/compilers/c.py
index 4294bb1..2560c82 100644
--- a/mesonbuild/compilers/c.py
+++ b/mesonbuild/compilers/c.py
@@ -422,11 +422,8 @@ class CCompiler(Compiler):
for_machine = MachineChoice.BUILD
else:
for_machine = MachineChoice.HOST
- if mode == 'preprocess':
- # Add CPPFLAGS from the env.
- args += env.coredata.get_external_preprocess_args(for_machine, self.language)
- elif mode == 'compile':
- # Add CFLAGS/CXXFLAGS/OBJCFLAGS/OBJCXXFLAGS from the env
+ if mode in {'compile', 'preprocess'}:
+ # Add CFLAGS/CXXFLAGS/OBJCFLAGS/OBJCXXFLAGS and CPPFLAGS from the env
sys_args = env.coredata.get_external_args(for_machine, self.language)
# Apparently it is a thing to inject linker flags both
# via CFLAGS _and_ LDFLAGS, even though the former are
diff --git a/mesonbuild/compilers/compilers.py b/mesonbuild/compilers/compilers.py
index 66195dc..d93a542 100644
--- a/mesonbuild/compilers/compilers.py
+++ b/mesonbuild/compilers/compilers.py
@@ -970,10 +970,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 use_preproc_flags(self):
+ """
+ Whether the compiler (or processes it spawns) cares about CPPFLAGS
+ """
+ return self.get_language() in ('c', 'cpp', 'objc', 'objcpp')
def get_args_from_envvars(self):
"""
@@ -1007,11 +1008,12 @@ class Compiler:
# this when the linker is stand-alone such as with MSVC C/C++, etc.
link_flags = compile_flags + link_flags
- # Pre-processor flags (not for fortran or D)
- preproc_flags = self.get_preproc_flags()
- log_var('CPPFLAGS', preproc_flags)
- preproc_flags = shlex.split(preproc_flags)
- compile_flags += preproc_flags
+ # Pre-processor flags for certain languages
+ if self.use_preproc_flags():
+ preproc_flags = os.environ.get('CPPFLAGS', '')
+ log_var('CPPFLAGS', preproc_flags)
+ preproc_flags = shlex.split(preproc_flags)
+ compile_flags += preproc_flags
return compile_flags, link_flags