大凡具有一定规模的系统都会分为多个子系统和模块,对应于软件开发工具的工程。在系统开发过程中,我们经常
以下是相应的Perl脚本,该脚本只在VC6的工程管理文件上使用过,对于其他版本的工程文件或许不能有效使用。
#!/usr/bin/perl
use strict;
my %prj2libs;
my %outLib2Prj;
while( <> ) {
if( /<DIR>.*?(/w+)/ ) {
chdir $1;
my @files = <*.dsp>;
foreach my $file ( @files ) {
if($file =~ /(.*)/.dsp/) {
my $prj = $1;
#print "$prj/n";
my $startEx = "";
open DSPFILE,'<',$file;
while(<DSPFILE>) {
#print;
if( $startEx ) {
if( /^# ADD LINK32|^# ADD LIB32/ ) {
#print;
my @allWords = split;
my @allDepLibs = ();
foreach my $word ( @allWords ) {
if( $word =~ /([^]*)/.lib/ ) {
push @allDepLibs,"/U${1}";
}
}
$prj2libs{$prj} = /@allDepLibs;
#/out.*//(w+)/.lib|out.*//(w+)/.dll/;
if( ///out.*?//([^//]+)/.dll/ or ///out.*?//([^//]+)/.lib/ ) {
$outLib2Prj{"/U${1}"} = $prj;
}
last;
}
}elsif ( /^!ELSEIF.+Win32 Debug/ ) {
#print;
$startEx = "true";
}else {
next;
}
}
close DSPFILE;
}
}
chdir "..";
}
}
#foreach my $key ( sort keys %prj2libs ) {
# print "key is:/t",$key,"/n";
# print "prj is $key with", @{$prj2libs{$key}}," are depent!/n";
#}
my @allPrjs = sort keys %prj2libs;
my %prjDepPrjs;
#print "All the Projects:/t@allPrjs/n";
foreach my $prj ( @allPrjs ) {
#print "$prj/n";
my @depPrjs = ();
foreach my $depLib ( @{$prj2libs{$prj}} ) {
push @depPrjs, $outLib2Prj{$depLib} if( exists $outLib2Prj{$depLib} );
}
$prjDepPrjs{$prj} = /@depPrjs;
}
$, = " ";
foreach my $prj ( sort keys %prjDepPrjs ) {
print "$prj depends on prjs:/t", (sort @{$prjDepPrjs{$prj}}),"/n";
}
#foreach my $outLib ( sort keys %outLib2Prj ) {
# print "out lib of $outLib2Prj{$outLib} is $outLib/n";
#}
Windows上可以使用的Perl包括ActiveState(www.activestate.com)公司提供的ActivePerl以及cygwin中的Perl(http://sourceware.redhat.com/cygwin/)