欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

gnu global创建索引文件时排除某些目录

程序员文章站 2022-07-14 13:15:16
...

软件主页:https://www.gnu.org/software/global/

GNU Global is a source code tagging system that works the same way across diverse environments, such as Emacs editor, Vi editor, Less viewer, Bash shell, various web browsers, etc.

通常来说,安装完gnu global后,进入代码工程的一级目录,执行gtags,就会生成tag索引文件。

如果我们想要排除某些目录下的文件,例如对于linux的源码工程,arch目录下不感兴趣的CPU架构类型,sound,tools目录等等排除后,可以减小索引文件的体积,使用时也会更加快捷,那么,怎么才能排除某些目录呢?

 

在代码工程的一级目录下新建文件 gtags.conf,按照如下格式编辑其内容:

default:\
common:\
:skip=/arch/m68k/: \
:skip=/arch/powerpc/: \
:skip=/sound/: \
:skip=/tools/:

这样,再执行gtags命令生成索引文件时,就会跳过 linux/arch/下m68k和powerpc目录,一级linux/下的sound和tools目录。把每个要排除的目录都写在单独的一行是为了方便修改。也可以合在一起。

参考:

skip (comma separated list)

Gtags skips files and directories which are given in this list. As a special exception, gtags collects values from multiple skip variables. If the value ends with ´/´, it is assumed as a directory and gtags skips all files under it. The value may include glob patterns (*, ?, [...], [!...], [^...]).

If the value starts with ´/´, it is assumed a relative path name from the root directory of the project. You cannot use glob patterns for a path name. However, this direction is out-of-date, and is not recommended. Instead, you can use -f option which can be combined with find(1). Since find(1) has rich options to select files, you can do everything. Additionally, this technique can also be applied to any other tagging systems like ctags(1)cscope(1), etc.