Win7系統上GVim為cscope增加數據庫文件的bat文件--記錄
::此.bat文件使用方法: 在Win7系統的cmd.exe環境下輸入,xxx.bat Path:\xxx\yyy\zzz GVIMx 0/1,其中第二個參數是源代碼路徑,第三個參數是已打開的GVim的實例
::(且是空的,沒有打開任何目錄及文件),比如GVIM,GVIM1,GVIM2等;第四個參數控制是否在GVim實例中打開源代碼根目錄
@echo off
@echo "Update %1 cscope database..."
::下述命令是為了不改變執行此.bat的cmd.exe的系統PATH變量值
setlocal
::路徑c:\cygwin64\bin是為了使用下面的find命令,即linux下的find命令;放在%SYSTEMROOT%\System32前面
::是為了不使用Window下的find命令(Window下的find命令幹什麽用沒有細究)
set PATH=D:\Program Files (x86)\Vim\vim81;C:\cygwin64\bin;%SYSTEMROOT%\System32
cd /d %1
@echo "clean ..."
if exist cscope.out del cscope.out
if exist tags del tags
if exist cscope.file del cscope.file
@echo "ctags ..."
::ctags.exe在D:\Program Files (x86)\Vim\vim81路徑下
ctags -R *
@echo "cscope ..."
if not exist cscope.file ( @ echo "Generating cscope.file ... find ./ -name "*.c" -or -iname "*.s" -or -name "*.h"> cscope.file)
::cscope.exe在D:\Program Files (x86)\Vim\vim81路徑下
cscope -Rbk -i cscope.file
@echo "Send cmd to %2 ..."
if %3 == 1 (vim --servername %2 --remote-send "<C-\><C-N>:Explore %1<CR>")
::vim.exe在D:\Program Files (x86)\Vim\vim81路徑下,可用vim --help來查看如何使用
::DisconnectCscope()是定義在GVim啟動文件中的函數(在D:\Program Files (x86)\Vim\vim81\_vimrc文件中)
vim --servername %2 --remote-expr "DisconnectCscope()"
copy %1\cscope.out %1\cscope_bak.out
vim --servername %2 --remote-expr "<C-\><C-N>:cs add %1\cscope_bak.out<CR>"
endlocal
cd /d D:\
@echo "OK!"
@echo on
以下是DisconnectCscope()的定義:
function DisconnectCscope()
cs kill -1
endfunction
Win7系統上GVim為cscope增加數據庫文件的bat文件--記錄