aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild
diff options
context:
space:
mode:
authorJohn Ericson <John.Ericson@Obsidian.Systems>2019-03-20 17:57:56 -0400
committerNirbheek Chauhan <nirbheek.chauhan@gmail.com>2019-03-27 14:45:42 +0000
commita69f7b0b5ad94fb6d89b659349f704c9153175d0 (patch)
tree5581df59a12ee5f2e80e4c58b84cda11038a80c1 /mesonbuild
parentc67ea5cd4d9ece70ab19456f588aff44cb1f7e3c (diff)
downloadmeson-a69f7b0b5ad94fb6d89b659349f704c9153175d0.zip
meson-a69f7b0b5ad94fb6d89b659349f704c9153175d0.tar.gz
meson-a69f7b0b5ad94fb6d89b659349f704c9153175d0.tar.bz2
compilers: Log difference between empty and absent env var
Diffstat (limited to 'mesonbuild')
-rw-r--r--mesonbuild/compilers/compilers.py31
1 files changed, 19 insertions, 12 deletions
diff --git a/mesonbuild/compilers/compilers.py b/mesonbuild/compilers/compilers.py
index 40f0251..208389e 100644
--- a/mesonbuild/compilers/compilers.py
+++ b/mesonbuild/compilers/compilers.py
@@ -14,7 +14,7 @@
import abc, contextlib, enum, os.path, re, tempfile, shlex
import subprocess
-from typing import List, Tuple
+from typing import List, Optional, Tuple
from ..linkers import StaticLinker
from .. import coredata
@@ -981,9 +981,11 @@ class Compiler:
Returns a tuple of (compile_flags, link_flags) for the specified language
from the inherited environment
"""
- def log_var(var, val):
+ def log_var(var, val: Optional[str]):
if val:
mlog.log('Appending {} from environment: {!r}'.format(var, val))
+ else:
+ mlog.debug('No {} in the environment, not changing global flags.'.format(var))
lang = self.get_language()
compiler_is_linker = False
@@ -993,14 +995,19 @@ class Compiler:
if lang not in cflags_mapping:
return [], []
- compile_flags = os.environ.get(cflags_mapping[lang], '')
- log_var(cflags_mapping[lang], compile_flags)
- compile_flags = shlex.split(compile_flags)
+ compile_flags = []
+ link_flags = []
+
+ env_compile_flags = os.environ.get(cflags_mapping[lang])
+ log_var(cflags_mapping[lang], env_compile_flags)
+ if env_compile_flags is not None:
+ compile_flags += shlex.split(env_compile_flags)
# Link flags (same for all languages)
- link_flags = os.environ.get('LDFLAGS', '')
- log_var('LDFLAGS', link_flags)
- link_flags = shlex.split(link_flags)
+ env_link_flags = os.environ.get('LDFLAGS')
+ log_var('LDFLAGS', env_link_flags)
+ if env_link_flags is not None:
+ link_flags += shlex.split(env_link_flags)
if compiler_is_linker:
# When the compiler is used as a wrapper around the linker (such as
# with GCC and Clang), the compile flags can be needed while linking
@@ -1010,10 +1017,10 @@ class Compiler:
# 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
+ env_preproc_flags = os.environ.get('CPPFLAGS')
+ log_var('CPPFLAGS', env_preproc_flags)
+ if env_preproc_flags is not None:
+ compile_flags += shlex.split(env_preproc_flags)
return compile_flags, link_flags