| OLD | NEW |
| 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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 | 49 |
| 50 Use as a workaround for https://github.com/Valloric/YouCompleteMe/issues/303 | 50 Use as a workaround for https://github.com/Valloric/YouCompleteMe/issues/303 |
| 51 | 51 |
| 52 Returns: | 52 Returns: |
| 53 (List of Strings) Compile flags to append. | 53 (List of Strings) Compile flags to append. |
| 54 """ | 54 """ |
| 55 try: | 55 try: |
| 56 with open(os.devnull, 'rb') as DEVNULL: | 56 with open(os.devnull, 'rb') as DEVNULL: |
| 57 output = subprocess.check_output(['clang', '-v', '-E', '-x', 'c++', '-'], | 57 output = subprocess.check_output(['clang', '-v', '-E', '-x', 'c++', '-'], |
| 58 stdin=DEVNULL, stderr=subprocess.STDOUT) | 58 stdin=DEVNULL, stderr=subprocess.STDOUT) |
| 59 except (FileNotFoundError, subprocess.CalledProcessError): | 59 except: |
| 60 return [] | 60 return [] |
| 61 includes_regex = r'#include <\.\.\.> search starts here:\s*' \ | 61 includes_regex = r'#include <\.\.\.> search starts here:\s*' \ |
| 62 r'(.*?)End of search list\.' | 62 r'(.*?)End of search list\.' |
| 63 includes = re.search(includes_regex, output.decode(), re.DOTALL).group(1) | 63 includes = re.search(includes_regex, output.decode(), re.DOTALL).group(1) |
| 64 flags = [] | 64 flags = [] |
| 65 for path in includes.splitlines(): | 65 for path in includes.splitlines(): |
| 66 path = path.strip() | 66 path = path.strip() |
| 67 if os.path.isdir(path): | 67 if os.path.isdir(path): |
| 68 flags.append('-isystem') | 68 flags.append('-isystem') |
| 69 flags.append(path) | 69 flags.append(path) |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 """ | 224 """ |
| 225 chrome_root = FindChromeSrcFromFilename(filename) | 225 chrome_root = FindChromeSrcFromFilename(filename) |
| 226 chrome_flags = GetClangCommandFromNinjaForFilename(chrome_root, | 226 chrome_flags = GetClangCommandFromNinjaForFilename(chrome_root, |
| 227 filename) | 227 filename) |
| 228 final_flags = flags + chrome_flags + _system_include_flags | 228 final_flags = flags + chrome_flags + _system_include_flags |
| 229 | 229 |
| 230 return { | 230 return { |
| 231 'flags': final_flags, | 231 'flags': final_flags, |
| 232 'do_cache': True | 232 'do_cache': True |
| 233 } | 233 } |
| OLD | NEW |