From e677704d2149db9ac91c5000633a3fac8f91956f Mon Sep 17 00:00:00 2001 From: John Ericson Date: Tue, 19 Mar 2019 17:58:46 -0400 Subject: 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. --- mesonbuild/compilers/compilers.py | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'mesonbuild/compilers/compilers.py') 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 -- cgit v1.1