releasing/cbrtools/perl/CheckBc.pm
author y4jin
Tue, 23 Nov 2010 14:07:04 +0800
changeset 705 67449e76cb84
parent 602 3145852acc89
permissions -rw-r--r--
Fix the illegal word scanned by sfchecksource tools
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
602
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     1
# Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     2
# All rights reserved.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     3
# This component and the accompanying materials are made available
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     4
# under the terms of the License "Eclipse Public License v1.0"
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     5
# which accompanies this distribution, and is available
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     6
# at the URL "http://www.eclipse.org/legal/epl-v10.html".
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     7
# 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     8
# Initial Contributors:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     9
# Nokia Corporation - initial contribution.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    10
# 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    11
# Contributors:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    12
# 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    13
# Description:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    14
# 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    15
#
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    16
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    17
use strict;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    18
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    19
package CheckBc;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    20
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    21
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    22
#
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    23
# Public.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    24
#
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    25
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    26
sub New {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    27
  my $pkg = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    28
  my $self = {};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    29
  bless $self, $pkg;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    30
  my $bldInfDir1 = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    31
  my $bldInfDir2 = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    32
  Utils::AbsoluteFileName(\$bldInfDir1);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    33
  Utils::AbsoluteFileName(\$bldInfDir2);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    34
  $self->{verbose} = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    35
  $self->{compName} = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    36
  $self->{additionalHeaders} = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    37
  $self->{additionalIncludePaths} = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    38
  my $ignoreClasses = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    39
  foreach my $thisClass (@$ignoreClasses) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    40
    $self->{ignoreClasses}->{$thisClass} = 1;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    41
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    42
  $self->{ignoreR3Unused} = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    43
  $self->{bldInf1} = BldInf->New($bldInfDir1, $self->{verbose});
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    44
  $self->{bldInf2} = BldInf->New($bldInfDir2, $self->{verbose});
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    45
  return $self;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    46
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    47
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    48
sub CheckAll {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    49
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    50
  my $passed = 1;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    51
  unless ($self->CheckDefFiles()) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    52
    $passed = 0;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    53
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    54
  unless ($self->CheckClassSizes()) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    55
    $passed = 0;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    56
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    57
  unless ($self->CheckVTables()) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    58
    $passed = 0;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    59
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    60
  return $passed;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    61
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    62
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    63
sub CheckDefFiles {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    64
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    65
  return $self->{bldInf1}->CheckDefFiles($self->{bldInf2}, $self->{ignoreR3Unused});
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    66
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    67
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    68
sub CheckClassSizes {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    69
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    70
  my $classSizes1 = $self->GetClassSizes($self->{bldInf1});
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    71
  my $classSizes2 = $self->GetClassSizes($self->{bldInf2});
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    72
  return $classSizes1->Check($classSizes2);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    73
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    74
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    75
sub CheckVTables {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    76
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    77
  my $vtable1 = $self->GetVTable($self->{bldInf1});
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    78
  my $vtable2 = $self->GetVTable($self->{bldInf2});
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    79
  return $vtable1->Check($vtable2);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    80
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    81
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    82
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    83
#
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    84
# Private.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    85
#
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    86
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    87
sub GetClassSizes {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    88
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    89
  my $bldInf = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    90
  my $constructorsToCheck = $self->GetConstructorsToCheck($bldInf->ListConstructors());
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    91
  my @headers;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    92
  if ($self->{additionalHeaders}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    93
    push (@headers, @{$self->{additionalHeaders}});
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    94
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    95
  foreach my $thisExport (@{$bldInf->ListExports()}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    96
    if ($thisExport =~ /\.h$/i) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    97
      push (@headers, $thisExport);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    98
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    99
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   100
  my $includes = $bldInf->ListIncludes();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   101
  if ($self->{additionalIncludePaths}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   102
    push (@$includes, @{$self->{additionalIncludePaths}});
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   103
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   104
  return ClassSize->New($constructorsToCheck, \@headers, $includes, $self->{verbose}, $self->{compName}, $bldInf->{dir});
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   105
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   106
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   107
sub GetVTable {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   108
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   109
  my $bldInf = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   110
  my $constructorsToCheck = $self->GetConstructorsToCheck($bldInf->ListConstructors());
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   111
  return VTable->New($bldInf->{dir}, $constructorsToCheck, $self->{verbose});
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   112
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   113
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   114
sub GetConstructorsToCheck {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   115
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   116
  my $constructors = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   117
  my @constructorsToCheck;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   118
  foreach my $thisConstructor (@$constructors) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   119
    unless (exists $self->{ignoreClasses}->{$thisConstructor}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   120
      push (@constructorsToCheck, $thisConstructor);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   121
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   122
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   123
  return \@constructorsToCheck;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   124
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   125
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   126
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   127
#
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   128
# BldInf
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   129
#
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   130
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   131
package BldInf;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   132
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   133
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   134
#
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   135
# Public.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   136
#
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   137
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   138
sub New {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   139
  my $pkg = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   140
  my $self = {};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   141
  bless $self, $pkg;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   142
  $self->{dir} = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   143
  $self->{verbose} = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   144
  $self->Parse();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   145
  return $self;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   146
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   147
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   148
sub CheckDefFiles {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   149
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   150
  my $other = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   151
  my $ignoreR3Unused = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   152
  my $passed = 1;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   153
  foreach my $thisMmp (keys %{$self->{mmps}}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   154
    if (exists $other->{mmps}->{$thisMmp}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   155
      unless ($self->{mmps}->{$thisMmp}->CheckDefFile($other->{mmps}->{$thisMmp}, $ignoreR3Unused)) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   156
	$passed = 0;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   157
      }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   158
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   159
    else {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   160
      print "Mmp file \"$thisMmp\" missing for bld.inf \"$other->{dir}\"\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   161
      $passed = 0;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   162
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   163
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   164
  return $passed;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   165
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   166
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   167
sub ListConstructors {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   168
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   169
  my @constructors = ();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   170
  foreach my $thisMmp (keys %{$self->{mmps}}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   171
    push (@constructors, @{$self->{mmps}->{$thisMmp}->ListConstructors()});
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   172
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   173
  return \@constructors;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   174
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   175
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   176
sub ListExports {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   177
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   178
  if (exists $self->{exports}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   179
    return $self->{exports};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   180
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   181
  return [];
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   182
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   183
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   184
sub ListIncludes {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   185
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   186
  my %includes = ();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   187
  foreach my $thisMmp (keys %{$self->{mmps}}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   188
    foreach my $thisInclude (@{$self->{mmps}->{$thisMmp}->ListIncludes()}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   189
      $includes{$thisInclude} = 1;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   190
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   191
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   192
  my @includes = keys %includes;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   193
  return \@includes;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   194
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   195
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   196
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   197
#
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   198
# Private.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   199
#
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   200
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   201
sub Parse {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   202
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   203
  if ($self->{verbose}) {  print "Parsing $self->{dir}\\bld.inf...\n"; }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   204
  Utils::PushDir($self->{dir});
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   205
  my $fullName = "$self->{dir}\\bld.inf";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   206
  unless (open (BLDINF, "cpp -DARM -DMARM $fullName|")) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   207
    Utils::PopDir();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   208
    die "Error: Couldn't open \"cpp -DARM -DMARM $fullName\": $!\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   209
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   210
  my $foundMmps = 0;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   211
  my $foundExports = 0;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   212
  my $doDie = 0;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   213
  my $currentDir = $self->{dir};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   214
  while (my $line = <BLDINF>) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   215
    if ($line =~ /^# \d+ "(.*)" \d+?/) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   216
	my $newFile = $1;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   217
	$newFile =~ s/\\\\/\\/g;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   218
	$newFile =~ s/\\$//;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   219
	Utils::AbsoluteFileName(\$newFile);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   220
	($currentDir) = Utils::SplitFileName($newFile);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   221
	next;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   222
      }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   223
    if ($line =~ /^#/ or $line =~ /^\s*$/) {	
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   224
	# Ignore lines starting with '#' or those filled with white space.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   225
	next;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   226
      }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   227
    chomp $line;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   228
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   229
    if ($line =~ /PRJ_MMPFILES/i) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   230
      $foundMmps = 1;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   231
      $foundExports = 0;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   232
      next;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   233
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   234
    elsif ($line =~ /PRJ_EXPORTS/i) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   235
      $foundMmps = 0;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   236
      $foundExports = 1;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   237
      next;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   238
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   239
    elsif ($line =~ /PRJ_/i) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   240
      $foundMmps = 0;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   241
      $foundExports = 0;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   242
      next;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   243
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   244
    if ($foundMmps) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   245
      if ($line =~ /makefile\s+(\S+)/i) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   246
	if ($self->{verbose}) { print "Info: \"makefile $1\" found in \"$self->{dir}\\bld.inf\", ignoring.\n"; }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   247
	next;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   248
      }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   249
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   250
      $line =~ /\s*(\S+)/;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   251
      my $mmpName = lc($1);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   252
      if (not $mmpName =~ /\.mmp$/) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   253
	$mmpName .= '.mmp';
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   254
      }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   255
      unless (-e $mmpName) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   256
	if (-e "$currentDir\\$mmpName") {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   257
	  $mmpName = "$currentDir\\$mmpName";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   258
	}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   259
	elsif (-e "$self->{dir}\\$mmpName") {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   260
	  $mmpName = "$self->{dir}\\$mmpName";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   261
	}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   262
	else {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   263
	  print "Warning: Couldn't find location of \"$mmpName\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   264
	  next;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   265
	}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   266
      }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   267
      Utils::AbsoluteFileName(\$mmpName);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   268
      (my $path, my $name, my $ext) = Utils::SplitFileName($mmpName);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   269
      eval {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   270
	$self->{mmps}->{lc("$name$ext")} = Mmp->New($mmpName, $self->{verbose});
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   271
      };
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   272
      if ($@) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   273
	$doDie = 1;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   274
	print "$@";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   275
      }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   276
      next;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   277
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   278
    elsif ($foundExports) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   279
      my $thisExport;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   280
      if ($line =~  /^\s*\"([^\"]*)/) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   281
	$thisExport = $1;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   282
      }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   283
      elsif ($line =~ /\s*(\S+)/) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   284
	$thisExport = $1;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   285
      }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   286
      else {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   287
	die;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   288
      }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   289
      unless (-e $thisExport) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   290
	if (-e "$currentDir\\$thisExport") {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   291
	  $thisExport = "$currentDir\\$thisExport";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   292
	}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   293
	elsif (-e "$self->{dir}\\$thisExport") {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   294
	  $thisExport = "$self->{dir}\\$thisExport";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   295
	}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   296
	else {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   297
	  print "Warning: Couldn't find location of \"$thisExport\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   298
	  next;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   299
	}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   300
      }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   301
      Utils::AbsoluteFileName(\$thisExport);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   302
      push (@{$self->{exports}}, $thisExport);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   303
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   304
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   305
  close (BLDINF);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   306
  Utils::PopDir();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   307
  if ($doDie) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   308
    die "Aborting due to above errors\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   309
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   310
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   311
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   312
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   313
#
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   314
# Mmp
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   315
#
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   316
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   317
package Mmp;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   318
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   319
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   320
#
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   321
# Public.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   322
#
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   323
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   324
sub New {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   325
  my $pkg = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   326
  my $self = {};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   327
  bless $self, $pkg;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   328
  $self->{name} = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   329
  $self->{verbose} = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   330
  $self->Parse();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   331
  return $self;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   332
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   333
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   334
sub CheckDefFile {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   335
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   336
  my $other = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   337
  my $ignoreR3Unused = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   338
  if ($self->{def}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   339
    return $self->{def}->Check($other->{def}, $ignoreR3Unused);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   340
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   341
  return 1;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   342
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   343
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   344
sub ListConstructors {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   345
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   346
  if ($self->{def}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   347
    return $self->{def}->ListConstructors();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   348
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   349
  return [];
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   350
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   351
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   352
sub ListIncludes {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   353
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   354
  if (exists $self->{includes}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   355
    my @includes = keys %{$self->{includes}};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   356
    return \@includes;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   357
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   358
  return [];
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   359
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   360
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   361
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   362
#
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   363
# Private.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   364
#
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   365
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   366
sub Parse {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   367
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   368
  if ($self->{verbose}) {  print "Parsing $self->{name}...\n"; }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   369
  (my $path) = Utils::SplitFileName($self->{name});
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   370
  $path =~ s/(.*)\\.*/$1/; # Extract path.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   371
  Utils::PushDir($path);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   372
  unless (open (MMP, "cpp -DARM -DMARM $self->{name}|")) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   373
    Utils::PopDir();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   374
    die "Error: Couldn't open \"cpp -DARM -DMARM $self->{name}\": $!\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   375
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   376
  my $noStrictDef = 0;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   377
  my $targetType = '';
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   378
  while (my $line = <MMP>) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   379
    if ($line =~ /^#/ or $line =~ /^\s*$/) {	
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   380
	# Ignore lines starting with '#' or those filled with white space.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   381
	next;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   382
      }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   383
    chomp $line;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   384
    if ($line =~ /^\s*targettype\s+(\S*)\s*$/i) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   385
	$targetType = $1;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   386
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   387
    elsif ($line =~ /^\s*deffile\s+(\S*)\s*$/i) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   388
      die if exists $self->{defFileName};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   389
      $self->{defFileName} = $1;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   390
    }	 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   391
    elsif ($line =~ /nostrictdef/i) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   392
      $noStrictDef = 1;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   393
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   394
    elsif ($line =~ /^\s*userinclude\s+(.+)/i) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   395
      my @userIncludes = split (/\s+/, $1);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   396
      foreach my $thisUserInclude (@userIncludes) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   397
	$thisUserInclude =~ s/\+/$ENV{EPOCROOT}epoc32/;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   398
	Utils::AbsoluteFileName(\$thisUserInclude);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   399
	$self->{includes}->{lc($thisUserInclude)} = 1;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   400
      }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   401
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   402
    elsif ($line =~ /^\s*systeminclude\s+(.+)/i) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   403
      my @systemIncludes = split (/\s+/, $1);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   404
      foreach my $thisSystemInclude (@systemIncludes) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   405
	$thisSystemInclude =~ s/\+/$ENV{EPOCROOT}epoc32/;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   406
	Utils::AbsoluteFileName(\$thisSystemInclude);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   407
	$self->{includes}->{lc($thisSystemInclude)} = 1;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   408
      }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   409
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   410
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   411
  close (MMP);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   412
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   413
  if ($targetType =~ /^(app|ani|ctl|ctpkg|epocexe|exe|exedll|fsy|kdll|kext|klib|ldd|lib|ecomiic|mda|mdl|notifier|opx|pdd|pdl|rdl|var|wlog)$/i) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   414
    # Don't bother looking for the deffile.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   415
    Utils::PopDir();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   416
    return;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   417
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   418
  
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   419
  (my $mmpPath, my $mmpBase) = Utils::SplitFileName($self->{name});
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   420
  if (exists $self->{defFileName}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   421
    (my $path, my $base, my $ext) = Utils::SplitFileName($self->{defFileName});
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   422
    if ($base eq '') {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   423
      $base = $mmpBase;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   424
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   425
    if ($ext eq '') {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   426
      $ext = '.def';
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   427
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   428
    if ($path eq '') {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   429
      $path = $mmpPath;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   430
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   431
    unless ($noStrictDef) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   432
      $base .= 'u';
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   433
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   434
    unless (-e "$path$base$ext") {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   435
      $path = "$path..\\bmarm\\";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   436
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   437
    unless (-e "$path$base$ext") {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   438
      $path = $mmpPath . $path;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   439
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   440
    $self->{defFileName} = "$path$base$ext";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   441
    Utils::AbsoluteFileName(\$self->{defFileName});
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   442
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   443
  else {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   444
    # Assume default.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   445
    $self->{defFileName} = $mmpBase;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   446
    unless ($noStrictDef) {	
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   447
      $self->{defFileName} .= 'u';
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   448
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   449
    $self->{defFileName} .= '.def';
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   450
    $self->AddDefaultDefFilePath();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   451
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   452
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   453
  if ($self->{defFileName}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   454
    $self->{def} = Def->New($self->{defFileName}, $self->{verbose});
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   455
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   456
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   457
  Utils::PopDir();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   458
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   459
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   460
sub AddDefaultDefFilePath {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   461
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   462
  (my $path) = Utils::SplitFileName($self->{name});
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   463
  $self->{defFileName} = "$path\\..\\bmarm\\$self->{defFileName}";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   464
  if (-e $self->{defFileName}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   465
    Utils::AbsoluteFileName(\$self->{defFileName});
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   466
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   467
  else {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   468
    print "Warning: Unable to find def file in \"$self->{name}\"\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   469
    delete $self->{defFileName};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   470
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   471
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   472
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   473
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   474
#
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   475
# Def
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   476
#
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   477
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   478
package Def;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   479
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   480
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   481
#
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   482
# Public.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   483
#
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   484
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   485
sub New {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   486
  my $pkg = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   487
  my $self = {};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   488
  bless $self, $pkg;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   489
  $self->{name} = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   490
  $self->{verbose} = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   491
  $self->Parse();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   492
  $self->DemangleNames();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   493
  return $self;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   494
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   495
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   496
sub Check {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   497
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   498
  my $other = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   499
  my $ignoreR3Unused = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   500
  if ($self->{verbose}) { print "Checking DEF file \"$self->{name}\" against \"$other->{name}\"...\n"; }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   501
  my $passed = 1;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   502
  if (exists $self->{data}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   503
    for (my $ii = 0; $ii < scalar(@{$self->{data}}); ++$ii) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   504
      my $ordinal = $ii + 1;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   505
      if ($ii >= scalar @{$other->{data}}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   506
	print "Failure reason: \"$self->{name}\" has more exports than \"$other->{name}\"\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   507
	$passed = 0;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   508
	last;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   509
      }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   510
      my $selfRaw = $self->{data}->[$ii]->{raw};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   511
      my $otherRaw = $other->{data}->[$ii]->{raw};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   512
      if ($ignoreR3Unused) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   513
	$selfRaw =~ s/R3UNUSED //;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   514
	$otherRaw =~ s/R3UNUSED //;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   515
      }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   516
      unless ($selfRaw eq $otherRaw) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   517
	$passed = 0;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   518
	print "Failure reason: Def file mismatch between \"$self->{name}\" and \"$other->{name}\" at $ordinal\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   519
	if ($self->{verbose}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   520
	  print "\t$self->{data}->[$ii]->{raw}\n\t$other->{data}->[$ii]->{raw}\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   521
	}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   522
      }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   523
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   524
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   525
  return $passed;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   526
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   527
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   528
sub ListConstructors {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   529
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   530
  my @constructors = ();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   531
  if (exists $self->{data}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   532
    my $ordinal = 0;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   533
    foreach my $thisEntry (@{$self->{data}}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   534
      $ordinal++;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   535
      die unless (exists $thisEntry->{function});
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   536
      if ($thisEntry->{function} =~ /(.+)::(.+)\(/) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   537
	if ($1 eq $2) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   538
	  push (@constructors, $1);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   539
	}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   540
      }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   541
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   542
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   543
  return \@constructors;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   544
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   545
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   546
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   547
#
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   548
# Private.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   549
#
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   550
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   551
sub Parse {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   552
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   553
  open (DEF, $self->{name}) or die "Error: Couldn't open \"$self->{name}\" for reading: $!\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   554
  my $lineNum = 0;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   555
  while (my $thisLine = <DEF>) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   556
    ++$lineNum;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   557
    chomp $thisLine;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   558
    if ($thisLine =~ /^(EXPORTS|;|\s*$)/) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   559
      next;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   560
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   561
	my $entry = {};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   562
    $entry->{raw} = $thisLine;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   563
	     
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   564
    push (@{$self->{data}}, $entry);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   565
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   566
      close (DEF);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   567
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   568
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   569
sub DemangleNames {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   570
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   571
  open (FILT, "type $self->{name} | c++filt |") or die "Error: Couldn't open \"type $self->{name} | c++filt |\": $!\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   572
  my $lineNum = 0;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   573
  while (my $line = <FILT>) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   574
    ++$lineNum;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   575
    chomp $line;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   576
    next if ($line =~ /^(EXPORT|;|\s*$)/);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   577
    if ($line =~ /^\s+(\"(.+)\"|(.+)) @ (\d+)/) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   578
      my $function;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   579
      if ($2) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   580
	$function = $2;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   581
      }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   582
      else {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   583
	die unless $3;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   584
	$function = $3;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   585
      }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   586
      my $ordinal = $4;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   587
      $self->{data}->[$ordinal - 1]->{function} = $function;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   588
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   589
    else {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   590
      die "Error: Unable to parse c++filt output for \"$self->{name}\" at line $lineNum\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   591
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   592
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   593
  close (FILT);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   594
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   595
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   596
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   597
#
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   598
# ClassSize
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   599
#
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   600
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   601
package ClassSize;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   602
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   603
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   604
#
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   605
# Public.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   606
#
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   607
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   608
sub New {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   609
  my $pkg = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   610
  my $self = {};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   611
  bless $self, $pkg;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   612
  $self->{classes} = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   613
  $self->{headers} = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   614
  $self->{includes} = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   615
  $self->{verbose} = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   616
  $self->{compName} = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   617
  $self->{bldInfDir} = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   618
  if (scalar @{$self->{classes}} > 0) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   619
    $self->GetClassSizes();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   620
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   621
  return $self;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   622
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   623
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   624
sub Check {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   625
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   626
  my $other = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   627
  if ($self->{verbose}) { print "Comparing class sizes of \"$self->{bldInfDir}\" against \"$other->{bldInfDir}\"..\n"; }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   628
  my $passed = 1;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   629
  foreach my $thisClass (keys %{$self->{classSizes}}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   630
    if ($self->{verbose}) { print "Examining class sizes of \"$thisClass\"...\n"; }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   631
    unless (exists $other->{classSizes}->{$thisClass}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   632
      print "Failure reason: \"$thisClass\" not found (possibly renamed)\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   633
      $passed = 0;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   634
      next;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   635
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   636
    unless ($self->{classSizes}->{$thisClass} == $other->{classSizes}->{$thisClass}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   637
      $passed = 0;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   638
      print "Failure reason: Class \"$thisClass\" has changed size from $self->{classSizes}->{$thisClass} to $other->{classSizes}->{$thisClass}\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   639
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   640
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   641
  return $passed;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   642
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   643
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   644
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   645
#
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   646
# Private.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   647
#
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   648
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   649
sub GetClassSizes {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   650
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   651
  eval {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   652
    $self->GenerateCode();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   653
    $self->CompileCode();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   654
    $self->GetOutput();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   655
  };
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   656
  $self->CleanUp();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   657
  if ($@) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   658
    die $@;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   659
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   660
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   661
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   662
sub GenerateCode {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   663
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   664
  open (CODE, '>__ClassSize.cpp') or die "Error: Couldn't open \"__ClassSize.cpp\" for writing: $!\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   665
  print CODE "#include <stdio.h>\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   666
  print CODE "#include <e32std.h>\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   667
  print CODE "#include <e32def.h>\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   668
  print CODE "#include <e32base.h>\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   669
  foreach my $thisHeader (@{$self->{headers}}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   670
    print CODE "#include <$thisHeader>\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   671
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   672
  print CODE "int main(int argc, char* argv[]) {\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   673
  foreach my $thisClass (@{$self->{classes}}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   674
    print CODE "\tprintf(\"$thisClass\\t%d\\n\", sizeof($thisClass));\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   675
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   676
  print CODE "\treturn 0; }\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   677
  close (CODE);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   678
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   679
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   680
sub CompileCode {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   681
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   682
  my $command = 'cl ';
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   683
  foreach my $thisInclude (@{$self->{includes}}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   684
    $command .= " /I$thisInclude";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   685
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   686
  $command .= " /D__VC32__ /D__WINS__ /D__SYMBIAN32__ /DWIN32 /D_WINDOWS /D_UNICODE __ClassSize.cpp";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   687
  unless ($self->{verbose}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   688
    $command .= ' /nologo 2>&1 > NUL';
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   689
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   690
  if (system ($command)) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   691
    if (exists $self->{compName} and $self->{compName}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   692
      rename ("__ClassSize.cpp", "$self->{compName}.cpp");
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   693
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   694
    else {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   695
      rename ("__ClassSize.cpp", "unknown.cpp");
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   696
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   697
    die "Error: Problem executing \"$command\"\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   698
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   699
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   700
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   701
sub GetOutput {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   702
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   703
  open (OUTPUT, '__ClassSize.exe|') or die "Error: Couldn't run \"__ClassSize.exe\": $!\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   704
  while (my $thisLine = <OUTPUT>) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   705
    chomp $thisLine;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   706
    next if ($thisLine =~ /^\s*$/);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   707
    if ($thisLine =~ /^(\S+)\t(\d+)$/) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   708
      $self->{classSizes}->{$1} = $2;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   709
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   710
    else {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   711
      die "Error: Problem parsing output of \"__ClassSize.exe\"\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   712
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   713
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   714
  close (OUTPUT);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   715
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   716
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   717
sub CleanUp {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   718
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   719
  DeleteFile('__ClassSize.cpp');
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   720
  DeleteFile('__ClassSize.obj');
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   721
  DeleteFile('__ClassSize.exe');
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   722
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   723
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   724
sub DeleteFile {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   725
  my $file = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   726
  if (-e $file) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   727
    unlink ($file) or die "Error: Couldn't delete \"$file\"\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   728
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   729
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   730
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   731
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   732
#
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   733
# VTable
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   734
#
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   735
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   736
package VTable;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   737
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   738
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   739
#
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   740
# Public.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   741
#
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   742
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   743
sub New {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   744
  my $pkg = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   745
  my $self = {};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   746
  bless $self, $pkg;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   747
  $self->{bldInfDir} = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   748
  my $classes = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   749
  foreach my $class (@$classes) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   750
    $self->{classes}->{$class} = 1;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   751
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   752
  $self->{verbose} = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   753
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   754
  Utils::PushDir($self->{bldInfDir});
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   755
  eval {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   756
    $self->BuildAssemblerListings();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   757
    $self->ParseAssemblerListings();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   758
    $self->DeleteAssemblerListings();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   759
    };
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   760
  Utils::PopDir();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   761
  if ($@) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   762
    die $@;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   763
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   764
  return $self;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   765
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   766
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   767
sub Check {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   768
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   769
  my $other = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   770
  if ($self->{verbose}) { print "Comparing vtable layout of \"$self->{bldInfDir}\" against \"$other->{bldInfDir}\"..\n"; }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   771
  my $passed = 1;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   772
  foreach my $class (keys %{$self->{vtables}}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   773
    if (exists $other->{vtables}->{$class}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   774
      if ($self->{verbose}) { print "Examining vtable of class \"$class\"...\n"; }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   775
      for (my $ii = 0; $ii < scalar (@{$self->{vtables}->{$class}}); ++$ii) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   776
	my $thisVTableEntry = $self->{vtables}->{$class}->[$ii];
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   777
	if ($ii >= scalar (@{$other->{vtables}->{$class}})) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   778
	  print "Failure reason: Unexpected vtable entry \"$thisVTableEntry\"\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   779
	  $passed = 0;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   780
	  last;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   781
	}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   782
	my $otherVTableEntry = $other->{vtables}->{$class}->[$ii];
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   783
	if ($thisVTableEntry eq $otherVTableEntry) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   784
	  if ($self->{verbose}) { print "\tMatched vtable entry \"$thisVTableEntry\"\n"; }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   785
	}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   786
	else {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   787
	  print "Failure reason: Mismatched vtable entries in class \"$class\"\n\t$thisVTableEntry\n\t$otherVTableEntry\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   788
	  $passed = 0;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   789
	}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   790
      }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   791
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   792
    else {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   793
      print "Failure reason: Vtable for \"$class\" missing from $other->{bldInfDir}\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   794
      $passed = 0;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   795
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   796
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   797
  return $passed;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   798
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   799
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   800
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   801
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   802
#
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   803
# Private.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   804
#
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   805
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   806
sub BuildAssemblerListings {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   807
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   808
  if ($self->{verbose}) { print "Calling \"bldmake bldfiles\" in \"$self->{bldInfDir}\"\n"; }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   809
  open (BLDMAKE, "bldmake bldfiles 2>&1 |") or die "Error: Couldn't run \"bldmake bldfiles\" in \"$self->{bldInfDir}\": $!\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   810
  while (my $line = <BLDMAKE>) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   811
    if ($line) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   812
      if ($self->{verbose}) { print "\t$line"; }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   813
      die "Error: Problem running \"bldmake bldfiles\" in \"$self->{bldInfDir}\"\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   814
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   815
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   816
  close (BLDMAKE);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   817
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   818
  if ($self->{verbose}) { print "Calling \"abld makefile arm4\" in \"$self->{bldInfDir}\"\n"; }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   819
  open (ABLD, "abld makefile arm4 2>&1 |") or die "Error: Couldn't run \"abld makefile arm4\" in \"$self->{bldInfDir}\": $!\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   820
  while (my $line = <ABLD>) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   821
    if ($line) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   822
      if ($self->{verbose}) { print "\t$line"; }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   823
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   824
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   825
  close (ABLD);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   826
  
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   827
  if ($self->{verbose}) { print "Calling \"abld listing arm4 urel\" in \"$self->{bldInfDir}\"\n"; }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   828
  open (ABLD, "abld listing arm4 urel 2>&1 |") or die "Error: Couldn't run \"abld listing arm4 urel\" in \"$self->{bldInfDir}\": $!\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   829
  while (my $line = <ABLD>) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   830
    if ($line) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   831
      if ($self->{verbose}) { print "\t$line"; }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   832
      if ($line =~ /^Created (.*)/) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   833
	my $listingFile = $1;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   834
	push (@{$self->{listingFiles}}, $listingFile);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   835
      }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   836
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   837
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   838
  close (ABLD);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   839
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   840
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   841
sub ParseAssemblerListings {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   842
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   843
  foreach my $listing (@{$self->{listingFiles}}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   844
    open (LISTING, $listing) or die "Error: Couldn't open \"$listing\" for reading: $!\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   845
    while (my $line = <LISTING>) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   846
      if ($line =~ /^\s.\d+\s+__vt_\d+(\D+):$/) {  # If start of vtable section.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   847
	my $class = $1;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   848
	if (exists $self->{classes}->{$class}) { # If one of the classes we're interested in.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   849
	  while (my $line2 = <LISTING>) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   850
	    if ($line2 =~ /^\s.\d+\s[\da-fA-F]{4}\s[\da-fA-F]{8}\s+\.word\s+(.*)/) {  # If this is a valid vtable entry.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   851
	      my $vtableEntry = $1;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   852
	      push (@{$self->{vtables}->{$class}}, $vtableEntry);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   853
	    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   854
	    else {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   855
	      last;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   856
	    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   857
	  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   858
	}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   859
      }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   860
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   861
    close (LISTING);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   862
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   863
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   864
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   865
sub DeleteAssemblerListings {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   866
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   867
  foreach my $listing (@{$self->{listingFiles}}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   868
    unlink $listing or die "Error: Unable to delete \"$listing\": $!\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   869
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   870
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   871
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   872
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   873
#
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   874
# Utils.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   875
#
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   876
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   877
package Utils;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   878
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   879
use File::Basename;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   880
use Cwd 'abs_path', 'cwd';
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   881
use Win32;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   882
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   883
sub AbsoluteFileName {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   884
  my $fileName = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   885
  unless (-e $$fileName) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   886
    die "Error: \"$$fileName\" does not exist\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   887
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   888
  (my $base, my $path) = fileparse($$fileName);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   889
  my $absPath = abs_path($path);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   890
  $$fileName = $absPath;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   891
  unless ($$fileName =~ /[\\\/]$/) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   892
    $$fileName .= "\\";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   893
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   894
  $$fileName .= $base;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   895
  TidyFileName($fileName);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   896
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   897
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   898
sub SplitFileName {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   899
  my $fileName = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   900
  my $path = '';
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   901
  my $base = '';
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   902
  my $ext = '';
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   903
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   904
  if ($fileName =~ /\\?([^\\]*?)(\.[^\\\.]*)?$/) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   905
    $base = $1;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   906
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   907
  if ($fileName =~ /^(.*\\)/) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   908
    $path = $1;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   909
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   910
  if ($fileName =~ /(\.[^\\\.]*)$/o) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   911
    $ext =  $1;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   912
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   913
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   914
  die unless ($fileName eq "$path$base$ext");
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   915
  return ($path, $base, $ext);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   916
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   917
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   918
sub TidyFileName {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   919
  my $a = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   920
  $$a =~ s/\//\\/g;      # Change forward slashes to back slashes.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   921
  $$a =~ s/\\\.\\/\\/g;  # Change "\.\" into "\".
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   922
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   923
  if ($$a =~ /^\\\\/) {  # Test for UNC paths.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   924
    $$a =~ s/\\\\/\\/g;  # Change "\\" into "\".
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   925
    $$a =~ s/^\\/\\\\/;  # Add back a "\\" at the start so that it remains a UNC path.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   926
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   927
  else {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   928
    $$a =~ s/\\\\/\\/g;  # Change "\\" into "\".
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   929
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   930
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   931
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   932
my @dirStack;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   933
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   934
sub PushDir {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   935
  my $dir = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   936
  my $cwd = cwd();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   937
  chdir ($dir) or die "Error: Couldn't change working directory to \"$dir\": $!\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   938
  push (@dirStack, $cwd);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   939
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   940
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   941
sub PopDir {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   942
  if (scalar @dirStack > 0) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   943
    my $dir = pop @dirStack;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   944
    chdir ($dir) or die "Error: Couldn't change working directory to \"$dir\": $!\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   945
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   946
  else {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   947
    die "Error: Directory stack empty";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   948
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   949
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   950
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   951
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   952
1;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   953
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   954
=head1 NAME
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   955
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   956
CheckBc.pm - A module that runs some simple tests to see if one component source tree is backwards compatible another.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   957
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   958
=head1 SYNOPSIS
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   959
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   960
  my $checkBc = CheckBc->New('\branch1\comp\group', '\branch2\comp\group', 0);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   961
  unless ($checkBc->CheckAll()) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   962
    print "Check failed\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   963
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   964
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   965
=head1 DESCRIPTION
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   966
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   967
C<CheckBc> does the following checks to see if a backwards compatibility breaking change has been introduced:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   968
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   969
=over 4
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   970
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   971
=item 1
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   972
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   973
Compares the ARM F<.def> files to ensure that only new lines have been added to the end of the file.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   974
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   975
=item 2
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   976
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   977
Compares the sizes of any classes that have an exported C++ constructor. This is done by compiling some generated C++ code that uses the C<sizeof> operator to print the relevant class sizes to C<STDOUT>. Compilation is done using the MSVC++ compiler.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   978
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   979
=item 3
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   980
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   981
Compares the v-table layouts of any classes that have an exported C++ constructor. This is done by compiling each source code set to ARM4 assembler listings, comparing the v-table sections.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   982
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   983
=back
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   984
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   985
=head1 LIMITATIONS
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   986
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   987
=over 4
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   988
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   989
=item 1
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   990
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   991
The component's headers must compile using Microsoft's Visual C++ compiler.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   992
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   993
=item 2
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   994
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   995
The component's exported headers must compile when they are all #include'd into a single F<.cpp> file. If this is not the case, then additional headers and include paths can be passed into the constructor.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   996
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   997
=item 3
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   998
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   999
Declarations of the component's exported C++ constructors must be found in one of the exported headers.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1000
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1001
=item 4
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1002
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1003
F<.def> file lines are expected to be identical. This can lead to checks failing falsely because, for example, the name of a function may be changed without breaking BC provided the F<.def> file is carefully edited.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1004
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1005
=item 5
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1006
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1007
The components must compile as ARM4. This is likely to mean that each set of source code needs to be accompanied with a suitable F<\epoc32> tree that allows it to be built. The simplest way to acheive this is to prepare a pair of subst'd drives.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1008
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1009
=back
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1010
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1011
=head1 KNOWN BUGS
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1012
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1013
F<bld.inf>, F<.mmp> and F<.def> file parsing is probably not as industrial strength as it should be.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1014
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1015
=head1 COPYRIGHT
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1016
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1017
 Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1018
 All rights reserved.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1019
 This component and the accompanying materials are made available
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1020
 under the terms of the License "Eclipse Public License v1.0"
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1021
 which accompanies this distribution, and is available
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1022
 at the URL "http://www.eclipse.org/legal/epl-v10.html".
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1023
 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1024
 Initial Contributors:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1025
 Nokia Corporation - initial contribution.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1026
 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1027
 Contributors:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1028
 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1029
 Description:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1030
 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1031
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1032
=cut