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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 # Autocompletion config for YouCompleteMe in Chromium. 5 # Autocompletion config for YouCompleteMe in Chromium.
6 # 6 #
7 # USAGE: 7 # USAGE:
8 # 8 #
9 # 1. Install YCM [https://github.com/Valloric/YouCompleteMe] 9 # 1. Install YCM [https://github.com/Valloric/YouCompleteMe]
10 # (Googlers should check out [go/ycm]) 10 # (Googlers should check out [go/ycm])
(...skipping 21 matching lines...) Expand all
32 # for everything I've used it for. 32 # for everything I've used it for.
33 # 33 #
34 # * That whole ninja & clang thing? We could support other configs if someone 34 # * That whole ninja & clang thing? We could support other configs if someone
35 # were willing to write the correct commands and a parser. 35 # were willing to write the correct commands and a parser.
36 # 36 #
37 # * This has only been tested on gPrecise. 37 # * This has only been tested on gPrecise.
38 38
39 39
40 import os 40 import os
41 import os.path 41 import os.path
42 import re
42 import subprocess 43 import subprocess
43 import sys 44 import sys
44 45
45 46
47 def SystemIncludeDirectoryFlags():
48 """Determines compile flags to include the system include directories.
49
50 Use as a workaround for https://github.com/Valloric/YouCompleteMe/issues/303
51
52 Returns:
53 (List of Strings) Compile flags to append.
54 """
55 try:
56 with open(os.devnull, 'rb') as DEVNULL:
57 output = subprocess.check_output(['clang', '-v', '-E', '-x', 'c++', '-'],
58 stdin=DEVNULL, stderr=subprocess.STDOUT)
59 except (FileNotFoundError, subprocess.CalledProcessError):
60 return []
61 includes_regex = r'#include <\.\.\.> search starts here:\s*' \
62 r'(.*?)End of search list\.'
63 includes = re.search(includes_regex, output.decode(), re.DOTALL).group(1)
64 flags = []
65 for path in includes.splitlines():
66 path = path.strip()
67 if os.path.isdir(path):
68 flags.append('-isystem')
69 flags.append(path)
70 return flags
71
72
73 _system_include_flags = SystemIncludeDirectoryFlags()
74
46 # Flags from YCM's default config. 75 # Flags from YCM's default config.
47 flags = [ 76 flags = [
48 '-DUSE_CLANG_COMPLETER', 77 '-DUSE_CLANG_COMPLETER',
49 '-std=c++11', 78 '-std=c++11',
50 '-x', 79 '-x',
51 'c++', 80 'c++',
52 ] 81 ]
53 82
54 83
55 def PathExists(*args): 84 def PathExists(*args):
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 filename: (String) Path to source file being edited. 218 filename: (String) Path to source file being edited.
190 219
191 Returns: 220 Returns:
192 (Dictionary) 221 (Dictionary)
193 'flags': (List of Strings) Command line flags. 222 'flags': (List of Strings) Command line flags.
194 'do_cache': (Boolean) True if the result should be cached. 223 'do_cache': (Boolean) True if the result should be cached.
195 """ 224 """
196 chrome_root = FindChromeSrcFromFilename(filename) 225 chrome_root = FindChromeSrcFromFilename(filename)
197 chrome_flags = GetClangCommandFromNinjaForFilename(chrome_root, 226 chrome_flags = GetClangCommandFromNinjaForFilename(chrome_root,
198 filename) 227 filename)
199 final_flags = flags + chrome_flags 228 final_flags = flags + chrome_flags + _system_include_flags
200 229
201 return { 230 return {
202 'flags': final_flags, 231 'flags': final_flags,
203 'do_cache': True 232 'do_cache': True
204 } 233 }
OLDNEW
« 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