aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild
diff options
context:
space:
mode:
Diffstat (limited to 'mesonbuild')
-rw-r--r--mesonbuild/compilers.py14
-rw-r--r--mesonbuild/coredata.py7
-rw-r--r--mesonbuild/environment.py6
-rw-r--r--mesonbuild/interpreter.py7
4 files changed, 19 insertions, 15 deletions
diff --git a/mesonbuild/compilers.py b/mesonbuild/compilers.py
index ce3f09a..6f08d98 100644
--- a/mesonbuild/compilers.py
+++ b/mesonbuild/compilers.py
@@ -953,12 +953,14 @@ class CCompiler(Compiler):
# Read c_args/cpp_args/etc from the cross-info file (if needed)
args += self.get_cross_extra_flags(env, compile=(mode != 'preprocess'),
link=(mode == 'link'))
- # Add CFLAGS/CXXFLAGS/OBJCFLAGS/OBJCXXFLAGS from the env
- # We assume that the user has ensured these are compiler-specific
- args += env.coredata.external_args[self.language]
- # Add LDFLAGS from the env. We assume that the user has ensured these
- # are compiler-specific
- if mode == 'link':
+ if mode == 'preprocess':
+ # Add CPPFLAGS from the env.
+ args += env.coredata.external_preprocess_args[self.language]
+ elif mode == 'compile':
+ # Add CFLAGS/CXXFLAGS/OBJCFLAGS/OBJCXXFLAGS from the env
+ args += env.coredata.external_args[self.language]
+ elif mode == 'link':
+ # Add LDFLAGS from the env
args += env.coredata.external_link_args[self.language]
args += self.get_compiler_check_args()
# extra_args must override all other arguments, so we add them last
diff --git a/mesonbuild/coredata.py b/mesonbuild/coredata.py
index 67516e7..27f1dd7 100644
--- a/mesonbuild/coredata.py
+++ b/mesonbuild/coredata.py
@@ -148,10 +148,11 @@ class CoreData:
self.user_options = {}
self.compiler_options = {}
self.base_options = {}
- # These two, external_*args, are set via env vars CFLAGS, LDFLAGS, etc
+ # These external_*args, are set via env vars CFLAGS, LDFLAGS, etc
# but only when not cross-compiling.
- self.external_args = {}
- self.external_link_args = {}
+ self.external_preprocess_args = {} # CPPFLAGS only
+ self.external_args = {} # CPPFLAGS + CFLAGS
+ self.external_link_args = {} # CFLAGS + LDFLAGS (with MSVC: only LDFLAGS)
if options.cross_file is not None:
self.cross_file = os.path.join(os.getcwd(), options.cross_file)
else:
diff --git a/mesonbuild/environment.py b/mesonbuild/environment.py
index f2de31a..cb62506 100644
--- a/mesonbuild/environment.py
+++ b/mesonbuild/environment.py
@@ -770,7 +770,7 @@ def get_args_from_envvars(compiler):
compiler_is_linker = (compiler.get_exelist() == compiler.get_linker_exelist())
if lang not in ('c', 'cpp', 'objc', 'objcpp', 'fortran', 'd'):
- return [], []
+ return [], [], []
# Compile flags
cflags_mapping = {'c': 'CFLAGS',
@@ -794,7 +794,7 @@ def get_args_from_envvars(compiler):
# this when the linker is stand-alone such as with MSVC C/C++, etc.
link_flags = compile_flags + link_flags
- # Pre-processof rlags (not for fortran)
+ # Pre-processor flags (not for fortran or D)
preproc_flags = ''
if lang in ('c', 'cpp', 'objc', 'objcpp'):
preproc_flags = os.environ.get('CPPFLAGS', '')
@@ -802,7 +802,7 @@ def get_args_from_envvars(compiler):
preproc_flags = shlex.split(preproc_flags)
compile_flags += preproc_flags
- return compile_flags, link_flags
+ return preproc_flags, compile_flags, link_flags
class CrossBuildInfo:
def __init__(self, filename):
diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py
index 959ce6a..85e2b9a 100644
--- a/mesonbuild/interpreter.py
+++ b/mesonbuild/interpreter.py
@@ -1787,9 +1787,10 @@ class Interpreter(InterpreterBase):
raise
mlog.log('Native %s compiler: ' % lang, mlog.bold(' '.join(comp.get_exelist())), ' (%s %s)' % (comp.id, comp.version), sep='')
if not comp.get_language() in self.coredata.external_args:
- (ext_compile_args, ext_link_args) = environment.get_args_from_envvars(comp)
- self.coredata.external_args[comp.get_language()] = ext_compile_args
- self.coredata.external_link_args[comp.get_language()] = ext_link_args
+ (preproc_args, compile_args, link_args) = environment.get_args_from_envvars(comp)
+ self.coredata.external_preprocess_args[comp.get_language()] = preproc_args
+ self.coredata.external_args[comp.get_language()] = compile_args
+ self.coredata.external_link_args[comp.get_language()] = link_args
self.build.add_compiler(comp)
if need_cross_compiler:
mlog.log('Cross %s compiler: ' % lang, mlog.bold(' '.join(cross_comp.get_exelist())), ' (%s %s)' % (cross_comp.id, cross_comp.version), sep='')