releasing/cbrtools/perl/MrpData.pm
author Zheng Shen <zheng.shen@nokia.com>
Wed, 27 Oct 2010 19:38:12 +0800
changeset 665 2068325a5906
parent 602 3145852acc89
permissions -rw-r--r--
Merge: remove incorrect heard
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
602
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     1
# Copyright (c) 2000-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
package MrpData;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    17
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    18
use strict;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    19
use base qw(Symbian::CBR::MRPInterface);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    20
use File::Find;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    21
use File::Copy;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    22
use File::Basename;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    23
use File::Spec;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    24
use Utils;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    25
use Cwd;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    26
use Symbian::CBR::MRP::Reader;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    27
use IniData;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    28
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    29
use Carp;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    30
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    31
use constant MAX_PATH_LENGTH => 245; #If a file name has a path > MAX_PATH_LENGTH an error will be produced.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    32
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    33
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    34
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    35
use File::Path;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    36
use XML::Simple;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    37
use POSIX qw(strftime);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    38
use Data::Dumper;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    39
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    40
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    41
our $cache = {}; # Persistent (private) cache
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    42
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    43
sub New {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    44
  my $pkg = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    45
  my $self = {};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    46
  bless $self, $pkg;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    47
  $self->{mrpName} = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    48
  $self->{ver} = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    49
  $self->{intVer} = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    50
  $self->{iniData} = shift || IniData->New();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    51
  $self->{verbose} = shift || 0;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    52
  $self->{fixMissingLibs} = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    53
  $self->ExpandMrpName();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    54
  
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    55
  # This will be used by the IPR stuff, so that it can popultate the MrpData object without circular stuff
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    56
  my $doNotRead = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    57
  
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    58
  #remove the / from mrpname
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    59
  $self->{mrpName} =~ s/^[\\\/]//;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    60
  
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    61
  # Lowercase the MRP name so that the case is consistent when checking the cache
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    62
  my $lcMrpName = lc ($self->{mrpName});
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    63
  
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    64
  if ($cache->{$lcMrpName}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    65
    $cache->{$lcMrpName}->{ver} = $self->{ver} if ($self->{ver});
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    66
    $cache->{$lcMrpName}->{intVer} = $self->{intVer} if ($self->{intVer});             
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    67
    return $cache->{$lcMrpName};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    68
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    69
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    70
  $cache->{$lcMrpName} = $self;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    71
  
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    72
  if (!$doNotRead) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    73
    $self->ReadMrp();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    74
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    75
  
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    76
  return $self;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    77
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    78
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    79
sub Populated {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    80
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    81
  
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    82
  return $self->{populated};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    83
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    84
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    85
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    86
sub ExpandMrpName {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    87
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    88
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    89
  unless ($self->{mrpName} =~ /.mrp$/i) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    90
    $self->{mrpName} .= '.mrp';
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    91
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    92
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    93
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    94
sub Component {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    95
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    96
  unless (exists $self->{comp}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    97
    die "Error: Component name not found in mrp\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    98
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    99
  return $self->{comp};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   100
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   101
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   102
sub MrpName {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   103
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   104
  return $self->{mrpName};
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 ExternalVersion {
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
  return $self->{ver};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   110
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   111
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   112
sub InternalVersion {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   113
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   114
  return $self->{intVer};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   115
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   116
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   117
sub NotesSource {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   118
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   119
  unless (exists $self->{notes_src}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   120
    die "Error: Notes source not found in mrp for $self->{comp}\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   121
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   122
  return $self->{notes_src};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   123
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   124
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   125
sub ClassifySource {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   126
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   127
  return if defined $self->{src};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   128
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   129
  foreach my $item (keys %{$self->{srcitems}}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   130
    if (-d Utils::PrependSourceRoot($item)) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   131
      $self->HandleSourceDir($item);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   132
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   133
    elsif (-f Utils::PrependSourceRoot($item)) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   134
      $self->HandleSourceFile($item);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   135
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   136
    else {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   137
      die "Error: \"$item\" is not a file or directory in $self->{mrpName}\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   138
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   139
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   140
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   141
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   142
sub SourceCategories {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   143
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   144
  $self->ClassifySource();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   145
  if (defined $self->{src}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   146
    my @categories = keys %{$self->{src}};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   147
    return \@categories;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   148
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   149
  return [];
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   150
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   151
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   152
sub Source {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   153
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   154
  my $category = uc(shift);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   155
  $self->ClassifySource();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   156
  unless (defined $category) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   157
    $category = 'unfiltered';
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   158
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   159
  if (defined $self->{src}->{$category}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   160
    return $self->{src}->{$category};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   161
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   162
  return [];
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   163
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   164
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   165
sub SourceFilterErrors {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   166
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   167
  $self->ClassifySource();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   168
  if (defined $self->{sourceFilterErrors}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   169
    return $self->{sourceFilterErrors};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   170
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   171
  return [];
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   172
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   173
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   174
sub BinaryCategories {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   175
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   176
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   177
  $self->ProcessBinaries();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   178
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   179
  if ($self->{bins}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   180
    my @categories = sort keys %{$self->{bins}};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   181
    return \@categories;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   182
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   183
  return [];
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   184
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   185
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   186
sub Binaries {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   187
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   188
  my $category = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   189
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   190
  $self->ProcessBinaries();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   191
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   192
  my @binList = ();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   193
  if ($category) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   194
    die unless (exists $self->{bins}->{$category});
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   195
    foreach my $thisBin (sort keys %{$self->{bins}->{$category}}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   196
      push (@binList, $self->{bins}->{$category}->{$thisBin});
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   197
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   198
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   199
  else {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   200
    foreach my $thisCategory (@{$self->BinaryCategories()}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   201
      push (@binList, @{$self->Binaries($thisCategory)});
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   202
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   203
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   204
  return \@binList;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   205
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   206
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   207
sub ExportCategories {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   208
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   209
  if ($self->{iniData}->CategoriseExports()) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   210
    $self->ProcessExports();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   211
    if ($self->{exports}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   212
      my @categories = sort keys %{$self->{exports}};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   213
      return \@categories;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   214
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   215
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   216
  return [];
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   217
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   218
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   219
sub Exports {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   220
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   221
  my $category = uc(shift);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   222
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   223
  $self->ProcessExports();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   224
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   225
  my @exportList = ();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   226
  if ($self->{iniData}->CategoriseExports()) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   227
    if ($category) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   228
      die unless (exists $self->{exports}->{$category});
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   229
      push (@exportList, @{$self->{exports}->{$category}});
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   230
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   231
    else {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   232
        foreach my $thisCategory (@{$self->ExportCategories()}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   233
          push (@exportList, @{$self->Exports($thisCategory)});
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   234
        }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   235
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   236
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   237
  elsif ($category) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   238
    die; # There are never any export categories if export categorisation is not enabled. Caller didn't call ExportCategories prior to this.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   239
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   240
  return \@exportList;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   241
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   242
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   243
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   244
sub ClassifyAutomaticExports {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   245
  # Classify exports that were specified using the 'exports' keyword.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   246
  #
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   247
  # This is a bit ugly. The problem's root is that it's not possible to ask the build tools where exports originated
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   248
  # from. This information is needed to be able to categorise exports. To get it, the release tools therefore have
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   249
  # to go 'under the hood' of the build tools. Yuk!
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   250
  #
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   251
  # Implementation choices were a) Parse bld.inf files, and b) Parse the generated export makefiles. Option (b) was
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   252
  # chosen because bld.infs are notoriously difficult to robustly parse.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   253
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   254
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   255
  if (exists $self->{exports}->{automatic}) { # Only perform the classification if we haven't already done it.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   256
    foreach my $thisAbldPath (@{$self->{exports}->{abldPaths}}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   257
      $thisAbldPath = Utils::PrependSourceRoot($thisAbldPath);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   258
      # Scan the makefile looking for the exports we're expecting (from invoking 'abld -w exports' in HandleExports).
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   259
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   260
      my $exportMakeFile;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   261
      my $testExportMakeFile;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   262
      $self->ExportMakeFile($thisAbldPath, \$exportMakeFile, \$testExportMakeFile);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   263
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   264
      if ($exportMakeFile){
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   265
        $self->ProcessExportMakeFile($exportMakeFile, $thisAbldPath);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   266
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   267
      }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   268
      if ($testExportMakeFile){
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   269
        $self->ProcessExportMakeFile($testExportMakeFile, $thisAbldPath);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   270
      }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   271
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   272
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   273
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   274
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   275
  if (scalar(keys %{$self->{exports}->{automatic}}) > 0) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   276
    foreach my $unprocessed_export (keys %{$self->{exports}->{automatic}})
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   277
	{
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   278
		print "UNPROCESSED EXPORT: $unprocessed_export\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   279
	}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   280
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   281
    die "Error: Problem extracting export IPR categories for \"$self->{mrpName}\"\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   282
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   283
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   284
  delete $self->{exports}->{automatic};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   285
  delete $self->{exports}->{abldPaths};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   286
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   287
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   288
sub ProcessExportMakeFile {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   289
	my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   290
	my $exportMakeFile = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   291
        my $abldPath = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   292
        my $errors = 0;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   293
        open (MAKEFILE, $exportMakeFile) or die "Error: Couldn't open \"$exportMakeFile\": $!\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   294
        while (my $line = <MAKEFILE>) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   295
          $line =~ s/\\ / /g; # Get rid of escaped spaces.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   296
          if ($line =~ /^(.*)\s+:\s+(.*)/) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   297
            # Found a possibility - need to see if it's one of the exports we're looking for.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   298
            my $destination = $1;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   299
            my $source = $2;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   300
            if (Utils::WithinEpocRoot($destination)) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   301
              $destination = Utils::RemoveEpocRoot($destination);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   302
            }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   303
            if (exists $self->{exports}->{automatic}->{lc($destination)}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   304
              $source = Utils::RemoveSourceRoot($source);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   305
              # Add to exports to be processed - source and destination
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   306
              push @{$self->{exportsToBeProcessed}}, {source => $source,
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   307
                                                      destination => $destination,
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   308
                                                      abldPath => $abldPath};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   309
              
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   310
              delete $self->{exports}->{automatic}->{lc($destination)};
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
          elsif ($line =~ /unzip\s+-u\s+-o\s+(.*)\s+-d\s+\"(.*)\"/) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   314
            # Looks like a zip file being exported - check contents.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   315
            my $zipFileName = $1;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   316
            my $destinationDir = $2;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   317
            my $zipContents = Utils::ListZip($zipFileName);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   318
            $zipFileName = Utils::RemoveSourceRoot($zipFileName);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   319
            foreach my $thisExport (@$zipContents) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   320
              $thisExport = Utils::ConcatenateDirNames($destinationDir, $thisExport);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   321
              if (Utils::WithinEpocRoot($thisExport)) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   322
                $thisExport = Utils::RemoveEpocRoot($thisExport);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   323
              }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   324
              if (exists $self->{exports}->{automatic}->{lc($thisExport)}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   325
                # Add to exports to be processed - source and destination
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   326
                push @{$self->{exportsToBeProcessed}}, {source => $zipFileName,
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   327
                                                        destination => $thisExport,
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   328
                                                        abldPath => $abldPath};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   329
                
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   330
                delete $self->{exports}->{automatic}->{lc($thisExport)};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   331
              }
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
        }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   335
        close (MAKEFILE);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   336
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   337
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   338
sub ExportMakeFile {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   339
  # Invoke 'bldmake bldfiles -v' to find the full path to the EXPORT.MAKE file.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   340
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   341
  my $abldPath = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   342
  my $exportMakeFileRef = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   343
  my $testExportMakeFileRef = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   344
  my $cwd = cwd();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   345
  my $last = 0;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   346
  chdir $abldPath or die "Error: Couldn't change working directory to \"$abldPath\": $!\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   347
  open (BLDMAKE, 'bldmake bldfiles -v |') or die "Error: Couldn't run \"bldmake bldfiles -v |\" in \"abldPath\": $!\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   348
  my $exportMakeFile;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   349
  my $testExportMakeFile;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   350
  while (my $line = <BLDMAKE>) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   351
    if ($line =~ /Creating \"(.*EXPORT.MAKE)\"/) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   352
      $exportMakeFile = $1;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   353
      if ($last == 1){ # found both EXPORT.MAKE and EXPORTTEST.MAKE
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   354
        last;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   355
      }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   356
      $last = 1;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   357
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   358
    elsif ($line =~ /Creating \"(.*EXPORTTEST.MAKE)\"/) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   359
      $testExportMakeFile = $1;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   360
      if ($last == 1){ # found both EXPORT.MAKE and EXPORTTEST.MAKE
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   361
        last;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   362
      }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   363
      $last = 1;
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
  close (BLDMAKE);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   367
  chdir $cwd or die "Error: Couldn't change working directory to \"$cwd\": $!\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   368
  unless ($exportMakeFile || $testExportMakeFile) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   369
    die "Error: Unable to find \"EXPORT.MAKE\" or \"EXPORTTEST.MAKE\" for \"$abldPath\"\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   370
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   371
  $$exportMakeFileRef = $exportMakeFile;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   372
  $$testExportMakeFileRef = $testExportMakeFile;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   373
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   374
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   375
sub ClassifyManualExports {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   376
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   377
  if (exists $self->{exports}->{manual}) { # Only perform the classification if we haven't already done it.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   378
    foreach my $thisSource (keys %{$self->{exports}->{manual}}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   379
      push @{$self->{exportsToBeProcessed}}, {source => $thisSource,
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   380
                                              destination => $self->{exports}->{manual}->{$thisSource}};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   381
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   382
    delete $self->{exports}->{manual};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   383
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   384
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   385
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   386
sub ExportInfoForCat {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   387
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   388
  my $category = uc(shift);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   389
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   390
  $self->ProcessExports();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   391
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   392
  return $self->{exportinfo}->{$category};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   393
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   394
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   395
sub ExportSourceFileInfoForCat {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   396
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   397
  my $category = uc(shift);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   398
  my $exportfile = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   399
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   400
  # In AddExport $category is called $class and $exportfile is $destination
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   401
  return $self->{exportinfo}->{$category}->{$exportfile};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   402
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   403
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   404
sub AddExport {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   405
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   406
  my $source = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   407
  my $destination = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   408
  my $successfullyAdded = 0;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   409
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   410
  my ($class) = Utils::ClassifyPath($self->{iniData}, $source, $self->{verbose}, 0, $self->Component());
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   411
  $class = uc($class);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   412
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   413
  if ($class) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   414
    $successfullyAdded = 1;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   415
    push (@{$self->{exports}->{$class}}, $destination);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   416
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   417
  else {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   418
    print "Error: Can't find IPR category for export \"$destination\" in \"$self->{mrpName}\"
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   419
       It should correspond to source file \"$source\"\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   420
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   421
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   422
  # Need to record the src paths.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   423
  $self->{exportinfo}->{$class}->{$destination} = $source;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   424
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   425
  return $successfullyAdded;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   426
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   427
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   428
sub BinariesAndExports {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   429
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   430
  # Exports need to be processed first.  If exports are not to be categorised then
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   431
  # they are treated as binary files.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   432
  my $list = $self->Exports();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   433
  push (@$list, @{$self->Binaries()});
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   434
  return $list;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   435
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   436
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   437
sub SourceItems {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   438
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   439
  return $self->{srcitems};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   440
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   441
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   442
sub ReadMrp {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   443
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   444
  my $mrpName = $self->{mrpName};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   445
  my $cwd = cwd();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   446
  # If there are mappings and the source root is \\, perform mappings on filename. Otherwise prepend source root.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   447
  if($self->{iniData}->HasMappings() && Utils::SourceRoot() eq "\\") {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   448
    $mrpName = $self->{iniData}->PerformMapOnFileName($mrpName);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   449
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   450
  else{
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   451
    $mrpName = Utils::PrependSourceRoot($mrpName);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   452
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   453
  
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   454
  my $mrpDir = dirname($mrpName);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   455
  
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   456
  chdir($mrpDir) or die "Error: Couldn't change working directory to \"$mrpDir\": $!\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   457
 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   458
  my $reader = Symbian::CBR::MRP::Reader->instance();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   459
  $reader->SetVerbose() if ($self->{verbose});
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   460
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   461
  $reader->ReadFile($mrpName, 'MRPDATA');
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   462
  
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   463
  chdir($cwd) or die "Error: Couldn't change working directory back to \"$cwd\": $!\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   464
  if ($@) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   465
    die $@;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   466
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   467
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   468
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   469
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   470
sub HandleSourceFile {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   471
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   472
  my $srcFile = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   473
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   474
  my $logErrors = !$self->{iniData}->IgnoreSourceFilterErrors();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   475
  my ($cat, $errors) = Utils::ClassifyPath($self->{iniData}, $srcFile, $self->{verbose}, $logErrors, $self->Component());
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   476
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   477
  if ($self->{verbose}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   478
    print "Handling source file $srcFile...\n";
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
  push @{$self->{sourceFilterErrors}}, @$errors if @$errors;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   482
  push @{$self->{src}->{uc($cat)}}, $srcFile;
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 HandleSourceDir {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   486
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   487
  my $srcDir = Utils::PrependSourceRoot(shift);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   488
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   489
  if ($self->{verbose}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   490
    print "Filtering source directory $srcDir into categories...\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   491
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   492
 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   493
  # Create function to handle files in a directory ($File::Find::dir)
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   494
  # Takes: List of items (files and dirs) in the directory 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   495
  my $dirhandler = sub {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   496
    my @entries = @_;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   497
    my $hasdistpol = scalar(grep(lc($_) eq "distribution.policy", @entries));
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   498
    
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   499
    @entries = grep(lc($_) ne "distribution.policy", @entries); # remove distribution.policy entries
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   500
    
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   501
    foreach my $entry (@entries) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   502
      if (Utils::CheckForUnicodeCharacters($entry)) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   503
          die "Error: \"$File::Find::dir\\$entry\" contains unicode characters, which are incompatible with the CBR Tools. This file can not be included in this release.\n"; 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   504
      }    
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   505
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   506
    
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   507
    my @files = grep(-f File::Spec->catfile($File::Find::dir,$_), @entries);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   508
    
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   509
    # Remove the abld entries from the source
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   510
    $self->RemoveAbldFromSource($File::Find::dir, \@files);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   511
    
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   512
    if (scalar(@files) > 0) {    
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   513
      
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   514
      # Tag all the entries in this directory with that category
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   515
      foreach my $entry (@files) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   516
        next if $entry =~ /^\.\.?$/; # Skip . and ..
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   517
        my $entry = File::Spec->catfile($File::Find::dir, $entry);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   518
        Utils::TidyFileName(\$entry);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   519
        
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   520
        $entry = Utils::RemoveSourceRoot($entry); # remove source root path or it will be added twice!
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   521
        my ($category, $errors) = Utils::ClassifyPath($self->{iniData}, $entry, $self->{verbose}, $self->{iniData}->IgnoreSourceFilterErrors(), $self->Component());
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   522
        push @{$self->{sourceFilterErrors}}, @$errors; # There will be no errors in @$errors if IgnoreSourceFilterErrors was set
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   523
        
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   524
        # (Optionally) guard against unclassified source
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   525
        if (lc($category) eq "x" and $self->{iniData}->DisallowUnclassifiedSource()) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   526
          die "Error: \"$File::Find::dir\" contains unclassified source code\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   527
        }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   528
        
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   529
        push @{$self->{src}->{uc($category)}}, $entry;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   530
      } 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   531
    } else {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   532
      # There are no files to categorise here
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   533
      if (($hasdistpol) and (!($self->{iniData}->IgnoreSourceFilterErrors()))) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   534
        push @{$self->{sourceFilterErrors}}, "Note: unnecessary policy file in $File::Find::dir\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   535
      }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   536
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   537
    
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   538
    # Return full list of entries to continue scan
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   539
    return @entries;
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
  # Traverse the directory tree in $srcDir calling &$dirhandler on all directories
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   543
  find({"wanted"=>sub{}, "preprocess"=>$dirhandler, "no_chdir" => 1}, $srcDir);
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
sub RemoveAbldFromSource {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   547
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   548
  my $dir = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   549
  my $files = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   550
  
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   551
  $dir = File::Spec->canonpath($dir);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   552
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   553
  foreach my $entry (@{$self->{binaryStatements}}, @{$self->{exportsStatements}}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   554
    if ($entry->{abldPath} eq $dir) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   555
      @$files = grep $_ !~ /abld.bat/i, @$files;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   556
      return;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   557
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   558
  }  
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   559
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   560
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   561
sub HandleBinDirOrFile {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   562
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   563
  my $remove = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   564
  my $category = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   565
  my $file = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   566
  my $successRef = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   567
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   568
  if (-d $file) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   569
    $self->HandleBinDir($remove, $category, $file, $successRef);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   570
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   571
  elsif ($file) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   572
    $self->HandleBinFile($remove, $category, $file, $successRef);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   573
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   574
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   575
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   576
sub HandleBinFile {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   577
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   578
  my $remove = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   579
  my $category = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   580
  my $file = Utils::RemoveEpocRoot(shift);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   581
  my $successRef = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   582
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   583
  my $lcFile = lc($file); # Note, duplicate check is performed on lower case file name. Original case is preserved within the hash.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   584
  Utils::TidyFileName(\$file);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   585
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   586
  die "No category was provided" unless $category;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   587
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   588
  if ($remove) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   589
    foreach my $thisClassification (keys %{$self->{bins}}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   590
      if (exists $self->{bins}->{$thisClassification}->{$lcFile}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   591
        if ($self->{verbose} > 1) { print "Excluding binary file \"$file\" from $thisClassification...\n"; }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   592
        delete $self->{bins}->{$thisClassification}->{$lcFile};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   593
        $$successRef = 1;
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
  else {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   598
    unless ($self->IsDuplicateBin($file)) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   599
      if ($self->{verbose} > 1) { print "Adding binary file \"$file\" to category $category...\n"; }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   600
      $self->{bins}->{$category}->{$lcFile} = $file;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   601
      $$successRef = 1;
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
  }
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 HandleBinDir {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   609
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   610
  my $remove = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   611
  my $category = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   612
  my $binDir = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   613
  my $successRef = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   614
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   615
  find($self->ProcessBinFile($remove, $category, $successRef), $binDir);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   616
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   617
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   618
sub ProcessBinFile {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   619
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   620
  my $remove = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   621
  my $category = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   622
  my $successRef = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   623
  return sub {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   624
    my $file = $File::Find::name;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   625
    
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   626
    if (Utils::CheckForUnicodeCharacters($file)) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   627
      die "Error: \"$file\" contains unicode characters, which are incompatible with the CBR Tools. This file can not be included in this release.\n"; 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   628
    }    
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   629
    
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   630
    if (-f $file) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   631
      Utils::TidyFileName(\$file);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   632
      $self->HandleBinFile($remove, $category, $file, $successRef);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   633
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   634
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   635
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   636
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   637
sub IsDuplicateBin {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   638
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   639
  my $fileName = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   640
  my $fileNameLc = lc ($fileName);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   641
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   642
  my $duplicate = 0;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   643
  foreach my $thisCategory (keys %{$self->{bins}}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   644
    if (exists $self->{bins}->{$thisCategory}->{$fileNameLc}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   645
      # This file has already been handled once, so it must be a duplicate.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   646
      # Therefore move it to the 'unclassified' category to ensure it doesn't get released twice.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   647
      if ($thisCategory ne 'unclassified') {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   648
	if ($self->{verbose} > 1) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   649
	  print "Moving binary file \"$fileName\" to from category $thisCategory to 'unclassified'...\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   650
	}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   651
	$self->{bins}->{unclassified}->{$fileNameLc} = $fileName;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   652
	delete $self->{bins}->{$thisCategory}->{$fileNameLc};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   653
      }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   654
      $duplicate = 1;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   655
      last;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   656
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   657
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   658
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   659
  return $duplicate;
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 HandleBinSet {
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
  my $remove = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   665
  my $test = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   666
  if ($test) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   667
    $test = 'test';
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   668
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   669
  else {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   670
    $test = '';
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   671
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   672
  my $successRef = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   673
  my $abldPath = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   674
  $abldPath = SourceRootPath($abldPath);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   675
  my $plat = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   676
  my $var = '';
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   677
  if ($_[0] and $_[0] =~ /(u?(?:deb|rel))/i) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   678
    $var = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   679
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   680
  my $mmp = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   681
  unless ($mmp) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   682
    $mmp = '';
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   683
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   684
  
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   685
  $self->ProcessCache($abldPath, $test) if (!exists($self->{abldcache}->{loaded}->{$abldPath}));
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   686
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   687
  my $plats = $self->ResolveAlias($abldPath, $plat);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   688
  my $vars;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   689
  foreach $plat (@$plats) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   690
    if ($var) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   691
      $vars = [$var];
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   692
    } elsif ($plat =~ /^tools2?$/i) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   693
      # Hard-coded and nasty
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   694
      $vars = [ 'deb', 'rel' ];
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   695
    } else {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   696
      $vars = [ 'udeb', 'urel' ];
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   697
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   698
    foreach $var (@$vars) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   699
      push @{$self->{binsets}}, {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   700
        path => Utils::RemoveSourceRoot($abldPath),
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   701
        plat => $plat,
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   702
        var => $var,
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   703
        mmp => $mmp,
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   704
        test => $test
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   705
      } unless ($remove);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   706
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   707
      $self->ReadBinaries($abldPath, $test, $plat, $var, $mmp, $remove, $successRef);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   708
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   709
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   710
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   711
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   712
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   713
sub ProcessCache {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   714
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   715
  my $abldPath = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   716
  my $test = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   717
  
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   718
  $self->CheckBuildSystem($abldPath) if(!$self->{buildSystem});
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   719
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   720
  if($self->{buildSystem} == 2){
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   721
    print "current build system is Raptor...\n" if ($self->{verbose});
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   722
    $self->ProcessRaptorCache($abldPath, $test);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   723
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   724
  else{
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   725
    print "current build system is Abld...\n" if ($self->{verbose});
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   726
    $self->ProcessAbldCache($abldPath);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   727
  }
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
#check which build system would be using
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   731
sub CheckBuildSystem {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   732
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   733
  my $abldPath = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   734
  my $buildSystem = $self->{iniData}->BuildSystemVersion($self->{verbose});
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   735
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   736
  if($buildSystem eq "1") {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   737
    if ($self->AbldAvailable($abldPath)){
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   738
      $self->{buildSystem} = 1;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   739
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   740
    else{
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   741
      die "Abld build system isn't available.\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   742
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   743
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   744
  else{
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   745
    if($buildSystem ne "2") {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   746
	    print "Warning: the value of build system is neither 1 nor 2 so we try to use Raptor.\n" if ($self->{verbose});
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   747
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   748
    
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   749
    if ($self->RaptorAvailable()){
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   750
      $self->{buildSystem} = 2;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   751
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   752
    elsif($buildSystem ne "2") {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   753
      print "Warning: Raptor is not available and we try to use Abld.\n" if ($self->{verbose});
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   754
	  	
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   755
      if ($self->AbldAvailable($abldPath)){
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   756
        $self->{buildSystem} = 1;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   757
      }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   758
      else{
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   759
        die "Neither Abld nor Raptor is available.\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   760
      }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   761
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   762
    else{
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   763
      die "Raptor build system is not available.\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   764
    }
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
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   768
sub ProcessAbldCache {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   769
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   770
  my $abldPath = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   771
  if (exists $ENV{ABLDCACHE}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   772
    $self->{abldcache}->{loaded}->{$abldPath}= 1;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   773
    my $cachefile=File::Spec->catdir($ENV{ABLDCACHE},$abldPath,"cache");
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   774
    if (-f $cachefile) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   775
      print "Reading ABLD Cache from $cachefile\n" if ($self->{verbose});
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   776
	
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   777
      open(CACHE, $cachefile) or die "Couldn't open abld cache data file '$cachefile'\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   778
      my @cache = <CACHE>;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   779
      close(CACHE);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   780
      eval (join("",@cache)) or die "Error: Couldn't parse abld cache data in '$cachefile': $@\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   781
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   782
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   783
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   784
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   785
sub ProcessRaptorCache {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   786
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   787
  my $abldPath = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   788
  my $test = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   789
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   790
  my $cwd = cwd();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   791
  my $driver = $cwd;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   792
  $driver =~ /^(.:)(.*)/;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   793
  $driver = $1."\\raptorcache";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   794
  my $logfile = File::Spec->catdir($driver.$abldPath,"info.xml");
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   795
  if(! -f $logfile){
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   796
    my $makefile = File::Spec->catdir($driver.$abldPath,"Makefile");
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   797
    print "execute SBS to create Raptor XML log file: $logfile\n" if($self->{verbose});
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   798
    chdir $abldPath or die "Error: Couldn't change working directory to \"$abldPath\": $!\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   799
    my $cmd = $self->RaptorLogCmd($abldPath, $logfile, $makefile, $test);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   800
    open (SBS, $cmd) or die "Error: Couldn't run \"$cmd\" in \"$abldPath\": $!\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   801
    my $foundLog;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   802
    my $errmsg;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   803
    while (my $line = <SBS>) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   804
      $errmsg = $1 if ($line =~ /sbs : errors: (\d+)/ and $1 > 0);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   805
      $foundLog = 1 if ($line =~ /sbs: build log in (\w+)/);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   806
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   807
    close (SBS);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   808
			  
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   809
    if($errmsg){
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   810
      my $trycount = 50;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   811
      my $errtag = 0;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   812
      while($trycount > 0){
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   813
        print "try to run sbs again: $trycount\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   814
        open (SBS, $cmd) or die "Error: Couldn't run \"$cmd\" in \"$abldPath\": $!\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   815
        $errtag = 0;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   816
        while (my $line = <SBS>) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   817
          if ($line =~ /sbs : errors: (\d+)/ and $1 > 0){
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   818
            $errtag = 1;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   819
            $trycount = $trycount - 1;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   820
          }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   821
          $foundLog = 1 if ($line =~ /sbs: build log in (\w+)/);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   822
        }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   823
        $trycount =0 if($errtag < 1);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   824
        close (SBS);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   825
      }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   826
      if($errtag == 1 and $trycount == 0) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   827
      	die "SBS Error: Couldn't run \"$cmd\" in \"$abldPath\"\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   828
      }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   829
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   830
    chdir $cwd or die "Error: Couldn't change working directory to \"$cwd\": $!\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   831
    unless ($foundLog) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   832
      die "Error: Unable to execute \"SBS\" in \"$abldPath\"\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   833
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   834
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   835
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   836
  $self->ParseRaptorXmlLog($logfile);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   837
  $self->PrintCache() if($self->{verbose});
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   838
  $self->{abldcache}->{loaded}->{$abldPath}= 1;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   839
  print "cache is generated successfully\n" if($self->{verbose});
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   840
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   841
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   842
sub RaptorLogCmd {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   843
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   844
  my $abldPath = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   845
  my $logfile = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   846
  my $makefile = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   847
  my $test = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   848
  if ($test) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   849
    $test = 'test';
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   850
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   851
  else {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   852
    $test = '';
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   853
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   854
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   855
  my $plat = "all";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   856
  my $iniAll = $self->{iniData}->TargetPlatforms($plat);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   857
  my $cmd = "SBS -b bld.inf -m $makefile -f $logfile -c default";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   858
  $cmd = $cmd." -c default.test" if ($test ne '');
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   859
  foreach my $e (@$iniAll) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   860
    $cmd = $cmd." -c tools_rel -c tools_deb" if ($e eq "TOOLS");
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   861
    $cmd = $cmd." -c tools2_rel -c tools2_deb" if ($e eq "TOOLS2");
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   862
    $cmd = $cmd." -c armv5.smp" if ($e eq "ARMV5SMP");
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   863
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   864
  $cmd = $cmd." WHAT |";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   865
  print "Raptor command: $cmd\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   866
  return $cmd;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   867
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   868
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   869
#check whether Abld build system is available
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   870
sub AbldAvailable {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   871
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   872
  my $abldPath = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   873
  my $path = File::Spec->catdir($abldPath,"");
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   874
  my $foundPlats = 0;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   875
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   876
  my $cwd = cwd();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   877
  chdir $abldPath or die "Error: Couldn't change working directory to \"$abldPath\": $!\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   878
  open (BLDMAKE, "bldmake bldfiles |") or die "Error: Couldn't run \"bldmake bldfiles\" in \"$abldPath\": $!\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   879
  while (my $line = <BLDMAKE>) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   880
    chomp $line;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   881
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   882
  close(BLDMAKE);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   883
	
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   884
  open (ABLD, "abld help |") or die "Error: Couldn't run \"abld help\" in \"$abldPath\": $!\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   885
  while (my $line = <ABLD>) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   886
    chomp $line;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   887
    $foundPlats = 1 if ($line =~ /project platforms:/);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   888
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   889
  close (ABLD);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   890
  chdir $cwd or die "Error: Couldn't change working directory to \"$cwd\": $!\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   891
  
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   892
  return $foundPlats;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   893
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   894
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   895
#check whether Raptor build system is available
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   896
sub RaptorAvailable {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   897
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   898
  my $maxver = 0;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   899
  my $midver = 0;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   900
  my $minver = 0;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   901
  
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   902
  return 0 if(!-f "\\epoc32\\data\\buildinfo.txt" and !-f "\\epoc32\\data\\kif.xml");
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   903
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   904
  open (SBS, "sbs -version |") or die "Error: Couldn't run \"sbs -version\": $!\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   905
  while (my $line = <SBS>) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   906
    chomp $line;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   907
    if ($line =~ /^sbs version (\d+)\.(\d+)\.(\d+)/){
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   908
      $maxver = $1;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   909
      $midver = $2;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   910
      $minver = $3;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   911
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   912
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   913
  close (SBS);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   914
  if ($maxver == 0 and $midver == 0 and $minver == 0) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   915
    return 0;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   916
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   917
  elsif ($maxver < 2 or ($maxver == 2 and $midver < 7)) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   918
    die "Error: Raptor build system version must be 2.7.0 or higher.\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   919
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   920
  return 1;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   921
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   922
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   923
sub ParseRaptorXmlLog {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   924
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   925
  my $xmlfile = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   926
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   927
  my $xmldata;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   928
  my $trycount = 20;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   929
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   930
  while ($trycount > 0) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   931
    eval {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   932
      $xmldata = XMLin($xmlfile);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   933
    };
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   934
    if ($@) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   935
      $trycount = $trycount - 1;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   936
      print "Try to open raptor log file [$trycount]: $xmlfile\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   937
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   938
    else{
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   939
      $trycount = 0;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   940
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   941
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   942
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   943
  my $whatLogElements = $self->WrapVarToArray($xmldata->{whatlog});
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   944
  foreach  my $whatLogElement (@$whatLogElements) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   945
    $self->ProcessWhatLogElement($whatLogElement);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   946
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   947
  
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   948
  foreach my $param (keys %{$self->{abldcache}->{exports}}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   949
    foreach my $destination (keys %{$self->{abldcache}->{exports}->{$param}}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   950
      push @{$self->{abldcache}->{$param}}, [$destination, $self->{abldcache}->{exports}->{$param}->{$destination}];
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   951
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   952
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   953
  delete $self->{abldcache}->{exports};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   954
  
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   955
  foreach my $param (keys %{$self->{abldcache}->{builds}}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   956
    foreach my $buildItem (keys %{$self->{abldcache}->{builds}->{$param}}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   957
      push @{$self->{abldcache}->{$param}}, $buildItem;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   958
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   959
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   960
  delete $self->{abldcache}->{builds};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   961
  
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   962
  foreach my $platform (keys %{$self->{abldcache}->{platforms}}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   963
    push @{$self->{abldcache}->{plats}}, uc($platform);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   964
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   965
  delete $self->{abldcache}->{platforms};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   966
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   967
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   968
sub ProcessWhatLogElement {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   969
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   970
  my $aWhatLogElement = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   971
  
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   972
  my $bldinf = $aWhatLogElement->{bldinf};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   973
  my $bldinfDir = $bldinf;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   974
  $bldinfDir =~ s/\//\\/g;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   975
  $bldinfDir =~ /^.:(.+)\\(.*)/;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   976
  $bldinfDir = $1;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   977
  
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   978
  my $mmp = $aWhatLogElement->{mmp};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   979
  my $config = $aWhatLogElement->{config};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   980
  
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   981
  my $platform = "";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   982
  my $variant = "";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   983
  my $test;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   984
  
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   985
  if ($config =~ /^(\w+)_(\w+)\.test/){
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   986
    $platform = $1;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   987
    $variant = $2;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   988
    $test = "test";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   989
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   990
  elsif ($config =~ /^(\w+)_(\w+)*/){
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   991
    $platform = $1;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   992
    $variant = $2;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   993
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   994
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   995
  if($aWhatLogElement->{export}){
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   996
    my $exports = $self->WrapVarToArray($aWhatLogElement->{export});
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   997
    foreach  my $export (@$exports) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   998
      $self->StoreExportItem ($bldinfDir, $export->{source}, $export->{destination}, $test);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   999
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1000
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1001
  if($aWhatLogElement->{archive}){
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1002
    my $archives = $self->WrapVarToArray($aWhatLogElement->{archive});
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1003
    foreach my $archive (@$archives){
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1004
      foreach  my $member (@{$archive->{member}}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1005
        $self->StoreExportItem ($bldinfDir, $archive->{zipfile}, $member, $test);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1006
      }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1007
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1008
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1009
  if($aWhatLogElement->{build}){
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1010
    my $buildItems = $self->WrapVarToArray($aWhatLogElement->{build});
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1011
    foreach  my $buildItem (@$buildItems) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1012
      $self->StoreBuildItem ($bldinfDir, $buildItem, $platform, $variant, $test);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1013
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1014
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1015
  if($aWhatLogElement->{resource}){
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1016
    my $resources = $self->WrapVarToArray($aWhatLogElement->{resource});
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1017
    foreach  my $buildItem (@$resources) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1018
      if($buildItem =~ /[\\|\/]epoc32[\\|\/]release[\\|\/]winscw[\\|\/](urel|udeb)[\\|\/]/g){
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1019
        $variant = $1;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1020
      }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1021
      else{
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1022
        $variant = "ALL"; 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1023
      }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1024
      $self->StoreBuildItem ($bldinfDir, $buildItem, $platform, $variant, $test);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1025
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1026
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1027
  if($aWhatLogElement->{bitmap}){
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1028
    my $bitmaps = $self->WrapVarToArray($aWhatLogElement->{bitmap});
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1029
    foreach  my $buildItem (@$bitmaps) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1030
      $self->StoreBuildItem ($bldinfDir, $buildItem, $platform, "ALL", $test);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1031
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1032
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1033
  if($aWhatLogElement->{stringtable}){
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1034
    my $stringTables = $self->WrapVarToArray($aWhatLogElement->{stringtable});
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1035
    foreach  my $buildItem (@$stringTables) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1036
      $self->StoreBuildItem ($bldinfDir, $buildItem, $platform, $variant, $test);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1037
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1038
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1039
  
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1040
  $self->{abldcache}->{platforms}->{$platform} = 1 if($platform ne "ALL");
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1041
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1042
  my $param = "$bldinfDir ";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1043
  $param = $param."test " if ($test);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1044
  $param = $param."export -what";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1045
  if(!$self->{abldcache}->{$param}){
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1046
    pop @{$self->{abldcache}->{$param}};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1047
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1048
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1049
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1050
sub StoreExportItem {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1051
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1052
  my $bldinfDir = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1053
  my $aSource = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1054
  my $aDestination =shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1055
  my $test = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1056
  $aSource = $self->ReleasableItem($aSource);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1057
  $aDestination = $self->ReleasableItem($aDestination);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1058
  my $param = "$bldinfDir ";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1059
  $param = $param."test " if ($test);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1060
  $param = $param."export -what";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1061
  $self->{abldcache}->{exports}->{$param}->{$aDestination} = $aSource;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1062
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1063
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1064
sub StoreBuildItem {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1065
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1066
  my $bldinfDir = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1067
  my $aBuildItem = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1068
  my $aPlatform = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1069
  my $aVariant = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1070
  my $test = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1071
	
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1072
  if($aPlatform ne "ALL" and $aVariant eq "ALL"){
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1073
    $self->StoreBuildItem($bldinfDir, $aBuildItem, $aPlatform, "urel", $test);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1074
    $self->StoreBuildItem($bldinfDir, $aBuildItem, $aPlatform, "udeb", $test);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1075
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1076
  else{
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1077
    $aBuildItem = $self->ReleasableItem($aBuildItem);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1078
    my $param = "$bldinfDir ";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1079
    $param = $param."test " if ($test);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1080
    $param = $param."target $aPlatform $aVariant -what";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1081
    $self->{abldcache}->{builds}->{$param}->{$aBuildItem} = 1;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1082
    $self->{abldcache}->{platforms}->{$aPlatform} = 1 if($aPlatform ne "ALL");
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1083
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1084
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1085
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1086
sub ReleasableItem {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1087
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1088
  my $aBuildItem = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1089
  $aBuildItem =~ s/\/\//\\/g;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1090
  $aBuildItem =~ s/\//\\/g;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1091
  $aBuildItem =~ s/\"//g;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1092
  $aBuildItem =~ /^.:(.+)/;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1093
  return $1;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1094
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1095
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1096
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1097
sub WrapVarToArray {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1098
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1099
  my $var = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1100
  my @result;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1101
  
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1102
  if($var){
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1103
    if($var =~/^ARRAY*/){
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1104
      return $var;	
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1105
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1106
    else{
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1107
      push (@result, $var);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1108
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1109
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1110
  return \@result;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1111
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1112
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1113
sub PrintCache {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1114
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1115
  print "print cache content\n" if($self->{verbose});
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1116
  foreach my $item (keys %{$self->{abldcache}}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1117
    if($item ne "loaded"){
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1118
      print "\$self->{abldcache}->{\'$item\'} =\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1119
      print " [\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1120
      my $first = 1;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1121
      
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1122
      foreach my $cachedata (@{$self->{abldcache}->{$item}}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1123
      	print ",\n" if($first > 1);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1124
      	$first = $first+1;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1125
        if($cachedata=~/^ARRAY*/){
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1126
    	    print " [\'@$cachedata[0]\', \'@$cachedata[1]\']";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1127
        }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1128
        else{
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1129
    	    print " \'$cachedata\'";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1130
        } 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1131
      }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1132
      print "\n ];\n\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1133
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1134
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1135
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1136
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1137
# Support for target alias file
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1138
# If the MRP specifies 'ALL' then the intersection of the
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1139
# definition of 'ALL' and the output of abld help is used
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1140
# as the platform list
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1141
sub ResolveAlias {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1142
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1143
  my $abldPath = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1144
  my $plat = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1145
  my @plats = ();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1146
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1147
  if (lc $plat eq 'all' || $self->{iniData}->HasTargetPlatforms($plat)) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1148
    if ($self->{iniData}->HasTargetPlatforms($plat)) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1149
      if (lc $plat eq 'all') {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1150
        # ALL and HasTargetPlatforms()
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1151
        # Do the set intersection with the output of abld help
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1152
        my $iniAll = $self->{iniData}->TargetPlatforms($plat);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1153
        my $abldHelp = $self->GetPlatforms($abldPath);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1154
        my %count;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1155
        foreach my $e (@$iniAll) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1156
          $count{$e} = 1;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1157
        }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1158
        foreach my $e (@$abldHelp) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1159
          if (exists $count{$e} and $count{$e} == 1) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1160
            push @plats, $e;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1161
          }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1162
        }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1163
        $self->RemoveIDEPlatforms(\@plats);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1164
        if ($self->{verbose} > 1) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1165
          print "Intersection of \"ALL\" alias and abld help is \"@plats\"\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1166
        }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1167
      } else {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1168
        # NOT ALL and HasTargetPlatforms()
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1169
        # Use the list of platforms from the iniData and this alias
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1170
        @plats = @{$self->{iniData}->TargetPlatforms($plat)};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1171
        if ($self->{verbose} > 1) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1172
          print "Resolution of \"$plat\" alias is \"@plats\"\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1173
        }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1174
      }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1175
    } else {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1176
      # ALL and NOT HasTargetPlatforms() so just use
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1177
      # the results of abld help
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1178
      @plats = @{$self->GetPlatforms($abldPath)};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1179
      $self->RemoveIDEPlatforms(\@plats);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1180
      if ($self->{verbose} > 1) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1181
        print "Resolution of \"ALL\" alias from abld help is \"@plats\"\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1182
      }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1183
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1184
  } else {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1185
    # NOT ALL and NOT HasTargetPlatforms() so use this as the platform
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1186
    @plats = $plat;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1187
    if ($self->{verbose} > 1) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1188
      print "Platform specified is \"@plats\"\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1189
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1190
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1191
  return \@plats;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1192
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1193
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1194
sub RemoveIDEPlatforms {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1195
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1196
  my $plats = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1197
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1198
  # Ugly hard-coded yukkiness
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1199
  @$plats = grep { !m/^cw_ide$/i && !m/^vc\d/i } @$plats;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1200
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1201
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1202
sub GetPlatforms {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1203
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1204
  my $bldInfDir = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1205
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1206
  if (exists $self->{abldcache}->{"plats"}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1207
    return $self->{abldcache}->{"plats"};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1208
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1209
  $self->CallBldMakeIfNecessary($bldInfDir);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1210
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1211
 TRYAGAIN:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1212
  my $foundPlats = 0;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1213
  my @plats;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1214
  my @errorLines;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1215
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1216
  my @abldOutput = `($bldInfDir\\abld help | perl -pe "s/^/stdout: /") 2>&1`; # Adds 'stdout: ' to the beginning of each STDOUT line, nothing is added to output on STDERR.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1217
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1218
  foreach my $line (@abldOutput) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1219
    chomp $line;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1220
      
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1221
    if ($line =~ s/^stdout: //) { # Output from STDOUT
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1222
      if ($foundPlats) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1223
        if ($self->{verbose}) { print "Found platforms: $line\n"; }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1224
        $line =~ s/^\s*//; # Strip off leading whitespace.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1225
        # Force platforms to upper case to match IniData::TargetPlatforms()
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1226
        $line = uc $line;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1227
        @plats = split /\s+/, $line;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1228
        last;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1229
      }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1230
      if ($line =~ /project platforms:/) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1231
        $foundPlats = 1;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1232
      }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1233
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1234
 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1235
    else { # Output from STDERR
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1236
      if ($line =~ m/project bldmake directory.*does not exist/i) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1237
        $self->CallBldMake($bldInfDir);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1238
        goto TRYAGAIN;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1239
      }  
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1240
      elsif ($line =~ /Can't find ABLD.PL on PATH/i) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1241
        push @errorLines, "Error: Couldn't run $bldInfDir\\abld: $line\n";      
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1242
      }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1243
      else {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1244
        push @errorLines, "$line\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1245
      }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1246
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1247
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1248
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1249
  if (scalar @errorLines > 0) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1250
    die @errorLines;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1251
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1252
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1253
  die "Error: didn't find any platforms\n" unless $foundPlats;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1254
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1255
  $self->{abldcache}->{"plats"} = \@plats;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1256
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1257
  return \@plats;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1258
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1259
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1260
sub ReadBinaries {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1261
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1262
  my $abldPath = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1263
  my $test = lc(shift);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1264
  my $plat = lc(shift);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1265
  my $var = lc(shift);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1266
  my $mmp = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1267
  my $remove = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1268
  my $successRef = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1269
  my $command = "target";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1270
  my $opts = "-what";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1271
  $command = "$test $command" if $test;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1272
  $opts = "$mmp $opts" if $mmp;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1273
  if ($self->{verbose}) { print "Extracting target info from \"$abldPath\\abld.bat\" using \"$command $plat $var\"...\n";  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1274
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1275
  my $bins = $self->GatherAbldOutput($abldPath, $plat, $command, $var, $test, $opts);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1276
  my $category = 'unclassified';
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1277
  if ($self->{iniData}->CategoriseBinaries() and not $plat =~ /^tools2?$/i) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1278
    $category = $plat . '_' . $var;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1279
    if ($test) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1280
      $category = $test . '_' . $category;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1281
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1282
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1283
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1284
  $self->AddBins($remove, $category, $bins, $successRef);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1285
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1286
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1287
sub HandleExports {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1288
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1289
  my $abldPath = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1290
  my $test = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1291
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1292
  $test = $test?"test ":"";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1293
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1294
  if ($self->{verbose}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1295
    print "Extracting ${test}export info from $abldPath\\abld.bat...\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1296
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1297
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1298
  my $exports = $self->GatherAbldOutput($abldPath, "", "${test}export", "", $test, "-what");
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1299
  if ($self->{iniData}->CategoriseExports()) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1300
    foreach my $thisExport (@$exports) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1301
      if ($self->{verbose} > 1) { print "Found export \"$thisExport\"...\n"; }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1302
      if (Utils::WithinEpocRoot($thisExport)) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1303
	$thisExport = Utils::RemoveEpocRoot($thisExport);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1304
      }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1305
      else {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1306
	print "Warning: Exported file \"$thisExport\" is not within EPOCROOT\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1307
      }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1308
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1309
      # Note, the hash key is case lowered to ensure duplicates are rejected.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1310
      # The original case is preserved in the hash values.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1311
      my $thisExportLc = lc($thisExport);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1312
      Utils::TidyFileName(\$thisExportLc);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1313
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1314
      # Note, the exports are not yet classified because this is done using the source code classifications.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1315
      # At this point we don't know if we've handled all the 'source' mrp keywords yet. Classification will
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1316
      # occur when the exports are asked for.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1317
      $self->{exports}->{automatic}->{$thisExportLc} = $thisExport;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1318
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1319
    Utils::AbsolutePath(\$abldPath);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1320
    push (@{$self->{exports}->{abldPaths}}, Utils::RemoveSourceRoot($abldPath));
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1321
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1322
  else {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1323
    # Handle exports treating them as binary files. Note, for a short while this code was changed to handle
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1324
    # exported directories (not just files). This functionality has been removed because bldmake doesn't
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1325
    # appear to cope with exported directories (it concatenates all the files in the specified directory into
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1326
    # a single file due to weird use of the 'copy' command).
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1327
    foreach my $thisExport (@$exports) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1328
      $self->HandleBinFile(0, 'unclassified', $thisExport); # 0 = don't remove.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1329
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1330
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1331
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1332
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1333
sub HandleExportFile {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1334
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1335
  my $source = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1336
  my $destination = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1337
  my $remove = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1338
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1339
  if ($self->{iniData}->CategoriseExports()) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1340
    if ($remove) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1341
      my $destinationLc = lc(Utils::RemoveEpocRoot($destination));
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1342
      Utils::TidyFileName(\$destinationLc);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1343
      if (exists $self->{exports}->{automatic}->{$destinationLc}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1344
	print "Excluding export \"$destination\"...\n" if ($self->{verbose});
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1345
	delete $self->{exports}->{automatic}->{$destinationLc};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1346
      } else {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1347
        my $comp = $self->{comp} || "component name unknown";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1348
        print "Warning: ($comp) -export_file: could not remove $destination, as it hadn't been added. Perhaps the lines in your MRP are in the wrong order, or you meant -binary?\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1349
      }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1350
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1351
    else {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1352
      Utils::CheckExists($source);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1353
      Utils::CheckIsFile($source);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1354
      Utils::CheckExists($destination);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1355
      Utils::CheckIsFile($destination);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1356
      $self->{exports}->{manual}->{Utils::RemoveSourceRoot($source)} = Utils::RemoveEpocRoot($destination);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1357
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1358
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1359
  else {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1360
    $self->HandleBinFile($remove, 'unclassified', $destination);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1361
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1362
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1363
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1364
sub AddBins {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1365
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1366
  my $remove = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1367
  my $category = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1368
  my $bins = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1369
  my $successRef = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1370
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1371
  foreach my $file (@$bins) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1372
    $self->HandleBinDirOrFile($remove, $category, $file, $successRef);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1373
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1374
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1375
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1376
sub EnsureDoesNotExist {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1377
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1378
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1379
  my $relDir = $self->{iniData}->PathData->LocalArchivePathForExistingOrNewComponent($self->{comp}, $self->{ver});
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1380
  if (-e $relDir) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1381
    die "Error: $self->{comp} $self->{ver} already exists\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1382
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1383
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1384
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1385
sub Validate {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1386
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1387
  my $warnNotError = shift; # produce warnings instead of errors for some messages
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1388
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1389
  return if $self->{validated};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1390
  $self->{validated} = 1;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1391
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1392
  $self->EnsureDoesNotExist;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1393
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1394
  unless (defined $self->{comp}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1395
    die "Error: No 'component' keyword specified in $self->{mrpName}\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1396
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1397
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1398
  $self->NotesSource(); # will die if we can't find a notes_source tag
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1399
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1400
  my @errors;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1401
  my @warnings;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1402
  
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1403
  foreach my $bin (@{$self->Binaries()}) {    
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1404
    my $file = Utils::PrependEpocRoot(lc($bin));
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1405
    
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1406
    if (my $result = $self->CheckPathLength($file)) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1407
      if ($warnNotError) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1408
        push (@warnings, "Warning: $result\n");
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1409
      } else { 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1410
        push (@errors, "Error: $result\n");
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1411
      }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1412
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1413
    
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1414
    if ($self->{fixMissingLibs}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1415
      unless (-e $file) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1416
        if ($file =~ /$ENV{EPOCROOT}epoc32\\release\\armi\\(\S+)\\(\S+\.lib)/) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1417
          my $fileToCopy = "$ENV{EPOCROOT}epoc32\\release\\thumb\\$1\\$2";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1418
          print "Copying $fileToCopy to $file...\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1419
          copy ($fileToCopy, $file) or push (@errors, "Error: Problem copying \"$fileToCopy\" to \"$file\": $!\n");
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1420
        }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1421
        else {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1422
          push (@errors, "Error: \"$file\" does not exist\n");
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1423
        }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1424
      }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1425
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1426
    else {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1427
      unless (-e $file) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1428
        push (@errors, "Error: \"$file\" does not exist\n");
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1429
      }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1430
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1431
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1432
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1433
  foreach my $thisCategory (@{$self->ExportCategories()}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1434
    foreach my $thisExport (@{$self->Exports($thisCategory)}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1435
      $thisExport = Utils::PrependEpocRoot($thisExport); 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1436
      
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1437
      if (my $result = $self->CheckPathLength($thisExport)) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1438
        if ($warnNotError) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1439
          push (@warnings, "Warning:  $result\n");
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1440
        } else { 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1441
          push (@errors, "Error:  $result\n");
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1442
        }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1443
      }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1444
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1445
      unless (-e $thisExport) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1446
        push (@errors, "Error: \"$thisExport\" does not exist\n");
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1447
      }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1448
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1449
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1450
 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1451
  foreach my $thisSourceCategory (@{$self->SourceCategories()}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1452
    foreach my $thisSourceFile (@{$self->Source($thisSourceCategory)}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1453
      if (my $result = $self->CheckPathLength($thisSourceFile)) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1454
        if ($warnNotError) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1455
          push (@warnings, "Warning:  $result\n");
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1456
        } else { 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1457
          push (@errors, "Error:  $result\n");
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1458
        }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1459
      }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1460
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1461
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1462
  
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1463
  if (@warnings) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1464
    print @warnings;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1465
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1466
  
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1467
  if (@errors and $#errors != -1) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1468
    if ($#errors == 0) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1469
      die $errors[0];
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1470
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1471
    else {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1472
      print @errors;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1473
      my $firstError = $errors[0];
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1474
      chomp $firstError;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1475
      die "Multiple errors (first - $firstError)\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1476
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1477
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1478
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1479
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1480
sub CallBldMakeIfNecessary {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1481
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1482
  my $abldPath = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1483
  if (-e "$abldPath\\abld.bat") {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1484
    # Check to see if bld.inf has been modifed since bldmake was last run.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1485
    my $abldMTime = Utils::FileModifiedTime("$abldPath\\abld.bat");
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1486
    my $bldInfMTime = Utils::FileModifiedTime("$abldPath\\bld.inf");
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1487
    if ($bldInfMTime > $abldMTime) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1488
      $self->CallBldMake($abldPath);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1489
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1490
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1491
  else {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1492
    $self->CallBldMake($abldPath);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1493
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1494
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1495
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1496
sub GatherAbldOutput {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1497
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1498
  my $abldPath = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1499
  my $plat = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1500
  my $abldCmnd = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1501
  my $var = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1502
  my $test = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1503
  my $opts = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1504
  my @output;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1505
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1506
  my $abldParms = $abldCmnd;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1507
  $abldParms .= " $plat" if $plat;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1508
  $abldParms .= " $var" if $var;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1509
  $abldParms .= " $opts" if $opts;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1510
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1511
  $abldPath=~s/\//\\/s; # Normalise all slashes to backslashes
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1512
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1513
  $self->ProcessCache($abldPath, $test) if (!exists($self->{abldcache}->{loaded}->{$abldPath}));
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1514
  
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1515
  if ($self->{abldcache}->{$abldPath." ".$abldParms}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1516
    # Why do we bother with a cache?
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1517
    # Because you might see this in an MRP:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1518
    #   binary \blah all
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1519
    #   -binary \blah mfrumpy
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1520
    # The "all" will be expanded to multiple calls to GatherAbldOutput, if we've got CategoriseBinaries on
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1521
    
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1522
    # The codes below are added to make MakeCBR follow cachefiles created by Raptor
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1523
    if($abldCmnd eq "export" and $opts eq "-what"){
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1524
        my $exports = $self->{abldcache}->{$abldPath." ".$abldParms};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1525
        if(@$exports[0]){
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1526
          my $firstExportFile = @$exports[0];
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1527
          if($firstExportFile=~/^ARRAY*/){
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1528
            foreach my $thisExport (@$exports) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1529
                push (@output, @$thisExport[0]);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1530
                push @{$self->{exportsToBeProcessed}}, {source => @$thisExport[1],
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1531
                                                        destination => @$thisExport[0],
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1532
                                                        abldPath => Utils::PrependSourceRoot($abldPath)};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1533
            }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1534
            $self->{raptorcache} = 1;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1535
            return \@output;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1536
          }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1537
        }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1538
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1539
    
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1540
    return $self->{abldcache}->{$abldPath." ".$abldParms};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1541
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1542
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1543
  # Remove repeat guards - these stop CallBldMake and CallMakMake from being called
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1544
  #                        forever if a fatal error occurs with a build script.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1545
  delete $self->{bldMakeCalled};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1546
  delete $self->{"makMakeCalled_$plat"};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1547
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1548
  $self->CallBldMakeIfNecessary($abldPath);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1549
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1550
 TRYAGAIN:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1551
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1552
  my @errorLines; # Used to store the error
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1553
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1554
  my $cmd = "$abldPath\\abld $abldParms";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1555
  print "Executing command: $cmd\n" if $self->{verbose} > 1;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1556
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1557
  my @abldOutput = `($cmd | perl -pe "s/^/stdout: /") 2>&1`;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1558
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1559
  foreach my $line (@abldOutput) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1560
    chomp $line;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1561
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1562
    if ($line =~ s/^stdout: //) { # Output from STDOUT 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1563
      if ($self->{verbose} > 1) { print "ABLD: $line\n"; }    
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1564
      
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1565
      if ($line =~ /(^(make|make\[\d+\]): .*)/) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1566
        print "Warning: $1\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1567
      }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1568
      elsif ($line =~ /given more than once in the same rule/) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1569
        print "$line\n";      
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1570
      }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1571
      elsif ($line =~ m/\.\./) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1572
        my $oldpath = cwd();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1573
        eval {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1574
          chdir($abldPath);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1575
          Utils::AbsoluteFileName(\$line);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1576
        };
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1577
        chdir($oldpath);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1578
        if ($@) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1579
          print "Warning: could not convert path \"$line\" to an absolute path because: $@\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1580
          # Do nothing. We just can't convert it to an absolute path. We'll push it onto the
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1581
          # output anyway because in some circumstances it will work out OK.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1582
        }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1583
        push (@output, $line);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1584
      } else {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1585
        # Lines without .. we don't bother making absolute, because it involves 4 chdir operations
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1586
        # so is a bit heavyweight.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1587
        push (@output, $line);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1588
      }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1589
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1590
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1591
    else { # Output from STDERR
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1592
      if ($self->{verbose} > 1) { print "ABLD: $line\n"; }    
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1593
  
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1594
      # Catch errors that look like the makefile isn't present.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1595
      # Note, different versions of the build tools produce different things, so the regular expression below is a bit evil.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1596
      if ($line =~ /^(U1052|make\[1\]: (?i:\Q$ENV{EPOCROOT}\EEPOC32\\BUILD\\.*): No such file or directory|make: \*\*\* \[.*\] Error 2)$/) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1597
  
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1598
        # Makefile not present, so generate it.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1599
  
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1600
        $self->CallMakMake($abldPath, $plat, $test);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1601
  
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1602
        goto TRYAGAIN;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1603
      }        
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1604
      elsif ($line =~ /^ABLD ERROR: Project Bldmake directory .* does not exist$/
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1605
          or $line =~ /^ABLD ERROR: .* not yet created$/
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1606
          or $line =~ /abld\.bat does not exist/) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1607
  
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1608
        #BldMake needs to be run.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1609
        $self->CallBldMake($abldPath);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1610
        goto TRYAGAIN;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1611
      }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1612
      elsif ($line =~ /^This project does not support platform/) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1613
        push @errorLines, "Error: Platform \"$plat\" not supported\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1614
      }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1615
      elsif ($line =~ /^MISSING:/) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1616
        print "$line\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1617
      }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1618
      elsif ($line =~ /Can't find ABLD.PL on PATH/i) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1619
        push @errorLines, "Error: Couldn't run abld $abldParms: $line\n";      
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1620
      }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1621
      else {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1622
        push @errorLines, "$line\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1623
      }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1624
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1625
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1626
  
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1627
  if (scalar @errorLines > 0) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1628
    die @errorLines;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1629
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1630
  
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1631
  $self->{abldcache}->{$abldPath." ".$abldParms} = \@output;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1632
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1633
  return \@output;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1634
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1635
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1636
sub CallBldMake {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1637
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1638
  my $abldPath = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1639
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1640
  if (exists $self->{bldMakeCalled}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1641
    die "Error: Problem calling bldmake in \"$abldPath\"\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1642
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1643
  else {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1644
    $self->{bldMakeCalled} = 1;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1645
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1646
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1647
  if ($self->{verbose}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1648
    print "Calling bldmake in $abldPath...\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1649
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1650
  my $cwd = cwd();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1651
  chdir $abldPath or die "Error: Couldn't change working directory to $abldPath: $!\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1652
  system "bldmake bldfiles";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1653
  chdir $cwd;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1654
  die "Error: \"bldmake bldfiles\" failed in \"$abldPath\" (exit status $?)\n" if ($?);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1655
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1656
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1657
sub CallMakMake {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1658
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1659
  my $abldPath = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1660
  my $plat = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1661
  my $test = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1662
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1663
  my $repeatGuard = "makMakeCalled_$plat";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1664
  if ($test) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1665
    $test = 'test';
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1666
    $repeatGuard .= '_test';
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1667
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1668
  else {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1669
    $test = '';
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1670
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1671
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1672
  if (exists $self->{$repeatGuard}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1673
    if ($test) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1674
      die "Error: Problem generating makefile for $test $plat in \"$abldPath\"\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1675
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1676
    else {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1677
      die "Error: Problem generating makefile for $plat in \"$abldPath\"\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1678
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1679
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1680
  else {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1681
    $self->{$repeatGuard} = 1;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1682
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1683
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1684
  if ($self->{verbose}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1685
    if ($test) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1686
      print "Generating makefile for $test $plat...\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1687
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1688
    else {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1689
      print "Generating makefile for $plat...\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1690
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1691
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1692
  system "$abldPath\\abld $test makefile $plat > NUL";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1693
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1694
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1695
sub BinSets {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1696
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1697
  
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1698
  $self->ProcessBinaries();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1699
  
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1700
  return $self->{binsets};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1701
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1702
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1703
sub SourceRootPath {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1704
  my $fileName = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1705
  if (Utils::IsAbsolute($fileName)) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1706
    $fileName = Utils::PrependSourceRoot($fileName);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1707
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1708
  else {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1709
    Utils::AbsoluteFileName(\$fileName);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1710
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1711
  Utils::CheckWithinSourceRoot($fileName);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1712
  $fileName =~ s/\\.$//;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1713
  return $fileName;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1714
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1715
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1716
sub WarnRedundantMRPLine {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1717
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1718
  my $remove = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1719
  my $line = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1720
  my $comp = $self->{comp} || "component name unknown";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1721
  my $sign = "";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1722
  my $action = "add";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1723
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1724
  if($remove) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1725
    $action = "remove";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1726
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1727
  print "Remark: ($comp) The MRP line \"$line\" does not $action any files. Therefore is this line necessary?\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1728
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1729
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1730
sub CheckPathLength {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1731
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1732
  my $path = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1733
  
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1734
  if (length ($path) > MAX_PATH_LENGTH) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1735
     return "The component \"$self->{comp}\" is pending release and contains a path which is " . length($path) . " characters long and will prevent the component from being released: \"$path\"."
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1736
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1737
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1738
  return 0;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1739
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1740
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1741
sub SetIPR {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1742
    my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1743
    my $category = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1744
    my $path = shift || 'default';
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1745
    my $exportRestricted = (shift) ? 1 : 0;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1746
    
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1747
    if (!$category || shift) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1748
      # caller(0))[3] gives the package and the method called, e.g. MrpData::SetIPR
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1749
      croak "Invalid number of arguments passed to " . (caller(0))[3] . "\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1750
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1751
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1752
    $path = File::Spec->canonpath($path); # Normalise the path
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1753
    
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1754
    # remove trailing slashes
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1755
    $path =~ s/[\\\/]$//;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1756
    
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1757
    if ($path ne 'default') {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1758
      $path = SourceRootPath($path);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1759
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1760
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1761
    if($self->{iniData}->HasMappings()){
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1762
      $path = $self->{iniData}->PerformMapOnFileName($path);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1763
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1764
    
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1765
    $path = Utils::RemoveSourceRoot($path) if ($path ne 'default');
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1766
    
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1767
    if (exists $self->{unresolvedIPR}->{$path}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1768
      return 0;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1769
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1770
    
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1771
    $self->{unresolvedIPR}->{$path} = {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1772
                    category => uc($category),
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1773
                    exportRestricted => $exportRestricted};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1774
    
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1775
    return 1;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1776
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1777
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1778
sub SetComponent {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1779
    my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1780
    my $operand = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1781
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1782
    croak "Invalid number of arguments passed to " . (caller(0))[3] . "\n" if (shift);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1783
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1784
    if (exists $self->{comp}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1785
        return 0;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1786
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1787
    
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1788
    $self->{comp} = $operand;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1789
    
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1790
    return 1;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1791
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1792
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1793
sub SetNotesSource {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1794
    my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1795
    my $operand = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1796
   
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1797
    if (!$operand || shift) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1798
      croak "Invalid number of arguments passed to " . (caller(0))[3] . "\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1799
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1800
    
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1801
    if (exists $self->{notes_src}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1802
        return 0;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1803
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1804
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1805
    $operand = File::Spec->canonpath($operand); # Normalise the path
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1806
    
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1807
    $operand = SourceRootPath($operand);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1808
    
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1809
    if($self->{iniData}->HasMappings()){
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1810
        $operand = $self->{iniData}->PerformMapOnFileName($operand);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1811
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1812
    
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1813
    Utils::CheckExists($operand);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1814
    Utils::CheckIsFile($operand);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1815
    $self->{notes_src} = Utils::RemoveSourceRoot($operand);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1816
    
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1817
    return 1;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1818
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1819
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1820
sub SetSource {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1821
    my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1822
    my $operand = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1823
    
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1824
    croak "Invalid number of arguments passed to " . (caller(0))[3] . "\n" if (shift);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1825
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1826
    if ($operand =~ /distribution\.policy$/i) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1827
      print "\nREMARK: Distribution Policy file included as source in \"$self->{mrpName}\"\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1828
      return 1;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1829
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1830
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1831
    $operand = File::Spec->canonpath($operand); # Normalise the path
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1832
        
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1833
    #remove trailing slashes
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1834
    $operand =~ s/[\\\/]$//;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1835
    
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1836
    $operand = SourceRootPath($operand);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1837
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1838
    if($self->{iniData}->HasMappings()){
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1839
      $operand = $self->{iniData}->PerformMapOnFileName($operand);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1840
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1841
    
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1842
    Utils::CheckExists($operand);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1843
    $self->{srcitems}->{Utils::RemoveSourceRoot($operand)} = 1;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1844
    # No longer classify the source. We do this on-demand later.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1845
    
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1846
    return 1;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1847
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1848
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1849
sub SetBinary {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1850
    my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1851
    my @words =  @{shift()};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1852
    my $test = (shift) ? 1 : 0;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1853
    my $remove = (shift) ? 1 : 0;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1854
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1855
    croak "Invalid number of arguments passed to " . (caller(0))[3] . "\n" if (shift);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1856
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1857
    my $path = shift @words;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1858
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1859
    $path = File::Spec->canonpath($path); # Normalise the path
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1860
    
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1861
    # tranfer to absolute path
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1862
    $path = SourceRootPath($path);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1863
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1864
    if (scalar @words) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1865
        if($self->{iniData}->HasMappings()){
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1866
            $path = $self->{iniData}->PerformMapOnFileName($path);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1867
        }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1868
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1869
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1870
    push @{$self->{binaryStatements}}, {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1871
                        abldPath => $path,
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1872
                        test     => $test,
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1873
                        remove   => $remove,
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1874
                        words    => [@words]};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1875
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1876
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1877
sub SetExports {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1878
    my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1879
    my $abldPath = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1880
    my $test = (shift) ? 1 : 0;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1881
    my $dependantComponent = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1882
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1883
    if (!$abldPath || shift) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1884
        croak "Invalid number of arguments passed to " . (caller(0))[3] . "\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1885
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1886
    
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1887
    if ($dependantComponent) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1888
    	push (@{$self->{_dependantComponents}->{$dependantComponent}}, $abldPath);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1889
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1890
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1891
    $abldPath = File::Spec->canonpath($abldPath); # Normalise the path
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1892
        
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1893
    $abldPath = SourceRootPath($abldPath);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1894
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1895
    if($self->{iniData}->HasMappings()){
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1896
      $abldPath = $self->{iniData}->PerformMapOnFileName($abldPath);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1897
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1898
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1899
    Utils::CheckExists($abldPath);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1900
    
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1901
    push @{$self->{exportsStatements}}, { abldPath => $abldPath,
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1902
                                           test => $test};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1903
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1904
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1905
sub SetExportFile {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1906
    my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1907
    my $source = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1908
    my $destination = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1909
    my $remove = (shift) ? 1 : 0;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1910
    my $dependantComponent = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1911
 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1912
    croak "Invalid number of arguments passed to " . (caller(0))[3] . "\n" if (shift);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1913
        
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1914
    unless ($source and $destination) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1915
	croak "Error: Incorrect syntax to 'export_file' keyword in \"$self->{mrpName}\"\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1916
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1917
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1918
    if ($dependantComponent) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1919
    	push (@{$self->{_dependantComponents}->{$dependantComponent}}, $source);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1920
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1921
    
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1922
    $source = File::Spec->canonpath($source); # Normalise the path
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1923
    $destination = File::Spec->canonpath($destination);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1924
        
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1925
    $source = SourceRootPath($source);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1926
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1927
    if($self->{iniData}->HasMappings()){
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1928
      $source = $self->{iniData}->PerformMapOnFileName($source);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1929
      $destination = $self->{iniData}->PerformMapOnFileName($destination);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1930
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1931
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1932
    $destination = Utils::PrependEpocRoot($destination);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1933
    
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1934
    push @{$self->{unprocessedExportFiles}}, { source => $source,
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1935
                                           destination => $destination,
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1936
                                           remove => $remove};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1937
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1938
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1939
sub GetIPRInformation {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1940
    my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1941
    
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1942
    if (exists $self->{IPR}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1943
        return $self->{IPR};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1944
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1945
    else {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1946
        return {};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1947
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1948
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1949
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1950
sub GetExportComponentDependencies {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1951
    my $self = shift;	
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1952
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1953
    if (defined $self->{_dependantComponents}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1954
            return (keys %{$self->{_dependantComponents}}); # Return an array of the dependencies
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1955
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1956
    
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1957
    return undef;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1958
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1959
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1960
sub ValidateParsing {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1961
    my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1962
    
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1963
    # This flag stops the reader from trying to populate the object more than once
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1964
    $self->{populated} = 1;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1965
    
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1966
    if (exists $self->{srcitems} && !exists $self->{unresolvedIPR}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1967
        # If no IPR information exists in the MRP file then we set the IPR category
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1968
        # for each source item to undef.  This is so that incorrect IPR information is
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1969
        # not returned.  A flag is also set to indicate that IPR information exists.  The
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1970
        # flag will be used to ensure other parts other parts of validation should will
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1971
        # not be performed (e.g. validating exports).
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1972
        
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1973
        $self->{noIprInformation} = 1;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1974
        
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1975
        foreach my $sourceItem (keys %{$self->{srcitems}}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1976
            $self->{IPR}->{$sourceItem} = {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1977
                                           category => undef,
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1978
                                           exportRestricted => undef,
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1979
                                           };
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1980
        }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1981
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1982
    else {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1983
        # Reconcile the IPR information here so that any warnings are produced sooner...
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1984
        # IPR information can only be included if it matches a source line in the MRP file
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1985
        # All other IPR lines will be ignored.  The reconciliation is done here as IPR
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1986
        # lines may appear before source lines in the MRP file.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1987
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1988
        if (!defined $self->{srcitems} && exists $self->{unresolvedIPR}->{default}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1989
            carp "Warning: The default IPR entry does not apply to any source statements in \"$self->{mrpName}\"\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1990
        }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1991
       
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1992
        # Match IPR against source statement by using the length...
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1993
        foreach my $sourceItem (keys %{$self->{srcitems}}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1994
            # The sort below sorts by longest line first, not shortest line first. Note $b <=> $a, not $a <=> $b...
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1995
            # This allows us to match the most relevant line first, based on longest length/best match 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1996
            foreach my $iprItem (sort {length($b) <=> length($a)} keys %{$self->{unresolvedIPR}}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1997
                next if ($iprItem eq 'default');
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1998
                # If the source item contains the IPR path then it is a match 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1999
                if ($sourceItem =~ m/^\Q$iprItem\E([\\\/]|$)/i) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2000
                    $self->{IPR}->{$sourceItem} = $self->{unresolvedIPR}->{$iprItem};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2001
                    
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2002
                    last;   
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2003
                }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2004
            }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2005
                 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2006
            # If it didn't match an IPR then we assign the default
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2007
            if (!exists $self->{IPR}->{$sourceItem}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2008
                $self->{IPR}->{$sourceItem} = $self->{unresolvedIPR}->{default};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2009
            }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2010
        }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2011
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2012
        delete $self->{unresolvedIPR}->{default};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2013
	    
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2014
        # Find IPR entries which do live under a source folder...
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2015
        foreach my $iprItem (keys %{$self->{unresolvedIPR}}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2016
            next if (exists $self->{IPR}->{$iprItem});
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2017
	    
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2018
            foreach my $sourceItem (keys %{$self->{srcitems}}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2019
                if ($iprItem =~ /^\Q$sourceItem\E/i) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2020
                    $self->{IPR}->{$iprItem} = $self->{unresolvedIPR}->{$iprItem};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2021
                    last;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2022
                }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2023
            }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2024
	    
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2025
            if (!grep /\Q$iprItem\E/i, (keys %{$self->{IPR}})) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2026
                # Otherwise this IPR statement does not apply to this MRP file...
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2027
                carp "Warning: The IPR entry for \"$iprItem\" does not apply to any source statements in \"$self->{mrpName}\"\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2028
            }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2029
        }    
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2030
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2031
  
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2032
    delete $self->{unresolvedIPR};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2033
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2034
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2035
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2036
sub ProcessExports {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2037
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2038
  my $confirmExportIprInformation = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2039
  
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2040
  return if ($self->{exportsProcessed});
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2041
  
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2042
  $self->{exportsProcessed} = 1;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2043
  
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2044
  foreach my $export (@{$self->{exportsStatements}}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2045
    $self->HandleExports($export->{abldPath}, $export->{test});
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2046
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2047
  
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2048
  foreach my $exportFile (@{$self->{unprocessedExportFiles}}) {    
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2049
    if($self->{raptorcache}){
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2050
      my $isHandle = 0;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2051
      foreach my $export (@{$self->{exportsToBeProcessed}}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2052
        if($export->{source} eq $exportFile->{source}){
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2053
          if (exists $self->{exports}->{automatic}->{lc(Utils::RemoveEpocRoot($export->{destination}))}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2054
            $self->HandleExportFile($export->{source}, $export->{destination}, $exportFile->{remove});
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2055
            $isHandle = 1;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2056
          }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2057
        }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2058
      }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2059
      if($isHandle == 0){
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2060
        foreach my $export (@{$self->{exportsToBeProcessed}}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2061
          if(lc($export->{destination}) eq lc($exportFile->{destination})){
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2062
            foreach my $tempExport (@{$self->{exportsToBeProcessed}}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2063
              if($export->{source} eq $tempExport->{source}){
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2064
                if (exists $self->{exports}->{automatic}->{lc(Utils::RemoveEpocRoot($tempExport->{destination}))}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2065
                  $self->HandleExportFile($tempExport->{source}, $tempExport->{destination}, $exportFile->{remove});
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2066
                }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2067
              }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2068
            }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2069
          }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2070
        }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2071
      }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2072
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2073
    else{
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2074
      $self->HandleExportFile($exportFile->{source}, $exportFile->{destination}, $exportFile->{remove});
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2075
    } 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2076
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2077
  
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2078
  delete $self->{unprocessedExportFiles};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2079
  
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2080
  # If exports are to be classified, or the caller wants to confirm the IPR information for exports is correct...
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2081
  if ($self->{iniData}->CategoriseExports() || $confirmExportIprInformation) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2082
      $self->ClassifyManualExports();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2083
      
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2084
      # The codes below are changed to make MakeCBR follow cachefiles created by Raptor
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2085
      if(!$self->{raptorcache}){
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2086
        $self->ClassifyAutomaticExports();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2087
      }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2088
      else{
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2089
        my @tempExports;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2090
        foreach my $export (@{$self->{exportsToBeProcessed}}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2091
          if (exists $self->{exports}->{automatic}->{lc(Utils::RemoveEpocRoot($export->{destination}))}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2092
            push @tempExports, $export;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2093
          }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2094
        }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2095
        @{$self->{exportsToBeProcessed}} = @tempExports;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2096
		
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2097
        delete $self->{exports}->{automatic};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2098
        delete $self->{exports}->{abldPaths};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2099
      }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2100
      delete $self->{raptorcache};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2101
      
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2102
      # If no IPR information exists in the MRP file then we do not validate the exports as we don't care about if
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2103
      # we need dependant components
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2104
      if (!$self->{noIprInformation}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2105
        # Check to see if the exports are owned by the component, or dependant components have been specified...
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2106
        foreach my $export (@{$self->{exportsToBeProcessed}}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2107
          # check if the exports are included as source in this component
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2108
          if (!grep keys %{$self->{srcitems}}, $export->{source}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2109
            # If not then check if another dependant component for the export has been specified
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2110
            
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2111
            # A dependant component is specified for either the export source or the exports abld path
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2112
            my $whatToTest = 'source';
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2113
            $whatToTest = 'abldPath' if (exists $export->{abldPath});
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2114
       
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2115
            my $dependencyExists = 0;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2116
  
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2117
            foreach my $dependantComponent (keys %{$self->{_dependantComponents}}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2118
              if (grep /\Q$export->{$whatToTest}\E/i, (@{$self->{_dependantComponents}->{$dependantComponent}})) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2119
                $dependencyExists = 1;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2120
              }            
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2121
            }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2122
            
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2123
            if (!$dependencyExists) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2124
              # If no dependency exists...
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2125
              warn "Warning: ".$self->Component()." contains an export '". $export->{source} ."' which is not included as source for this component, and does not contain dependencies on another component\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2126
            }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2127
          }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2128
        }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2129
      }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2130
      
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2131
      # If we only processed exports to that we can confirm the IPR information, but
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2132
      # we don't actually want to categorise exports then we delete them
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2133
      if (!$self->{iniData}->CategoriseExports() && $confirmExportIprInformation) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2134
        delete $self->{exportsToBeProcessed};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2135
      }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2136
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2137
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2138
  my $errors;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2139
  
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2140
  foreach my $export (@{$self->{exportsToBeProcessed}}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2141
    if (!$self->AddExport($export->{source}, $self->RemoveRoot($export->{destination}))) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2142
      $errors = 1;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2143
    }        
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2144
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2145
  if ($errors) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2146
    die "Aborting due to above error(s)\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2147
  }  
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2148
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2149
  delete $self->{exportsToBeProcessed};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2150
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2151
  if ($self->{binariesProcessed}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2152
    # if binaries and exports have been processed then we delete the abldcach as
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2153
    # it is no longer required and takes up a lot of memory
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2154
    delete $self->{abldcache};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2155
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2156
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2157
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2158
sub RemoveRoot {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2159
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2160
  my $path = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2161
  return $1 if($path =~ /^\\(.+)/);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2162
  return $path;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2163
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2164
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2165
sub ProcessBinaries {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2166
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2167
  
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2168
  return if ($self->{binariesProcessed});
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2169
  
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2170
  $self->{binariesProcessed} = 1;  
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2171
  
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2172
  foreach my $binary (@{$self->{binaryStatements}}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2173
  
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2174
    my $success = 0;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2175
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2176
    if (!scalar(@{$binary->{words}})) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2177
        $binary->{abldPath} = Utils::PrependEpocRoot($binary->{abldPath});
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2178
        # Pass a reference of $success to HandleBinDirOrFile which can only be changed in HandleBinFile if the operation is successful.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2179
        $self->HandleBinDirOrFile($binary->{remove}, "unclassified", $binary->{abldPath}, \$success);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2180
        if ($success == 0 )
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2181
        {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2182
            my $line;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2183
            $line = 'test' if ($binary->{test});
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2184
            $line .=  'binary ' . join ' ', @{$binary->{words}};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2185
            $self->WarnRedundantMRPLine($binary->{remove}, $line);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2186
        }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2187
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2188
    else {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2189
        # Pass a reference of $success to HandleBinSet which can only be changed in HandleBinFile if the operation is successful.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2190
        $self->HandleBinSet($binary->{remove}, $binary->{test}, \$success, $binary->{abldPath}, @{$binary->{words}});
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2191
        if ($success == 0 )
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2192
        {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2193
            my $line;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2194
            $line = 'test' if ($binary->{test});
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2195
            $line .=  'binary ' . join ' ', @{$binary->{words}};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2196
            $self->WarnRedundantMRPLine($binary->{remove}, $line);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2197
        }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2198
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2199
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2200
  
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2201
  if ($self->{exportsProcessed}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2202
    # if binaries and exports have been processed then we delete the abldcache as
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2203
    # it is no longer required and takes up a lot of memory
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2204
    delete $self->{abldcache};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2205
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2206
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2207
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2208
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2209
1;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2210
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2211
__END__
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2212
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2213
=head1 NAME
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2214
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2215
MrpData.pm - Provides an interface to the contents of a component's MakeRel project (mrp) file.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2216
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2217
=head1 DESCRIPTION
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2218
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2219
Once a C<MrpData> object has been created using the C<New> method, the remaining methods can be used to access the F<.mrp> data.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2220
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2221
=head1 INTERFACE
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2222
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2223
=head2 New
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2224
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2225
Expects to be passed the name of the mrp file. This doesn't necessarily have to have a F<.mrp> extension. The parser supports the following keyword / value pairs:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2226
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2227
  component    <component_name>
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2228
  source       <source_file|source_directory>
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2229
  binary       [<abld_path> <platform> [<variant> <program>]] | [<binary_file>] | [<binary_directory>]
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2230
  -binary      [<abld_path> <platform> [<variant> <program>]] | [<binary_file>] | [<binary_directory>]
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2231
  testbinary   <abld_path> <platform> [<variant> <program>]
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2232
  -testbinary  <abld_path> <platform> [<variant> <program>]
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2233
  exports      <abld_path>
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2234
  notes_source <release_notes_source_path>
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2235
  ipr          [<export-restricted>] type [<directory>]
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2236
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2237
=head2 Component
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2238
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2239
Returns a string containing the name of the component.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2240
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2241
=head2 MrpName
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2242
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2243
Returns a string containing the full path name of the component's F<mrp> file.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2244
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2245
=head2 ExternalVersion
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2246
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2247
Returns a string containing the external version of the component to be released.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2248
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2249
=head2 InternalVersion
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2250
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2251
Returns a string containing the internal version of the component to be released.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2252
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2253
=head2 SourceCategories
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2254
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2255
Returns a reference to a list of source IPR categories present in the component. Each of these may be used as an input to C<Source>. These categories are defined in 'distribution.policy' files.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2256
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2257
=head2 Source
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2258
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2259
Expects to be passed a scalar containing the required source category. Returns a reference to a list of source files corresponding to the specified category for this component.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2260
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2261
=head2 SourceItems
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2262
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2263
Expects no arguments. Returns a list of the operands of all the "source" statements found in the MRP file. This is then stored in the RelData file and is later used by validation to work out which director(y|ies) to check for added files.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2264
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2265
=head2 BinaryCategories
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2266
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2267
Returns a reference to a list of binary categories present in the component. Each of these may be used as an input to C<Binaries>. The binary categories are determined by the structure of the F<mrp> file. For example, the statement C<binary \mycomp thumb urel> will result in the associated binaries being classified and C<thumb_urel>. The statement C<testbinary \mycomp arm4> will generate two categories - C<test_arm4_udeb> and C<test_arm4_urel>. Any binary files or directories that are explictly referenced (e.g. C<binary \epoc32\myfile.txt> or C<binary \epoc32\mydir>) are categorised as C<unclassified>. Also, any binary files that are found to be common between any two categories and re-categorised as C<unclassified>. This is to ensure that each binary F<zip> file contains a unique set of files.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2268
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2269
If the C<categorise_binaries> keyword has not been specified in the user's F<reltools.ini> file, this interface will always return a reference to a list with a single entry in it - C<unclassified>.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2270
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2271
=head2 Binaries
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2272
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2273
Returns a reference to a list of binary files for this component. May optionally be passed a scalar containing the required binary category, in which case it returns a list of just the binaries in the specified category. Dies if the requested category is not present.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2274
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2275
=head2 ExportCategories
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2276
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2277
Returns a reference to a list of export categories present in the component. If the C<categorise_exports> keyword has not been specified in the user's F<reltools.ini> file, this list will contain a single entry - C<unclassified>. Otherwise, each exported file will be categorised according to the rules used for categorising source code. The returned list will in this case contain the set of exported source categories present in the component. Elements in this list may be used as inputs to the method below (C<Exports>).
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2278
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2279
=head2 Exports
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2280
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2281
Returns a reference to a list of exported file for this component. May optionally be passed a scalar containing the required export category, in which case it returns a list of just the exports in the specified category. Dies if the requested category is not present.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2282
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2283
=head2 ExportInfoForCat
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2284
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2285
Expects a category to be passed. Returns the exportinfo for the category.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2286
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2287
=head2 BinariesAndExports
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2288
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2289
Returns a reference to a list of all the binaries and exports of this component. Note, unlike the methods C<Binaries> and C<Exports>, this method does not allow a category to be specified. This is because binaries are categorised according to build type and exports are categorised according to source intellectual property rights rules. They two types of categorisation are incompatible.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2290
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2291
=head2 NotesSource
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2292
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2293
Returns a string containing the path and name of the release notes source file for this component.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2294
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2295
=head2 BinSets
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2296
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2297
Returns a reference to an array of hashes, representing each "binary <path> <platform> <variant>" line. The hashes have these fields: path, plat, var, mmp (often ''), and test (a Boolean). This method is used by C<MakeRel> and C<MakeEnv> to build the component before release.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2298
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2299
=head2 EnsureDoesNotExist
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2300
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2301
Checks that the version given does not already exist in an archive.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2302
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2303
=head2 Validate
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2304
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2305
Checks that all the files shown in the MRP do actually exist.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2306
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2307
=head2 ClassifyAutomaticExports
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2308
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2309
Classify exports that were specified using the 'exports' or 'testexports' keyword in the mrp file.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2310
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2311
=head2 ProcessExportMakeFile
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2312
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2313
Expect EXPORT.MAKE/EXPORTTEST.MAKE file, classify exports that were specified using the 'exports'/'testexports' keyword in the mrp file.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2314
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2315
=head2 WarnRedundantMRPLine
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2316
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2317
Output warnings about redundant MRP lines (full redundancy).
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2318
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2319
=head2 GetIPRInformation()
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2320
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2321
Returns a hash containing the IPR information for the component.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2322
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2323
The format is the returned data is a hash:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2324
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2325
    Path = (
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2326
                    category = char,
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2327
                    exportRestricted = boolean
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2328
            )
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2329
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2330
=head2 SetBinary(@arguments, test, remove)
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2331
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2332
Sets the binary information.  @arguments is an array containing the arguments
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2333
from the MRP line, in the order in which they appeared.  
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2334
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2335
=head2 SetComponent(componentName)
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2336
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2337
Sets the name of the component to componentName.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2338
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2339
=head2 SetExportFile(source, destination, remove, dependantComponent)
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2340
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2341
Sets the export file information.  The source and destination arguments are both
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2342
required, if they are not specified a fatal error will be produced.  The source
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2343
file will also be checked to see if it exists and that it has not already been
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2344
specified as an export file.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2345
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2346
If the export file is not included as source for the current MRP component then
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2347
the dependant component will also need to be specified.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2348
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2349
=head2 SetExports(path, test, dependantComponent)
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2350
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2351
Sets the location of the bld.inf from where the export information can be derived.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2352
The location will be checked to see if it exists and that it has not already been
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2353
specified.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2354
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2355
If the exports are not included as source for the current MRP component then
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2356
the dependant component will also need to be specified.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2357
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2358
=head2 SetIPR(category, path, exportRestricted)
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2359
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2360
Sets the IPR information for the component.  If no path is specified then the
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2361
IPR category is set to be the default category for the component.  The
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2362
exportRestricted argument is boolean.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2363
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2364
If the same path is specified more than once a fatal error will be produced.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2365
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2366
=head2 SetNotesSource(noteSourcePath)
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2367
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2368
Sets the notes source to the notesSourcePath specified.  If the notes source has
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2369
already been set, or the path does not exist, a fatal error will be produced.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2370
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2371
=head2 SetSource(sourcePath)
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2372
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2373
Adds the sourcePath to the list of included source entries for the component.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2374
If the source path does not exist or the path has already been added then a
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2375
fatal error will be produced.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2376
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2377
=head2 ValidateParsing()
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2378
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2379
This method needs to be called once the parser has finished setting all the
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2380
information.  Currently this method reconciles IPR statements against the
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2381
components source, and also checks that required dependant components have
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2382
been set.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2383
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2384
If this method is not run then IPR information will be unavailable.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2385
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2386
=head2 GetExportComponentDependencies()
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2387
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2388
Returns an array containing the any components which the current component has
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2389
dependencies on.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2390
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2391
=head2 Populated()
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2392
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2393
The MRP file is parsed by a reader, which then populates this MRP object.  The
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2394
Populated method returns a boolean value indicating if the object has been
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2395
populated.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2396
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2397
=head1 KNOWN BUGS
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2398
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2399
None.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2400
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2401
=head1 COPYRIGHT
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2402
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2403
 Copyright (c) 2000-2009 Nokia Corporation and/or its subsidiary(-ies).
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2404
 All rights reserved.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2405
 This component and the accompanying materials are made available
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2406
 under the terms of the License "Eclipse Public License v1.0"
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2407
 which accompanies this distribution, and is available
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2408
 at the URL "http://www.eclipse.org/legal/epl-v10.html".
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2409
 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2410
 Initial Contributors:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2411
 Nokia Corporation - initial contribution.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2412
 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2413
 Contributors:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2414
 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2415
 Description:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2416
 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2417
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2418
=cut