繁体   English   中英

符号链接文件的 cscope

[英]cscope for files which are symlinks

我有一个包含多个文件的源目录。 其中一些是指向其他文件的符号链接。

我创建了一个 cscope.files 文件。 但是当我执行 cscope. 它抱怨是符号链接的文件:

cscope: cannot find file /home/bla/source/file.cc

我认为这不是很好,但也许到 go 的正确方法是更改“查找”脚本,只写符号链接的目的地?

目前我正在使用:

# Write only the files which are NOT symlinks
find `pwd` \( \( -iname "*.c" -o -iname "*.cc" -o -iname "*.h" \) -and \( -not -type l \) \) -print > cscope.files
# Add the target of the symlink for all files matching the right extension, and are symlinks
find `pwd` \( \( -iname "*.c" -o -iname "*.cc" -o -iname "*.h" \) -and -type l \) -printf "%l\n"  >> cscope.files

但这似乎是一个可怕的解决方案。 还在寻找一个更好的

例如,如果您想要/作为cscope的路径,并希望cscope搜索扩展名为.c / .h / .x / .s / .S的文件,您可以将find命令作为:

find / -type f -name "*.[chxsS]" -print -exec readlink -f {} \;> cscope.files

这将包括常规文件,包括符号链接的目标。

我认为您可以使用该命令查找您搜索的文件夹中的所有真实路径

find -L [your searched folder] -name [your searched pattern] -exec realpath {} \; >> cscope.files

例如,如果我想将开发的文件夹和Linux内核头文件添加到cscope.files,我将使用以下命令:

find -L `pwd` -iname "*.c" -o -iname "*.h" > cscope.files
find -L /usr/src/linux-headers-3.19.0-15-generic/ -iname '*.h' -exec realpath {} \; >> cscope.files

我希望答案可以帮到你。

我只是执行以下操作以避免符号链接,并获取cscope.files中的绝对路径。 使用绝对路径,当cscope与vim编辑器集成时,您可以从沙箱中的任何目录进行搜索

find /"path-to-your-sandbox" -path .git -prune -o -name "*.[ch]"  -exec readlink -f {} \; > cscope.files

注意:如果从find中省略-print,则不会在cscope.files中仅将符号链接路径放在已解析的路径中。

在 bash 脚本中更好:

#!/bin/bash
#
# find_cscope_files.sh

extension_list=(c cpp cxx cc h hpp hxx hh)
for x in "${extension_list[@]}"; do
    find . -name "*.$x" -print -exec readlink -f {} \;
done

供我目前正在使用的其他人参考。

find "$(pwd)" \( -name "*.[chCS]" -o -name "*.[ch][ci]" -o -name "*.[ch]pp" -o -name "*.[ch]++" -o -name "*.[ch]xx" ) -not \( -ipath "*unittest*" -or -ipath "*regress*" \) \( \( -type l -xtype f -exec readlink -f {} \; \) -o \( -type f -print \) \) >cscope.files
cscope -q -R -b -i cscope.files

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM