生成cscope.out的bash脚本
来源:互联网 发布:mac的照片如何导出ipad 编辑:程序博客网 时间:2024/06/08 12:26
生成cscope.out的bash脚本,接收两个参数,第一个是源文件路径,第二个是存放cscope.out文件的目录名。
修改和make_find_arg()里面的FILETYPES和FILENAMES数组,就可以修改和增删cscope需要解析的文件。
########################################################################## File Name: makescope.sh# Author: tintinr# mail: tintinr@gmail.com# Created Time: 日 8/ 4 10:51:38 2013##########################################################################!/bin/bashmake_find_arg(){# 文件类型,如*.cFILETYPES=("c" "cc" "cpp" "h" "mk" 'sh' "java" "S")# 文件名,如MakefileFILENAMES=("Makefile" "makefile")for each_file_type in ${FILETYPES[@]}doif [ -n "$find_arg" ]thensingle_find_arg=" -o "elsesingle_find_arg=""fisingle_find_arg+="-name \"*." single_find_arg+=$each_file_typesingle_find_arg+="\" "find_arg+=$single_find_argdonefor each_file in ${FILENAMES[@]}dosingle_find_arg=" -o -name \""single_find_arg+=$each_filesingle_find_arg+="\" "find_arg+=$single_find_argdone}usage(){echo "Usage: makescope src_path project_name"echo "==src_path: source root path"echo "==project_name: cscope db will be stored in ~/cscope/project_name/ dir"}if [ $# -ne 2 ]thenusagereturn -1fisrc_path=$1project_path=~/cscope/$2current_dir=$(PWD)mkdir -p $project_pathcd $project_pathfind_arg=""make_find_argecho "find" $src_path " " $find_argfind_str="find "find_str+=$src_pathfind_str+=" "find_str+=$find_argeval $find_str > cscope.filescscope -bkq -i cscope.filescd $current_dir
功能虽然实现了,但是看上去有些丑,重构之:
########################################################################## File Name: makescope.sh# Author: tintinr# mail: tintinr@gmail.com# Created Time: 日 8/ 4 10:51:38 2013##########################################################################!/bin/bashmake_find_name_arg(){file_prefix=$1declare -a file_types=("${!2}")for each_file in ${file_types[@]}doif [ -n "$find_arg" ]thensingle_find_arg="-o "elsesingle_find_arg=""fisingle_find_arg+="-name \""single_find_arg+=$file_prefixsingle_find_arg+=$each_filesingle_find_arg+="\" "find_arg+=$single_find_argdone}make_find_arg(){# 文件类型,如*.clocal FILETYPES=("c" "cc" "cpp" "h" "mk" 'sh' "java" "S")# 文件名,如Makefilelocal FILENAMES=("Makefile" "makefile")make_find_name_arg "*." FILETYPES[@]make_find_name_arg "" FILENAMES[@]}build_ecsope_file(){find_arg=""make_find_arg#echo "find" $src_path " " $find_argfind_str="find "find_str+=$src_pathfind_str+=" "find_str+=$find_argeval $find_str > cscope.files}usage(){echo "Usage: makescope src_path project_name"echo "==src_path: source root path"echo "==project_name: cscope db will be stored in ~/cscope/project_name/ dir"}main(){current_dir=$(PWD)mkdir -p $project_pathcd $project_pathbuild_ecsope_filecscope -bkq -i cscope.filescd $current_dir}if [ $# -ne 2 ]thenusagereturn -1fisrc_path=$1project_path=~/cscope/$2main
在脚本验证过程中,貌似发现cscope两个限制:
1、文件名长度限制:最长只支持250个字符。
2、重复文件名的文件解析会失败。
- 生成cscope.out的bash脚本
- 公布生成cscope.out, cscope.files, tags的脚本文件
- 简单脚本生成cscope.out和LookupFile所用tag文件
- cscope数据库生成脚本
- [python]生成cscope符号索引文件的脚本
- vimrc添加cscope.out
- bash脚本的坑!
- bash脚本的坑
- 生成cscope、ctags的索引文件
- bash: ./a.out: Permission denied的问题
- vim自动加载cscope.out
- 编写高效的bash脚本
- 写出健壮的 Bash 脚本
- 写出健壮的Bash脚本
- 写出健壮的Bash脚本
- 写出健壮的Bash脚本
- 写出健壮的Bash脚本
- 写出健壮的Bash脚本
- 传智播客学习日记Day9
- iOS: NSString的方法rangeOfCharacterFromSet:options:
- ASP.NET中的ExecuteNonQuery()方法的用法
- 排序算法c语言描述---冒泡排序
- iOS: NSString的方法rangeOfCharacterFromSet:options:range:
- 生成cscope.out的bash脚本
- Unable to add window -- token null is not for an application
- coco2d-x 2.0 + 版本设置竖屏
- Junit测试详解
- pkg-config学习
- 华为上机之四
- HP服务器更换主板前后的注意事项
- OpenStack Folsm版 Quantum 插件(Plugin)功能对比
- VC 组合框重绘大全 效果图(附下载链接)