sbsv1/abld/platform/bpabiutl.pm
author Ross Qin <ross.qin@nokia.com>
Tue, 30 Nov 2010 13:59:58 +0800
changeset 712 df89378e9223
parent 599 fa7a3cc6effd
permissions -rw-r--r--
Fix these errors: Some cases of PREQ1230 fail because of buildrom issue rombuild crashs when create ext-romimage readimage crashes on reading wk42 vasco_ui core image vc2008 compiling issues
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
599
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
     1
# Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
     2
# All rights reserved.
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
     3
# This component and the accompanying materials are made available
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
     4
# under the terms of "Eclipse Public License v1.0"
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
     5
# which accompanies this distribution, and is available
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
     6
# at the URL "http://www.eclipse.org/legal/epl-v10.html".
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
     7
#
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
     8
# Initial Contributors:
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
     9
# Nokia Corporation - initial contribution.
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    10
#
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    11
# Contributors:
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    12
#
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    13
# Description:
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    14
# This package  does various ancillary things for BPABI (Base Platform ABI) platforms
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    15
# 
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    16
#
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    17
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    18
package BPABIutl;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    19
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    20
require Exporter;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    21
@ISA=qw(Exporter);
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    22
@EXPORT=qw(
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    23
	BPABIutl_Plat_List
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    24
	BPABIutl_Config_Path
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    25
	BPABIutl_Get_Config_Variables
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    26
);
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    27
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    28
use E32Variant;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    29
require E32Plat;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    30
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    31
my %ConfigPath;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    32
my $variantABIV2Keyword = &Variant_GetMacro();
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    33
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    34
sub BPABIutl_Plat_List {
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    35
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    36
# Identify the BPABI platforms to be supported based on the compiler configuration files
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    37
# present in the location specified by the environment variable "SYMBIAN_COMPILATION_CONFIG_DIR"
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    38
# and in the directory $EPOCROOT\epoc32\tools\compilation_config
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    39
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    40
	my @CompilerConfigPath;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    41
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    42
	if (exists($ENV{'SYMBIAN_COMPILATION_CONFIG_DIR'})) 
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    43
	{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    44
		my $Path = $ENV{SYMBIAN_COMPILATION_CONFIG_DIR};
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    45
		@CompilerConfigPath = split(/;/, $Path);
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    46
	}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    47
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    48
	push @CompilerConfigPath, "$ENV{EPOCROOT}epoc32\\tools\\compilation_config";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    49
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    50
	my $ConfigDir;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    51
	my @BPABIPlats = ();
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    52
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    53
	foreach $ConfigDir (@CompilerConfigPath)
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    54
	{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    55
		opendir DIR, "$ConfigDir";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    56
		my @Plats=grep /\.mk$/i, readdir DIR;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    57
		my $Plat;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    58
		foreach $Plat (@Plats) 
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    59
		{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    60
# The platform name will be same as the name of the configuration file <config.mk>
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    61
# with the suffix '.mk' removed
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    62
			$Plat =~ s/\.mk//;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    63
			if ($variantABIV2Keyword) {
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    64
				if ($Plat =~ /^armv5_abiv2$/i) {
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    65
					$Plat = "ARMV5";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    66
				}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    67
			}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    68
			else {
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    69
				if ($Plat =~ /^armv5$/i) {
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    70
					$Plat = "ARMV5_ABIV2";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    71
				}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    72
			}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    73
			unless (grep /$Plat$/i, @BPABIPlats) {
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    74
				$Plat = uc $Plat;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    75
				push @BPABIPlats, $Plat;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    76
				if (!$variantABIV2Keyword && $Plat =~ /^ARMV5_ABIV2$/i) {
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    77
					$ConfigPath{$Plat} = "$ConfigDir\\ARMV5.mk";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    78
				}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    79
				else {
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    80
					$ConfigPath{$Plat} = "$ConfigDir\\$Plat.mk";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    81
				}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    82
			}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    83
		}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    84
	}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    85
	closedir DIR;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    86
	return @BPABIPlats;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    87
}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    88
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    89
sub BPABIutl_Config_Path($) {
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    90
	my ($plat) = @_;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    91
# Returns the Path of the compiler configuration file
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    92
	if (!keys(%ConfigPath))
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    93
	{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    94
	    # Running for first time so initialise ConfigPath
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    95
	    BPABIutl_Plat_List();
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    96
	}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    97
	if (!$ConfigPath{$plat})
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    98
	{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    99
		# Get the root platform name to support hierarchy of customizations
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   100
		my $CustomizedPlat =  &E32Plat::Plat_Root($plat);
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   101
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   102
# In default ABIV1 mode, the platform name for v2 mode of ARMV5 is ARMV5_ABIV2
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   103
		if ( !$variantABIV2Keyword && $CustomizedPlat =~ /^ARMV5$/i ){
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   104
			$ConfigPath{$plat} = $ConfigPath{ARMV5_ABIV2};
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   105
		}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   106
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   107
# In default ABIV2 mode, the platform name for v2 mode of ARMV5 is ARMV5
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   108
		elsif ( $variantABIV2Keyword && $CustomizedPlat =~ /^ARMV5$/i) {
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   109
			$ConfigPath{$plat} = $ConfigPath{ARMV5};
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   110
		}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   111
		else{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   112
			$ConfigPath{$plat}=$ConfigPath{$CustomizedPlat};
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   113
		}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   114
	}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   115
	return "$ConfigPath{$plat}";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   116
}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   117
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   118
# routine to extract a set of variables from the compilation configuration
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   119
# file. The variables extracted are determined by the extractvars.make file.
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   120
# The variables are returned in a hash.
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   121
sub BPABIutl_Get_Config_Variables
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   122
{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   123
    my ($plat) = @_;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   124
    my $configfile = BPABIutl_Config_Path($plat);
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   125
    my $extractvars = "$ENV{EPOCROOT}epoc32\\tools\\compilation_config\\extractvars.make";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   126
    my $command = "make CONFIG_FILE=$configfile -s -f $extractvars" ;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   127
    my $result = `$command`;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   128
    my %vars;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   129
    my @lines = split('\n', $result);
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   130
    foreach my $line (@lines)
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   131
    {
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   132
	chomp $line;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   133
	if ($line =~ /(\w+)=(.*)/)
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   134
	{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   135
	    $vars{$1} = $2;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   136
	}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   137
    }
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   138
    return %vars;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   139
}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   140
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   141
1;