免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2148 | 回复: 0
打印 上一主题 下一主题

windows下用的cscope-indexer.exe [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2008-11-18 23:11 |只看该作者 |倒序浏览

                                在windows下装了emacs+ecb+cedet+cscope以后,唯一的问题是cscope-indexer是shell脚本,无法在windows下执行.这样就没办法主动生成cscope用的index文件了,虽然可以自己用find命令生成cscope.files,但非常不方便.很不爽
今天偶然在网上找到了一个cscope-indexer perl version
http://wenbinhome.blogspot.com/2008/09/cscope-indexer-perl-version.html
#!/usr/bin/perl -w
# cscope-indexer.pl ---
# Author: Ye Wenbin @gmail.com>
# 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} = "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了.
下面就是解决把perl脚本转成exe文件的方法
首先我们安装需要的模块,这里以 windows 平台下的 ActivePerl 为例
(Windows 下的最通用发行版本)。
打开 ppm,安装一下模块:
Parse-Binary, Win32-Exe, Module-ScanDeps, PAR-Dist, PAR, File-Temp.ppd
然后安装par-packer
[color="#993366"]ppm install http://www.bribes.org/perl/ppm/PAR-Packer.ppd
测试一下转换
使用你喜欢的编辑器,进行编辑:
#! /usr/bin/perl -w
use strict;
print "Hello,world!\n";
#:~
保存为 hello.pl。
接下来我们进行编译,在控制台下输入:
pp -o hello.exe hello.pl
好了,检查一下生成的 hello.exe 吧
同样的方法将cscope-indexer.pl转成cscope-indexer.exe,这样xcscope.el就可以完全正常使用了.
附件里是我现在用的cscope-indexer.pl文件,改了cscope-indexer和cscope的路径.
至此windows上的ecb+cscope配合得非常完美.

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

本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u1/44068/showart_1423133.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP