sbsv1/abld/platform/e32plat.pm
changeset 599 fa7a3cc6effd
equal deleted inserted replaced
596:9f25be3da657 599:fa7a3cc6effd
       
     1 # Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 # All rights reserved.
       
     3 # This component and the accompanying materials are made available
       
     4 # under the terms of "Eclipse Public License v1.0"
       
     5 # which accompanies this distribution, and is available
       
     6 # at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 #
       
     8 # Initial Contributors:
       
     9 # Nokia Corporation - initial contribution.
       
    10 #
       
    11 # Contributors:
       
    12 #
       
    13 # Description:
       
    14 # Module providing platform details for platforms supported
       
    15 # by Symbian OS
       
    16 # all data is uppercase
       
    17 # 
       
    18 #
       
    19 
       
    20 package E32Plat;
       
    21 
       
    22 require Exporter;
       
    23 @ISA=qw(Exporter);
       
    24 
       
    25 @EXPORT=qw(
       
    26 	Plat_SetVerbose
       
    27 	Plat_Init
       
    28 	Plat_GetL
       
    29 	Plat_List
       
    30 	Plat_AssocIDE
       
    31 	Plat_Customizations
       
    32 	Plat_Customizes
       
    33 	Plat_Root
       
    34 	Plat_SupportsFeatureVariants
       
    35 );
       
    36 
       
    37 use Winutl;
       
    38 use RVCT_plat2set;
       
    39 use BPABIutl;
       
    40 use E32Variant;
       
    41 
       
    42 my $variantABIV2Keyword = &Variant_GetMacro();
       
    43 
       
    44 my %Mode=(
       
    45 	Verbose=>0
       
    46 );
       
    47 my $ModulePath;
       
    48 
       
    49 sub Plat_SetVerbose () {
       
    50 	$Mode{Verbose}=1;
       
    51 }
       
    52 
       
    53 my %BldLists=(
       
    54 	EPOC32=>['UREL','UDEB'],
       
    55 	WINS=>['UDEB','UREL'],
       
    56 	TOOLS=>['DEB','REL'],
       
    57 	TOOLS2=>['DEB','REL'],
       
    58 );
       
    59 
       
    60 my %BldMacros=(
       
    61 	DEB=>['_DEBUG'],
       
    62 	REL=>['NDEBUG'],
       
    63 	UDEB=>['_DEBUG','_UNICODE'],
       
    64 	UREL=>['NDEBUG','_UNICODE']
       
    65 );
       
    66 
       
    67 
       
    68 my @EpocMacros=('__SYMBIAN32__');
       
    69 
       
    70 my @BPABIPlats = &BPABIutl_Plat_List;
       
    71 
       
    72 my %Plat=(
       
    73 	ARM4=>{
       
    74 		ABI=>'ARM4',
       
    75 		ASSP=>'MARM',
       
    76 		ASSPABI=>'',
       
    77 		Generic=>1,
       
    78 	},
       
    79 	ARM4SMP=>{
       
    80 		ABI=>'ARM4',
       
    81 		ASSP=>'MARM',
       
    82 		ASSPABI=>'',
       
    83 		Generic=>1,
       
    84 		SMP=>1,
       
    85 		StatLink=>'ARM4SMP',
       
    86 	},
       
    87 	ARM4T=>{
       
    88 		ABI=>'ARM4T',
       
    89 		ASSP=>'MARM',
       
    90 		ASSPABI=>'',
       
    91 		Generic=>1,
       
    92 	},
       
    93 	ARMI=>{
       
    94 		ASSP=>'MARM',
       
    95 		Generic=>1,
       
    96 		ASSPABI=>'',
       
    97 	},
       
    98 	SARM4=>{
       
    99 		ABI=>'ARM4',
       
   100 		ASSP=>'MARM',
       
   101 		ASSPABI=>'',
       
   102 		Generic=>1,
       
   103 		Single=>1,
       
   104 	},
       
   105 	SARMI=>{
       
   106 		ASSP=>'MARM',
       
   107 		ASSPABI=>'',
       
   108 		Generic=>1,
       
   109 		Single=>1,
       
   110 	},
       
   111 	STHUMB=>{
       
   112 		ABI=>'THUMB',
       
   113 		ASSP=>'MARM',
       
   114 		ASSPABI=>'',
       
   115 		Generic=>1,
       
   116 		Single=>1,
       
   117 	},
       
   118 	THUMB=>{
       
   119 		ABI=>'THUMB',
       
   120 		ASSP=>'MARM',
       
   121 		ASSPABI=>'',
       
   122 		Generic=>1,
       
   123 	},
       
   124 	TOOLS=>{
       
   125 		ABI=>'TOOLS',
       
   126 		ASSPABI=>'',
       
   127 		Compiler=>'VC32',
       
   128 		CPU=>'TOOLS',
       
   129 		OS=>'TOOLS',
       
   130 		MakeMod=>'Cl_win',
       
   131 		MakeCmd=>'nmake',
       
   132 	},
       
   133 	TOOLS2=>{
       
   134 		ABI=>'TOOLS2',
       
   135 		ASSPABI=>'',
       
   136 		Compiler=>'GCC32',
       
   137 		CPU=>'TOOLS2',
       
   138 		OS=>'TOOLS2',
       
   139 		MakeMod=>'Cl_mingw',
       
   140 		MakeCmd=>'make',
       
   141 	},
       
   142 	CWTOOLS=>{
       
   143 		ABI=>'TOOLS',
       
   144 		ASSPABI=>'',
       
   145 		Compiler=>'CW32',
       
   146 		CPU=>'TOOLS',
       
   147 		OS=>'TOOLS',
       
   148 		MakeMod=>'Cl_tools',
       
   149 		MakeCmd=>'make',
       
   150 	},
       
   151 	VC6TOOLS=>{
       
   152 		ABI=>'TOOLS',
       
   153 		ASSPABI=>'',
       
   154 		Compiler=>'VC32',
       
   155 		CPU=>'TOOLS',
       
   156 		Ext=>'.DSP',
       
   157 		MakeMod=>'Ide_vc6',
       
   158 		MakeCmd=>'nmake',
       
   159 		OS=>'TOOLS',
       
   160 		Real=>'TOOLS',
       
   161 		UsrHdrsOnly=>1,
       
   162 	},
       
   163 	WINS=>{
       
   164 		ABI=>'WINS',
       
   165 		ASSPABI=>'',
       
   166 		Compiler=>'VC32',
       
   167 		CPU=>'WINS',
       
   168 		MakeMod=>'Cl_win',
       
   169 		MakeCmd=>'nmake',
       
   170 		OS=>'WINS',
       
   171 	},
       
   172 	VC6=>{
       
   173 		ABI=>'WINS',
       
   174 		ASSPABI=>'',
       
   175 		Compiler=>'VC32',
       
   176 		CPU=>'WINS',
       
   177 		Ext=>'.DSP',
       
   178 		MakeMod=>'Ide_vc6',
       
   179 		MakeCmd=>'nmake',
       
   180 		OS=>'WINS',
       
   181 		Real=>'WINS',
       
   182 		UsrHdrsOnly=>1,
       
   183 	},
       
   184 	WINSCW=>{
       
   185 		ABI=>'WINSCW',
       
   186 		ASSPABI=>'',
       
   187 		Compiler=>'CW32',
       
   188 		CPU=>'WINS',
       
   189 		MakeMod=>'Cl_codewarrior',
       
   190 		OS=>'WINS',
       
   191 		DefFile=>'WINS',	# use the MSVC def files
       
   192 	},
       
   193 	CW_IDE=>{
       
   194 		ABI=>'WINSCW',
       
   195 		ASSPABI=>'',
       
   196 		Compiler=>'CW32',
       
   197 		CPU=>'WINS',
       
   198 		Ext=>'.xml',
       
   199 		MakeMod=>'Ide_cw',
       
   200 		MakeCmd=>'make',
       
   201 		OS=>'WINS',
       
   202 		Real=>'WINSCW',
       
   203 		DefFile=>'WINS',	# use the MSVC def files
       
   204 		UsrHdrsOnly=>1,
       
   205 		SupportsMultiplePlatforms=>1,	# supports more than one real platform
       
   206 	},
       
   207 	X86=>{
       
   208 		ABI=>'X86',
       
   209 		ASSPABI=>'',
       
   210 		Compiler=>'VC32',
       
   211 		CPU=>'X86',
       
   212 		MakeMod=>'Cl_x86',
       
   213 		MakeCmd=>'nmake',
       
   214 		OS=>'EPOC32',
       
   215 		DefFile=>'X86',
       
   216 		Generic=>1,
       
   217 	},
       
   218 	X86SMP=>{
       
   219 		ABI=>'X86',
       
   220 		ASSPABI=>'',
       
   221 		Compiler=>'VC32',
       
   222 		CPU=>'X86',
       
   223 		MakeMod=>'Cl_x86',
       
   224 		MakeCmd=>'nmake',
       
   225 		OS=>'EPOC32',
       
   226 		DefFile=>'X86',
       
   227 		Generic=>1,
       
   228 		SMP=>1,
       
   229 		StatLink=>'X86SMP',
       
   230 	},
       
   231 	X86GCC=>{
       
   232 		ABI=>'X86gcc',
       
   233 		ASSPABI=>'',
       
   234 		Compiler=>'X86GCC',
       
   235 		CPU=>'X86',
       
   236 		MakeMod=>'Cl_x86gcc',
       
   237 		OS=>'EPOC32',
       
   238 		DefFile=>'x86gcc',
       
   239 		Generic=>1,
       
   240 	},	
       
   241 	X86GMP=>{
       
   242 		ABI=>'X86gcc',
       
   243 		ASSPABI=>'',
       
   244 		Compiler=>'X86GCC',
       
   245 		CPU=>'X86',
       
   246 		MakeMod=>'Cl_x86gcc',
       
   247 		OS=>'EPOC32',
       
   248 		DefFile=>'x86gcc',
       
   249 		Generic=>1,
       
   250 		SMP=>1,
       
   251 		StatLink=>'X86GMP',
       
   252 	},	
       
   253 	ARMV4=>{
       
   254 		ABI=>'ARMV4',
       
   255 		ASSP=>'MARM',
       
   256 		ASSPABI=>'',
       
   257 		Generic=>1,
       
   258 		MakeMod=>'Cl_arm',
       
   259 		Compiler=>'ARMCC',
       
   260 		DefFile=>'EABI',
       
   261 		EABI=>1,
       
   262 	},
       
   263 	ARMV4SMP=>{
       
   264 		ABI=>'ARMV4',
       
   265 		ASSP=>'MARM',
       
   266 		ASSPABI=>'',
       
   267 		Generic=>1,
       
   268 		MakeMod=>'Cl_arm',
       
   269 		Compiler=>'ARMCC',
       
   270 		DefFile=>'EABI',
       
   271 		EABI=>1,
       
   272 		SMP=>1,
       
   273 		StatLink=>'ARMV4SMP',
       
   274 	},
       
   275 	ARMV5_ABIV1=>{
       
   276 		ABI=>'ARMV5',
       
   277 		ASSP=>'MARM',
       
   278 		ASSPABI=>'',
       
   279 		Generic=>1,
       
   280 		MakeMod=>'Cl_arm',
       
   281 		Compiler=>'ARMCC',
       
   282 		DefFile=>'EABI',
       
   283 		EABI=>1,
       
   284 		SupportsFeatureVariants=>1,
       
   285 	},
       
   286 	ABIV2=>{
       
   287 		ABI=>'ARMV5',
       
   288 		ASSP=>'MARM',
       
   289 		ASSPABI=>'',
       
   290 		Generic=>1,
       
   291 		MakeMod=>'Cl_bpabi',
       
   292 		DefFile=>'EABI',
       
   293 		EABI=>1,
       
   294 		SupportsFeatureVariants=>1,
       
   295 	},
       
   296 	GCCXML=>{
       
   297 		ABI=>'ARM4',
       
   298 		ASSP=>'MARM',
       
   299 		ASSPABI=>'',
       
   300 		Generic=>1,
       
   301 		MakeMod=>'cl_gccxml',
       
   302 	},
       
   303 	VS6=>{
       
   304 		ABI=>'WINSCW',
       
   305 		ASSPABI=>'',
       
   306 		Compiler=>'CW32',
       
   307 		CPU=>'WINS',
       
   308 		MakeMod=>'Cl_vscw',
       
   309 		OS=>'WINS',
       
   310 		Real=>'WINSCW',
       
   311 		DefFile=>'WINS',	# use the MSVC def files
       
   312 		Ext=>'.mak'		
       
   313 	},
       
   314 	VS2003=>{
       
   315 		ABI=>'WINSCW',
       
   316 		ASSPABI=>'',
       
   317 		Compiler=>'CW32',
       
   318 		CPU=>'WINS',
       
   319 		MakeMod=>'Cl_vscw',
       
   320 		OS=>'WINS',
       
   321 		Real=>'WINSCW',
       
   322 		DefFile=>'WINS',	# use the MSVC def files
       
   323 		Ext=>'.mak'
       
   324 	},
       
   325 	EDG=>{
       
   326 		ABI=>'ARMV5',
       
   327 		ASSP=>'MARM',
       
   328 		ASSPABI=>'',
       
   329 		Generic=>1,
       
   330 		MakeMod=>'cl_edg',
       
   331 	},
       
   332 
       
   333 	# ASSP platforms should be described using .ASSP files
       
   334 	# Do not add additional ASSP platforms to this file.
       
   335 );
       
   336 
       
   337 sub Set_Plat() 
       
   338 {
       
   339 	@BPABIPlats = &BPABIutl_Plat_List;
       
   340 	foreach my $Candidate (@BPABIPlats)
       
   341 	{
       
   342 # All BPABI platforms inherit from ABIV2 properties as listed in the platlist
       
   343 # and Platlist is updated to include the BPABI platforms.
       
   344 		my ( $key, $value);
       
   345 		while (($key, $value) = each %{$Plat{ABIV2}}) {
       
   346 			$Plat{$Candidate}{$key}=$value;
       
   347 		}
       
   348 	}
       
   349 }
       
   350 
       
   351 sub Plat_SupportsFeatureVariants($)
       
   352 	{
       
   353 	my ($plat) = @_;
       
   354 
       
   355 	# In a non-ABIV2 world, ARMV5 means ARMV5_ABIV1 within e32plat content
       
   356 	if (!$variantABIV2Keyword && $plat =~ /^ARMV5$/i)
       
   357 		{
       
   358 		$plat .= "_ABIV1";
       
   359 		}
       
   360 		
       
   361 	return ($plat && defined $Plat{$plat}{SupportsFeatureVariants}) ? $Plat{$plat}{SupportsFeatureVariants} : 0;
       
   362 	}
       
   363 
       
   364 sub Plat_Customizations($) {
       
   365         my ($plat) = @_;
       
   366 	my @empty = ();
       
   367 	return @{$Plat{$plat}{'CUSTOMIZATIONS'}} if $Plat{$plat}{'CUSTOMIZATIONS'};
       
   368 	return @empty;
       
   369       }
       
   370 
       
   371 sub Plat_Customizes($) {
       
   372 	my ($plat) = @_;
       
   373 	return $Plat{$plat}{'CUSTOMIZES'} ? $Plat{$plat}{'CUSTOMIZES'} : "";
       
   374 }
       
   375 
       
   376 sub Plat_Root($) {
       
   377 	my ($plat) = @_;
       
   378 
       
   379 	my $RootName = $Plat{$plat}{'ROOTPLATNAME'};
       
   380 
       
   381 	if ($RootName) {
       
   382 		return $RootName;
       
   383 	}
       
   384 	else {
       
   385 		# A non-BSF platform is its own root.
       
   386 		return $plat;
       
   387 	}
       
   388 }
       
   389 
       
   390 sub Init_BSFs($) {
       
   391 	my ($Path)=@_;  
       
   392 #	get a list of modules
       
   393 	opendir DIR, $Path;
       
   394 	my @BSFs=grep s/^([^\.].*)\.BSF$/$1/, map { uc $_ } sort readdir DIR;
       
   395 	closedir DIR;
       
   396 
       
   397 	my $BSF;
       
   398 	foreach $BSF (@BSFs) {
       
   399 		my $File=$Path.$BSF.'.bsf';
       
   400 #		check whether the assp is already defined
       
   401 		if (defined %{$Plat{$BSF}}) {
       
   402 			warn(
       
   403 				"$File : warning: Platform \"$BSF\" already defined\n",
       
   404 				" ... skipping this spec\n"
       
   405 			);
       
   406 			delete $Plat{$BSF};
       
   407 			next;
       
   408 		}
       
   409 #		open the module
       
   410 		unless (open FILE, $File) {
       
   411 			delete $Plat{$BSF};
       
   412 			warn "warning: Can't open BSF specification \"$File\"\n";
       
   413 			next;
       
   414 		}
       
   415 		my $line1 = <FILE>;
       
   416 		$line1 = uc($line1);
       
   417 		unless ($line1 =~ /^\#\<BSF\>\#/) {
       
   418 			warn "warning: \"$File\" Invalid BSF specification - missing #<bsf>#\n";
       
   419 			delete $Plat{$BSF};
       
   420 			close FILE;
       
   421                   next;
       
   422             }
       
   423             my $custom;
       
   424             while ($custom = <FILE>) {
       
   425 					#skip blank lines and comments
       
   426 			delete $Plat{$BSF};
       
   427 					last unless ($custom =~ /^$|^\#/);
       
   428             }
       
   429             $custom = uc $custom;
       
   430             unless ($custom =~ /^\s*CUSTOMIZES\s+(\S+)/) {
       
   431 				warn "warning: \"$File\" Invalid BSF specification - 'customizes' missing\n";
       
   432 				delete $Plat{$BSF};
       
   433 				close FILE;
       
   434 			next;
       
   435             }
       
   436 		my $root = $1;
       
   437 		my $platname = '';
       
   438 		my $CustomizedPlatName = '';		
       
   439 
       
   440 		# In v1 mode, ARMV5 platform implies ARMV5_ABIV1 platform listed in the platlist		
       
   441 		my $Armv5Flag = 0;
       
   442 		if (!$variantABIV2Keyword && $root =~ /^ARMV5$/i) {
       
   443 			$Armv5Flag = 1;
       
   444 		}
       
   445 
       
   446 		# Support for Hierarchy of Customizations (BSF file customization of another BSF file)
       
   447 		# 1. Check whether the BSF file customizes another BSF file.
       
   448 		# 2. If so, check whether the root BSF file has already been read.
       
   449 		# 3. If not read, then defer the current BSF file reading until the root file is read.
       
   450 		my $rootPlatFound = 0;
       
   451 		if (defined %{$Plat{$root}} || $Armv5Flag) 
       
   452 		{
       
   453 			# BSF platform customizes another valid BSF platform
       
   454 			if (defined $Plat{$root}{'CUSTOMIZES'}) 
       
   455 			{
       
   456 				$rootPlatFound = 1;
       
   457 				$platname = $root;
       
   458 				$CustomizedPlatName = $root;
       
   459 
       
   460 				# Set the root platform name which is same as of customizes platform
       
   461 				$Plat{$BSF}{'ROOTPLATNAME'} = $Plat{$root}{'ROOTPLATNAME'};
       
   462 			}
       
   463 			# BSF platform customizes to one of the existing ABI platforms
       
   464 			else
       
   465 			{
       
   466 				# All BPABI platforms inherits from ABIV2 platform listed in the platlist
       
   467 				if (grep /^$root$/i, @BPABIPlats) {
       
   468 					$platname = "ABIV2";
       
   469 				}
       
   470 				elsif ($Armv5Flag) {
       
   471 				# In v1 mode, ARMV5 platform implies ARMV5_ABIV1 platform listed in the platlist
       
   472 					$platname = "ARMV5_ABIV1";	
       
   473 				}
       
   474 				else {
       
   475 					$platname = $root;
       
   476 				}
       
   477 				
       
   478 				$CustomizedPlatName=$root;
       
   479 
       
   480 				# BSF File check Begins 
       
   481 				# The following check is included to handle the existing BSF files which has to behave in different manner
       
   482 				# in default v1 mode and v2 mode. The following code changes the BSF name and the custmoized platform name
       
   483 				# to the implied names. This is done to support switching between v1 and v2 modes by enabling the keyword in
       
   484 				# the variant configuration file.
       
   485 				# In v1 mode, the ARMV6_ABIV1 => ARMV6 platform and ARMV6 => ARMV6_ABIV2 platform.
       
   486 				if (!$variantABIV2Keyword) {
       
   487 					if ($BSF =~ /^ARMV6_ABIV1$/i) {
       
   488 						$BSF = "ARMV6";	
       
   489 						$CustomizedPlatName = "ARMV5";	
       
   490 					}
       
   491 					elsif ($BSF =~ /^ARMV6$/i) {
       
   492 						$BSF = "ARMV6_ABIV2";	
       
   493 						$CustomizedPlatName = "ARMV5_ABIV2";
       
   494 						$platname = "ABIV2";
       
   495 					}
       
   496 				}
       
   497 				# BSF File check Ends
       
   498 
       
   499 				# Set the root platform name
       
   500 				$Plat{$BSF}{'ROOTPLATNAME'} = $CustomizedPlatName;
       
   501 			}			
       
   502 		}
       
   503 		else
       
   504 		{
       
   505 			my $rootbsf = $Path.$root.".bsf";			
       
   506 			if ( -e $rootbsf ) {
       
   507 				# BSF file customizes another BSF file which has not been read yet.
       
   508 				# So defer current BSF file reading until the root BSF file is read.				
       
   509 				delete $Plat{$BSF};
       
   510 				push(@BSFs, $BSF);
       
   511 				next;		
       
   512 			}
       
   513 		}
       
   514 		# If the customizes platform is not a valid BSF platform or BPABI platorm or ARMV5 or ARMV5_ABIV1,
       
   515 		# then throw warning.
       
   516 		unless ($rootPlatFound || $root =~ /^ARMV5(_ABIV1)?$/ || (grep /^$root$/i, @BPABIPlats)) {
       
   517 			warn "warning: \"$File\" Invalid BSF specification - customization restricted to ARMV5, ABIv2 and valid BSF platforms\n";
       
   518 			close FILE;
       
   519 			delete $Plat{$BSF};
       
   520 			next;
       
   521 		}
       
   522 			
       
   523 		my ( $key, $value);
       
   524 		while (($key, $value) = each %{$Plat{$platname}}) {
       
   525 			$Plat{$BSF}{$key}=$value;
       
   526 		}
       
   527 		
       
   528 		push @{$Plat{$CustomizedPlatName}{'CUSTOMIZATIONS'}}, $BSF;
       
   529 		$Plat{$BSF}{'CUSTOMIZES'} = $CustomizedPlatName;
       
   530 		while (<FILE>) {
       
   531 			next if (/^$|^\#/);
       
   532 			if (/^\s*SMP\s*$/i) {
       
   533 				$Plat{$BSF}{'SMP'} = 1;
       
   534 				$Plat{$BSF}{'StatLink'} = lc $BSF;
       
   535 				next;
       
   536 			}
       
   537 			$Plat{$BSF}{'CUSTOMIZATION_DATA'} .= $_;
       
   538 		}
       
   539 		# BSF file statements will have newline character("\n") at the end, except for the last statement.
       
   540 		# So append "\n" for the last BSF file statement.
       
   541 		# "\n" will be used to split BSF statements to support hierarchy of customizations.
       
   542 		$Plat{$BSF}{'CUSTOMIZATION_DATA'} .= "\n";
       
   543 		close FILE;
       
   544 	}
       
   545 	1;
       
   546 }
       
   547 
       
   548 sub Plat_Init ($) { # takes path to ASSP modules
       
   549 	my ($Path)=@_;
       
   550 
       
   551 	my %PlatHashKeys=(
       
   552 		ABI=>1,
       
   553 		ASSPABI=>1,
       
   554 		SINGLE=>1,
       
   555 		Compiler=>1,
       
   556 		CPU=>1,
       
   557 		MakeMod=>1,
       
   558 		MakeCmd=>1,
       
   559 		OS=>1,
       
   560 		DefFile=>1,
       
   561 		ASSP=>1,
       
   562 	);
       
   563 
       
   564 #	Include the list of BPABI platforms
       
   565 	&Set_Plat;
       
   566 
       
   567 	Init_BSFs($Path);
       
   568 
       
   569 #	get a list of modules
       
   570 	opendir DIR, $Path;
       
   571 	my @_ASSPs=grep s/^([^\.].*)\.ASSP$/$1/, map { uc $_ } readdir DIR;
       
   572 	closedir DIR;
       
   573 
       
   574 	my @ASSPs;
       
   575 	foreach (@_ASSPs) {
       
   576 		if (!$ENV{USEARMCC} and /EDG$/i) {
       
   577 #			warn(
       
   578 #				"Note: ASSP \"$_\" disabled\n"
       
   579 #			);
       
   580 
       
   581 			next;
       
   582 		}
       
   583 		push @ASSPs, $_;
       
   584 	}
       
   585 
       
   586 #	open each module in turn, and add it to the array
       
   587 	my $ASSP;
       
   588 	foreach $ASSP (@ASSPs) {
       
   589 		my $File=$Path.$ASSP.'.assp';
       
   590 #		check whether the assp is already defined
       
   591 		if (defined %{$Plat{$ASSP}}) {
       
   592 			warn(
       
   593 				"$File : warning: ASSP \"$ASSP\" already defined\n",
       
   594 				" ... skipping this module\n"
       
   595 			);
       
   596 
       
   597 			next;
       
   598 		}
       
   599 #		open the module
       
   600 		unless (open FILE, $File) {
       
   601 			warn "warning: Can't open assp module \"$File\"\n";
       
   602 			next;
       
   603 		}
       
   604 		my %Data=();
       
   605 		my %SingleData=();
       
   606 		my $MatchingSingle="";
       
   607 		my @Errors=();
       
   608 		while (<FILE>) {
       
   609 #			strip comments
       
   610 			s/^([^#]*)#.*$/$1/o;
       
   611 #			skip blank lines
       
   612 			if (/^\s*$/o) {
       
   613 				next;
       
   614 			}
       
   615 #			get the key-value pair
       
   616 			unless (/^\s*(\w+)\s+(\w+)\s*$/o) {
       
   617 				push @Errors, "$File($.) : warning: syntax error - only key-value pairs allowed\n";
       
   618 				next;
       
   619 			}
       
   620 			my ($Key, $Val)=($1, $2);
       
   621 			if ($PlatHashKeys{$Key}!=1) {
       
   622 				push @Errors, "$File($.) : warning: unrecognized keyword - $Key\n";
       
   623 				next;
       
   624 			}
       
   625 			if ($Key eq "SINGLE") {
       
   626 				$SingleData{Single} = 1;
       
   627 				$SingleData{ASSP} = $ASSP;
       
   628 				$MatchingSingle = uc $2;
       
   629 			} else {
       
   630 				$Data{$Key}=$Val;
       
   631 				$SingleData{$Key}=$Val;
       
   632 			}
       
   633 		}
       
   634 		close FILE;
       
   635 		if (@Errors) {
       
   636 			warn(
       
   637 				@Errors,
       
   638 				" ... skipping this module\n"
       
   639 			);
       
   640 			next;
       
   641 		}
       
   642 # change -  Allow ASSPs to pick up all the options of the ABI they specify, 
       
   643 # in particular the compiler they need.
       
   644 			$Data{'ASSP'} = $ASSP unless $Data{'ASSP'};
       
   645 			if ($Plat{$Data{'ABI'}}) {
       
   646 			foreach (keys %{$Plat{$Data{'ABI'}}}) {
       
   647 			$Data{$_} = $Plat{$Data{'ABI'}}{$_} unless ($_ =~ /^GENERIC$/i) or $Data{$_};
       
   648 			}
       
   649 		}
       
   650 
       
   651 		%{$Plat{$ASSP}}=%Data;
       
   652 		if ($MatchingSingle ne "") {
       
   653 			foreach (keys %Data) {
       
   654 			$SingleData{$_} = $Data{$_} unless ($_ =~ /^GENERIC$/i) or $SingleData{$_};
       
   655 			}
       
   656 			%{$Plat{$MatchingSingle}}=%SingleData;
       
   657 		}			
       
   658 	}
       
   659 }
       
   660 
       
   661 sub Plat_GetL ($$$$) { # takes Platform name, ref to plat hash, ref to bldmacrohash, bldmake plat command notifier
       
   662 	my ($Candidate,$PlatHash_ref,$BldMacrosHash_ref,$platcommand)=@_;
       
   663 	$Candidate=uc $Candidate;
       
   664 
       
   665 # is platform in our list?
       
   666 	unless (defined $Plat{$Candidate}) {
       
   667 
       
   668 		# is platform BPABI compliant one?
       
   669 		if (!$variantABIV2Keyword && $Candidate eq 'ARMV5') {
       
   670 		}
       
   671 		elsif (not(grep /^$Candidate$/i, @BPABIPlats))
       
   672 		{
       
   673 			die "ERROR: Platform \"$Candidate\" not supported\n";
       
   674 		}
       
   675 	}
       
   676 
       
   677 	my $BPABIPlat;
       
   678 	my %PlatHash=();
       
   679 
       
   680 # check the data
       
   681 # All BPABI platforms inherit ABIV2 properties 
       
   682 	if (grep /^$Candidate$/i, @BPABIPlats) 
       
   683 	{
       
   684 		$BPABIPlat='ABIV2';
       
   685 		%PlatHash=%{$Plat{$BPABIPlat}};
       
   686 	}
       
   687 # In v1 mode, ARMV5 platform implies ARMV5_ABIV1 platform listed in the platlist
       
   688 	elsif (!$variantABIV2Keyword && $Candidate eq 'ARMV5') {
       
   689 		%PlatHash=%{$Plat{ARMV5_ABIV1}};
       
   690 	}
       
   691 	else {
       
   692 		%PlatHash=%{$Plat{$Candidate}};
       
   693 	}
       
   694 
       
   695 # set the defaults
       
   696 	$PlatHash{Name}=$Candidate;
       
   697 	$PlatHash{Real}=$PlatHash{Name} unless $PlatHash{Real};
       
   698 	$PlatHash{Ext}=".$PlatHash{Real}" unless $PlatHash{Ext};
       
   699 	$PlatHash{ASSP}=$PlatHash{Real} unless $PlatHash{ASSP};
       
   700 
       
   701 # Get the root platform name to support hierarchy of customizations
       
   702 	my $CustomizedPlat=$PlatHash{'ROOTPLATNAME'};
       
   703 
       
   704 	if ((defined($Candidate)  && ($Candidate =~ /^ARMV5/i)) || (defined($CustomizedPlat) && ($CustomizedPlat =~ /^ARMV5/i))) {
       
   705 # Compiler name should be set as ARMCC for all ARMV5 platforms
       
   706 		$PlatHash{Compiler}='ARMCC';
       
   707 		$PlatHash{Toolchain}='rvct22';
       
   708 	}
       
   709 	elsif ($BPABIPlat) {
       
   710 # Compiler name should be set as that of platform name for all BPABI platforms
       
   711 		$PlatHash{Compiler}=$Candidate;
       
   712 		$PlatHash{Toolchain}=$Candidate;
       
   713 	}
       
   714 	elsif ($CustomizedPlat) {
       
   715 # Compiler name should be set as that of the customized platform name incase of customization
       
   716 		$PlatHash{Compiler}=$CustomizedPlat;
       
   717 		$PlatHash{Toolchain}=$CustomizedPlat;
       
   718 	}
       
   719 
       
   720 	$PlatHash{Compiler}='GCC32' unless $PlatHash{Compiler};
       
   721 	$PlatHash{OS}='EPOC32' unless $PlatHash{OS};
       
   722 	$PlatHash{MakeMod}='Cl_gcc' unless $PlatHash{MakeMod};
       
   723 	$PlatHash{MakeCmd}='make' unless $PlatHash{MakeCmd};
       
   724 	$PlatHash{CPU}='MARM' unless $PlatHash{CPU};
       
   725 	$PlatHash{Single}=0 unless $PlatHash{Single};
       
   726 	$PlatHash{UsrHdrsOnly}=0 unless $PlatHash{UsrHdrsOnly};
       
   727 	$PlatHash{Generic}=0 unless $PlatHash{Generic}; # generic means "for a target device but no particular ASSP"
       
   728 	$PlatHash{SupportsMultiplePlatforms}=0 unless $PlatHash{SupportsMultiplePlatforms};
       
   729 
       
   730 	$PlatHash{ABI}='ARMI' unless $PlatHash{ABI};
       
   731 	$PlatHash{ASSPABI}='ARM4' unless defined $PlatHash{ASSPABI};
       
   732 
       
   733 	unless (defined $PlatHash{DefFile}) {
       
   734 		if ($PlatHash{Compiler} eq 'VC32') {
       
   735 			$PlatHash{DefFile}='WINS';
       
   736 		} else {
       
   737 			$PlatHash{DefFile}='MARM';
       
   738 		}
       
   739 	}
       
   740 	
       
   741 # .MMP macros - keeping the order is useful
       
   742 	@{$PlatHash{MmpMacros}}=$PlatHash{Compiler};
       
   743 	push @{$PlatHash{MmpMacros}}, $PlatHash{OS};
       
   744 	push @{$PlatHash{MmpMacros}}, $PlatHash{CPU} unless $PlatHash{CPU} eq $PlatHash{OS};
       
   745 	push @{$PlatHash{MmpMacros}}, $PlatHash{ASSP} unless $PlatHash{ASSP}=~/^($PlatHash{CPU}|$PlatHash{OS})$/;
       
   746 
       
   747 	if ($PlatHash{Single}) {
       
   748 		push @{$PlatHash{MmpMacros}}, 'SINGLE';
       
   749 	}
       
   750 	if ($PlatHash{SMP}) {
       
   751 		push @{$PlatHash{MmpMacros}}, 'SMP';
       
   752 	}
       
   753 	if ($PlatHash{EABI}) {
       
   754 		push @{$PlatHash{MmpMacros}}, 'EABI';
       
   755 	}
       
   756 	if ($PlatHash{Compiler} eq 'VC32') {
       
   757 		my $MSVCVer = &Winutl_MSVCVer($platcommand);
       
   758 		my $MSVCSubVer = &Winutl_MSVCSubVer($platcommand);
       
   759 		push @{$PlatHash{MmpMacros}}, 'MSVC'.$MSVCVer;
       
   760 		push @{$PlatHash{MmpMacros}}, 'MSVC'.$MSVCVer.$MSVCSubVer;
       
   761 		if ($MSVCVer > 6) {
       
   762 			push @{$PlatHash{MmpMacros}}, 'MSVCDOTNET';
       
   763 		}
       
   764 	}
       
   765 	if ($PlatHash{Compiler} eq 'ARMCC') {
       
   766 		my ($MajVer, $MinVer) = RVCT_plat2set::get_version_list($Candidate);
       
   767 		push @{$PlatHash{MmpMacros}}, 'ARMCC_'.$MajVer;
       
   768 		push @{$PlatHash{MmpMacros}}, 'ARMCC_'.$MajVer.'_'.$MinVer;
       
   769 	}
       
   770 	
       
   771 	if ($PlatHash{Compiler} eq 'X86GCC') {	
       
   772 			push @{$PlatHash{MmpMacros}}, 'GCC32';
       
   773 	}
       
   774 
       
   775 	## TOOLS2 Specific Macros ##
       
   776 	
       
   777 	if ($PlatHash{Compiler} eq 'GCC32') {
       
   778 		push @{$PlatHash{MmpMacros}}, 'MINGW32';
       
   779 		push @{$PlatHash{MmpMacros}}, '_STLP_LITTLE_ENDIAN';
       
   780 		
       
   781 	}
       
   782 
       
   783     # add GCCXML to the mmp macro list, so we can filter out stuff in bld.inf files and mmps.
       
   784     # note that this mean that __GCCXML__ is automacally routed to makefile, so we can take out explicit call. 
       
   785     if( $PlatHash{Name} eq "GCCXML") {
       
   786         push @{$PlatHash{MmpMacros}}, 'GCCXML';
       
   787     }
       
   788 	
       
   789 # add specific platform macros for platforms customising others.
       
   790 	if (Plat_Customizes($PlatHash{Name})) {
       
   791 		push @{$PlatHash{MmpMacros}}, $PlatHash{Name} unless grep /$PlatHash{Name}/, @{$PlatHash{MmpMacros}};
       
   792 	}
       
   793 
       
   794 # compilation macros
       
   795 	@{$PlatHash{Macros}}=@EpocMacros;
       
   796 	foreach (@{$PlatHash{MmpMacros}}) {
       
   797 		## If STLP_LTTLE_ENDIAN is used, then dont append __ to the macro name ##
       
   798 		if ($_ =~ m/STLP_LITTLE_ENDIAN/) {
       
   799 			push @{$PlatHash{Macros}}, $_;
       
   800 		} else {
       
   801 		push @{$PlatHash{Macros}}, '__'.$_.'__';
       
   802 		}
       
   803 	}
       
   804 
       
   805 #	extra special .MMP macros which aren't applied for compilation
       
   806 	if ($PlatHash{Generic}) {
       
   807 		push @{$PlatHash{MmpMacros}}, "GENERIC_$PlatHash{CPU}";
       
   808 		if ($PlatHash{CPU} eq 'MARM') {
       
   809 #			we can't define this for ASSP platforms because we won't be sure what
       
   810 #			the ABI is until we've processed the .MMP file
       
   811 			push @{$PlatHash{MmpMacros}}, "MARM_$PlatHash{ABI}";
       
   812 		}
       
   813 	}
       
   814 
       
   815 # builds
       
   816 	@{$PlatHash{Blds}}=@{$BldLists{$PlatHash{OS}}};
       
   817 
       
   818 # output some information
       
   819 	if ($Mode{Verbose}) {
       
   820 		print
       
   821 			"Platform         $PlatHash{Name}\n",
       
   822 			"Real Name        $PlatHash{Real}\n",
       
   823 			"Compiler         $PlatHash{Compiler}\n",
       
   824 			"OS               $PlatHash{OS}\n",
       
   825 			"CPU              $PlatHash{CPU}\n",
       
   826 			"ASSP             $PlatHash{ASSP}\n",
       
   827 			"ABI              $PlatHash{ABI}\n",
       
   828 			"ASSPABI          $PlatHash{ASSPABI}\n",
       
   829 			"Makefile Module  $PlatHash{MakeMod}\n",
       
   830 			"Makefile Type    $PlatHash{MakeCmd}\n",
       
   831 			"MMP Macros       @{$PlatHash{MmpMacros}}\n",
       
   832 			"Macros           @{$PlatHash{Macros}}\n",
       
   833 			"Blds             @{$PlatHash{Blds}}\n"
       
   834 		;
       
   835 	}
       
   836 
       
   837 	%{$PlatHash_ref}=%PlatHash;
       
   838 	%{$BldMacrosHash_ref}=%BldMacros;
       
   839 }
       
   840 
       
   841 sub Plat_List () {
       
   842 
       
   843 #	Include the list of BPABI platforms
       
   844 	&Set_Plat;
       
   845 
       
   846 #	return list of supported platforms
       
   847 
       
   848 	#sort keys %Plat;
       
   849 	my @PlatList;
       
   850 	my $Key;
       
   851 	foreach $Key (keys %Plat) {
       
   852 		if (!$variantABIV2Keyword && $Key =~ /^armv5_abiv1$/i) {
       
   853 			$Key = 'ARMV5';
       
   854 		}
       
   855 		unless (grep /^$Key$/i, @PlatList) {
       
   856 			push @PlatList, $Key;
       
   857 		}
       
   858 	}
       
   859 	return @PlatList
       
   860 }
       
   861 
       
   862 sub Plat_AssocIDE ($$) {
       
   863 #	return the IDE associated with a "Real" platform if there is one
       
   864 	my ($Candidate, $AssocIDEs)=@_;
       
   865 
       
   866 	unless (defined $Plat{$Candidate}) {
       
   867 		die "ERROR: Platform \"$Candidate\" not supported\n";
       
   868 	}
       
   869 
       
   870 	my $Key;
       
   871 	foreach $Key (keys %Plat) {
       
   872 		if (${Plat{$Key}}{Real}) {
       
   873 			if (${Plat{$Key}}{Real} eq $Candidate) {
       
   874 				push @$AssocIDEs, $Key;
       
   875 			}
       
   876 		}
       
   877 	}
       
   878 }
       
   879 
       
   880 1;