sbsv1/abld/test/mmpscan.pl
author lorewang
Wed, 17 Nov 2010 11:24:29 +0800
changeset 685 39f7ecf8fbc7
parent 599 fa7a3cc6effd
permissions -rw-r--r--
pull from trunk
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
599
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
     1
# Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
     2
# All rights reserved.
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
     3
# This component and the accompanying materials are made available
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
     4
# under the terms of "Eclipse Public License v1.0"
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
     5
# which accompanies this distribution, and is available
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
     6
# at the URL "http://www.eclipse.org/legal/epl-v10.html".
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
     7
#
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
     8
# Initial Contributors:
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
     9
# Nokia Corporation - initial contribution.
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    10
#
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    11
# Contributors:
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    12
#
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    13
# Description:
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    14
# Perl script to scan tree looking for MMP files with particular keywords
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    15
# 
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    16
#
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    17
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    18
use strict;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    19
use File::Find;			# for find()
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    20
use File::Basename;		# for fileparse()
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    21
use Cwd;				# for getcwd()
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    22
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    23
use Getopt::Long;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    24
my %Options=();
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    25
GetOptions(\%Options, "f=s");
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    26
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    27
my @patterns = (
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    28
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    29
'START\s+BITMAP.*\.MCL',
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    30
'START\s+BITMAP.*\.MBW',
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    31
'START\s+BITMAP',
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    32
'START\s+RESOURCE',
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    33
'ALWAYS_BUILD_AS_ARM',
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    34
'ASSPABI',
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    35
'ASSPEXPORTS',
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    36
'ASSPLIBRARY',
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    37
'CAPABILITY',
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    38
'COMPRESSTARGET',
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    39
'DEFFILE',
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    40
'DOCUMENT',
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    41
'EPOCALLOWDLLDATA',
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    42
'EPOCCALLDLLENTRYPOINTS',
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    43
'EPOCDATALINKADDRESS',
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    44
'EPOCFIXEDPROCESS',
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    45
'EPOCHEAPSIZE',
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    46
'EPOCPROCESSPRIORITY',
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    47
'EPOCSTACKSIZE',
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    48
'EXPORTLIBRARY',
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    49
'EXPORTUNFROZEN',
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    50
'FIRSTLIB',
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    51
'LANG',
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    52
# 'LIBRARY',
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    53
'DEBUGLIBRARY',
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    54
'LINKAS',
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    55
'MACRO\s+__SECURE_API__',
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    56
'MACRO',
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    57
'NOCOMPRESSTARGET',
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    58
'NOEXPORTLIBRARY',
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    59
'NOSTRICTDEF',
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    60
'OPTION',
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    61
'RAMTARGET',
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    62
'RESOURCE',
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    63
'ROMTARGET',
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    64
'SECUREID',
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    65
'SRCDBG',
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    66
# 'SOURCE',
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    67
# 'SOURCEPATH',
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    68
'STATICLIBRARY',
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    69
'STRICTDEPEND',
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    70
'SYSTEMINCLUDE',
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    71
'SYSTEMRESOURCE',
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    72
# 'TARGET',
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    73
'TARGETPATH',
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    74
'TARGETTYPE\s+ANI',
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    75
'TARGETTYPE\s+APP',
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    76
'TARGETTYPE\s+CTL',
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    77
'TARGETTYPE\s+DLL',
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    78
'TARGETTYPE\s+ECOMIIC',
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    79
'TARGETTYPE\s+EPOCEXE',
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    80
'TARGETTYPE\s+EXEDLL',
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    81
'TARGETTYPE\s+EXEXP',		# must precede TARGETTYPE EXE
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    82
'TARGETTYPE\s+EXE',
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    83
'TARGETTYPE\s+FSY',
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    84
'TARGETTYPE\s+IMPLIB',
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    85
'TARGETTYPE\s+KDLL',
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    86
'TARGETTYPE\s+KEXT',
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    87
'TARGETTYPE\s+KLIB',
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    88
'TARGETTYPE\s+LDD',
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    89
'TARGETTYPE\s+LIB',
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    90
'TARGETTYPE\s+MDA',
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    91
'TARGETTYPE\s+MDL',
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    92
'TARGETTYPE\s+NOTIFIER2',
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    93
'TARGETTYPE\s+NOTIFIER',
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    94
'TARGETTYPE\s+PDD',
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    95
'TARGETTYPE\s+PDL',
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    96
'TARGETTYPE\s+PLUGIN',
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    97
'TARGETTYPE\s+PLUGIN3',
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    98
'TARGETTYPE\s+RDL',
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    99
'TARGETTYPE\s+TEXTNOTIFIER2',
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   100
'TARGETTYPE\s+VAR',
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   101
'UID',
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   102
'USERINCLUDE',
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   103
'VENDORID',
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   104
'VERSION',
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   105
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   106
# from START WINS ... END
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   107
'START\s+WINS',
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   108
'BASEADDRESS',
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   109
'WIN32_LIBRARY',
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   110
'WIN32_RESOURCE',
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   111
'COPY_FOR_STATIC_LINKAGE',
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   112
'WIN32_HEADERS',
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   113
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   114
# count some unmatched things
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   115
'AIF',
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   116
'SOURCE\s.*\.CIA',			# CIA files
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   117
'TARGETTYPE\s+(other)?',	# a trick to catch unsupported targettypes
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   118
'TARGET\s.*DUMMY',			# who doesn't really want a TARGET
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   119
'#IF',
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   120
'#INCLUDE_FAILURE',			# unresolved #include directives
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   121
'#INCLUDE',
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   122
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   123
);
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   124
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   125
my %instances = ();
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   126
my %patternsbyfile = ();
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   127
my $mmpcount = 0;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   128
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   129
sub read_mmp($$$)
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   130
	{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   131
	my ($top,$name,$lines) =@_;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   132
	open MMP, "<$name" or print "error: $name $top\n" and return 0;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   133
	my @mmplines=<MMP>;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   134
	close MMP;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   135
	
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   136
	foreach my $line (@mmplines)
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   137
		{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   138
		push @$lines, $line;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   139
		if ($line =~/^\#include\s+(\"|\<)([^"<]+)(\"|\>)/)
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   140
			{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   141
			my $currentdir = getcwd();
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   142
			my $includename = $2;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   143
			if (-f $2)
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   144
				{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   145
				# name exists relative to current directory
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   146
				}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   147
			elsif (-f "$ENV{EPOCROOT}epoc32/include/$includename")
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   148
				{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   149
				$includename = "$ENV{EPOCROOT}epoc32/include/$includename";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   150
				}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   151
			else
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   152
				{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   153
				print "Can't locate $2 from $currentdir/$name $top\n";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   154
				push @$lines, "#INCLUDE_FAILURE";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   155
				next;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   156
				}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   157
			my ($newname, $newdir, $newext) = fileparse($includename, '\..*');
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   158
			chdir($newdir);
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   159
			read_mmp("from $name $top", "$newname$newext", $lines);
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   160
			chdir($currentdir);
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   161
			}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   162
		}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   163
	return 1;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   164
	}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   165
	
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   166
sub mmpgrep 
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   167
	{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   168
	my $fullname = $File::Find::name;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   169
	return if (defined($patternsbyfile{$fullname}));
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   170
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   171
	my ($name,$dir,$ext) = fileparse($fullname,'\..*');
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   172
	return unless (lc($ext) eq '.mmp');
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   173
	
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   174
	my %found = ();
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   175
	my @lines = ();
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   176
	return if (read_mmp("", "$name$ext", \@lines)==0);
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   177
	
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   178
	$mmpcount++;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   179
	my $line;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   180
	LINE: foreach $line (@lines)
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   181
		{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   182
		$line = uc $line;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   183
		foreach (@patterns)
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   184
			{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   185
			if ($line =~/^\s*$_/)
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   186
				{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   187
				$found{$_} = 1;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   188
				next LINE;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   189
				}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   190
			}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   191
		}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   192
	close MMP;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   193
	foreach (keys %found)
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   194
		{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   195
		@{$instances{$_}} = () if (!defined $instances{$_});
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   196
		push @{$instances{$_}}, $fullname;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   197
		}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   198
	@{$patternsbyfile{$fullname}} = sort keys %found;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   199
	}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   200
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   201
# Scan the tree, processing each filename with mmpgrep
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   202
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   203
my @scanlist = ();
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   204
if ($Options{f})
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   205
	{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   206
	open FILELIST, "<$Options{f}" or die "Cannot open $Options{f}\n";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   207
	my $line;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   208
	while ($line = <FILELIST>)
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   209
		{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   210
		$line =~ s/#.*$//;		# remove comments
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   211
		$line =~ s/\s*$//;		# remove trailing ws
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   212
		$line =~ s/^\s*//;		# remove leading ws
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   213
		next if ($line eq "");
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   214
		push @scanlist, $line;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   215
		}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   216
	close FILELIST;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   217
	}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   218
push @scanlist, @ARGV;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   219
find (\&mmpgrep,@scanlist);
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   220
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   221
# Report the results
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   222
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   223
print "$mmpcount mmp files processed\n";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   224
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   225
my $pattern;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   226
print "\nSummary by pattern\n";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   227
foreach $pattern (@patterns)
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   228
	{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   229
	my $count=0;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   230
	my $list = $instances{$pattern};
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   231
	$count = scalar @{$list} if (defined $list);
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   232
	printf "%-30s %5d\n", $pattern, $count;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   233
	}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   234
	
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   235
print "\nDetail\n";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   236
foreach $pattern (sort keys %instances)
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   237
	{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   238
	my $list = $instances{$pattern};
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   239
	my $title = $pattern;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   240
	$title =~ s/\\s\+/ /;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   241
	print "\n$title:\n";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   242
	foreach my $file (@{$list})
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   243
		{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   244
		print "  $file\n";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   245
		}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   246
	}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   247
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   248
foreach (sort keys %patternsbyfile)
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   249
	{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   250
	print "\n$_ :  ", join(" ",@{$patternsbyfile{$_}});
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   251
	}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   252
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   253
print "\n";