use warnings;
use strict;
use Getopt::Long qw/:config pass_through/;
use File::Find;
# May have to edit this:
if ( $^O =~ /win/ ) {
$ENV{PATH} = "d:\\Programs\\cygwin\\usr\\local\\bin;$ENV{PATH}";
}
else {
$ENV{PATH} = "/usr/local/bin:/sbin:/usr/sbin:/bin:/usr/bin:$ENV{PATH}";
}
my $LIST_ONLY;
my $DIR='.';
my $LIST_FILE='cscope.files';
my $DATABASE_FILE='cscope.out';
my $RECURSE;
my $VERBOSE;
GetOptions(
"file=s" => \$DATABASE_FILE,
"index=s" => \$LIST_FILE,
"list" => \$LIST_ONLY,
"recurse" => \$RECURSE,
"verbose" => \$VERBOSE,
);
$DIR = shift if @ARGV;
message("Creating list of files to index ...");
my @files;
if ( $RECURSE ) {
find( sub {
if ( -f $_ || -l $_ ) {
push @files, $File::Find::name;
}
}, $DIR);
} else {
@files = ;
}
@files = sort map {s{^\./}{}; $_} grep { /\.([chly](xx|pp)?|cc|hh)$/
&& $_ !~ m{/CVS/}
&& $_ !~ m{/RCS/}
} @files;
open(my $fh, ">", $LIST_FILE) or die "Can't create file $LIST_FILE: $!";
print {$fh} join("\n", @files), "\n";
close $fh;
message("Creating list of files to index ... done");
if ( $LIST_ONLY ) {
exit;
}
message("Indexing files ...");
system("cscope", "-b", "-i", $LIST_FILE, "-f", $DATABASE_FILE) == 0 or die "$!";
message("Indexing files ... done");
sub message {
print @_, "\n" if $VERBOSE;
}
-----------------------------------------------------------------
首先必须保证在PATH路径中能找到find和grep,也许还需要sed,总之是cscope-indexer里用到的命令,默认安装
一下cygwin就可以搞定了.
然后把上面的脚本编辑成cscope-indexer.pl执行(当然要安装ActivePerl,还有,要注意cscope-indexer.pl里
面的路径要正确,一个是cscope-indexer的路径,另外一个是cscope.exe的路径,最好的方法就是编辑完路径后执行一下,
直到看到cscope: no source files found就没问题了),
但xcscope.el还是认不到,不过如果把pl文件转成exe文件就完全成为windows下使用的cscope-indexer了.