| 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 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 # Ninja might execute several commands to build something. We want the last | 153 # Ninja might execute several commands to build something. We want the last |
| 154 # clang command. | 154 # clang command. |
| 155 clang_line = None | 155 clang_line = None |
| 156 for line in reversed(stdout.split('\n')): | 156 for line in reversed(stdout.split('\n')): |
| 157 if 'clang' in line: | 157 if 'clang' in line: |
| 158 clang_line = line | 158 clang_line = line |
| 159 break | 159 break |
| 160 else: | 160 else: |
| 161 return chrome_flags | 161 return chrome_flags |
| 162 | 162 |
| 163 # Parse out the -I and -D flags. These seem to be the only ones that are | 163 # Parse flags that are important for YCM's purposes. |
| 164 # important for YCM's purposes. | |
| 165 for flag in clang_line.split(' '): | 164 for flag in clang_line.split(' '): |
| 166 if flag.startswith('-I'): | 165 if flag.startswith('-I'): |
| 167 # Relative paths need to be resolved, because they're relative to the | 166 # Relative paths need to be resolved, because they're relative to the |
| 168 # output dir, not the source. | 167 # output dir, not the source. |
| 169 if flag[2] == '/': | 168 if flag[2] == '/': |
| 170 chrome_flags.append(flag) | 169 chrome_flags.append(flag) |
| 171 else: | 170 else: |
| 172 abs_path = os.path.normpath(os.path.join(out_dir, flag[2:])) | 171 abs_path = os.path.normpath(os.path.join(out_dir, flag[2:])) |
| 173 chrome_flags.append('-I' + abs_path) | 172 chrome_flags.append('-I' + abs_path) |
| 173 elif flag.startswith('-std'): |
| 174 chrome_flags.append(flag) |
| 174 elif flag.startswith('-') and flag[1] in 'DWFfmO': | 175 elif flag.startswith('-') and flag[1] in 'DWFfmO': |
| 175 if flag == '-Wno-deprecated-register' or flag == '-Wno-header-guard': | 176 if flag == '-Wno-deprecated-register' or flag == '-Wno-header-guard': |
| 176 # These flags causes libclang (3.3) to crash. Remove it until things | 177 # These flags causes libclang (3.3) to crash. Remove it until things |
| 177 # are fixed. | 178 # are fixed. |
| 178 continue | 179 continue |
| 179 chrome_flags.append(flag) | 180 chrome_flags.append(flag) |
| 180 | 181 |
| 181 return chrome_flags | 182 return chrome_flags |
| 182 | 183 |
| 183 | 184 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 194 """ | 195 """ |
| 195 chrome_root = FindChromeSrcFromFilename(filename) | 196 chrome_root = FindChromeSrcFromFilename(filename) |
| 196 chrome_flags = GetClangCommandFromNinjaForFilename(chrome_root, | 197 chrome_flags = GetClangCommandFromNinjaForFilename(chrome_root, |
| 197 filename) | 198 filename) |
| 198 final_flags = flags + chrome_flags | 199 final_flags = flags + chrome_flags |
| 199 | 200 |
| 200 return { | 201 return { |
| 201 'flags': final_flags, | 202 'flags': final_flags, |
| 202 'do_cache': True | 203 'do_cache': True |
| 203 } | 204 } |
| OLD | NEW |