sl@0: @rem sl@0: @rem Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: @rem All rights reserved. sl@0: @rem This component and the accompanying materials are made available sl@0: @rem under the terms of the License "Eclipse Public License v1.0" sl@0: @rem which accompanies this distribution, and is available sl@0: @rem at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: @rem sl@0: @rem Initial Contributors: sl@0: @rem Nokia Corporation - initial contribution. sl@0: @rem sl@0: @rem Contributors: sl@0: @rem sl@0: @rem Description: sl@0: @rem sl@0: sl@0: @perl -x check.bat sl@0: @goto end sl@0: #!perl sl@0: sl@0: require Cwd; sl@0: $cwd=Cwd::getcwd(); sl@0: #print "cwd: ",$cwd,"\n"; sl@0: $cwd =~ s/\//\\/; sl@0: $cwd =~ /^(\w:)?([\\|\/]\S+[\\|\/])/isx; sl@0: $drive=$1; sl@0: $prjroot=$2; sl@0: #print "drive ",$drive,"\n"; sl@0: #print "project root: ",$prjroot,"\n"; sl@0: @cpps=(); sl@0: @mmps=(); sl@0: @mmpflags=(); sl@0: %sources=(); sl@0: %sourceusers=(); sl@0: ls ($prjroot); sl@0: #print "CPP files:\n"; sl@0: #foreach $entry (@cpps) sl@0: # { sl@0: # print $entry,"\n"; sl@0: # } sl@0: #print "MMP files:\n"; sl@0: $count=0; sl@0: $countz=0; sl@0: $countsrc=0; sl@0: foreach $entry (@mmps) sl@0: { sl@0: # print $entry,"\n"; sl@0: $srclist=$sources{$entry}; sl@0: $mmpflags[$count]=0; sl@0: ++$count; sl@0: ++$countz if (scalar(@$srclist)==0); sl@0: $countsrc += scalar(@$srclist); sl@0: foreach $src (@$srclist) sl@0: { sl@0: $uselist=$sourceusers{$src}; sl@0: $sourceusers{$src}=$uselist." ".$entry; sl@0: # print "\t",$src,"\n"; sl@0: } sl@0: } sl@0: $hashsize=scalar(%sources); sl@0: #print $hashsize; sl@0: #print "Count=",$count,"\n"; sl@0: #print "CountZ=",$countz,"\n"; sl@0: #print "CountSrc=",$countsrc,"\n"; sl@0: sl@0: foreach $entry (@cpps) sl@0: { sl@0: $uses=$sourceusers{$entry}; sl@0: print "File ",$entry," not referenced by any .MMP file\n" unless $uses; sl@0: } sl@0: sl@0: parsebldinf(); sl@0: sl@0: $i=0; sl@0: foreach $entry (@mmps) sl@0: { sl@0: next if $mmpflags[$i++]; sl@0: print "\n",$entry,".MMP does not appear in BLD.INF\n"; sl@0: print "\t Source files:\n"; sl@0: $srclist=$sources{$entry}; sl@0: foreach $src (@$srclist) sl@0: { sl@0: print "\t",$src,"\n"; sl@0: } sl@0: } sl@0: end; sl@0: sl@0: sub ls sl@0: { sl@0: my $dir=@_[0]; sl@0: $dir =~ s/\//\\/; sl@0: # print $dir,"\n"; sl@0: opendir(DIR,$dir); sl@0: my @dir=readdir(DIR); sl@0: closedir(DIR); sl@0: my $entry; sl@0: my $fullentry; sl@0: foreach $entry (@dir) sl@0: { sl@0: $entry=~s/\//\\/; sl@0: next if (($entry eq ".") or ($entry eq "..")); sl@0: $fullentry=$dir.$entry; sl@0: if (-d $fullentry) sl@0: { sl@0: ls($fullentry."\\"); sl@0: } sl@0: else sl@0: { sl@0: push @cpps, uc($fullentry) if ($entry =~ /\S+\.cpp/isx); sl@0: if ($entry =~ /(\S+)\.mmp/isx) sl@0: { sl@0: push @mmps, uc($1); sl@0: parsemmp($fullentry,\%sources); sl@0: } sl@0: # print $fullentry,"\n"; sl@0: } sl@0: } sl@0: } sl@0: sl@0: sub parsemmp sl@0: { sl@0: my $mmpfile=@_[0]; sl@0: my $array=@_[1]; sl@0: my $project; sl@0: my $subproject; sl@0: # print "ParseMMP ",$mmpfile,"\n"; sl@0: open(MMP,$mmpfile); sl@0: my @sources=(); sl@0: while() sl@0: { sl@0: if (/^PROJECT\s+(\S+)/isx) sl@0: { sl@0: $project=uc($1); sl@0: # print "Project ",$project,"\n"; sl@0: } sl@0: elsif (/^SUBPROJECT\s+(\S+)/isx) sl@0: { sl@0: $subproject=uc($1); sl@0: # print "Subproject ",$subproject,"\n"; sl@0: } sl@0: elsif (/^source\s*(.+)/isx) sl@0: { sl@0: # print $1; sl@0: my $list=$1; sl@0: while($list) sl@0: { sl@0: $list =~ /^(\S+)\s*(.*)/isx; sl@0: push @sources, "\\".$project."\\".$subproject."\\".uc($1); sl@0: $list=$2; sl@0: # print "\t Source ",$1,"\n"; sl@0: } sl@0: } sl@0: } sl@0: close(MMP); sl@0: $mmpfile =~ /\S*\\(\S+)\.mmp/isx; sl@0: $mmpfileshort=uc($1); sl@0: $$array{$mmpfileshort}=\@sources; sl@0: } sl@0: sl@0: sub parsebldinf sl@0: { sl@0: my $reachedmmps=0; sl@0: open(BLDINF,"bld.inf"); sl@0: while () sl@0: { sl@0: # print; sl@0: if ($reachedmmps==0) sl@0: { sl@0: $reachedmmps=1 if (/PRJ_MMPFILES|PRJ_TESTMMPFILES/isx); sl@0: next; sl@0: } sl@0: /(\S+)\s*.*/isx; sl@0: my $mmpfile=uc($1); sl@0: # print "****************",$mmpfile,"\n"; sl@0: my $mmp; sl@0: my $i=0; sl@0: foreach $mmp (@mmps) sl@0: { sl@0: $mmpflags[$i]=1 if ($mmp eq $mmpfile); sl@0: ++$i; sl@0: } sl@0: } sl@0: close(BLDINF); sl@0: } sl@0: sl@0: __END__ sl@0: :end