imgtools/buildrom/tools/romutl.pm
author y4jin
Thu, 18 Nov 2010 13:41:24 +0800
changeset 703 a23be6984256
parent 600 6d08f4a05d93
permissions -rw-r--r--
Fix the illegal word scanned by sfchecksource tools
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
600
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
     1
# Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
     2
# All rights reserved.
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
     3
# This component and the accompanying materials are made available
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
     4
# under the terms of the License "Eclipse Public License v1.0"
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
     5
# which accompanies this distribution, and is available
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
     6
# at the URL "http://www.eclipse.org/legal/epl-v10.html".
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
     7
#
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
     8
# Initial Contributors:
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
     9
# Nokia Corporation - initial contribution.
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    10
#
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    11
# Contributors:
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    12
#
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    13
# Description:
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    14
# Collection of utilitiy functions which is copied from Symbian OS perl modules. 
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    15
# It provides platform related information to ROM Tools including buildrom, 
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    16
# features.pl, etc.
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    17
# 
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    18
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    19
package romutl;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    20
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    21
require Exporter;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    22
@ISA=qw(Exporter);
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    23
@EXPORT=qw(
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    24
  init_plat
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    25
  init_bsfs
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    26
  init_platwithbpabi
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    27
  
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    28
  get_epocroot
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    29
  get_drive
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    30
  get_epocdrive
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    31
  get_versionedname
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    32
  get_bpabiplatlist
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    33
  get_platlist
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    34
  get_platcustomizes
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    35
  get_platroot
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    36
  get_makeeabspath
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    37
  get_variantmacrolist  
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    38
  get_variantmacroHRHfile
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    39
  get_abiv2mode
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    40
  get_variantfullpath
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    41
  get_BVbinname
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    42
  get_variant
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    43
  
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    44
  is_existinpath
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    45
  
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    46
  set_verbose
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    47
  
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    48
  check_varfile
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    49
  split_path
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    50
  append_driveandquote  
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    51
  write_32bit
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    52
);
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    53
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    54
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    55
# EPOCROOT with proper format 
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    56
my $epocroot;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    57
my $epocdrive = "";
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    58
my $drive = "";
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    59
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    60
BEGIN {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    61
    require 5.005_03;       # check user has a version of perl that will cope
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    62
    
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    63
    $epocroot = $ENV{EPOCROOT};
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    64
    $epocroot = "\/" if (!$epocroot); # use "\" if EPOCROOT is not specified
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    65
    $epocroot =~ s/\\/\//g;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    66
    $epocroot .= "\/" unless $epocroot =~ /\/$/;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    67
}
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    68
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    69
use strict;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    70
use Cwd;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    71
use File::Spec;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    72
use romosvariant;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    73
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    74
my $verbose=0;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    75
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    76
########################
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    77
#Init
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    78
#
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    79
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    80
#die "ERROR: EPOCROOT must specify an existing directory." if (!-d $epocroot);
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    81
#die "ERROR: EPOCROOT must not be a UNC path\n" if ($epocroot =~ /^\\\\/);
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    82
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    83
$drive=$1 if (cwd =~ /^(.:)/);
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    84
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    85
if ($epocroot =~ /^(.:)/)
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    86
{
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    87
    $epocdrive=$1;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    88
}
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    89
else
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    90
{
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    91
# current working directory is different to SDK's
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    92
    $epocdrive=$drive
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    93
}
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    94
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    95
#####################################
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    96
# General functions
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    97
#
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    98
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    99
sub get_epocroot
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   100
{
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   101
    return $epocroot;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   102
}
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   103
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   104
sub get_epocdrive
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   105
{
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   106
    return $epocdrive;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   107
}
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   108
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   109
sub get_drive
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   110
{
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   111
    return $drive;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   112
}
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   113
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   114
sub set_verbose
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   115
{
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   116
    $verbose = shift;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   117
}
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   118
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   119
use constant QUIET_NOT_FOUND => 0; #  return 0 if file not found in the PATH
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   120
use constant DIE_NOT_FOUND => 1; #  issue error and die if file not found in the PATH
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   121
use constant ERROR_NOT_FOUND => 2; #  issue error and return 0 if file not found in the PATH
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   122
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   123
# Simulate shell to locate executable file in the PATH
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   124
#
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   125
# WARNING: don't use this func in a deep loop because of the
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   126
#          less efficient implementation
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   127
#
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   128
# usage:  is_existinpath <filename> [<flag>]
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   129
#
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   130
#   flag == DIE_NOT_FOUND    die and display error when not found
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   131
#   flag == ERROR_NOT_FOUND  display error and return 0 when not found
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   132
#   else return 0 when not found
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   133
#   return 1 when found     
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   134
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   135
sub is_existinpath
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   136
{
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   137
    my ($filename, $flag)=@_;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   138
    return 0 unless defined $filename;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   139
    return 0 if ($filename =~ /\\/);
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   140
    return 0 if ($filename =~ /\//); 
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   141
    
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   142
    my @paths;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   143
    my $delimiter = &env_delimiter;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   144
 		@paths = split(/$delimiter/, $ENV{PATH});
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   145
    unshift @paths, "\.";
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   146
    
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   147
    foreach my $path (@paths)
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   148
    {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   149
        next if ($path =~ /^\s*$/);
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   150
        chomp $path;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   151
        $path =~ s/\\/\//g;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   152
        $path .= "\/" unless ($path =~ /\/$/);
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   153
        $path = $path.$filename;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   154
        foreach my $ext ("", ".bat", ".cmd", ".exe", ".com", ".pl", ".py")
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   155
        {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   156
            return 1 if (-e $path.$ext);
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   157
        }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   158
    }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   159
    die "Error: Cannot found \"$filename\" in the PATH.\n" if ($flag == DIE_NOT_FOUND);
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   160
    print "Error: Cannot found \"$filename\" in the PATH.\n" if ($flag == ERROR_NOT_FOUND);
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   161
    return 0;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   162
} 
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   163
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   164
#########################################
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   165
# Symbian variant functions and variables
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   166
# 
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   167
# copy from e32variant.pm
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   168
#
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   169
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   170
my $toolspath = $epocroot . "epoc32\/tools\/";
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   171
# SPPR begin
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   172
# enable includation of spp_variant.cfg if it exist
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   173
my $spp_cfgFile = $toolspath . "variant\/spp_variant.cfg";
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   174
my $cfgFile = $toolspath . "variant\/variant.cfg"; # default location
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   175
$cfgFile = $spp_cfgFile if -e $spp_cfgFile; # use spp_variant.cfg
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   176
# SPPR End
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   177
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   178
my $variantABIV2Keyword = &get_abiv2mode;    # if variant ABIv2 mode enabled
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   179
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   180
my $hrhdrive = $epocdrive;   # variant hrh drive
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   181
my $hrhfile;    # variant hrh file
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   182
my @macros;     # variant macros
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   183
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   184
if ($cfgFile =~ /^(.:)/i)
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   185
{
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   186
   $hrhdrive = lc($1); 
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   187
}
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   188
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   189
# returns the variant specific macro definitions as a list
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   190
sub get_variantmacrolist{
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   191
    
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   192
    return @macros if (@macros);
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   193
    
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   194
    my $vfile = get_variantmacroHRHfile();
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   195
    
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   196
    if($vfile)
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   197
    {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   198
        my $VariantFilePath = split_path('Path',$vfile);
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   199
        chop( $VariantFilePath );
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   200
        $VariantFilePath = &append_driveandquote($VariantFilePath);
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   201
        $vfile = &append_driveandquote($vfile);
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   202
        my $e32Path = &append_driveandquote($epocroot."epoc32\/include");
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   203
        
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   204
        open CPPPIPE,"cpp -I $e32Path -I $VariantFilePath -undef -dM $vfile |" or die "ERROR: Can't invoke CPP.EXE\n";
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   205
        while(<CPPPIPE>){
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   206
            if($_ =~ /(\#define)(\s+)(.+)/){
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   207
                push @macros, $3;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   208
            }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   209
        }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   210
        close CPPPIPE;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   211
    }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   212
    return @macros;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   213
}
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   214
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   215
# return hrh filename defined in variant cfg file
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   216
# notice: abort if hrh file located in different drive to cfg file
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   217
sub get_variantmacroHRHfile{
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   218
    
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   219
    return $hrhfile if ($hrhfile);
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   220
    if(-e $cfgFile){
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   221
        open(FILE, $cfgFile) || die "\nCould not open: " . $cfgFile ."\n";
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   222
        while (<FILE>) {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   223
            # strip comments
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   224
            s/^([^#]*)#.*$/$1/o;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   225
            # skip blank lines
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   226
            if (/^\s*$/o) {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   227
                next;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   228
            }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   229
            # get the hrh file
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   230
            if($_ =~ /\.hrh/xi){
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   231
                $hrhfile = $_; 
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   232
                last;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   233
            }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   234
        }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   235
        close FILE;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   236
        die "\nERROR: No variant file specified in $cfgFile!\n" unless $hrhfile;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   237
        $hrhfile =~ s/\s+//g;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   238
        $hrhfile=~s/^(.:)//io;    # remove drive letter
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   239
        my $paths_drive = lc($1);
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   240
        
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   241
        chomp $hrhfile;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   242
        $hrhfile = get_makeeabspath($epocroot."epoc32\/", $epocroot, $hrhfile); # assume relative to EPOCROOT
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   243
        
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   244
        
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   245
        if($paths_drive){
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   246
            die "\nERROR: Variant file specified in $cfgFile is not on the same drive as \/epoc32\/\n" 
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   247
            unless ($paths_drive eq $hrhdrive);
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   248
        }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   249
        die "\nERROR: $cfgFile specifies $hrhfile which doesn't exist!\n" unless (-e $hrhfile);
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   250
        
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   251
        # make sure it is in unix syntax
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   252
        $hrhfile=~ s/\\/\//g;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   253
    }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   254
    return $hrhfile;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   255
}
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   256
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   257
# get status of EANBLE_ABIV2_MODE
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   258
# 1=enabled 0=disabled
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   259
sub get_abiv2mode{
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   260
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   261
    return $variantABIV2Keyword if (defined $variantABIV2Keyword);
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   262
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   263
    $variantABIV2Keyword=0;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   264
    if(-e $cfgFile){
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   265
        open(FILE, $cfgFile) || die "\nCould not open: " . $cfgFile ."\n";
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   266
        while (<FILE>) {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   267
            # strip comments
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   268
            s/^([^#]*)#.*$/$1/o;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   269
            # skip blank lines
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   270
            if (/^\s*$/o) {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   271
            next;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   272
            }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   273
            # get the hrh file
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   274
            if($_ =~ /^ENABLE_ABIV2_MODE$/xi){
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   275
                $variantABIV2Keyword=1;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   276
                last;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   277
            }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   278
        }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   279
        close FILE;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   280
    }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   281
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   282
    return $variantABIV2Keyword;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   283
}
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   284
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   285
#############################
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   286
# Path utilities
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   287
#
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   288
# copy from pathutl.pm
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   289
#
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   290
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   291
#args: $_[0] Start EPOCPath Abs FilePath/Path $_[1]... list of (Abs/Rel FilePath/Path)
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   292
# Variant of MakAbs which also maps "+\\" to "${EPOCPath}"
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   293
sub get_makeeabspath ($@) {    
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   294
    return undef unless $_[0]=~m-^(.:)?[\\\/]-o;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   295
    my ($EPOCPath,$Path,@List)=@_;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   296
    my $BasePath=&split_path("Path",$Path);
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   297
    undef $Path;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   298
    my $p;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   299
    foreach $p (@List) {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   300
    		$p =~ s-\\-\/-g;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   301
        if ($p=~m-^\/?epoc32\/(.*)$-io) {    # change - special case for existing \\epoc32 references
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   302
            $p=$EPOCPath.$1;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   303
            next;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   304
        }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   305
        if ($p=~m-^\s*\+\/(.*)$-o) {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   306
            $p=$EPOCPath.$1;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   307
            next;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   308
        }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   309
        if ($p=~m-^\.{2}-o) {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   310
            $p=&strip_path($BasePath.$p);
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   311
            next;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   312
        }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   313
        if ($p=~m-^[^\.\/]-o) {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   314
            $p=$BasePath.$p unless ($p =~ m-^.:-o);
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   315
            next;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   316
        }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   317
        if ($p=~m-^(.:)?\/-o) {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   318
            next;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   319
        }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   320
        if ($p=~m-^\.\/(.*)$-o) {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   321
            $p=&strip_path($BasePath.$1);
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   322
            next;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   323
        }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   324
        return undef;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   325
    }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   326
    return wantarray ? @List : $List[0];
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   327
}
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   328
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   329
#args: $_[0] Abs FilePath/Path
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   330
# Remove excess occurrences of '..' and '.' from a path
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   331
sub strip_path ($) {   
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   332
    return undef unless $_[0]=~m-^(.:)?[\/\\]-o;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   333
    my $P=$_[0];
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   334
    while ($P=~s-([\/\\])\.[\/\\]-$1-go) { }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   335
    while ($P=~s-[\\](?!\.{2}\\)[^\\]*\\\.{2}(?=\\)--go) { }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   336
    $P;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   337
}
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   338
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   339
#args: $_[0] 'Path' or 'Base' or 'Ext' $_[1] Abs/Rel FilePath/Path
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   340
# return the section of a file path required - Path, Base, Ext or File
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   341
sub split_path ($$) { 
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   342
    my ($Sect,$P)=@_;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   343
    
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   344
    return '' if !$P;    
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   345
    $Sect= ucfirst lc $Sect;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   346
    if ($Sect eq 'Path') {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   347
        if ($P=~/^(.*[\\\/])/o) {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   348
            return $1;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   349
        }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   350
        return '';
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   351
    }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   352
    undef;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   353
}
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   354
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   355
sub append_driveandquote ($) {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   356
# Take a path, or list of paths, and prefix with drive based on 1. epocroot, 2.CWD.
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   357
# Relative paths are just quoted.
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   358
    my @List=@_;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   359
    my $Path;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   360
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   361
    
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   362
    foreach $Path (@List) {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   363
        next if ($Path !~ /^[\/\\]/); # skip prefix with drive letter or relative path
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   364
        $Path=$epocdrive.$Path;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   365
    }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   366
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   367
    foreach $Path (@List) {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   368
        chomp $Path;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   369
        $Path="\"".$Path."\"";
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   370
    }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   371
    
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   372
    return wantarray ? @List : $List[0];
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   373
}
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   374
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   375
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   376
###############################
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   377
# General Utilities
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   378
#
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   379
# copy from genutl.pm
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   380
#
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   381
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   382
# return name with well formated version id in hex
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   383
sub get_versionedname($) {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   384
    my ($name) = @_;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   385
    if ($name =~ /(.*)\{\s*(\d+)\s*\.\s*(\d+)\s*\}(.*?)$/i) {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   386
        my $a = $1;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   387
        my $b = $4;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   388
        my $major = $2;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   389
        my $minor = $3;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   390
        return $a.sprintf("{%04x%04x}",$major,$minor).$b if ($major<32768 and $minor<32768);
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   391
    }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   392
    return $name;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   393
}
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   394
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   395
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   396
###############################
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   397
# BPABI Platform Utilities
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   398
#
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   399
# copy from bpabiutl.pm
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   400
#
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   401
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   402
my @BPABIPlats;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   403
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   404
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   405
# Identify the BPABI platforms to be supported based on the compiler configuration files
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   406
# present in the location specified by the environment variable "SYMBIAN_COMPILATION_CONFIG_DIR"
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   407
# and in the directory $EPOCROOT\epoc32\tools\compilation_config
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   408
sub get_bpabiplatlist 
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   409
{
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   410
    return @BPABIPlats if (scalar(@BPABIPlats));
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   411
    
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   412
    my @CompilerConfigPath;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   413
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   414
    if (exists($ENV{'SYMBIAN_COMPILATION_CONFIG_DIR'})) 
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   415
    {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   416
        my $Path = $ENV{SYMBIAN_COMPILATION_CONFIG_DIR};
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   417
        @CompilerConfigPath = split(/;/, $Path);
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   418
    }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   419
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   420
    push @CompilerConfigPath, "${epocroot}epoc32\/tools\/compilation_config";
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   421
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   422
    my $ConfigDir;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   423
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   424
    foreach $ConfigDir (@CompilerConfigPath)
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   425
    {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   426
        opendir DIR, "$ConfigDir";
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   427
        my @Plats=grep /\.mk$/i, readdir DIR;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   428
        my $Plat;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   429
        foreach $Plat (@Plats) 
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   430
        {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   431
# The platform name will be same as the name of the configuration file <config.mk>
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   432
# with the suffix '.mk' removed
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   433
            $Plat =~ s/\.mk//;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   434
            if ($variantABIV2Keyword) {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   435
                if ($Plat =~ /^armv5_abiv2$/i) {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   436
                    $Plat = "ARMV5";
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   437
                }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   438
            }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   439
            else {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   440
                if ($Plat =~ /^armv5$/i) {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   441
                    $Plat = "ARMV5_ABIV2";
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   442
                }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   443
            }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   444
            unless (grep /$Plat$/i, @BPABIPlats) {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   445
                $Plat = uc $Plat;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   446
                push @BPABIPlats, $Plat;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   447
            }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   448
        }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   449
    }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   450
    closedir DIR;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   451
    return @BPABIPlats;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   452
}
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   453
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   454
#############################
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   455
# Platform Utilities
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   456
#
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   457
# copy from e32plat.pm
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   458
#
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   459
my %Plat=(
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   460
    ARM4=>{
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   461
        ABI=>'ARM4',
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   462
        ASSP=>'MARM',
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   463
        ASSPABI=>'',
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   464
        Generic=>1,
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   465
    },
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   466
    ARM4SMP=>{
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   467
        ABI=>'ARM4',
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   468
        ASSP=>'MARM',
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   469
        ASSPABI=>'',
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   470
        Generic=>1,
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   471
        SMP=>1,
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   472
        StatLink=>'ARM4SMP',
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   473
    },
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   474
    ARM4T=>{
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   475
        ABI=>'ARM4T',
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   476
        ASSP=>'MARM',
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   477
        ASSPABI=>'',
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   478
        Generic=>1,
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   479
    },
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   480
    ARMI=>{
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   481
        ASSP=>'MARM',
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   482
        Generic=>1,
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   483
        ASSPABI=>'',
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   484
    },
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   485
    SARM4=>{
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   486
        ABI=>'ARM4',
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   487
        ASSP=>'MARM',
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   488
        ASSPABI=>'',
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   489
        Generic=>1,
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   490
        Single=>1,
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   491
    },
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   492
    SARMI=>{
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   493
        ASSP=>'MARM',
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   494
        ASSPABI=>'',
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   495
        Generic=>1,
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   496
        Single=>1,
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   497
    },
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   498
    STHUMB=>{
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   499
        ABI=>'THUMB',
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   500
        ASSP=>'MARM',
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   501
        ASSPABI=>'',
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   502
        Generic=>1,
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   503
        Single=>1,
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   504
    },
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   505
    THUMB=>{
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   506
        ABI=>'THUMB',
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   507
        ASSP=>'MARM',
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   508
        ASSPABI=>'',
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   509
        Generic=>1,
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   510
    },
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   511
    TOOLS=>{
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   512
        ABI=>'TOOLS',
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   513
        ASSPABI=>'',
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   514
        Compiler=>'VC32',
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   515
        CPU=>'TOOLS',
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   516
        OS=>'TOOLS',
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   517
        MakeMod=>'Cl_win',
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   518
        MakeCmd=>'nmake',
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   519
    },
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   520
    TOOLS2=>{
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   521
        ABI=>'TOOLS2',
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   522
        ASSPABI=>'',
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   523
        Compiler=>'GCC32',
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   524
        CPU=>'TOOLS2',
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   525
        OS=>'TOOLS2',
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   526
        MakeMod=>'Cl_mingw',
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   527
        MakeCmd=>'make',
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   528
    },
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   529
    CWTOOLS=>{
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   530
        ABI=>'TOOLS',
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   531
        ASSPABI=>'',
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   532
        Compiler=>'CW32',
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   533
        CPU=>'TOOLS',
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   534
        OS=>'TOOLS',
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   535
        MakeMod=>'Cl_tools',
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   536
        MakeCmd=>'make',
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   537
    },
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   538
    VC6TOOLS=>{
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   539
        ABI=>'TOOLS',
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   540
        ASSPABI=>'',
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   541
        Compiler=>'VC32',
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   542
        CPU=>'TOOLS',
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   543
        Ext=>'.DSP',
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   544
        MakeMod=>'Ide_vc6',
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   545
        MakeCmd=>'nmake',
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   546
        OS=>'TOOLS',
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   547
        Real=>'TOOLS',
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   548
        UsrHdrsOnly=>1,
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   549
    },
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   550
    WINS=>{
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   551
        ABI=>'WINS',
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   552
        ASSPABI=>'',
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   553
        Compiler=>'VC32',
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   554
        CPU=>'WINS',
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   555
        MakeMod=>'Cl_win',
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   556
        MakeCmd=>'nmake',
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   557
        OS=>'WINS',
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   558
    },
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   559
    VC6=>{
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   560
        ABI=>'WINS',
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   561
        ASSPABI=>'',
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   562
        Compiler=>'VC32',
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   563
        CPU=>'WINS',
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   564
        Ext=>'.DSP',
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   565
        MakeMod=>'Ide_vc6',
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   566
        MakeCmd=>'nmake',
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   567
        OS=>'WINS',
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   568
        Real=>'WINS',
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   569
        UsrHdrsOnly=>1,
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   570
    },
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   571
    WINSCW=>{
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   572
        ABI=>'WINSCW',
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   573
        ASSPABI=>'',
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   574
        Compiler=>'CW32',
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   575
        CPU=>'WINS',
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   576
        MakeMod=>'Cl_codewarrior',
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   577
        OS=>'WINS',
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   578
        DefFile=>'WINS',    # use the MSVC def files
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   579
    },
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   580
    CW_IDE=>{
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   581
        ABI=>'WINSCW',
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   582
        ASSPABI=>'',
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   583
        Compiler=>'CW32',
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   584
        CPU=>'WINS',
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   585
        Ext=>'.xml',
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   586
        MakeMod=>'Ide_cw',
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   587
        MakeCmd=>'make',
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   588
        OS=>'WINS',
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   589
        Real=>'WINSCW',
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   590
        DefFile=>'WINS',    # use the MSVC def files
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   591
        UsrHdrsOnly=>1,
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   592
        SupportsMultiplePlatforms=>1,   # supports more than one real platform
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   593
    },
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   594
    X86=>{
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   595
        ABI=>'X86',
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   596
        ASSPABI=>'',
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   597
        Compiler=>'VC32',
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   598
        CPU=>'X86',
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   599
        MakeMod=>'Cl_x86',
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   600
        MakeCmd=>'nmake',
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   601
        OS=>'EPOC32',
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   602
        DefFile=>'X86',
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   603
        Generic=>1,
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   604
    },
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   605
    X86SMP=>{
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   606
        ABI=>'X86',
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   607
        ASSPABI=>'',
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   608
        Compiler=>'VC32',
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   609
        CPU=>'X86',
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   610
        MakeMod=>'Cl_x86',
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   611
        MakeCmd=>'nmake',
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   612
        OS=>'EPOC32',
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   613
        DefFile=>'X86',
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   614
        Generic=>1,
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   615
        SMP=>1,
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   616
        StatLink=>'X86SMP',
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   617
    },
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   618
    X86GCC=>{
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   619
        ABI=>'X86gcc',
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   620
        ASSPABI=>'',
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   621
        Compiler=>'X86GCC',
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   622
        CPU=>'X86',
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   623
        MakeMod=>'Cl_x86gcc',
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   624
        OS=>'EPOC32',
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   625
        DefFile=>'x86gcc',
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   626
        Generic=>1,
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   627
    },  
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   628
    X86GMP=>{
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   629
        ABI=>'X86gcc',
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   630
        ASSPABI=>'',
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   631
        Compiler=>'X86GCC',
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   632
        CPU=>'X86',
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   633
        MakeMod=>'Cl_x86gcc',
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   634
        OS=>'EPOC32',
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   635
        DefFile=>'x86gcc',
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   636
        Generic=>1,
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   637
        SMP=>1,
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   638
        StatLink=>'X86GMP',
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   639
    },  
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   640
    ARMV4=>{
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   641
        ABI=>'ARMV4',
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   642
        ASSP=>'MARM',
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   643
        ASSPABI=>'',
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   644
        Generic=>1,
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   645
        MakeMod=>'Cl_arm',
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   646
        Compiler=>'ARMCC',
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   647
        DefFile=>'EABI',
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   648
        EABI=>1,
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   649
    },
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   650
    ARMV4SMP=>{
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   651
        ABI=>'ARMV4',
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   652
        ASSP=>'MARM',
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   653
        ASSPABI=>'',
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   654
        Generic=>1,
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   655
        MakeMod=>'Cl_arm',
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   656
        Compiler=>'ARMCC',
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   657
        DefFile=>'EABI',
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   658
        EABI=>1,
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   659
        SMP=>1,
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   660
        StatLink=>'ARMV4SMP',
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   661
    },
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   662
    ARMV5_ABIV1=>{
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   663
        ABI=>'ARMV5',
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   664
        ASSP=>'MARM',
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   665
        ASSPABI=>'',
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   666
        Generic=>1,
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   667
        MakeMod=>'Cl_arm',
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   668
        Compiler=>'ARMCC',
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   669
        DefFile=>'EABI',
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   670
        EABI=>1,
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   671
        SupportsFeatureVariants=>1,
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   672
    },
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   673
    ABIV2=>{
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   674
        ABI=>'ARMV5',
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   675
        ASSP=>'MARM',
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   676
        ASSPABI=>'',
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   677
        Generic=>1,
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   678
        MakeMod=>'Cl_bpabi',
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   679
        DefFile=>'EABI',
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   680
        EABI=>1,
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   681
        SupportsFeatureVariants=>1,
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   682
    },
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   683
    GCCXML=>{
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   684
        ABI=>'ARM4',
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   685
        ASSP=>'MARM',
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   686
        ASSPABI=>'',
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   687
        Generic=>1,
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   688
        MakeMod=>'cl_gccxml',
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   689
    },
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   690
    VS6=>{
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   691
        ABI=>'WINSCW',
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   692
        ASSPABI=>'',
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   693
        Compiler=>'CW32',
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   694
        CPU=>'WINS',
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   695
        MakeMod=>'Cl_vscw',
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   696
        OS=>'WINS',
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   697
        Real=>'WINSCW',
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   698
        DefFile=>'WINS',    # use the MSVC def files
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   699
        Ext=>'.mak'     
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   700
    },
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   701
    VS2003=>{
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   702
        ABI=>'WINSCW',
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   703
        ASSPABI=>'',
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   704
        Compiler=>'CW32',
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   705
        CPU=>'WINS',
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   706
        MakeMod=>'Cl_vscw',
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   707
        OS=>'WINS',
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   708
        Real=>'WINSCW',
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   709
        DefFile=>'WINS',    # use the MSVC def files
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   710
        Ext=>'.mak'
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   711
    },
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   712
    EDG=>{
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   713
        ABI=>'ARMV5',
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   714
        ASSP=>'MARM',
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   715
        ASSPABI=>'',
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   716
        Generic=>1,
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   717
        MakeMod=>'cl_edg',
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   718
    },
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   719
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   720
    # ASSP platforms should be described using .ASSP files
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   721
    # Do not add additional ASSP platforms to this file.
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   722
);
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   723
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   724
my $init_bsfs_done = 0;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   725
my $init_plat_done = 0;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   726
my @PlatList;       # Platlist returned by list_plat()
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   727
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   728
# initialize BSF platforms into %Plat
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   729
sub init_bsfs($) {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   730
    return $init_bsfs_done if ($init_bsfs_done);
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   731
        
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   732
    my ($Path)=@_;  
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   733
#   get a list of modules
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   734
    opendir DIR, $Path;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   735
    my @BSFs=grep s/^([^\.].*)\.BSF$/$1/, map { uc $_ } sort readdir DIR;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   736
    closedir DIR;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   737
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   738
    my $BSF;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   739
    foreach $BSF (@BSFs) {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   740
        my $File=$Path.lc($BSF).'.bsf';
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   741
#       check whether the assp is already defined
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   742
        if (defined %{$Plat{$BSF}}) {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   743
            warn(
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   744
                "$File : warning: Platform \"$BSF\" already defined\n",
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   745
                " ... skipping this spec\n"
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   746
            );
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   747
            delete $Plat{$BSF};
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   748
            next;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   749
        }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   750
#       open the module
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   751
        unless (open FILE, $File) {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   752
            delete $Plat{$BSF};
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   753
            warn "warning: Can't open BSF specification \"$File\"\n";
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   754
            next;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   755
        }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   756
        my $line1 = <FILE>;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   757
        $line1 = uc($line1);
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   758
        unless ($line1 =~ /^\#\<BSF\>\#/) {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   759
            warn "warning: \"$File\" Invalid BSF specification - missing #<bsf>#\n";
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   760
            delete $Plat{$BSF};
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   761
            close FILE;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   762
                  next;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   763
        }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   764
        my $custom;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   765
        while ($custom = <FILE>) {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   766
            #skip blank lines and comments
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   767
            delete $Plat{$BSF};
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   768
            last unless ($custom =~ /^$|^\#/);
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   769
        }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   770
        $custom = uc $custom;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   771
        unless ($custom =~ /^\s*CUSTOMIZES\s+(\S+)/) {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   772
            warn "warning: \"$File\" Invalid BSF specification - 'customizes' missing\n";
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   773
            delete $Plat{$BSF};
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   774
            close FILE;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   775
            next;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   776
        }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   777
        my $root = $1;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   778
        my $platname = '';
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   779
        my $CustomizedPlatName = '';        
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   780
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   781
        # In v1 mode, ARMV5 platform implies ARMV5_ABIV1 platform listed in the platlist        
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   782
        my $Armv5Flag = 0;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   783
        if (!$variantABIV2Keyword && $root =~ /^ARMV5$/i) {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   784
            $Armv5Flag = 1;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   785
        }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   786
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   787
        # Support for Hierarchy of Customizations (BSF file customization of another BSF file)
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   788
        # 1. Check whether the BSF file customizes another BSF file.
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   789
        # 2. If so, check whether the root BSF file has already been read.
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   790
        # 3. If not read, then defer the current BSF file reading until the root file is read.
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   791
        my $rootPlatFound = 0;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   792
        if (defined %{$Plat{$root}} || $Armv5Flag) 
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   793
        {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   794
            # BSF platform customizes another valid BSF platform
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   795
            if (defined $Plat{$root}{'CUSTOMIZES'}) 
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   796
            {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   797
                $rootPlatFound = 1;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   798
                $platname = $root;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   799
                $CustomizedPlatName = $root;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   800
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   801
                # Set the root platform name which is same as of customizes platform
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   802
                $Plat{$BSF}{'ROOTPLATNAME'} = $Plat{$root}{'ROOTPLATNAME'};
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   803
            }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   804
            # BSF platform customizes to one of the existing ABI platforms
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   805
            else
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   806
            {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   807
                # All BPABI platforms inherits from ABIV2 platform listed in the platlist
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   808
                if (grep /^$root$/i, @BPABIPlats) {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   809
                    $platname = "ABIV2";
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   810
                }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   811
                elsif ($Armv5Flag) {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   812
                # In v1 mode, ARMV5 platform implies ARMV5_ABIV1 platform listed in the platlist
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   813
                    $platname = "ARMV5_ABIV1";  
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   814
                }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   815
                else {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   816
                    $platname = $root;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   817
                }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   818
                
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   819
                $CustomizedPlatName=$root;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   820
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   821
                # BSF File check Begins 
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   822
                # The following check is included to handle the existing BSF files which has to behave in different manner
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   823
                # in default v1 mode and v2 mode. The following code changes the BSF name and the custmoized platform name
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   824
                # to the implied names. This is done to support switching between v1 and v2 modes by enabling the keyword in
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   825
                # the variant configuration file.
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   826
                # In v1 mode, the ARMV6_ABIV1 => ARMV6 platform and ARMV6 => ARMV6_ABIV2 platform.
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   827
                if (!$variantABIV2Keyword) {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   828
                    if ($BSF =~ /^ARMV6_ABIV1$/i) {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   829
                        $BSF = "ARMV6"; 
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   830
                        $CustomizedPlatName = "ARMV5";  
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   831
                    }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   832
                    elsif ($BSF =~ /^ARMV6$/i) {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   833
                        $BSF = "ARMV6_ABIV2";   
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   834
                        $CustomizedPlatName = "ARMV5_ABIV2";
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   835
                        $platname = "ABIV2";
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   836
                    }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   837
                }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   838
                # BSF File check Ends
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   839
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   840
                # Set the root platform name
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   841
                $Plat{$BSF}{'ROOTPLATNAME'} = $CustomizedPlatName;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   842
            }           
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   843
        }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   844
        else
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   845
        {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   846
            my $rootbsf = $Path.$root.".bsf";           
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   847
            if ( -e $rootbsf ) {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   848
                # BSF file customizes another BSF file which has not been read yet.
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   849
                # So defer current BSF file reading until the root BSF file is read.                
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   850
                delete $Plat{$BSF};
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   851
                push(@BSFs, $BSF);
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   852
                next;       
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   853
            }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   854
        }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   855
        # If the customizes platform is not a valid BSF platform or BPABI platorm or ARMV5 or ARMV5_ABIV1,
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   856
        # then throw warning.
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   857
        unless ($rootPlatFound || $root =~ /^ARMV5(_ABIV1)?$/ || (grep /^$root$/i, @BPABIPlats)) {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   858
            warn "warning: \"$File\" Invalid BSF specification - customization restricted to ARMV5, ABIv2 and valid BSF platforms\n";
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   859
            close FILE;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   860
            delete $Plat{$BSF};
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   861
            next;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   862
        }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   863
            
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   864
        my ( $key, $value);
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   865
        while (($key, $value) = each %{$Plat{$platname}}) {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   866
            $Plat{$BSF}{$key}=$value;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   867
        }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   868
        
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   869
        push @{$Plat{$CustomizedPlatName}{'CUSTOMIZATIONS'}}, $BSF;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   870
        $Plat{$BSF}{'CUSTOMIZES'} = $CustomizedPlatName;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   871
        while (<FILE>) {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   872
            next if (/^$|^\#/);
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   873
            if (/^\s*SMP\s*$/i) {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   874
                $Plat{$BSF}{'SMP'} = 1;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   875
                $Plat{$BSF}{'StatLink'} = lc $BSF;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   876
                next;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   877
            }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   878
            $Plat{$BSF}{'CUSTOMIZATION_DATA'} .= $_;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   879
        }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   880
        # BSF file statements will have newline character("\n") at the end, except for the last statement.
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   881
        # So append "\n" for the last BSF file statement.
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   882
        # "\n" will be used to split BSF statements to support hierarchy of customizations.
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   883
        $Plat{$BSF}{'CUSTOMIZATION_DATA'} .= "\n";
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   884
        close FILE;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   885
    }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   886
    $init_bsfs_done = 1;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   887
}
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   888
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   889
# setup Plat with bpabi platforms
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   890
sub init_platwithbpabi() 
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   891
{
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   892
    foreach my $Candidate (&get_bpabiplatlist)
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   893
    {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   894
# All BPABI platforms inherit from ABIV2 properties as listed in the platlist
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   895
# and Platlist is updated to include the BPABI platforms.
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   896
        my ( $key, $value);
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   897
        while (($key, $value) = each %{$Plat{ABIV2}}) {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   898
            $Plat{$Candidate}{$key}=$value;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   899
        }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   900
    }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   901
}
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   902
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   903
# initialize %Plat with BSF/Bpabi/ASSP
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   904
sub init_plat ($) { # takes path to ASSP modules
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   905
    
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   906
    return $init_plat_done if ($init_plat_done);
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   907
    
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   908
    my ($Path)=@_;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   909
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   910
    my %PlatHashKeys=(
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   911
        ABI=>1,
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   912
        ASSPABI=>1,
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   913
        SINGLE=>1,
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   914
        Compiler=>1,
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   915
        CPU=>1,
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   916
        MakeMod=>1,
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   917
        MakeCmd=>1,
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   918
        OS=>1,
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   919
        DefFile=>1,
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   920
        ASSP=>1,
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   921
    );
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   922
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   923
#   Include the list of BPABI platforms
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   924
    &init_platwithbpabi;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   925
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   926
    init_bsfs($Path);
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   927
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   928
#   get a list of modules
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   929
    opendir DIR, $Path;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   930
    my @_ASSPs=grep s/^([^\.].*)\.ASSP$/$1/, map { uc $_ } readdir DIR;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   931
    closedir DIR;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   932
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   933
    my @ASSPs;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   934
    foreach (@_ASSPs) {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   935
        next if (!$ENV{USEARMCC} and /EDG$/i);
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   936
        push @ASSPs, $_;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   937
    }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   938
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   939
#   open each module in turn, and add it to the array
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   940
    my $ASSP;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   941
    foreach $ASSP (@ASSPs) {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   942
        my $File=$Path.$ASSP.'.assp';
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   943
#       check whether the assp is already defined
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   944
        if (defined %{$Plat{$ASSP}}) {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   945
            warn(
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   946
                "$File : warning: ASSP \"$ASSP\" already defined\n",
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   947
                " ... skipping this module\n"
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   948
            );
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   949
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   950
            next;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   951
        }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   952
#       open the module
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   953
        unless (open FILE, $File) {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   954
            warn "warning: Can't open assp module \"$File\"\n";
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   955
            next;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   956
        }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   957
        my %Data=();
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   958
        my %SingleData=();
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   959
        my $MatchingSingle="";
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   960
        my @Errors=();
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   961
        while (<FILE>) {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   962
#           strip comments
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   963
            s/^([^#]*)#.*$/$1/o;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   964
#           skip blank lines
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   965
            if (/^\s*$/o) {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   966
                next;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   967
            }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   968
#           get the key-value pair
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   969
            unless (/^\s*(\w+)\s+(\w+)\s*$/o) {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   970
                push @Errors, "$File($.) : warning: syntax error - only key-value pairs allowed\n";
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   971
                next;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   972
            }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   973
            my ($Key, $Val)=($1, $2);
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   974
            if ($PlatHashKeys{$Key}!=1) {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   975
                push @Errors, "$File($.) : warning: unrecognized keyword - $Key\n";
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   976
                next;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   977
            }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   978
            if ($Key eq "SINGLE") {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   979
                $SingleData{Single} = 1;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   980
                $SingleData{ASSP} = $ASSP;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   981
                $MatchingSingle = uc $2;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   982
            } else {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   983
                $Data{$Key}=$Val;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   984
                $SingleData{$Key}=$Val;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   985
            }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   986
        }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   987
        close FILE;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   988
        if (@Errors) {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   989
            warn(
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   990
                @Errors,
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   991
                " ... skipping this module\n"
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   992
            );
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   993
            next;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   994
        }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   995
# change -  Allow ASSPs to pick up all the options of the ABI they specify, 
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   996
# in particular the compiler they need.
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   997
            $Data{'ASSP'} = $ASSP unless $Data{'ASSP'};
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   998
            if ($Plat{$Data{'ABI'}}) {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   999
            foreach (keys %{$Plat{$Data{'ABI'}}}) {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1000
            $Data{$_} = $Plat{$Data{'ABI'}}{$_} unless ($_ =~ /^GENERIC$/i) or $Data{$_};
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1001
            }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1002
        }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1003
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1004
        %{$Plat{$ASSP}}=%Data;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1005
        if ($MatchingSingle ne "") {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1006
            foreach (keys %Data) {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1007
            $SingleData{$_} = $Data{$_} unless ($_ =~ /^GENERIC$/i) or $SingleData{$_};
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1008
            }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1009
            %{$Plat{$MatchingSingle}}=%SingleData;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1010
        }           
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1011
    }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1012
    $init_plat_done=1;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1013
}
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1014
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1015
#   return list of supported platforms
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1016
#   should be invoked atfer init_plat
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1017
sub get_platlist () {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1018
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1019
    return @PlatList if (scalar(@PlatList));
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1020
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1021
    &init_plat;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1022
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1023
    my $Key;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1024
    foreach $Key (keys %Plat) {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1025
        if (!$variantABIV2Keyword && $Key =~ /^armv5_abiv1$/i) {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1026
            $Key = 'ARMV5';
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1027
        }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1028
        unless (grep /^$Key$/i, @PlatList) {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1029
            push @PlatList, $Key;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1030
        }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1031
    }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1032
    return @PlatList
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1033
}
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1034
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1035
# return customizes BSF plat if any
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1036
sub get_platcustomizes($) {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1037
    my ($plat) = @_;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1038
    return $Plat{$plat}{'CUSTOMIZES'} ? $Plat{$plat}{'CUSTOMIZES'} : "";
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1039
}
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1040
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1041
# return root of a specific plat
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1042
sub get_platroot($) {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1043
    my ($plat) = @_;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1044
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1045
    my $RootName = $Plat{$plat}{'ROOTPLATNAME'};
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1046
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1047
    if ($RootName) {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1048
        return $RootName;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1049
    }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1050
    else {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1051
        # A non-BSF platform is its own root.
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1052
        return $plat;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1053
    }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1054
}
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1055
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1056
#################################
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1057
# featurevariant map functions
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1058
#
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1059
# copy from featurevariantmap.pm
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1060
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1061
my $featureListDir = "${epocroot}epoc32\/include\/variant\/featurelists";
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1062
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1063
# Usage:    get_BVbinname("my.dll", "myvar")
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1064
#
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1065
# Look for a binary using its "final" name. We will use the feature
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1066
# variant map and the feature variant name to deduce the "variant"
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1067
# binary name and test for its existence.
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1068
#
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1069
# "my.dll"  - the final target (full path)
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1070
# "myvar"   - the feature variant name
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1071
#
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1072
# returns the file name if found, or "" otherwise.
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1073
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1074
sub get_BVbinname
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1075
{
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1076
    my $binName = shift;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1077
    my $varName = shift;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1078
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1079
    # look for the vmap file
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1080
    my $vmapFile = "$binName.$varName.vmap";
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1081
    
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1082
    if (! -e $vmapFile)
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1083
    {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1084
    	# compatible to old BV
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1085
    	$vmapFile = "$binName.vmap";
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1086
    }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1087
    
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1088
    if (-e $vmapFile)
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1089
    {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1090
        my $key = get_vmapkey($varName, $vmapFile);
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1091
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1092
        if ($key)
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1093
        {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1094
            $binName =~ /^(.*)\.([^\.]*)$/;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1095
            $binName = "$1.$key.$2";
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1096
        }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1097
        else
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1098
        {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1099
            print "ERROR: No \'$varName\' variant for $binName in $vmapFile\n";
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1100
            return "";  # file not found
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1101
        }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1102
    }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1103
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1104
    # check that the actual binary exists
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1105
    if (-e $binName)
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1106
    {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1107
        return $binName;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1108
    }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1109
    return "";  # file not found
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1110
}
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1111
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1112
# internal functions
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1113
sub get_vmapkey
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1114
{
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1115
    my @res = get_vmapdata(@_);
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1116
    return $res[0];
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1117
}
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1118
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1119
# Usage:    featurevariantmap->GetDataFromVMAP("myvar", "mydll.vmap")
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1120
#
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1121
# Opens the vmap file indicated and returns the data for the requested variant
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1122
#
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1123
# "myvar"   - the feature variant name
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1124
# "my.vmap" - the final target vmap file (full path)
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1125
#
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1126
# Returns a list ( hash, features ) for the variant in the vmap or undef if not found
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1127
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1128
sub get_vmapdata
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1129
{
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1130
    my $varName = shift;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1131
    my $fileName = shift;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1132
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1133
    if (!open(VMAP, $fileName))
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1134
    {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1135
        print "ERROR: Could not read VMAP from $fileName\n";
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1136
        return "";
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1137
    }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1138
    while (<VMAP>)
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1139
    {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1140
        chomp;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1141
        if (/(\w{32})\s+$varName\s+(.*)$/i or /(\w{32})\s+$varName$/i)
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1142
        {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1143
            my ( $hash, $features ) = ( $1, $2 ? $2 : '' );
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1144
            close(VMAP);
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1145
            return ( $hash, $features );
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1146
        }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1147
    }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1148
    close(VMAP);
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1149
    return;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1150
}
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1151
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1152
######################################
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1153
# Feature variant parser
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1154
#
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1155
# copy from featurevariantparser.pm
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1156
#
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1157
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1158
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1159
# Parses .VAR files and returns key variables.
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1160
# The following hashes can be used with this module:
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1161
# NAME              -> Returns the name of the variant file (without the extension)
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1162
# FULLPATH          -> Returns the full path of the variant file (including the extension)
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1163
# VALID             -> Set to 1 if the variant file is valid, otherwise set to 0
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1164
# VIRTUAL           -> Set to 1 if the variant is a grouping node, otherwise set to 0
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1165
# ROM_INCLUDES      -> Returns a pointer to the list of ROM_INCLUDES (including Parent nodes).
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1166
# VARIANT_HRH       -> Returns the full VARIANT_HRH file path used by the VAR file.
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1167
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1168
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1169
my $defaultDir = "${epocroot}epoc32\/tools\/variant";
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1170
my $pathregex = '.+[^\s]'  ;   # Regex to match all characters (including \ or /), excluding whitespaces.
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1171
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1172
my @rominclude;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1173
my @parents;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1174
my @childNodes;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1175
my $virtual;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1176
my $childNodeStatus;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1177
my $varianthrh;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1178
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1179
my $dir;        #var directory
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1180
my $fullpath;   #full path of var file
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1181
my $fulldir;    #
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1182
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1183
# Wrapper function to return all the correct variables
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1184
# Arguments : (Variant Name, Variant Directory(optional))
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1185
# Returns a Hash.
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1186
sub get_variant
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1187
{
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1188
    @rominclude      = ();
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1189
    @parents         = ();
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1190
    @childNodes      = ();
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1191
    $dir             = "";
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1192
    $fullpath        = "";
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1193
    $varianthrh      = "";
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1194
    $virtual         = 0;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1195
    $childNodeStatus = 0;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1196
    
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1197
    
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1198
    my %data;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1199
    my $romincs   = "";
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1200
    
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1201
    $data{'VALID'} = 0;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1202
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1203
    my ( $varname, $dirname ) = @_;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1204
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1205
    my $fullvarpath = get_variantfullpath( $varname, $dirname );
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1206
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1207
    if ( $dirname )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1208
    {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1209
        $fulldir = $dirname;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1210
    }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1211
    else
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1212
    {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1213
        $fulldir = $defaultDir;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1214
    }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1215
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1216
    $data{'FULLPATH'} = "$fullvarpath";
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1217
    $data{'NAME'}     = "$varname";
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1218
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1219
    # If the variant file exists, check the syntax and setup variables.
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1220
    if ( -e $fullvarpath )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1221
    {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1222
        if ( check_varfile( $fullvarpath, $varname ) )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1223
        {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1224
            $data{'VALID'} = 1;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1225
        }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1226
    }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1227
    else
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1228
    {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1229
        print "ERROR: $fullvarpath" . " does not exist\n";
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1230
    }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1231
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1232
    my $count = 0;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1233
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1234
    # If VAR file is valid, setup all other variables.
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1235
    if ( $data{'VALID'} )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1236
    {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1237
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1238
        $romincs   = find_varrominc($fullvarpath);
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1239
        
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1240
        # Remove empty elements from the ROM_INCLUDE list
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1241
        @$romincs = grep /\S/, @$romincs;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1242
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1243
        # Fix paths for all ROM_INCLUDES
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1244
        for ( my $i = 0 ; $i < scalar(@$romincs) ; $i++ )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1245
        {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1246
            @$romincs[$i] = get_fixpath( @$romincs[$i] );
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1247
        }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1248
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1249
        $data{'ROM_INCLUDES'}   = clone_list($romincs);
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1250
        $data{'VARIANT_HRH'}    = $varianthrh;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1251
        $data{'VIRTUAL'}        = $virtual;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1252
    }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1253
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1254
    # If variant file is not valid, return reference to a blank array
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1255
    else
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1256
    {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1257
        $data{'ROM_INCLUDES'}   = [];
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1258
        $data{'VARIANT_HRH'}    = "";
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1259
    }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1260
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1261
    return %data;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1262
}
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1263
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1264
# Method to construct a full variant path from the variant file and directory
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1265
sub get_variantfullpath
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1266
{
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1267
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1268
    my $vardirectory = $_[1];
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1269
    my $varname      = $_[0];
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1270
    
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1271
    my $dir;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1272
    
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1273
    # Check if a directory is supplied
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1274
    if ($vardirectory)
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1275
    {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1276
        $dir = "$vardirectory";
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1277
    }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1278
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1279
    else
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1280
    {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1281
        $dir = $defaultDir;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1282
    }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1283
    my $filename = "$varname" . "\.var";
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1284
    $fullpath = File::Spec->catfile( File::Spec->rel2abs($dir), $filename );
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1285
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1286
    if ( !File::Spec->file_name_is_absolute($fullpath) )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1287
    {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1288
        $fullpath = File::Spec->rel2abs($fullpath);
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1289
    }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1290
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1291
    return $fullpath;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1292
}
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1293
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1294
# Checks the variant file for the correct syntax and reports any errors
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1295
# Also sets up some variables(VIRTUAL ,VARIANT_HRH and VARIANT) whilst file is being parsed.
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1296
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1297
# Usage: check_varfile(<fullpath>,<varfile>) . Note: <varfile> without .var
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1298
sub check_varfile
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1299
{
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1300
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1301
    my $fullpath          = $_[0];
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1302
    my $varname           = $_[1];
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1303
    my $varianthrhpresent = 0;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1304
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1305
    open( READVAR, "<$fullpath" );
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1306
    my $exp  = "#";
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1307
    my $line = "";
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1308
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1309
    while (<READVAR>)
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1310
    {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1311
        s/\r\n/\n/g;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1312
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1313
        $line = $.;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1314
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1315
    # Checks for a valid argument supplied to EXTENDS keyword. Checks for one and only one argument supplied.
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1316
        if (/^EXTENDS/)
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1317
        {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1318
            if ( !m/^EXTENDS\s+./ )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1319
            {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1320
                print "\nERROR: Invalid format supplied to argument EXTENDS on line "
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1321
                  . "$."
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1322
                  . " in file "
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1323
                  . "$fullpath";
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1324
                return 0;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1325
            }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1326
            my $str = get_extends($_);
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1327
            if ( $str =~ /\s+/ )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1328
            {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1329
                print "\nERROR: Cannot extend from two nodes. Error in line "
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1330
                  . "$."
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1331
                  . " in file "
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1332
                  . "$fullpath";
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1333
                return 0;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1334
            }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1335
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1336
            $childNodeStatus = 1;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1337
        }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1338
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1339
        # Checks for the grammar of BUILD_INCLUDE, i.e. KEYWORD MODIFIER VALUE
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1340
        elsif (/^BUILD_INCLUDE/)
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1341
        {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1342
            # skip build inc checking
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1343
        }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1344
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1345
        # Checks for the grammar of ROM_INCLUDE, i.e. KEYWORD MODIFIER VALUE
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1346
        elsif (/^ROM_INCLUDE/)
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1347
        {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1348
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1349
            if (!m/^ROM_INCLUDE\s+(append|prepend|set)\s+$pathregex/)
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1350
            {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1351
                print "\nERROR: Invalid syntax supplied to keyword ROM_INCLUDE on line "
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1352
                  . "$."
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1353
                  . " in file "
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1354
                  . "$fullpath";
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1355
                return 0;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1356
            }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1357
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1358
            if (m/^ROM_INCLUDE\s+(append|prepend|set)\s+$pathregex\s+$pathregex/)
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1359
            {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1360
                print "\nERROR: Too many arguments supplied to keyword ROM_INCLUDE on line "
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1361
                  . "$."
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1362
                  . " in file "
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1363
                  . "$fullpath";
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1364
                return 0;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1365
            }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1366
        }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1367
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1368
        # Checks for a valid VARIANT name
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1369
        elsif (/^VARIANT[^_HRH]/)
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1370
        {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1371
            if ( !m/^VARIANT\s+\w+/ )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1372
            {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1373
                print "\nERROR: VARIANT name not specified on line " . "$."
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1374
                  . " in file "
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1375
                  . "$fullpath";
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1376
                return 0;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1377
            }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1378
            if ( uc("$varname") ne uc( get_variantname($_) ) )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1379
            {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1380
                print "\nERROR: VARIANT filename does not match variant name specified on line "
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1381
                  . "$line"
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1382
                  . " in file "
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1383
                  . "$fullpath"
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1384
                  . "\nVariant value extracted from the VAR file is " . "$_";
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1385
            }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1386
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1387
        }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1388
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1389
        # Checks that keyword VIRTUAL is declared correctly
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1390
        elsif (/^VIRTUAL/)
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1391
        {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1392
            if (m/^VIRTUAL\s+\w+/)
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1393
            {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1394
                print "\nERROR: Invalid declaration of VIRTUAL on line " . "$."
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1395
                  . " in file "
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1396
                  . "$fullpath";
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1397
                return 0;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1398
            }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1399
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1400
            $virtual = 1;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1401
        }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1402
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1403
        # Checks if VARIANT_HRH is declared correctly.
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1404
        elsif (/^VARIANT_HRH/)
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1405
        {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1406
            $varianthrhpresent = 1;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1407
            my $lineno = $.;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1408
            if ( !m/^VARIANT_HRH\s+./ )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1409
            {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1410
                print "\nERROR: Invalid format supplied to argument VARIANT_HRH on line "
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1411
                  . "$lineno"
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1412
                  . " in file "
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1413
                  . "$fullpath";
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1414
                return 0;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1415
            }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1416
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1417
            my $str = get_hrhname($_);
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1418
            if ( $str =~ /\s+/ )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1419
            {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1420
                print "\nERROR: Cannot have 2 or more hrh files. Error in line "
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1421
                  . "$lineno"
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1422
                  . " in file "
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1423
                  . "$fullpath";
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1424
                return 0;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1425
            }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1426
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1427
            unless( -e get_fixpath($str) )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1428
            {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1429
                print "\nERROR: VARIANT HRH file : "
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1430
                  . get_fixpath($str)
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1431
                  . " specified on line "
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1432
                  . "$lineno"
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1433
                  . " does not exist";
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1434
                return 0;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1435
            }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1436
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1437
            $varianthrh = get_fixpath( get_hrhname($_) );
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1438
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1439
        }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1440
        
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1441
        # If none of the valid keywords are found
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1442
        else
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1443
        {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1444
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1445
            # Do nothing if a comment or blank line is found
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1446
            if ( (m/$exp\s+\S/) || (m/$exp\S/) || ( !m/./ ) || (m/^\n/) )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1447
            {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1448
            }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1449
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1450
            # Unsupported keyword
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1451
            else
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1452
            {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1453
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1454
                print "\nERROR: Invalid keyword " . '"' . "$_" . '"'
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1455
                  . " found on line " . "$."
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1456
                  . " in file "
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1457
                  . "$fullpath";
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1458
                return 0;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1459
            }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1460
        }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1461
    }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1462
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1463
    close(READVAR);
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1464
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1465
    # If no HRH file defined, check if the default one exists
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1466
    if ( !$varianthrhpresent )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1467
    {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1468
        print "\nINFO: No VARIANT_HRH defined in VAR file, using ${epocroot}epoc32\/include\/variant\/$varname\.hrh" if ($verbose);
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1469
        my $str =
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1470
          get_hrhname(
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1471
            "VARIANT_HRH ${epocroot}epoc32\/include\/variant\/$varname\.hrh"
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1472
          );
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1473
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1474
        if ( ! -e $str )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1475
        {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1476
            print "\nERROR: VARIANT HRH file : " . "$str " . "does not exist\n";
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1477
            return 0;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1478
        }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1479
        else
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1480
        {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1481
            $varianthrh = $str;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1482
        }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1483
    }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1484
    return 1;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1485
}
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1486
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1487
# Extract the value of the VARIANT keyword
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1488
sub get_variantname
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1489
{
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1490
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1491
    $_[0] =~ m/^VARIANT\s+(\w+)/i;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1492
    return $1;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1493
}
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1494
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1495
# Extracts the value of the HRH file from the VARIANT_HRH line supplied
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1496
sub get_hrhname
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1497
{
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1498
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1499
    $_[0] =~ m/^VARIANT_HRH\s+($pathregex)/;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1500
    return $1;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1501
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1502
}
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1503
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1504
# Method to find the immediate parent node of a child node
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1505
sub get_extends
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1506
{
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1507
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1508
    $_[0] =~ m/^EXTENDS\s+(\w+)/;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1509
    return $1;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1510
}
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1511
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1512
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1513
# Method to correct all the slashes, and also append EPOCROOT if the path begins with a \ or /
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1514
# If path doesn't start with \ or /, returns an abosulte canonical path
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1515
sub get_fixpath
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1516
{
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1517
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1518
    my $arr = $_[0];
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1519
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1520
    if ( $arr =~ m/^\// )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1521
    {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1522
       $arr =~ s/^\/?//;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1523
        return File::Spec->canonpath( "$epocroot" . "$arr" );
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1524
    }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1525
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1526
    elsif ( $arr =~ m/^\\/ )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1527
    {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1528
        $arr =~ s/^\\?//;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1529
        return File::Spec->canonpath( "$epocroot" . "$arr" );
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1530
    }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1531
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1532
    else
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1533
    {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1534
        return File::Spec->rel2abs( File::Spec->canonpath("$arr") );
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1535
    }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1536
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1537
}
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1538
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1539
# Method to find the ROMINCLUDE values of the VAR file.
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1540
sub find_varrominc
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1541
{
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1542
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1543
    my $filename = $_[0];
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1544
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1545
    my $parentNodes;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1546
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1547
    # Construct a list of parent nodes if node is a child
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1548
    if ($childNodeStatus)
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1549
    {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1550
        $parentNodes = find_varparentnode("$filename");
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1551
    }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1552
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1553
    if ($parentNodes)
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1554
    {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1555
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1556
        # Go through and build the list of all parent ROM_INCLUDES
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1557
        for ( my $i = scalar(@$parentNodes) - 1 ; $i >= 0 ; $i-- )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1558
        {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1559
            my $t = get_variantfullpath( @$parentNodes[$i], $fulldir );
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1560
            open( NEWHANDLE, "<$t" );
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1561
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1562
            while (<NEWHANDLE>)
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1563
            {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1564
                if (/ROM_INCLUDE/)
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1565
                {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1566
                    get_varrominc($_);
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1567
                }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1568
            }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1569
            close(NEWHANDLE);
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1570
        }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1571
    }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1572
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1573
    # Append the ROM_INCLUDES of the VAR file in the end
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1574
    open( NEWHANDLE, "<$filename" );
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1575
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1576
    while (<NEWHANDLE>)
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1577
    {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1578
        if (/ROM_INCLUDE/)
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1579
        {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1580
            get_varrominc($_);
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1581
        }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1582
    }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1583
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1584
    undef(@parents);    # Flush out parent array;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1585
    return \@rominclude;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1586
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1587
}
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1588
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1589
# Constructs a list of Parent nodes for a given Child node.
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1590
sub find_varparentnode
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1591
{
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1592
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1593
    my $filename   = $_[0];
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1594
    my $hasparents = 0;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1595
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1596
    open( READHANDLE, "<$filename" );
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1597
    while (<READHANDLE>)
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1598
    {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1599
        if (/EXTENDS/)
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1600
        {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1601
            $hasparents = 1;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1602
            push( @parents, get_extends($_) );
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1603
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1604
        }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1605
    }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1606
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1607
    close(READHANDLE);
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1608
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1609
    if ( $hasparents == 1 )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1610
    {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1611
        find_varparentnode(
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1612
            get_variantfullpath( @parents[ scalar(@parents) - 1 ], $fulldir )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1613
        );
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1614
    }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1615
    else
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1616
    {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1617
        return \@parents;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1618
    }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1619
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1620
}
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1621
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1622
# Method to extract the ROM_INCLUDE value of a node.
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1623
sub get_varrominc
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1624
{
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1625
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1626
# If modifier append is found, push the rominclude to the end of the array list.
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1627
    if (/^ROM_INCLUDE\s+append\s+($pathregex)/)
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1628
    {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1629
        push( @rominclude, ($1) );
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1630
    }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1631
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1632
# If modifier prepend is found, push the rominclude to the beginning of the array list.
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1633
    if (/^ROM_INCLUDE\s+prepend\s+($pathregex)/)
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1634
    {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1635
        unshift( @rominclude, ($1) );
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1636
    }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1637
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1638
# If keyword set is found, then empty the rominclude variable and push the new value
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1639
    if (/^ROM_INCLUDE\s+set\s+($pathregex)/)
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1640
    {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1641
        undef(@rominclude);
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1642
        push( @rominclude, ($1) );
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1643
    }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1644
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1645
}
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1646
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1647
# Helper method that clones a reference to a simple list
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1648
sub clone_list
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1649
    {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1650
    my $ref = shift;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1651
    
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1652
    # Check the reference is a list
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1653
    die "Not a list ref" if ref($ref) ne 'ARRAY';
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1654
    
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1655
    # Create a new list object
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1656
    my @list;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1657
    foreach my $entry ( @$ref )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1658
        {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1659
        # Only clone lists of scalars
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1660
        die "Not a scalar" if ref($entry);
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1661
        
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1662
        # Add the entry to the new list
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1663
        push @list, $entry;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1664
        }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1665
    
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1666
    # return a reference to the copy    
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1667
    return \@list;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1668
    }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1669
    
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1670
##############################
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1671
#  write helper
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1672
#
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1673
# copy from writer.pm
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1674
sub write_32bit # little-endian
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1675
{
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1676
    my $fileHandle=shift;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1677
    my $integer=shift;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1678
    &write_8bit($fileHandle, $integer&0x000000ff);
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1679
    &write_8bit($fileHandle, ($integer>>8)&0x000000ff);
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1680
    &write_8bit($fileHandle, ($integer>>16)&0x000000ff);
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1681
    &write_8bit($fileHandle, ($integer>>24)&0x000000ff);
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1682
}
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1683
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1684
sub write_8bit
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1685
{
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1686
    my $fileHandle=shift;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1687
    my $integer=shift;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1688
    if ($integer&0xffffff00)
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1689
    {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1690
        die("Error: the integer ".sprintf("0x%08x", $integer)." is too large to write into 8 bits\n");
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1691
    }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1692
    printf $fileHandle "%c", $integer;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1693
}
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1694
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1695
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1696
1;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1697