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

Unified Diff: tools/vim/ninja-build.vim

Issue 11090084: Add a CrBuild command to ninja-build.vim (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/vim/ninja-build.vim
diff --git a/tools/vim/ninja-build.vim b/tools/vim/ninja-build.vim
index af416b6d1710762661bd134f69b5d81ac62eba2a..044fccd041ea127d00edb8134bc9b4e5b134fb9d 100644
--- a/tools/vim/ninja-build.vim
+++ b/tools/vim/ninja-build.vim
@@ -56,7 +56,7 @@ def guess_configuration():
return configuration
-def compute_ninja_command(configuration=None):
+def compute_ninja_command_for_current_buffer(configuration=None):
"""Returns the shell command to compile the file in the current buffer."""
if not configuration: configuration = guess_configuration()
build_dir = os.path.join(path_to_source_root(), 'out', configuration)
@@ -70,11 +70,21 @@ def compute_ninja_command(configuration=None):
def set_makepgr_to_single_file_ninja():
- build_cmd = compute_ninja_command()
+ build_cmd = compute_ninja_command_for_current_buffer()
if sys.platform == 'win32':
# Escape \ for Vim, and ^ for both Vim and shell.
build_cmd = build_cmd.replace('\\', '\\\\').replace('^', '^^^^')
vim.command('let &makeprg=\'%s\'' % build_cmd)
+
+
+def compute_ninja_command_for_target(target='', configuration=None):
+ if not configuration: configuration = guess_configuration()
+ build_dir = os.path.join(path_to_source_root(), 'out', configuration)
+ return ' '.join(['ninja', '-C', build_dir, target])
+
+
+def set_makepgr_to_target_ninja(target=''):
+ vim.command('let &makeprg=\'%s\'' % compute_ninja_command_for_target(target))
endpython
fun! CrCompileFile()
@@ -87,7 +97,19 @@ fun! CrCompileFile()
let &makeprg = l:oldmakepgr
endfun
+fun! CrCompileTarget(...)
Nico 2012/10/15 22:41:35 This does more than just compiling. Maybe CrBuildT
enne (OOO) 2012/10/16 00:09:17 I have mixed feelings about default building chrom
+ let l:oldmakepgr = &makeprg
+ let l:target = a:0 > 0 ? a:1 : ''
+ python set_makepgr_to_target_ninja(vim.eval('l:target'))
+ silent make | cwindow
+ if !has('gui_running')
+ redraw!
+ endif
+ let &makeprg = l:oldmakepgr
+endfun
Nico 2012/10/15 22:41:35 Can you think of a way to not make this function l
enne (OOO) 2012/10/16 00:09:17 Yeah, yeah. I was optimizing for minimal vimscrip
+
command! CrCompileFile call CrCompileFile()
+command! -nargs=? CrCompileTarget call CrCompileTarget(<args>)
if has('mac')
map <D-k> :CrCompileFile<cr>
« 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