sbsv1_os/e32toolp/platform/cl_edg.pm
changeset 0 83f4b4db085c
child 1 d4b442d23379
equal deleted inserted replaced
-1:000000000000 0:83f4b4db085c
       
     1 # Copyright (c) 2004-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 # Cl_edg;
       
    15 # 
       
    16 #
       
    17 
       
    18 package Cl_edg;
       
    19 
       
    20 require Exporter;
       
    21 @ISA=qw(Exporter);
       
    22 @EXPORT=qw(
       
    23 	PMHelp_Mmp
       
    24 	PMStartBldList
       
    25 	PMBld
       
    26 	PMStartSrcList
       
    27 	PMStartSrc
       
    28 	PMSrcDepend
       
    29 	PMSrcBldDepend
       
    30 	PMEndSrcBld
       
    31 	PMEndSrc
       
    32 	PMEndSrcList
       
    33 );
       
    34 use cl_generic;
       
    35 use Genutl;
       
    36 use File::Path;
       
    37 use Cwd;
       
    38 
       
    39 sub PMHelp_Mmp {
       
    40 	print "// No additional keywords for this platform\n";
       
    41 }
       
    42 
       
    43 my $epocroot = $ENV{EPOCROOT};
       
    44 $epocroot=~ s-\\$--;            # chop trailing \\
       
    45 my $Makecmd;
       
    46 sub PMStartBldList($) {
       
    47 	($Makecmd) = @_;
       
    48 	my $BasicTrgType=&main::BasicTrgType;
       
    49 	my @BldList=&main::BldList;
       
    50 	my @ChopRTWSysIncPaths=&main::Path_Chop(&main::Path_RltToWork(&main::SysIncPaths)); # old style
       
    51 	my @ChopRTWUserIncPaths=&main::Path_Chop(&main::Path_RltToWork(&main::UserIncPaths)); # old style
       
    52 	my $RelPath="$epocroot\\EPOC32\\RELEASE";
       
    53 	my $RPath = &main::Path_RltToWork($RelPath);
       
    54 	my @MacroList=&main::MacroList();
       
    55 	my $VariantFile=&main::VariantFile();
       
    56 	my $Trg=&main::Trg;
       
    57 	my $DPath = &main::Path_RltToWork($epocroot);
       
    58 	my $DefFile = &main::DefFile;
       
    59 	my $EABIDefFile = &main::EABIDef;
       
    60     
       
    61     my $EdgSysIncludeList = "Edg_sysinc_list.txt";
       
    62     my $EdgUserIncludeList = "Edg_userinc_list.txt";
       
    63     my $EdgUdebReportList = "Edg_udeb_rep_list.txt";
       
    64     my $EdgUrelReportList = "Edg_urel_rep_list.txt";
       
    65 
       
    66 	&Generic_Header(0,$Makecmd);	# define standard things using relative paths
       
    67 
       
    68 	# EDG report file generation
       
    69 	
       
    70 	&main::Output(
       
    71 		"GXPTRGUDEB = $RPath\\EDG\\UDEB\n",
       
    72 		"GXPTRGUREL = $RPath\\EDG\\UREL\n\n",
       
    73 		"DEFFILE = $DefFile\n\n",
       
    74         "EABIDEFFILE = $EABIDefFile\n\n",
       
    75 		"EDG_SYSINC_LIST=\${EPOCBLD}\\..\\..\\", $EdgSysIncludeList,
       
    76 		"\n",
       
    77 		"EDG_USERINC_LIST=\${EPOCBLD}\\..\\..\\", $EdgUserIncludeList,
       
    78 		"\n",
       
    79 		"EDG_UREL_REP_LIST=\${EPOCBLD}\\..\\..\\",$EdgUrelReportList,
       
    80 		"\n",
       
    81 		"EDG_UDEB_REP_LIST=\${EPOCBLD}\\..\\..\\", $EdgUdebReportList,
       
    82 		"\n\n"
       
    83 	);
       
    84 
       
    85 	&main::Output(
       
    86 		"INCDIR ="
       
    87 	);
       
    88 	
       
    89 
       
    90 	foreach (@ChopRTWUserIncPaths) {
       
    91 		&main::Output(
       
    92 			" --include_directory \"$_\""
       
    93 		);
       
    94 	}
       
    95 
       
    96 	&main::Output(
       
    97 		"\n"
       
    98 	);
       
    99 
       
   100 
       
   101 	&main::Output(
       
   102 		"SYSINCDIR ="
       
   103 	);
       
   104 
       
   105 	foreach (@ChopRTWSysIncPaths) {
       
   106 	     &main::Output(
       
   107 			" --sys_include \"$_\"",
       
   108 	     );
       
   109 	}
       
   110 
       
   111 	&main::Output(
       
   112 		"\n",
       
   113 		"\n"
       
   114 	);
       
   115 	
       
   116 
       
   117 	my $preinclude =   "--preinclude \$(EPOCINC)\\edg\\edg3_7_rvct2_2.h";#this is the variant line you must change to "simulate" another compiler.
       
   118 	&main::Output( 
       
   119 		"GCCFLAGS = --wchar_t_keyword --no_code_gen --exceptions --no_warnings",
       
   120 		" ${preinclude}",
       
   121 		"\n"
       
   122 	);
       
   123 
       
   124 	&main::Output(
       
   125 		"GCCDEFS = -D __MARM_THUMB__ -D __MARM_INTERWORK__ -D __ARMCC__ -D __EPOC32__ -D __MARM__ -D __EABI__ -D __ARMCC_2__ -D __ARMCC_2_2__ -D __SUPPORT_CPP_EXCEPTIONS__  -D IMPORT_C= -D EXPORT_C= -D __softfp="
       
   126 	);
       
   127 	foreach(@MacroList) {
       
   128 		&main::Output(
       
   129 			" -D $_"
       
   130 		);
       
   131 	}
       
   132 	if($VariantFile){
       
   133 	    &main::Output(" -D __PRODUCT_INCLUDE__=\\\"${VariantFile}\\\"");
       
   134 	}
       
   135 	&main::Output(
       
   136 		" \$(USERDEFS)\n",
       
   137 		"\n"
       
   138 	);
       
   139 
       
   140 	foreach (@BldList) {
       
   141 		&main::Output(
       
   142 			"GCC$_ = cpfe"
       
   143 		);
       
   144 		
       
   145 		&main::Output(
       
   146 			' $(GCCFLAGS)'
       
   147 		);
       
   148 		foreach (&main::MacroList($_)) {
       
   149 			&main::Output(
       
   150 				" -D $_"
       
   151 			);
       
   152 		}
       
   153                 
       
   154 		&main::Output(
       
   155 			" \$(GCCDEFS)\n"
       
   156 		);
       
   157 	}
       
   158 	&main::Output(
       
   159 		"\n",
       
   160 		"\n"
       
   161 	);
       
   162 	
       
   163 	&main::Output(
       
   164 			"LIBRARY:\n",
       
   165 			"\t\@echo Nothing to do\n"
       
   166 	);
       
   167 
       
   168 	&main::Output(
       
   169 		"RESOURCEUREL:\n",
       
   170 		"\t\@echo Nothing to do\n"
       
   171 	);
       
   172 
       
   173 	&main::Output(
       
   174 		"RESOURCEUDEB:\n",
       
   175 		"\t\@echo Nothing to do\n\n\n"
       
   176 	);
       
   177 
       
   178 	foreach (@BldList) {
       
   179 		&main::Output(
       
   180 			"$_ :"
       
   181 		);
       
   182 
       
   183 		if ($BasicTrgType !~ /IMPLIB/io) {
       
   184 			my $TrgBase = &main::Path_Split('base',$Trg);           
       
   185 			&main::Output (
       
   186 			" \\\n\t",
       
   187 			&Generic_Quote("\$(GXPTRG$_)\\$TrgBase.gxp")
       
   188 			);
       
   189 		}
       
   190 		&main::Output(
       
   191 			"\n",
       
   192 			"\n"
       
   193 		);
       
   194 	}
       
   195 }
       
   196 	
       
   197 sub PMBld {
       
   198 	my @ASSPLibList=&main::ASSPLibList;
       
   199 	my @SrcList=&main::SrcList;
       
   200 	my $BaseTrg=&main::BaseTrg;
       
   201 	my $Bld=&main::Bld;
       
   202 	my $ChopBldPath=&main::Path_Chop(&main::BldPath);
       
   203 	my $EPOCIncPath=&main::EPOCIncPath;
       
   204 	my $BasicTrgType=&main::BasicTrgType;
       
   205 	my $ChopRelPath=&main::Path_Chop(&main::RelPath);
       
   206 	my $RelPath=&main::RelPath;
       
   207 	my $Trg=&main::Trg;
       
   208 	my $TrgType=&main::TrgType;
       
   209 	my @UidList=&main::UidList;
       
   210 	# DefFile
       
   211 	my $DefFile = &main::DefFile;
       
   212 	# EABIDefFile
       
   213 	my $EABIDefFile = &main::EABIDef;
       
   214 
       
   215 	# REAL TARGETS
       
   216 	#-------------
       
   217 	&main::Output(
       
   218 		"# REAL TARGET - BUILD VARIANT $Bld\n",
       
   219 		"\n"
       
   220 	);
       
   221 
       
   222 	&main::Output(
       
   223 		"WHAT$Bld : WHATGENERIC\n",
       
   224 		"\n",
       
   225 		"CLEAN$Bld : CLEANBUILD$Bld CLEANRELEASE$Bld\n",
       
   226 		"\n",
       
   227 		"CLEANBUILD$Bld : \n",
       
   228 		"\t\@perl -S ermdir.pl \"\$(EPOCBLD$Bld)\"\n",
       
   229 		"\n",
       
   230 		"CLEANRELEASE$Bld : CLEANGENERIC CLEANEDGTEMPFILES$Bld\n",
       
   231 		"\n"
       
   232 	);
       
   233 
       
   234 	&main::Output("CLEANEDGTEMPFILES$Bld :\n",
       
   235 			"\t\-\$(ERASE) \$(EDG_SYSINC_LIST) ",
       
   236 			"\$(EDG_USERINC_LIST) ",
       
   237 			"\$(EDG_${Bld}_REP_LIST) "
       
   238 			);
       
   239 
       
   240 	my @releaseables;
       
   241 	&Generic_WhatCleanTargets($Bld, "WHAT$Bld", "CLEANRELEASE$Bld", @releaseables);
       
   242 	&Generic_MakeWorkDir("MAKEWORK$Bld",$ChopBldPath);
       
   243 	&Generic_MakeWorkDir("MAKEWORK$Bld",$ChopRelPath);
       
   244 
       
   245 	&main::Output(
       
   246 		"\n",
       
   247 		"\n"
       
   248 	);
       
   249 
       
   250 	# XML Stuff
       
   251 	&main::Output(
       
   252 				&Generic_Quote("\$(GXPTRG$Bld)\\$BaseTrg.gxp"), " : ",
       
   253 				&Generic_Quote("\$(EPOCBLD$Bld)\\$BaseTrg.gxp"),
       
   254 	);
       
   255 	my @ChopRTWSysIncPaths=&main::Path_Chop(&main::Path_RltToWork(&main::SysIncPaths)); # old style
       
   256 	foreach my $incPath (@ChopRTWSysIncPaths) {
       
   257 	&main::Output(
       
   258 		"\n\t\@echo $incPath >> \$(EDG_SYSINC_LIST)",
       
   259 		);
       
   260 	}
       
   261 	
       
   262 	my @ChopRTWUserIncPaths=&main::Path_Chop(&main::Path_RltToWork(&main::UserIncPaths)); # old style
       
   263 	foreach my $incPath (@ChopRTWUserIncPaths) {
       
   264 	&main::Output(
       
   265 		"\n\t\@echo $incPath >> \$(EDG_USERINC_LIST)",
       
   266 		);
       
   267 	}
       
   268 
       
   269 	&main::Output(
       
   270 		"\n",
       
   271 		"\n"
       
   272 	);
       
   273         
       
   274 	# TARGET *.GXP
       
   275 	#------------
       
   276 	if (scalar @SrcList >150) {
       
   277 		# deal with very long lists by splitting them into 150 file pieces, which allows
       
   278 		# about 200 bytes per filename if the underlying max size is 32K
       
   279 		#
       
   280         
       
   281 		my $counter1=150;	# i.e. trigger new variable immediately
       
   282 		my $counter2=0;
       
   283 		my @objvarlist=();
       
   284 		foreach (@SrcList) {
       
   285 			if ($counter1==150) {
       
   286 				$counter1=0;
       
   287 				$counter2++;
       
   288 				my $objvar = "OBJECTS$Bld$counter2";
       
   289 				push @objvarlist, " \$($objvar)";
       
   290 				&main::Output(
       
   291 					"\n",
       
   292 					"$objvar="
       
   293 				);
       
   294 			}
       
   295 			my $BaseSrc = &main::Path_Split('Base', $_);
       
   296 			my $Ext = &main::Path_Split('Ext', $_);
       
   297                         next if (lc($Ext) eq '.cia');
       
   298 			&main::Output(
       
   299 				" \\\n\t", &Generic_Quote("\$(EPOCBLD$Bld)\\$BaseSrc$Ext.aut")
       
   300 			);
       
   301 			$counter1++;
       
   302 		}
       
   303 		
       
   304         &main::Output(
       
   305 			"\n\n"
       
   306 		);
       
   307 	} else {
       
   308 		# shorter lists remain unchanged
       
   309 		#
       
   310 		&main::Output(
       
   311 			"OBJECTS$Bld="
       
   312 		);
       
   313                 foreach (@SrcList) {
       
   314 			my $BaseSource = &main::Path_Split('Base', $_);
       
   315 			my $Ext = &main::Path_Split('Ext', $_);
       
   316                         next if (lc($Ext) eq '.cia');
       
   317 			&main::Output(
       
   318 			" \\\n\t", &Generic_Quote("\$(EPOCBLD$Bld)\\$BaseSource$Ext.aut")
       
   319 			);  
       
   320 		}       
       
   321 		
       
   322 		&main::Output(
       
   323 			"\n",
       
   324 			"\n"
       
   325 		);
       
   326 
       
   327 		&main::Output("RESOURCEINFO$Bld=");
       
   328 		&main::Output("\n\n");
       
   329 		
       
   330 		&main::Output(
       
   331             
       
   332 			&Generic_Quote("\$(EPOCBLD$Bld)\\$BaseTrg.gxp"), " : \$(OBJECTS$Bld) \$(EABIDEFFILE) \$(RESOURCEINFO$Bld)\n",
       
   333 			"\n\n"
       
   334 		);
       
   335 	}
       
   336 }
       
   337 
       
   338 
       
   339 sub PMStartSrcList {
       
   340 
       
   341 	&main::Output(
       
   342 		"# SOURCES\n",
       
   343 		"\n"
       
   344 	);
       
   345 }
       
   346 
       
   347 sub PMStartSrc {
       
   348 	my $Src=&main::Src;
       
   349 
       
   350 	&main::Output(
       
   351 		"# Source $Src\n",
       
   352 		"\n"
       
   353 	);
       
   354 }
       
   355 
       
   356 sub PMSrcDepend {
       
   357 	my @BldList=&main::BldList;	
       
   358 	my @DepList=&main::DepList;
       
   359 	my $BaseSrc=&main::BaseSrc;
       
   360 	my $ExtSrc=&main::ExtSrc;
       
   361 	my $cia = (lc($ExtSrc) eq '.cia') ? "_" : "";
       
   362 
       
   363 	return if (@DepList == 0);
       
   364 
       
   365 	foreach (@BldList) {
       
   366 		&main::Output(
       
   367 			&Generic_Quote("\$(EPOCBLD$_)\\$BaseSrc$cia.lis"), " ",
       
   368 			&Generic_Quote("\$(EPOCBLD$_)\\$BaseSrc$cia.aut"), " \\\n",
       
   369 		);
       
   370 	}
       
   371 	&main::Output(
       
   372 		":"
       
   373 	);
       
   374 	foreach (@DepList) {
       
   375 		&main::Output(
       
   376 		" \\\n\t", &Generic_Quote($_)
       
   377 		);
       
   378 	}
       
   379 	&main::Output(
       
   380 		"\n",
       
   381 		"\n"
       
   382 	);
       
   383 }
       
   384 
       
   385 sub PMSrcBldDepend {
       
   386 	my $Bld=&main::Bld;
       
   387 	my @DepList=&main::DepList;
       
   388 	my $BaseSrc=&main::BaseSrc;
       
   389 	my $ExtSrc=&main::ExtSrc;
       
   390     my $cia = (lc($ExtSrc) eq '.cia') ? "" : "";
       
   391 
       
   392 	return if (@DepList == 0);
       
   393 
       
   394 	&main::Output(
       
   395 		&Generic_Quote("\$(EPOCBLD$Bld)\\$BaseSrc$cia.lis"), " ",
       
   396 		&Generic_Quote("\$(EPOCBLD$Bld)\\$BaseSrc$cia.aut"), " :",
       
   397 	);
       
   398 	foreach (@DepList) {
       
   399 		&main::Output(
       
   400 			" \\\n\t", &Generic_Quote($_)
       
   401 		);
       
   402 	}
       
   403 	&main::Output( 
       
   404 		"\n",
       
   405 		"\n"
       
   406 	);
       
   407 }
       
   408 
       
   409 my %sources;
       
   410 
       
   411 sub PMEndSrcBld {
       
   412 	my $ABI=&main::ABI;
       
   413 	my $BaseSrc=&main::BaseSrc;
       
   414 	my $Bld=&main::Bld;
       
   415 	my $Src=ucfirst lc &main::Src;
       
   416 	my $SrcPath=&main::SrcPath;
       
   417 	my $Ext = &main::Path_Split('Ext', $Src);
       
   418 	my $Cia = (lc($Ext) eq '.cia') ? 1 : 0;
       
   419 
       
   420 	my $RTWSrcPath=&main::Path_Chop(&main::Path_RltToWork($SrcPath));
       
   421 
       
   422 	# add source path, source file and build type to hashmap. 
       
   423     $sources{$SrcPath}{$Src}{$Bld}=1;
       
   424    
       
   425 	# Use GCC trick to get assembler source files preprocessed with CPP
       
   426 	$Src =~ s/\.s$/.S/i;
       
   427 
       
   428 	@browser = ();
       
   429 	my $EdgReportFile = "\$(EDG_UREL_REP_LIST)";
       
   430 	if($Bld =~ /udeb/i){
       
   431 		$EdgReportFile = "\$(EDG_UDEB_REP_LIST)";
       
   432 	}
       
   433 
       
   434 	if ($Cia) {
       
   435 		&main::Output(
       
   436 			&Generic_Quote("\$(EPOCBLD$Bld)\\$BaseSrc\_.aut"), " : ",
       
   437 			&Generic_Quote("$SrcPath$Src"), "\n",
       
   438 			"\t\$(GCC$Bld) -D __CIA__ --include_directory \"$RTWSrcPath\" \$(INCDIR) --xref \"\$\@\" \"$RTWSrcPath\\$Src\"\n",
       
   439 		"\t\@echo \"\$\<\" >> $EdgReportFile\n",
       
   440 		"\n");
       
   441 	} else {
       
   442 		
       
   443                 my $BldPath=&main::BldPath;
       
   444                 my $EdgReportFilePath=UpDir(UpDir(UpDir($BldPath)));
       
   445 		
       
   446 		&main::Output(
       
   447 			&Generic_Quote("\$(EPOCBLD$Bld)\\$BaseSrc$Ext.aut"), " : ",
       
   448 			&Generic_Quote("$SrcPath$Src"), "\n",
       
   449 			"\t\$(GCC$Bld) --include_directory \"$RTWSrcPath\" \$(INCDIR) \$(SYSINCDIR) --xref \"\$\@\" \"$RTWSrcPath\\$Src\"\n",
       
   450 			"\t\@echo \$(EPOCBLD$Bld)\\$BaseSrc$Ext.aut >> $EdgReportFile\n",
       
   451 			"\n"
       
   452 		);
       
   453 
       
   454 		foreach $browser (@browser)
       
   455 		{
       
   456 		 print "$browser\n";
       
   457 		}
       
   458 	}
       
   459 }
       
   460 
       
   461 sub PMEndSrc {
       
   462 	&main::Output(
       
   463 		"\n",
       
   464 		"\n"
       
   465 	);
       
   466 }
       
   467 
       
   468 sub PMEndSrcList {
       
   469 		&Generic_End;
       
   470 }
       
   471 
       
   472 
       
   473 
       
   474 sub UpDir($)
       
   475 	{
       
   476 	my ($aPath) = @_;
       
   477 
       
   478 	my $lastChar = substr($aPath,-1);
       
   479 	my $end = length($aPath)-1;
       
   480 
       
   481 	if ( ($lastChar eq '\\') || ($lastChar eq '/') )
       
   482 		{
       
   483 		$end -= 1;
       
   484 		}
       
   485 
       
   486 	my $last = rindex($aPath,'\\',$end);
       
   487 	if ( (rindex($aPath,'/',$end)>$last) | ($last == -1) )
       
   488 		{ $last = rindex($aPath,'/',$end); }
       
   489 
       
   490 	if ($last == -1)
       
   491 		{ return ""; }
       
   492 	else
       
   493 		{ return substr($aPath,0,$last).'/'; }
       
   494 	}
       
   495 
       
   496 1;