Permalink
Browse files

Merge branch 'add_builtin_directories' of git://github.com/tobig/clan…

…g_complete into builtin-dirs
  • Loading branch information...
Rip-Rip committed Feb 15, 2013
2 parents e88527c + a491430 commit 4aa62c6488782e9fbc241b6efd02c41af4208cdb
Showing with 23 additions and 13 deletions.
  1. +23 −13 plugin/libclang.py
View
@@ -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, \
@@ -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()

0 comments on commit 4aa62c6

Please sign in to comment.