[cfe-commits] r143842 - /cfe/trunk/test/lit.cfg

Chandler Carruth chandlerc at gmail.com
Sat Nov 5 16:29:28 PDT 2011


Author: chandlerc
Date: Sat Nov  5 18:29:28 2011
New Revision: 143842

URL: http://llvm.org/viewvc/llvm-project?rev=143842&view=rev
Log:
Switch Lit to directly query the driver for the builtin inclue path.
Thanks to Peter for pointing out how easy this is to do. I'm now much
happier with this solution.

Modified:
    cfe/trunk/test/lit.cfg

Modified: cfe/trunk/test/lit.cfg
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/lit.cfg?rev=143842&r1=143841&r2=143842&view=diff
==============================================================================
--- cfe/trunk/test/lit.cfg (original)
+++ cfe/trunk/test/lit.cfg Sat Nov  5 18:29:28 2011
@@ -148,25 +148,19 @@
 # Note that when substituting %clang_cc1 also fill in the include directory of
 # the builtin headers. Those are part of even a freestanding environment, but
 # Clang relies on the driver to locate them.
-def getClangVersion(clang):
+def getClangBuiltinIncludeDir(clang):
     # FIXME: Rather than just getting the version, we should have clang print
     # out its resource dir here in an easy to scrape form.
-    cmd = subprocess.Popen([clang, '-v'], stderr=subprocess.PIPE)
+    cmd = subprocess.Popen([clang, '-print-file-name=include'],
+                           stdout=subprocess.PIPE)
+    if not cmd.stdout:
+      lit.fatal("Couldn't find the include dir for Clang ('%s')" % clang)
+    return cmd.stdout.read().strip()
 
-    for line in cmd.stderr:
-        m = re.match( r'^clang version ([^ ]+) ', line)
-        if m is not None:
-            return m.group(1)
-
-    lit.fatal("Couldn't find the version of Clang ('%s')" % clang)
-
-clang_directory = os.path.dirname(os.path.realpath(config.clang))
-clang_builtin_includes = os.path.join(os.path.dirname(clang_directory),
-                                      'lib', 'clang',
-                                      getClangVersion(config.clang), 'include')
 config.substitutions.append( ('%clang_cc1',
                               '%s -cc1 -internal-nosysroot-isystem %s'
-                              % (config.clang, clang_builtin_includes)) )
+                              % (config.clang,
+                                 getClangBuiltinIncludeDir(config.clang))) )
 
 config.substitutions.append( ('%clangxx', ' ' + config.clang +
                               ' -ccc-clang-cxx -ccc-cxx '))





More information about the cfe-commits mailing list