From 09fee02dd9484e682401469ff890cf99ef5fa56a Mon Sep 17 00:00:00 2001 From: Nirbheek Chauhan Date: Fri, 24 Mar 2017 20:58:09 +0530 Subject: Use shlex.split() to split CFLAGS/LDFLAGS/etc This allows people to use spaces in the environment variables as long as they use the correct quoting. --- mesonbuild/environment.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'mesonbuild/environment.py') diff --git a/mesonbuild/environment.py b/mesonbuild/environment.py index 1beb63c..f2de31a 100644 --- a/mesonbuild/environment.py +++ b/mesonbuild/environment.py @@ -781,12 +781,12 @@ def get_args_from_envvars(compiler): 'd': 'DFLAGS'} compile_flags = os.environ.get(cflags_mapping[lang], '') log_var(cflags_mapping[lang], compile_flags) - compile_flags = compile_flags.split() + compile_flags = shlex.split(compile_flags) # Link flags (same for all languages) link_flags = os.environ.get('LDFLAGS', '') log_var('LDFLAGS', link_flags) - link_flags = link_flags.split() + link_flags = shlex.split(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 @@ -799,7 +799,8 @@ def get_args_from_envvars(compiler): if lang in ('c', 'cpp', 'objc', 'objcpp'): preproc_flags = os.environ.get('CPPFLAGS', '') log_var('CPPFLAGS', preproc_flags) - compile_flags += preproc_flags.split() + preproc_flags = shlex.split(preproc_flags) + compile_flags += preproc_flags return compile_flags, link_flags -- cgit v1.1