[libcxx] r295511 - test: prevent incorrect quoting of paths

Saleem Abdulrasool via cfe-commits cfe-commits at lists.llvm.org
Fri Feb 17 15:08:47 PST 2017


Author: compnerd
Date: Fri Feb 17 17:08:46 2017
New Revision: 295511

URL: http://llvm.org/viewvc/llvm-project?rev=295511&view=rev
Log:
test: prevent incorrect quoting of paths

The path would previously get an extra leading space as the arguments
would be parsed when generating the final command to run.  Pretokenise
the arguments to permit proper quoting of the paths.  This avoids a
number of ignoring non-existent path warnings from clang.

Modified:
    libcxx/trunk/utils/libcxx/test/config.py

Modified: libcxx/trunk/utils/libcxx/test/config.py
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/utils/libcxx/test/config.py?rev=295511&r1=295510&r2=295511&view=diff
==============================================================================
--- libcxx/trunk/utils/libcxx/test/config.py (original)
+++ libcxx/trunk/utils/libcxx/test/config.py Fri Feb 17 17:08:46 2017
@@ -229,21 +229,19 @@ class Configuration(object):
         self.cxx.compile_env['CCACHE_CPP2'] = '1'
 
     def _configure_clang_cl(self, clang_path):
+        def _split_env_var(var):
+            return [p.strip() for p in os.environ.get(var, '').split(';') if p.strip()]
+
+        def _prefixed_env_list(var, prefix):
+            from itertools import chain
+            return list(chain.from_iterable((prefix, path) for path in _split_env_var(var)))
+
         assert self.cxx_is_clang_cl
         flags = []
-        compile_flags = []
-        link_flags = []
-        if 'INCLUDE' in os.environ:
-            compile_flags += ['-isystem %s' % p.strip()
-                              for p in os.environ['INCLUDE'].split(';')
-                              if p.strip()]
-        if 'LIB' in os.environ:
-            for p in os.environ['LIB'].split(';'):
-                p = p.strip()
-                if not p:
-                    continue
-                link_flags += ['-L%s' % p]
-                self.add_path(self.exec_env, p)
+        compile_flags = _prefixed_env_list('INCLUDE', '-isystem')
+        link_flags = _prefixed_env_list('LIB', '-L')
+        for path in _list_env_var('LIB'):
+            self.add_path(self.exec_env, path)
         return CXXCompiler(clang_path, flags=flags,
                            compile_flags=compile_flags,
                            link_flags=link_flags)




More information about the cfe-commits mailing list