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