Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1235794
  • 博文数量: 264
  • 博客积分: 10772
  • 博客等级: 上将
  • 技术积分: 2325
  • 用 户 组: 普通用户
  • 注册时间: 2007-07-25 11:54
文章分类

全部博文(264)

文章存档

2012年(4)

2011年(51)

2010年(31)

2009年(57)

2008年(51)

2007年(70)

分类: C/C++

2009-01-01 15:21:24

文件:cscope-indexer.zip
大小:1360KB
下载:下载

用perl脚本转成.exe的,不知道使用的话需不需要perl环境
当然,路径中需要有grep和find命令,这个默认安装一下cygwin就可以了
有了这个就不用再手动生成cscope.files文件了

perl脚本是
# cscope-indexer.pl ---
# Author: Ye Wenbin
# Created: 10 Sep 2008
# Version: 0.01

use warnings;
use strict;
use Getopt::Long qw/:config pass_through/;
use File::Find;

# May have to edit this:
if ( $^O =~ /win/ ) {
   $ENV{PATH} = "$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 = <$DIR/*>;
}
@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;
}
阅读(1895) | 评论(0) | 转发(1) |
给主人留下些什么吧!~~