| 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 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 else: | 159 else: |
| 160 if filename.startswith(blink_root): | 160 if filename.startswith(blink_root): |
| 161 # If this is a Blink file, we can at least try to get a reasonable | 161 # If this is a Blink file, we can at least try to get a reasonable |
| 162 # approximation. | 162 # approximation. |
| 163 filename = default_blink_file | 163 filename = default_blink_file |
| 164 else: | 164 else: |
| 165 # If this is a standalone .h file with no source, the best we can do is | 165 # If this is a standalone .h file with no source, the best we can do is |
| 166 # try to use the default flags. | 166 # try to use the default flags. |
| 167 return chrome_flags | 167 return chrome_flags |
| 168 | 168 |
| 169 out_dir = GetNinjaOutputDirectory(chrome_root) | 169 out_dir = os.path.realpath(GetNinjaOutputDirectory(chrome_root)) |
| 170 | 170 |
| 171 # Ninja needs the path to the source file relative to the output build | 171 # Ninja needs the path to the source file relative to the output build |
| 172 # directory. | 172 # directory. |
| 173 rel_filename = os.path.relpath(os.path.realpath(filename), | 173 rel_filename = os.path.relpath(os.path.realpath(filename), out_dir) |
| 174 os.path.realpath(out_dir)) | |
| 175 | 174 |
| 176 # Ask ninja how it would build our source file. | 175 # Ask ninja how it would build our source file. |
| 177 p = subprocess.Popen(['ninja', '-v', '-C', out_dir, '-t', | 176 p = subprocess.Popen(['ninja', '-v', '-C', out_dir, '-t', |
| 178 'commands', rel_filename + '^'], | 177 'commands', rel_filename + '^'], |
| 179 stdout=subprocess.PIPE) | 178 stdout=subprocess.PIPE) |
| 180 stdout, stderr = p.communicate() | 179 stdout, stderr = p.communicate() |
| 181 if p.returncode: | 180 if p.returncode: |
| 182 return chrome_flags | 181 return chrome_flags |
| 183 | 182 |
| 184 # Ninja might execute several commands to build something. We want the last | 183 # Ninja might execute several commands to build something. We want the last |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 """ | 225 """ |
| 227 chrome_root = FindChromeSrcFromFilename(filename) | 226 chrome_root = FindChromeSrcFromFilename(filename) |
| 228 chrome_flags = GetClangCommandFromNinjaForFilename(chrome_root, | 227 chrome_flags = GetClangCommandFromNinjaForFilename(chrome_root, |
| 229 filename) | 228 filename) |
| 230 final_flags = flags + chrome_flags | 229 final_flags = flags + chrome_flags |
| 231 | 230 |
| 232 return { | 231 return { |
| 233 'flags': final_flags, | 232 'flags': final_flags, |
| 234 'do_cache': True | 233 'do_cache': True |
| 235 } | 234 } |
| OLD | NEW |