Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(234)

Unified Diff: tools/vim/chromium.ycm_extra_conf.py

Issue 842053003: YouCompleteMe workaround: explicitly include system include dirs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@ycm_symlinks
Patch Set: Avoid needless isdir("") Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..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',
@@ -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,
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698