Skip to content

Commit ae95127

Browse files
committed
Merging r143842:
------------------------------------------------------------------------ r143842 | chandlerc | 2011-11-05 16:29:28 -0700 (Sat, 05 Nov 2011) | 3 lines 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. ------------------------------------------------------------------------ llvm-svn: 143944
1 parent c1c82ee commit ae95127

File tree

1 file changed

+8
-14
lines changed

1 file changed

+8
-14
lines changed

clang/test/lit.cfg

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -148,25 +148,19 @@ if not lit.quiet:
148148
# Note that when substituting %clang_cc1 also fill in the include directory of
149149
# the builtin headers. Those are part of even a freestanding environment, but
150150
# Clang relies on the driver to locate them.
151-
def getClangVersion(clang):
151+
def getClangBuiltinIncludeDir(clang):
152152
# FIXME: Rather than just getting the version, we should have clang print
153153
# out its resource dir here in an easy to scrape form.
154-
cmd = subprocess.Popen([clang, '-v'], stderr=subprocess.PIPE)
154+
cmd = subprocess.Popen([clang, '-print-file-name=include'],
155+
stdout=subprocess.PIPE)
156+
if not cmd.stdout:
157+
lit.fatal("Couldn't find the include dir for Clang ('%s')" % clang)
158+
return cmd.stdout.read().strip()
155159

156-
for line in cmd.stderr:
157-
m = re.match( r'^clang version ([^ ]+) ', line)
158-
if m is not None:
159-
return m.group(1)
160-
161-
lit.fatal("Couldn't find the version of Clang ('%s')" % clang)
162-
163-
clang_directory = os.path.dirname(os.path.realpath(config.clang))
164-
clang_builtin_includes = os.path.join(os.path.dirname(clang_directory),
165-
'lib', 'clang',
166-
getClangVersion(config.clang), 'include')
167160
config.substitutions.append( ('%clang_cc1',
168161
'%s -cc1 -internal-nosysroot-isystem %s'
169-
% (config.clang, clang_builtin_includes)) )
162+
% (config.clang,
163+
getClangBuiltinIncludeDir(config.clang))) )
170164

171165
config.substitutions.append( ('%clangxx', ' ' + config.clang +
172166
' -ccc-clang-cxx -ccc-cxx '))

0 commit comments

Comments
 (0)