大凡具有一定規模的系統都會分爲多個子系統和模塊,對應於軟件開發工具的工程。在系統開發過程中,我們經常
以下是相應的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/)