为Boost生成合理的ctags数据库
我正在运行 Ubuntu 8.04,并运行命令:
$ ctags -R --c++-kinds=+p --fields=+iaS --extra=+q -f ~/.vim/tags/stdlibcpp /usr/include/c++/4.2.4/
在我的系统上为标准 C++ 库和 STL ( libstdc++ ) 生成 ctags 数据库,以便与 OmniCppComplete vim 脚本。这给了我一个非常合理的 4MB 标签文件,它看起来工作得相当好。
然而,当我对已安装的 Boost 标头运行相同的命令时:
$ ctags -R --c++-kinds=+p --fields=+iaS --extra=+q -f ~/.vim/tags/boost /usr/include/boost/
我最终得到了一个 1.4 GB 标签文件! 我还没有尝试过,但这似乎太大了有用的。有没有办法为我安装的 Boost 标头获取更精简、更可用的标签文件?
编辑
需要注意的是,libstdc++ 包含 TR1,其中分配了 Boost 库。因此,libstdc++ 产生 4 MB 标签文件,而 Boost 最终产生 1.4 GB 标签文件,肯定发生了一些奇怪的事情。
刚刚在 Boost 邮件列表上遇到了这个:
答案
感谢 Neg_EV 找出问题所在,但是有比他建议的更好的方法来解决问题:
确保 apt-file 已安装,然后运行以下命令命令
(我将库标签保存在 ~/.vim/tags/ 中):
$ sudo apt-file update
$ apt-file list boost | grep -E -o '/usr/include/.*\.(h|hpp)' | grep -v '/usr/include/boost/typeof/' > ~/.vim/tags/boost-filelist
$ ctags --sort=foldcase --c++-kinds=+p --fields=+iaS --extra=+q -f ~/.vim/tags/boost -L ~/.vim/tags/boost-filelist
我已经升级到 Ubuntu 10.04 和 Boost 1.40,这就是我测试此解决方案的原因,但据我所知,它应该适用于任何 Boost 版本。
I'm running Ubuntu 8.04 and I ran the command:
$ ctags -R --c++-kinds=+p --fields=+iaS --extra=+q -f ~/.vim/tags/stdlibcpp /usr/include/c++/4.2.4/
to generate a ctags database for the standard C++ library and STL ( libstdc++ ) on my system for use with the OmniCppComplete vim script. This gave me a very reasonable 4MB tags file which seems to work fairly well.
However, when I ran the same command against the installed Boost headers:
$ ctags -R --c++-kinds=+p --fields=+iaS --extra=+q -f ~/.vim/tags/boost /usr/include/boost/
I ended up with a 1.4 GB tags file! I haven't tried it yet, but that seems likes it's going to be too large to be useful. Is there a way to get a slimmer, more usable tags file for my installed Boost headers?
Edit
Just as a note, libstdc++ includes TR1, which has allot of Boost libs in it. So there must be something weird going on for libstdc++ to come out with a 4 MB tags file and Boost to end up with a 1.4 GB tags file.
Just ran across this on the Boost mailing list:
Boost-users Boost and autocompletion
THE ANSWER
Thanks to Neg_EV for figuring out what the problem was, but there's a much better way of solving the problem than what he suggested:
Make sure apt-file is install, and run the following commands
( I keep my library tags in ~/.vim/tags/ ):
$ sudo apt-file update
$ apt-file list boost | grep -E -o '/usr/include/.*\.(h|hpp)' | grep -v '/usr/include/boost/typeof/' > ~/.vim/tags/boost-filelist
$ ctags --sort=foldcase --c++-kinds=+p --fields=+iaS --extra=+q -f ~/.vim/tags/boost -L ~/.vim/tags/boost-filelist
I've upgraded to Ubuntu 10.04 and Boost 1.40 and that's what I tested this solution on, but it should work with any Boost version as far as I can tell.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我知道这篇文章有点旧,但我刚刚遇到了同样的问题。我进一步研究了一下,似乎是 boost 中的一个文件夹导致了问题:typeof。我使用的是 boost 1.37,我的标签文件是 1.5G,typeof 是 1.4G。所以我只是创建了一个不包含该目录的标签文件,结果大小为 70M。我什至能够在没有空间不足的情况下对它进行排序:)我想在较新版本的 boost 中,它们可能是太大的其他项目,但是我发现的一般解决方案是这样......
这是我使用的脚本(摘自评论):
希望这会有所帮助。
I know this post is a little old, but I just ran into the same problem. I looked into it a little further and it seems it is one folder in boost that is causing the problem: typeof. I am using boost 1.37 and my tags file was 1.5G, typeof was 1.4G of that. So I just created a tags file without that directory included and the resulting size was 70M. I was even able to sort it without running out of space :) I imagine in newer versions of boost they may be other projects that are too large however the general solution I found is this...
This is the script I used (taken from comments):
Hope this helps.
使用选项
这样标签的搜索就会变得更快。
引用 ctags 手册页:
“foldcase 值指定不区分大小写(或大小写折叠)排序。使用大小写折叠排序的标记文件的快速二进制搜索需要使用标记文件的工具的特殊支持,例如 ctags readtags 库或 Vim 版本 6.2 中的工具或更高版本(使用“setignorecase”)。此选项必须出现在第一个文件名之前。
use the option
With this the searching of the tags becomes faster.
Quoting from the man page of ctags :
"The foldcase value specifies case insensitive (or case-folded) sorting. Fast binary searches of tag files sorted with case-folding will require special support from tools using tag files, such as that found in the ctags readtags library, or Vim version 6.2 or higher (using "set ignorecase"). This option must appear before the first file name"
您应该将此选项添加到您的 ctags 调用中:
这是我用于 Boost 1.55 的整个 /usr/include/boost 子目录的内容。我得到一个约 128MB 的标签文件。 -I 似乎是这里的关键,有助于过滤掉虚假标签的生成。
注意:我在 Ubuntu 14.04 上使用 ctags 5.9。我有一个特殊的 -I 用于为 C++ 标准头生成 ctags。我花了一段时间才弄清楚为什么有些头文件几乎不生成标签,而另一些头文件则生成大量标签。
You SHOULD add this option to your ctags invocation:
This is what I use for the ENTIRE /usr/include/boost subdirectory for Boost 1.55. I get a tags file that is ~128MB. The -I seems to be the key here and helps filter out spurious tag generation.
NOTE: I'm using ctags 5.9 on Ubuntu 14.04. I have a special -I for generating ctags for C++ standard headers. This took a while for me to figure out why some header files generated almost no tags while others generated enormous amounts of tags.
因为生成的方法(例如,vector50.hpp、vector100.hpp ...)太多,所以 ctags 生成一个大标签文件
beacuse the methods generatored(eg. vector50.hpp vector100.hpp ...) is too much so that ctags generator a large tags file