Skip to content

Commit

Permalink
Updated vim ide script.
Browse files Browse the repository at this point in the history
  • Loading branch information
dariomanesku committed Jun 25, 2015
1 parent 7f36375 commit 52bb3c8
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 22 deletions.
39 changes: 30 additions & 9 deletions .ide.vim
Original file line number Diff line number Diff line change
@@ -1,26 +1,38 @@
"
" Copyright 2015 Dario Manesku. All rights reserved.
" License: http://www.opensource.org/licenses/BSD-2-Clause
"

" Run vim as 'vim --servername VIM'.

if has("unix")
set makeprg=make

let s:proj_root = expand("<sfile>:p:h")
let s:log_file = s:proj_root."/make.log"
let s:make_action = "linux-debug64"
let s:exec_action = "!../_build/linux64_gcc/bin/cmftDebug"
let s:proj_name = "cmft"
let s:proj_root = expand("<sfile>:p:h")
let s:makebg_file = s:proj_root."/.makebg.sh"
let s:log_file = s:proj_root."/make.log"

let s:exec_action = "!../_build/linux64_gcc/bin/".s:proj_name."Debug"
let s:gdb_action = "!gdb -x ".s:proj_root."/.gdbinit"." --args ../_build/linux64_gcc/bin/".s:proj_name."Debug"

let s:make_action = "linux-debug64"

function! SetDebug()
let s:make_action = "linux-debug64"
let s:exec_action = "!../_build/linux64_gcc/bin/cmftDebug"
let s:exec_action = "!../_build/linux64_gcc/bin/".s:proj_name."Debug"
endfunc
command! -nargs=0 SetDebug :call SetDebug()

function! SetRelease()
let s:make_action = "linux-release64"
let s:exec_action = "!../_build/linux64_gcc/bin/cmftRelease"
let s:exec_action = "!../_build/linux64_gcc/bin/".s:proj_name."Release"
endfunc
command! -nargs=0 SetRelease :call SetRelease()

function! Build()
let s:make_command = "make ".s:proj_root." ".s:make_action
let s:build_action = "!".s:proj_root."/.makebg.sh ".v:servername." \"".s:make_command."\" ".s:log_file
let s:build_action = "!".s:makebg_file." ".v:servername." \"".s:make_command."\" ".s:log_file
let curr_dir = getcwd()
exec 'cd' s:proj_root
exec s:build_action
Expand All @@ -35,7 +47,16 @@ if has("unix")
exec 'cd' curr_dir
endfunc

nmap ,rr :call Build()<cr><cr>
nmap ,ee :call Execute()<cr>
function! DebugGdb()
let s:runtime_dir = s:proj_root."/runtime"
let curr_dir = getcwd()
exec 'cd' s:runtime_dir
exec s:gdb_action
exec 'cd' curr_dir
endfunc

nmap ,rr :call Build()<cr><cr>
nmap ,ee :call Execute()<cr>
nmap ,gdb :call DebugGdb()<cr>
endif
19 changes: 6 additions & 13 deletions .makebg.sh
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
#!/bin/sh
# Use: .makebg.sh VIMSERVERNAME MAKEPRG LOGFILE TEMPFILE
# Save this file as: ~/.vim/makebg.sh
# Make a vim script in the project root dir as folowing:
#
# let proj_root = expand("<sfile>:p:h")
# let build_target = "linux-gcc-example01"
# let log_file = proj_root."/make.log"
# let make_command = "make -R -C ".proj_root." ".build_target"
# let app_path = proj_root."/build/linux-gmake-gcc/x64-Debug/bin/example01"
# nmap ,rr :w<cr>:execute "!~/.vim/makebg.sh " .v:servername. " \"".make_command."\" ".log_file<cr><cr>
# nmap ,ee :w<cr>:execute "!~/.vim/makerunbg.sh ".v:servername." \"".make_command."\" ".log_file. " ".app_path<cr><cr>
# Copyright 2015 Dario Manesku. All rights reserved.
# License: http://www.opensource.org/licenses/BSD-2-Clause
#

# Use as: .makebg.sh VIMSERVERNAME MAKEPRG LOGFILE TEMPFILE

server="${1:-VIM}"
makeprg="${2:-make}"
Expand All @@ -28,15 +23,13 @@ tempfile="${4:-.make.tmp}"
success=$?
exec 3>&1
sed -i 's/In file included from //' $tempfile
# sed -i '/\[.*\]/d' $tempfile;
# $makeprg 2>&1 | sed -e's/In file included from //' | sed -e'/make.*/d' >> "$tempfile";

cat "$logfile" >> "$tempfile"
mv "$tempfile" "$logfile";
vim --servername "$server" --remote-send "<Esc>:cgetfile $logfile<CR>" ;

if [ $success -eq 0 ]; then
vim --servername "$server" --remote-send "<Esc>:redraw | :echo \"Build sucessful.\"<CR>" ;
vim --servername "$server" --remote-send "<Esc>:redraw | :echo \"Build successful.\"<CR>" ;
else
vim --servername "$server" --remote-send "<Esc>:redraw | :echo \"Build ERROR!\"<CR>" ;
fi
Expand Down

0 comments on commit 52bb3c8

Please sign in to comment.