上篇文章:【vim 学习系列文章 4 - vim与系统剪切板之间的交互】
下篇文章:【vim 学习系列文章 6 – vim 如何从上次退出的位置打开文件】文章来源地址https://www.toymoban.com/news/detail-662697.html
cscope 过滤目录介绍
第一步创建自己的cscope脚本~/.local/bin/cscope.sh
,如下:
function my_cscope()
{
CODE_PATH=`pwd`
echo "$CODE_PATH"
echo "start cscope...."
if [ ! -f "$CODE_PATH/cscope.files" ];then
echo "cscope.files not exist!"
else
rm -f $CODE_PATH/cscope.*
fi
if [ ! -d "$CODE_PATH/rt-thread" ];then
find . \( -path './arch/arc' \
-o -path './arch/alpha' \
-o -path "./arch/blackfin" \
-o -path "./arch/cris" \
-o -path "./arch/h8300" \
-o -path "./arch/ia64" \
-o -path "./arch/m68k" \
-o -path "./arch/microblaze" \
-o -path "./arch/mn10300" \
-o -path "./arch/openrisc" \
-o -path "./arch/powerpc" \
-o -path "./arch/score" \
-o -path "./arch/sparc" \
-o -path "./arch/um" \
-o -path "./arch/x86" \
-o -path "./arch/c6x" \
-o -path "./arch/m32r" \
-o -path "./arch/microblaze" \
-o -path "./arch/nios2" \
-o -path "./arch/powerpc" \
-o -path "./arch/sh" \
-o -path "./arch/um" \
-o -path "./arch/xtensa" \
-o -path "./arch/cris" \
-o -path "./arch/hexagon" \
-o -path "./arch/mips" \
-o -path "./arch/openrisc" \
-o -path "./arch/s390" \
-o -path "./arch/sparc" \
-o -path "./arch/unicore32" \
-o -path "./arch/parisc" \
-o -path "./arch/tile" \
-o -path "./arch/tile" \
-o -path './arch/c6x' \) \
-prune -o -name "*.[chxsS]" -print > cscope.files
else
find . \( -path "./rtos/rt-thread/rt-thread/bsp/mb9*" \
-o -path "./rtos/rt-thread/rt-thread/bsp/at91*" \
-o -path "./rtos/rt-thread/rt-thread/bsp/ess*" \
-o -path "./rtos/rt-thread/rt-thread/bsp/gd3*" \
-o -path "./rtos/rt-thread/rt-thread/bsp/lpc*" \
-o -path "./rtos/rt-thread/rt-thread/bsp/ls*" \
-o -path "./rtos/rt-thread/rt-thread/bsp/mi*" \
-o -path "./rtos/rt-thread/rt-thread/bsp/imx*" \
-o -path "./rtos/rt-thread/rt-thread/bsp/rasp*" \
-o -path "./rtos/rt-thread/packages/packages/iot/*" \
-o -path "./rtos/rt-thread/rt-thread/bsp/stm32/stm32f*" \
-o -path "./bootrom" \
-o -path "./u-boot" \
-o -path "./tools" \) \
-prune -name "*.cc" -o -name "*.[chxsS]" \
-print > cscope.files
fi
echo "cscope -Rbkq -i cscope.files"
cscope -Rbkq -i $PWD/cscope.files > cscope.log 2>&1
echo "cscope finished"
}
my_cscope;
我的这个脚本首先去区分当前执行cscope
命令的目录是rt-thread
目录还是linux
目录,因为不同的代码要过滤过目录不一样。
此外,还会通过 重定向 将cscope
在解析文件cscope.files
过程中输出的log
重定向到 cscope.log
方便问题问题。关于 find 命令的使用见 find 命令高效使用文章
第二步在 ~/.bashrc
中添加 mycscope 命令,添加完后,别忘记执行 source ~/.bashrc
。
alias mycscope='source ~/.local/bin/cscope.sh'
第三部测试效果:
(*^~^*) ~/workbase/cix_linux/linux> mycscope
/home/sam/workbase/linux
start cscope....
cscope -Rbkq -i cscope.files
cscope finished
(*^~^*) ~/workbase/cix_linux/linux> ls
arch COPYING cscope.files cscope.out drivers init Kconfig LICENSES mm samples sound virt
block CREDITS cscope.in.out cscope.po.out fs ipc kernel MAINTAINERS net scripts tools
certs crypto cscope.log Documentation include Kbuild lib Makefile README security usr
从下图中可以看到通过cscope命令查找 函数定义定义时只显示了linux/arch 目录下的几个文件,滤除了上文中设置的那些目录:
文章来源:https://www.toymoban.com/news/detail-662697.html
上篇文章:【vim 学习系列文章 4 - vim与系统剪切板之间的交互】
下篇文章:【vim 学习系列文章 6 – vim 如何从上次退出的位置打开文件】
到了这里,关于【vim 学习系列文章 5 - cscope 过滤掉某些目录】的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!