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

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

Issue 1940753002: Enable YouCompleteMe and :CrCompile to find GN build directory (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Change from 'out/Debug' to 'out/gn' directory in tests. Created 4 years, 7 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 | tools/vim/ninja_output.py » ('j') | 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 " 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. On Windows, Ctrl-F7 (which is the same as the VS default). 6 " this command. On Windows, Ctrl-F7 (which is the same as the VS default).
7 " On Linux, <Leader>o, which is \o by default ("o"=creates .o files) 7 " On Linux, <Leader>o, which is \o by default ("o"=creates .o files)
8 " 8 "
9 " Adds a "Build this target" function, using ninja. This is not bound 9 " Adds a "Build this target" function, using ninja. This is not bound
10 " to any key by default, but can be used via the :CrBuild command. 10 " to any key by default, but can be used via the :CrBuild command.
(...skipping 23 matching lines...) Expand all
34 # would find "src/v8" for files below "src/v8", as "src/v8/build/common.gypi" 34 # would find "src/v8" for files below "src/v8", as "src/v8/build/common.gypi"
35 # exists). The longer it is, the more likely it is to break when we rename 35 # exists). The longer it is, the more likely it is to break when we rename
36 # directories. 36 # directories.
37 fingerprints = ['chrome', 'net', 'v8', 'build', 'skia'] 37 fingerprints = ['chrome', 'net', 'v8', 'build', 'skia']
38 while candidate and not all( 38 while candidate and not all(
39 [os.path.isdir(os.path.join(candidate, fp)) for fp in fingerprints]): 39 [os.path.isdir(os.path.join(candidate, fp)) for fp in fingerprints]):
40 candidate = os.path.dirname(candidate) 40 candidate = os.path.dirname(candidate)
41 return candidate 41 return candidate
42 42
43 43
44 def path_to_build_dir(configuration): 44 def path_to_build_dir():
45 """Returns <chrome_root>/<output_dir>/(Release|Debug).""" 45 """Returns <chrome_root>/<output_dir>/(Release|Debug|<other>)."""
46 46
47 chrome_root = path_to_source_root() 47 chrome_root = path_to_source_root()
48 sys.path.append(os.path.join(chrome_root, 'tools', 'vim')) 48 sys.path.append(os.path.join(chrome_root, 'tools', 'vim'))
49 from ninja_output import GetNinjaOutputDirectory 49 from ninja_output import GetNinjaOutputDirectory
50 return GetNinjaOutputDirectory(chrome_root, configuration) 50 return GetNinjaOutputDirectory(chrome_root)
51 51
52 def compute_ninja_command_for_current_buffer(configuration=None): 52 def compute_ninja_command_for_current_buffer():
53 """Returns the shell command to compile the file in the current buffer.""" 53 """Returns the shell command to compile the file in the current buffer."""
54 build_dir = path_to_build_dir(configuration) 54 build_dir = path_to_build_dir()
55 55
56 # ninja needs filepaths for the ^ syntax to be relative to the 56 # ninja needs filepaths for the ^ syntax to be relative to the
57 # build directory. 57 # build directory.
58 file_to_build = path_to_current_buffer() 58 file_to_build = path_to_current_buffer()
59 file_to_build = os.path.relpath(file_to_build, build_dir) 59 file_to_build = os.path.relpath(file_to_build, build_dir)
60 60
61 build_cmd = ' '.join(['ninja', '-C', build_dir, file_to_build + '^']) 61 build_cmd = ' '.join(['ninja', '-C', build_dir, file_to_build + '^'])
62 if sys.platform == 'win32': 62 if sys.platform == 'win32':
63 # Escape \ for Vim, and ^ for both Vim and shell. 63 # Escape \ for Vim, and ^ for both Vim and shell.
64 build_cmd = build_cmd.replace('\\', '\\\\').replace('^', '^^^^') 64 build_cmd = build_cmd.replace('\\', '\\\\').replace('^', '^^^^')
65 vim.command('return "%s"' % build_cmd) 65 vim.command('return "%s"' % build_cmd)
66 66
67 67
68 def compute_ninja_command_for_targets(targets='', configuration=None): 68 def compute_ninja_command_for_targets(targets=''):
69 build_cmd = ' '.join(['ninja', '-C', path_to_build_dir(configuration), 69 build_cmd = ' '.join(['ninja', '-C', path_to_build_dir(),
70 targets]) 70 targets])
71 vim.command('return "%s"' % build_cmd) 71 vim.command('return "%s"' % build_cmd)
72 endpython 72 endpython
73 73
74 fun! s:MakeWithCustomCommand(build_cmd) 74 fun! s:MakeWithCustomCommand(build_cmd)
75 let l:oldmakepgr = &makeprg 75 let l:oldmakepgr = &makeprg
76 let &makeprg=a:build_cmd 76 let &makeprg=a:build_cmd
77 if exists(':Make') == 2 77 if exists(':Make') == 2
78 Make 78 Make
79 else 79 else
(...skipping 30 matching lines...) Expand all
110 110
111 if has('mac') 111 if has('mac')
112 map <D-k> :CrCompileFile<cr> 112 map <D-k> :CrCompileFile<cr>
113 imap <D-k> <esc>:CrCompileFile<cr> 113 imap <D-k> <esc>:CrCompileFile<cr>
114 elseif has('win32') 114 elseif has('win32')
115 map <C-F7> :CrCompileFile<cr> 115 map <C-F7> :CrCompileFile<cr>
116 imap <C-F7> <esc>:CrCompileFile<cr> 116 imap <C-F7> <esc>:CrCompileFile<cr>
117 elseif has('unix') 117 elseif has('unix')
118 map <Leader>o :CrCompileFile<cr> 118 map <Leader>o :CrCompileFile<cr>
119 endif 119 endif
OLDNEW
« no previous file with comments | « no previous file | tools/vim/ninja_output.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698