| Index: tools/vim/chromium.ycm_extra_conf.py
|
| diff --git a/tools/vim/chromium.ycm_extra_conf.py b/tools/vim/chromium.ycm_extra_conf.py
|
| index c0de6486aa26797fcd701a52f9a259a7b7d3eb47..2901c545dd08d8623a557fb2830f2b2f89b9c941 100644
|
| --- a/tools/vim/chromium.ycm_extra_conf.py
|
| +++ b/tools/vim/chromium.ycm_extra_conf.py
|
| @@ -39,10 +39,39 @@
|
|
|
| import os
|
| import os.path
|
| +import re
|
| import subprocess
|
| import sys
|
|
|
|
|
| +def SystemIncludeDirectoryFlags():
|
| + """Determines compile flags to include the system include directories.
|
| +
|
| + Use as a workaround for https://github.com/Valloric/YouCompleteMe/issues/303
|
| +
|
| + Returns:
|
| + (List of Strings) Compile flags to append.
|
| + """
|
| + try:
|
| + with open(os.devnull, 'rb') as DEVNULL:
|
| + output = subprocess.check_output(['clang', '-v', '-E', '-x', 'c++', '-'],
|
| + stdin=DEVNULL, stderr=subprocess.STDOUT)
|
| + except (FileNotFoundError, subprocess.CalledProcessError):
|
| + return []
|
| + includes_regex = r'#include <\.\.\.> search starts here:\s*' \
|
| + r'(.*?)End of search list\.'
|
| + includes = re.search(includes_regex, output.decode(), re.DOTALL).group(1)
|
| + flags = []
|
| + for path in includes.splitlines():
|
| + path = path.strip()
|
| + if os.path.isdir(path):
|
| + flags.append('-isystem')
|
| + flags.append(path)
|
| + return flags
|
| +
|
| +
|
| +_system_include_flags = SystemIncludeDirectoryFlags()
|
| +
|
| # Flags from YCM's default config.
|
| flags = [
|
| '-DUSE_CLANG_COMPLETER',
|
| @@ -68,14 +97,15 @@ def FindChromeSrcFromFilename(filename):
|
| (String) Path of 'src/', or None if unable to find.
|
| """
|
| curdir = os.path.normpath(os.path.dirname(filename))
|
| - while not (PathExists(curdir, 'src') and PathExists(curdir, 'src', 'DEPS')
|
| - and (PathExists(curdir, '.gclient')
|
| - or PathExists(curdir, 'src', '.git'))):
|
| + while not (os.path.basename(os.path.realpath(curdir)) == 'src'
|
| + and PathExists(curdir, 'DEPS')
|
| + and (PathExists(curdir, '..', '.gclient')
|
| + or PathExists(curdir, '.git'))):
|
| nextdir = os.path.normpath(os.path.join(curdir, '..'))
|
| if nextdir == curdir:
|
| return None
|
| curdir = nextdir
|
| - return os.path.join(curdir, 'src')
|
| + return curdir
|
|
|
|
|
| def GetClangCommandFromNinjaForFilename(chrome_root, filename):
|
| @@ -195,7 +225,7 @@ def FlagsForFile(filename):
|
| chrome_root = FindChromeSrcFromFilename(filename)
|
| chrome_flags = GetClangCommandFromNinjaForFilename(chrome_root,
|
| filename)
|
| - final_flags = flags + chrome_flags
|
| + final_flags = flags + chrome_flags + _system_include_flags
|
|
|
| return {
|
| 'flags': final_flags,
|
|
|