您的位置:首页 > 其它

为VC系统头文件生成tags

2012-08-30 22:15 169 查看
@echo off
rem 用法:把些文件命名为vctag.bat,放在系统目录下,在命令行中运行vctag filename
rem 功能:本批处理是针对VC编写的。为filename的include树中的所有文件,在当前目录,生成tags文件,方便其它编辑器(如VIM)使用。
rem 备注:此文件依赖于CTAGS工具和VC编译器。ctags官网http://ctags.sourceforge.net;VC方面,需要手动指定编译器环境配置文件,即下面的vcvarsall.bat文件
rem       如果当前目录已经存在tags文件,则把头文件的tags附加到原有tags中,否则为filename生成tags,再附加

if "%1"=="" (
goto errorL
)

rem 配置环境变量,不一定相同,用户根据自己情况手动指定批处理文件
call "C:\Program Files\Microsoft Visual Studio 9.0\VC\vcvarsall.bat" x86

cd /d %~dp1
rem del /Q /S tags 1>nul 2>nul

if not exist "tags" (
call ctags %1
)

setlocal enabledelayedexpansion 

for /f "tokens=3,4 delims=:" %%i in ('cl /Zs /nologo /showIncludes %1') do (

set "str=%%i:%%j"

rem 清除路径前面的空格
for /f "tokens=1* delims= " %%i in ("!str!") do (
set "str=%%i %%j"
)

rem 如果使用start替换call,会出现多进程同步问题,所以用call 
call ctags --append=yes "!str!" 

)

goto end

:errorL
echo Source file lose! 
echo Usage: vctag filename
:end


GVIM下的用法:

用GVIM打开你要处理的源文件,再运行:!vctag %
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: