Chromium Code Reviews| 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 bb988388d4c0c69413d501cdcca320848d0c01e5..9b1d5569e509d169aa9883b550e072d6223c4352 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:' \ |
| + r'(.*?)End of search list\.' |
| + includes = re.search(includes_regex, output.decode(), re.DOTALL).group(1) |
| + flags = [] |
| + for path in includes.split('\n'): |
| + path = path.strip() |
| + if os.path.isdir(path): |
|
eroman
2015/01/21 02:33:00
You may want to skip if len(path) == 0
(Haven't t
johnme
2015/01/21 12:23:35
It was possible, but os.path.isdir('') returns Fal
|
| + flags.append('-isystem') |
| + flags.append(path) |
| + return flags |
| + |
| + |
| +_system_include_flags = SystemIncludeDirectoryFlags() |
| + |
| # Flags from YCM's default config. |
| flags = [ |
| '-DUSE_CLANG_COMPLETER', |
| @@ -196,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, |