Skip to content

Commit

Permalink
Merge branch 'add_builtin_directories' of git://github.com/tobig/clan…
Browse files Browse the repository at this point in the history
…g_complete into builtin-dirs
  • Loading branch information
xavierd committed Feb 15, 2013
2 parents e88527c + a491430 commit 4aa62c6
Showing 1 changed file with 23 additions and 13 deletions.
36 changes: 23 additions & 13 deletions plugin/libclang.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,31 @@ def canFindBuiltinHeaders(index, args = []):
# This function tries to derive a path to clang's builtin header files. We are
# just guessing, but the guess is very educated. In fact, we should be right
# for all manual installations (the ones where the builtin header path problem
# is very common).
# is very common) as well as a set of very common distributions.
def getBuiltinHeaderPath(library_path):
path = library_path + "/../lib/clang"
try:
files = os.listdir(path)
except:
return None
knownPaths = [
library_path + "/../lib/clang", # default value
library_path + "/../clang", # gentoo
library_path + "/clang", # opensuse
library_path + "/", # Google
"/usr/lib/clang"
]

for path in knownPaths:
try:
files = os.listdir(path)
if len(files) >= 1:
files = sorted(files)
subDir = files[-1]
else:
subDir = '.'
path = path + "/" + subDir + "/include/"
arg = "-I" + path
if canFindBuiltinHeaders(index, [arg]):
return path
except:
pass

files = sorted(files)
path = path + "/" + files[-1] + "/include/"
arg = "-I" + path
if canFindBuiltinHeaders(index, [arg]):
return path
return None

def initClangComplete(clang_complete_flags, clang_compilation_database, \
Expand Down Expand Up @@ -67,8 +79,6 @@ def initClangComplete(clang_complete_flags, clang_compilation_database, \
print "WARNING: libclang can not find the builtin includes."
print " This will cause slow code completion."
print " Please report the problem."
print " To work around this issue you can add the path of the"
print " clang builtin includes to g:clang_user_options."

global translationUnits
translationUnits = dict()
Expand Down

0 comments on commit 4aa62c6

Please sign in to comment.