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

Side by Side Diff: tools/vim/ninja-build.vim

Issue 9265016: vim: Let ninja-build.vim detect Release correctly if out/Debug/protoc doesn't exist at all. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 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 | Annotate | Revision Log
« 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) 2011 The Chromium Authors. All rights reserved. 1 " Copyright (c) 2011 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 " Adds a "Compile this file" function, using ninja. On Mac, binds Cmd-k to 5 " Adds a "Compile this file" function, using ninja. On Mac, binds Cmd-k to
6 " this command. 6 " this command.
7 " 7 "
8 " Requires that gyp has already generated build.ninja files, and that ninja is 8 " Requires that gyp has already generated build.ninja files, and that ninja is
9 " in your path (which it is automatically if depot_tools is in your path). 9 " in your path (which it is automatically if depot_tools is in your path).
10 " 10 "
(...skipping 25 matching lines...) Expand all
36 return candidate 36 return candidate
37 37
38 38
39 def guess_configuration(): 39 def guess_configuration():
40 """Default to the configuration with either a newer build.ninja or a newer 40 """Default to the configuration with either a newer build.ninja or a newer
41 protoc.""" 41 protoc."""
42 root = os.path.join(path_to_source_root(), 'out') 42 root = os.path.join(path_to_source_root(), 'out')
43 def is_release_15s_newer(test_path): 43 def is_release_15s_newer(test_path):
44 try: 44 try:
45 debug_mtime = os.path.getmtime(os.path.join(root, 'Debug', test_path)) 45 debug_mtime = os.path.getmtime(os.path.join(root, 'Debug', test_path))
46 except os.error:
47 debug_mtime = 0
48 try:
46 rel_mtime = os.path.getmtime(os.path.join(root, 'Release', test_path)) 49 rel_mtime = os.path.getmtime(os.path.join(root, 'Release', test_path))
47 return rel_mtime - debug_mtime >= 15
48 except os.error: 50 except os.error:
49 return False 51 rel_mtime = 0
52 return rel_mtime - debug_mtime >= 15
50 configuration = 'Debug' 53 configuration = 'Debug'
51 if is_release_15s_newer('build.ninja') or is_release_15s_newer('protoc'): 54 if is_release_15s_newer('build.ninja') or is_release_15s_newer('protoc'):
52 configuration = 'Release' 55 configuration = 'Release'
53 return configuration 56 return configuration
54 57
55 58
56 def compute_ninja_command(configuration=None): 59 def compute_ninja_command(configuration=None):
57 """Returns the shell command to compile the file in the current buffer.""" 60 """Returns the shell command to compile the file in the current buffer."""
58 if not configuration: configuration = guess_configuration() 61 if not configuration: configuration = guess_configuration()
59 build_dir = os.path.join(path_to_source_root(), 'out', configuration) 62 build_dir = os.path.join(path_to_source_root(), 'out', configuration)
(...skipping 17 matching lines...) Expand all
77 let &makeprg = l:oldmakepgr 80 let &makeprg = l:oldmakepgr
78 endfun 81 endfun
79 82
80 command! CrCompileFile call CrCompileFile() 83 command! CrCompileFile call CrCompileFile()
81 84
82 if has('mac') 85 if has('mac')
83 map <D-k> :CrCompileFile<cr> 86 map <D-k> :CrCompileFile<cr>
84 imap <D-k> <esc>:CrCompileFile<cr> 87 imap <D-k> <esc>:CrCompileFile<cr>
85 endif 88 endif
86 " TODO(linuxuser): Suggest a keyboard shortcut and send review to thakis@. 89 " TODO(linuxuser): Suggest a keyboard shortcut and send review to thakis@.
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