为Boost生成合理的ctags数据库

发布于 2024-09-01 05:56:01 字数 1438 浏览 7 评论 0原文

我正在运行 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 邮件列表上遇到了这个:

Boost-users Boost 和自动完成< /a>

答案

感谢 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

半寸时光 2024-09-08 05:56:01

我知道这篇文章有点旧,但我刚刚遇到了同样的问题。我进一步研究了一下,似乎是 boost 中的一个文件夹导致了问题:typeof。我使用的是 boost 1.37,我的标签文件是 1.5G,typeof 是 1.4G。所以我只是创建了一个不包含该目录的标签文件,结果大小为 70M。我什至能够在没有空间不足的情况下对它进行排序:)我想在较新版本的 boost 中,它们可能是太大的其他项目,但是我发现的一般解决方案是这样......

  1. 为每个 boost 文件夹分别生成一个标记文件,一个简单的 bash for 循环应该能够做到这一点。
  2. 看看哪些太大了。
  3. 要么创建一个新的单个标记文件,排除那些大目录,要么将标记文件分开,只需删除太大的标记文件。

这是我使用的脚本(摘自评论):

for i in $(find -maxdepth 1 -type d | grep -v '^\.

希望这会有所帮助。

| sed 's/\.\///' ); do echo $i; ctags -f ~/tmp_tags/$i.tags -R --c++-kinds=+p --fields=+iaS --extra=+q --languages=c++ --sort=foldcase $i; done

希望这会有所帮助。

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...

  1. Generate a tag file for each boost folder seperately, a simple bash for loop should be able to do this.
  2. Look at which ones are too large.
  3. Either create a new single tags file excluding those large directories or keep the tag files separated simply deleting the ones that are too large.

This is the script I used (taken from comments):

for i in $(find -maxdepth 1 -type d | grep -v '^\.

Hope this helps.

| sed 's/\.\///' ); do echo $i; ctags -f ~/tmp_tags/$i.tags -R --c++-kinds=+p --fields=+iaS --extra=+q --languages=c++ --sort=foldcase $i; done

Hope this helps.

云巢 2024-09-08 05:56:01

使用选项

--sort=foldcase

这样标签的搜索就会变得更快。

引用 ctags 手册页
“foldcase 值指定不区分大小写(或大小写折叠)排序。使用大小写折叠排序的标记文件的快速二进制搜索需要使用标记文件的工具的特殊支持,例如 ctags readtags 库或 Vim 版本 6.2 中的工具或更高版本(使用“setignorecase”)。此选项必须出现在第一个文件名之前。

use the option

--sort=foldcase

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"

等数载,海棠开 2024-09-08 05:56:01

您应该将此选项添加到您的 ctags 调用中:

    -I "BOOST_SYMBOL_VISIBLE BOOST_SYMBOL_IMPORT BOOST_SYMBOL_EXPORT BOOST_FORCEINLINE BOOST_CONSTEXPR=constexpr BOOST_CONSTEXPR_OR_CONST=constexpr BOOST_STATIC_CONSTEXPR=static\ constexpr BOOST_STD_EXTENSION_NAMESPACE=std BOOST_MOVABLE_BUT_NOT_COPYABLE+ BOOST_COPYABLE_AND_MOVABLE+ BOOST_COPYABLE_AND_MOVABLE_ALT+ BOOST_NOEXCEPT=noexcept BOOST_NOEXCEPT_OR_NOTHROW=noexcept BOOST_NOEXCEPT_IF+ BOOST_NOEXCEPT_EXPR+ BOOST_STATIC_CONSTANT BOOST_DELETED_FUNCTION BOOST_DEFAULTED_FUNCTION BOOST_NESTED_TEMPLATE BOOST_UNREACHABLE_RETURN+ BOOST_DEDUCED_TYPENAME=typename BOOST_CTOR_TYPENAME=typename BOOST_LIKELY+ BOOST_UNLIKELY+ BOOST_ALIGNMENT+ BOOST_FALLTHROUGH"

这是我用于 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:

    -I "BOOST_SYMBOL_VISIBLE BOOST_SYMBOL_IMPORT BOOST_SYMBOL_EXPORT BOOST_FORCEINLINE BOOST_CONSTEXPR=constexpr BOOST_CONSTEXPR_OR_CONST=constexpr BOOST_STATIC_CONSTEXPR=static\ constexpr BOOST_STD_EXTENSION_NAMESPACE=std BOOST_MOVABLE_BUT_NOT_COPYABLE+ BOOST_COPYABLE_AND_MOVABLE+ BOOST_COPYABLE_AND_MOVABLE_ALT+ BOOST_NOEXCEPT=noexcept BOOST_NOEXCEPT_OR_NOTHROW=noexcept BOOST_NOEXCEPT_IF+ BOOST_NOEXCEPT_EXPR+ BOOST_STATIC_CONSTANT BOOST_DELETED_FUNCTION BOOST_DEFAULTED_FUNCTION BOOST_NESTED_TEMPLATE BOOST_UNREACHABLE_RETURN+ BOOST_DEDUCED_TYPENAME=typename BOOST_CTOR_TYPENAME=typename BOOST_LIKELY+ BOOST_UNLIKELY+ BOOST_ALIGNMENT+ BOOST_FALLTHROUGH"

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.

温暖的光 2024-09-08 05:56:01

因为生成的方法(例如,vector50.hpp、vector100.hpp ...)太多,所以 ctags 生成一个大标签文件

  1. find /usr/include ( -name ".h" -o -name ".hpp" ) boost/typeof > boost_files.txt
  2. 编辑 boost_files.txt 并删除 vector50.hpp、vector100.hpp、vector150.hpp、vector200.hpp
  3. ctags --c++-kinds=+px --fields=+iaS --extra=+q -f test.tags -L boost_files 。TXT

beacuse the methods generatored(eg. vector50.hpp vector100.hpp ...) is too much so that ctags generator a large tags file

  1. find /usr/include ( -name ".h" -o -name ".hpp" ) boost/typeof > boost_files.txt
  2. edit boost_files.txt and remove vector50.hpp vector100.hpp vector150.hpp vector200.hpp
  3. ctags --c++-kinds=+px --fields=+iaS --extra=+q -f test.tags -L boost_files.txt
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文