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