mmtestenv/mmtesttools/Build/fullMmBuild.pl
changeset 0 40261b775718
equal deleted inserted replaced
-1:000000000000 0:40261b775718
       
     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 #
       
    15 
       
    16 # Full build
       
    17 
       
    18 use strict;
       
    19 
       
    20 
       
    21 my $ARGC = @ARGV;
       
    22 if  (($ARGV[0] eq "-h") ||
       
    23      ($ARGV[0] eq "--h") ||
       
    24      ($ARGV[0] eq "-help") ||
       
    25      ($ARGV[0] eq "--help") ||
       
    26      ($ARGV[0] eq "help")
       
    27 	 )
       
    28 	{
       
    29 	print "fullMmBuild\n\n";
       
    30 	print "Syntax : fullMmBuild [-x] [-k] [-c] [-f] [-eabi] [-y] [-a] [-g] [-s] [-dir=directory] [-a3flog]\n";
       
    31 	print "-x       include optional elements\n";
       
    32 	print "-k       keep going\n";
       
    33 	print "-c       clean build\n";
       
    34 	print "-f       build A3F and A3F DevSound instead of Legacy DevSound\n";
       
    35 	print "-l		build Legacy DevSound instead of A3F (ignored if -f given)\n";
       
    36 	print "-eabi    build rom for armv5 EABI\n";
       
    37 	print "-arm4    build the extra components for arm4\n"; 
       
    38 	print "-y       build for ccover (wins only)\n";
       
    39 	print "-a       call mmbuildrom with MMAutoExec.iby\n";
       
    40 	print "-g       include build of gccxml target, to allow check of BC etc\n";
       
    41 	print "-s       skip setup and makefile stages (useful on rebuild following minor changes)\n";
       
    42 	print "-dir     location of TestTools\\Build directory\n";
       
    43 	print "-a3flog		enables A3F logging\n";
       
    44 	print "-iclTestdata	builds ICL test data\n";
       
    45 	exit 0;
       
    46 	}
       
    47 
       
    48 
       
    49 use Getopt::Long;
       
    50 my %optctl = ();
       
    51 keys(%optctl)=8;
       
    52 unless (GetOptions (\%optctl, "x", "c", "k", "f", "eabi" ,"y", "a", "g", "s", "l", "dir=s","arm4","a3flog","iclTestdata")) 
       
    53   {exit 1;}
       
    54 
       
    55 my $ccover_target = "wins";
       
    56 my $eka2IdentifyFile  = "$ENV{EPOCROOT}epoc32\\release\\winscw\\udeb\\winsgui.dll"; # if file present, is EKA2 build
       
    57 my $x86gccIdentifyFile  = "$ENV{EPOCROOT}epoc32\\release\\x86gcc\\udeb\\euser.dll"; # if file present, x86 environment present
       
    58 
       
    59 # main 
       
    60 	{
       
    61 	my $auto = "-a " if ($optctl{"a"});
       
    62 	my $optional = "-x " if ($optctl{"x"});
       
    63 	my $eabi = "-eabi " if ($optctl{"eabi"});
       
    64 	my $keep = "-k " if ($optctl{"k"});
       
    65 	my $target = ""; # default to all
       
    66 	my $gccxml = "-g " if ($optctl{"g"});
       
    67 	my $skipSetup = "-s " if ($optctl{"s"});
       
    68 	my $iclTest = " --iclTestdata " if ($optctl{"iclTestdata"});
       
    69 	$target = " " . $ccover_target if ($optctl{"y"});
       
    70 
       
    71 	##################  A3F Section #######################################
       
    72 	my $a3f_define = 'SYMBIAN_MULTIMEDIA_A3FDEVSOUND';
       
    73 	my $search_item = '#define\s+'.$a3f_define;  # looking for this
       
    74 	my $hrh_filename = "$ENV{EPOCROOT}epoc32\\include\\variant\\Symbian_OS.hrh"; # assign hrh file and location
       
    75 	my $found_search_item = 0; #false
       
    76 	# print "HRH filename is : $hrh_filename\n";
       
    77 	
       
    78  	if ($optctl{"f"})
       
    79 	 	{
       
    80 	 	# This displays the content of the hash table
       
    81 	 	# use it to confirm the "f" entry has been added.
       
    82 	 	#
       
    83 	 	# my $key;  # holds the command line options
       
    84 	 	# my $value; # redundant for hash entry as only a key is used.
       
    85 		# while (($key, $value) = each(%optctl))
       
    86 		#	{
       
    87 		# 	print $key.", ".$value."\n";
       
    88 		#	}
       
    89 
       
    90 		# opens up the hrh file for reading
       
    91 		open(FILEHANDLE, "<", $hrh_filename) or die "Unable to open $hrh_filename for reading. $!\n";
       
    92 
       
    93 		my @file_data=<FILEHANDLE>; # read all file data into array
       
    94 
       
    95 		#check the contents of the array (i.e. the contents of the file)
       
    96 		for(@file_data)
       
    97 			{
       
    98 			# print "$_\n";  #display the line in the file
       
    99 			
       
   100 			# search line for string of interest: =~ is equals, !~ is not equal
       
   101 			if(($_ =~ m/$search_item/i))
       
   102 				{
       
   103 				$found_search_item = 1;  #found the macro 
       
   104 				# print "Search item found: $_\n";    #display the line containing the search item
       
   105 				}
       
   106 			else
       
   107 				{
       
   108 				# Search item not found, do nothing
       
   109 				}
       
   110 			} #for loop 
       
   111 
       
   112 		close(FILEHANDLE) or die "Can't close file $hrh_filename.\n";  # readonly file
       
   113 		
       
   114 		if(!$found_search_item)  #search item has not been found
       
   115 			{
       
   116 			# print warning
       
   117 			print "Modifying file $hrh_filename to enable A3F as -f flag has been used.\n";
       
   118 			
       
   119 			# open file for append
       
   120 			open(FILEHANDLE, ">>", $hrh_filename) or die "Unable to open $hrh_filename for appending. $!\n";
       
   121 			print FILEHANDLE "\n#define $a3f_define\n"; # append macro to the file
       
   122 			close(FILEHANDLE) or die "Can't close appended file $hrh_filename.\n";  # readonly file
       
   123 			}
       
   124 			
       
   125 	 	# Now remove the "f" from the hash table so there is no chance of it being passed
       
   126 	 	# to mmbuildrom.
       
   127 	 	######## NOTE removal of flag from Hash table ############
       
   128 	 	delete($optctl{f});   
       
   129 	 	
       
   130 	 	# This displays the content of the hash table
       
   131 	 	# use it to confirm the "f" entry has been removed.
       
   132 	 	#
       
   133 		# while (($key, $value) = each(%optctl))
       
   134 		#	{
       
   135 		#	print $key.", ".$value."\n";
       
   136 		#	}
       
   137 	 	} # if $optctl{"f"}
       
   138  	elsif ($optctl{"l"})
       
   139  		{
       
   140  		 ########### Remove the macro from the hrh as "-l" but not "-f" is specified  ###############
       
   141  		
       
   142  		$found_search_item = 0 ; # false
       
   143 		# opens up the original hrh file for reading
       
   144 		open(FILEHANDLE, "<", $hrh_filename) or die "Unable to open $hrh_filename for reading. $!\n";
       
   145 
       
   146 		# temporary file
       
   147 		my $temp_hrh_filename = "$ENV{EPOCROOT}epoc32\\include\\variant\\temp_Symbian_OS.hrh";
       
   148 		# open temporary file for writing
       
   149 		open(TEMPFILEHANDLE, ">", $temp_hrh_filename) or die "can't open tempory file $temp_hrh_filename. $!\n";
       
   150 		
       
   151 		my @file_data=<FILEHANDLE>; # read all original hrh file data into array
       
   152 
       
   153 		#check the contents of the array (i.e. the contents of the file)
       
   154 		for(@file_data)
       
   155 			{
       
   156 			# print "$_\n";  #display the line in the file
       
   157 			
       
   158 			# search line for string of interest: =~ is equals, !~ is not equal
       
   159 			if(($_ =~ m/(.*)$search_item(.*)/i))
       
   160 				{
       
   161 				#display a warning message (only do so once)
       
   162 				if( !$found_search_item )
       
   163 					{
       
   164 					print "Modifying file $hrh_filename to disable A3F as -l has been given.\n";
       
   165 					}
       
   166 				
       
   167 				# write line excluding the #define bit to temp file. (to preserve any other bits in this line. e.g.: comment delimiters)
       
   168 				print TEMPFILEHANDLE $1." ".$2."\n";
       
   169 				$found_search_item = 1 ; # true
       
   170 				# Do not write line to the file as we want to remove it.
       
   171 				}
       
   172 			else
       
   173 				{
       
   174 				print TEMPFILEHANDLE $_;  # copy unchanged line to temporary file
       
   175 				}
       
   176 			} #for loop 
       
   177 
       
   178 		close(FILEHANDLE) or die "Can't close file $hrh_filename.$!\n";  # readonly file
       
   179 		close(TEMPFILEHANDLE) or die "Can't close file $temp_hrh_filename. $!\n";  # temp file
       
   180 		if($found_search_item)
       
   181 			{
       
   182 			my $orig_hrh_filename = "$ENV{EPOCROOT}epoc32\\include\\variant\\orig.hrh";
       
   183 			rename($hrh_filename, $orig_hrh_filename) or die "can't rename $hrh_filename to $orig_hrh_filename: $!\n";
       
   184 			rename($temp_hrh_filename, $hrh_filename)  or die "can't rename $temp_hrh_filename to $hrh_filename: $!\n";
       
   185 			unlink $orig_hrh_filename;  # delete the original as it is no longer needed
       
   186 			}
       
   187 		else
       
   188 			{
       
   189 			unlink $temp_hrh_filename;  # no changes to be made so delete the temporary file
       
   190 			}
       
   191 		
       
   192  		}  # main else for A3F
       
   193  	
       
   194 	##################  End A3F Section ####################################
       
   195 
       
   196 	##################  A3F Logging Section ####################################
       
   197 
       
   198 	my $search_item = "SYMBIAN_MULTIMEDIA_A3F_ENABLE_LOGGING";  # looking for this	
       
   199 	my $hrh_filename = "$ENV{EPOCROOT}epoc32\\include\\variant\\Symbian_OS.hrh"; # assign hrh file and location
       
   200 	my $found_search_item = 0; #false
       
   201 	
       
   202  	if ($optctl{"a3flog"})
       
   203 	 	{
       
   204 		# opens up the hrh file for reading
       
   205 		open(FILEHANDLE, "<", $hrh_filename) or die "Unable to open $hrh_filename for reading. $!\n";
       
   206 
       
   207 		my @file_data=<FILEHANDLE>; # read all file data into array
       
   208 
       
   209 		#check the contents of the array (i.e. the contents of the file)
       
   210 		for(@file_data)
       
   211 			{
       
   212 			# search line for string of interest: =~ is equals, !~ is not equal
       
   213 			if(($_ =~ m/$search_item/i))
       
   214 				{
       
   215 				$found_search_item = 1;  #found the macro 
       
   216 				}
       
   217 			else
       
   218 				{
       
   219 				# Search item not found, do nothing
       
   220 				}
       
   221 			} #for loop 
       
   222 
       
   223 		close(FILEHANDLE) or die "Can't close file $hrh_filename.\n";  # readonly file
       
   224 		
       
   225 		if(!$found_search_item)  #search item has not been found
       
   226 			{
       
   227 			# open file for append
       
   228 			open(FILEHANDLE, ">>", $hrh_filename) or die "Unable to open $hrh_filename for appending. $!\n";
       
   229 			print FILEHANDLE "\n#define $search_item\n"; # append macro to the file
       
   230 			close(FILEHANDLE) or die "Can't close appended file $hrh_filename.\n";  # readonly file
       
   231 			}
       
   232 			
       
   233 	 	# Now remove the "log" from the hash table so there is no chance of it being passed
       
   234 	 	# to anything called in this file.
       
   235 	 	######## NOTE removal of flag from Hash table ############
       
   236 	 	delete($optctl{log});   		
       
   237 	 	} # if $optctl{"log"}
       
   238  	else
       
   239  		{
       
   240  		 ########### Remove the macro from the hrh as "-a3flog" is not specified  ###############
       
   241  		
       
   242  		$found_search_item = 0 ; # false
       
   243 		# opens up the original hrh file for reading
       
   244 		open(FILEHANDLE, "<", $hrh_filename) or die "Unable to open $hrh_filename for reading. $!\n";
       
   245 
       
   246 		# temporary file
       
   247 		my $temp_hrh_filename = "$ENV{EPOCROOT}epoc32\\include\\variant\\temp_Symbian_OS.hrh";
       
   248 		# open temporary file for writing
       
   249 		open(TEMPFILEHANDLE, ">", $temp_hrh_filename) or die "can't open tempory file $temp_hrh_filename. $!\n";
       
   250 		
       
   251 		my @file_data=<FILEHANDLE>; # read all original hrh file data into array
       
   252 
       
   253 		#check the contents of the array (i.e. the contents of the file)
       
   254 		for(@file_data)
       
   255 			{
       
   256 			# search line for string of interest: =~ is equals, !~ is not equal
       
   257 			if(($_ =~ m/$search_item/i))
       
   258 				{
       
   259 				#display a warning message
       
   260 				print "Removing $_ from file $hrh_filename as -a3flog flag has not been used to indicate an A3F logging build is required.\n";
       
   261 				$found_search_item = 1 ; # true
       
   262 				# Do not write line to the file as we want to remove it.
       
   263 				}
       
   264 			else
       
   265 				{
       
   266 				# Ensure the last newline after the macro is not written to the file.
       
   267 				# the last new line was added by the macro append in the previous section.
       
   268 				# The asssumes the macro is the last entry in the file. If it is not then 
       
   269 				# the if statement should be removed and the print statement left on its own
       
   270 				# to copy the last line to file.
       
   271 				if(!$found_search_item)  
       
   272 					{
       
   273 					print TEMPFILEHANDLE $_;  # copy unchanged line to temporary file
       
   274 					}
       
   275 				}
       
   276 			} #for loop 
       
   277 
       
   278 		close(FILEHANDLE) or die "Can't close file $hrh_filename.$!\n";  # readonly file
       
   279 		close(TEMPFILEHANDLE) or die "Can't close file $temp_hrh_filename. $!\n";  # temp file
       
   280 		if($found_search_item)
       
   281 			{
       
   282 			my $orig_hrh_filename = "$ENV{EPOCROOT}epoc32\\include\\variant\\orig.hrh";
       
   283 			rename($hrh_filename, $orig_hrh_filename) or die "can't rename $hrh_filename to $orig_hrh_filename: $!\n";
       
   284 			rename($temp_hrh_filename, $hrh_filename)  or die "can't rename $temp_hrh_filename to $hrh_filename: $!\n";
       
   285 			unlink $orig_hrh_filename;  # delete the original as it is no longer needed
       
   286 			}
       
   287 		else
       
   288 			{
       
   289 			unlink $temp_hrh_filename;  # no changes to be made so delete the temporary file
       
   290 			}
       
   291 		
       
   292  		}  # main else for A3F
       
   293  		
       
   294 	##################  End A3F Logging Section ####################################
       
   295 	
       
   296 	if($optctl{"dir"})
       
   297 		{
       
   298 		my $dir = $optctl{"dir"};
       
   299 		chdir $dir or die "Can't cd $dir - $!";
       
   300 		}
       
   301 
       
   302 	my $targetToolsDir = "..\\..\\..\\..\\..\\TargetTools\\Build";
       
   303 	my $testToolsDir = "..\\..\\..\\..\\..\\os\\mm\\mmtestenv\\mmtesttools\\Build";
       
   304 	my $targetToolsExists = 0;
       
   305 	if (-d $targetToolsDir)
       
   306 		{
       
   307 		$targetToolsExists = 1;
       
   308 		print "TargetTools directory exists: $targetToolsDir\n"
       
   309 		}
       
   310 
       
   311 	# DEF113945:DRM tests fail due to the change from DEF112928
       
   312 	my $rtaUtilsDir = "..\\..\\..\\..\\..\\Rtautils\\Build";
       
   313 	my $rtaUtilsExists = 0;
       
   314 	if (-d $rtaUtilsDir)
       
   315 		{
       
   316 		$rtaUtilsExists = 1;
       
   317 		print "RtaUtils directory exists: $rtaUtilsDir\n";
       
   318 		}
       
   319 
       
   320 	# DEF113945:DRM tests fail due to the change from DEF112928
       
   321 	my $testExecuteDir = "..\\..\\..\\..\\..\\Testexecute\\Build";
       
   322 	my $testExecuteExists = 0;
       
   323 	if (-d $testExecuteDir)
       
   324 		{
       
   325 		$testExecuteExists = 1;
       
   326 		print "TestExecute directory exists: $testExecuteDir\n";
       
   327 		}
       
   328 
       
   329 	my $command;
       
   330 
       
   331  	# mmbuild [-x] [-k] setup
       
   332  	$command = "mmbuild " . $optional . $keep . "setup" . $iclTest;
       
   333  	if ($skipSetup ne "")
       
   334  		{
       
   335  		print "Skipping setup...\n";
       
   336  		}
       
   337  	else
       
   338  		{
       
   339  		(system ($command)==0 )or die "Couldn't execute $command";
       
   340  		}
       
   341  	
       
   342  	if ($optctl{"c"})
       
   343  		{
       
   344  		# mmbuild -t clean (throw away result - so we ignore any no-export errors)
       
   345  		$command = "mmbuild -t clean >\$NULL 2>&1";
       
   346  		print $command, "\n";
       
   347  		(system ($command)==0 )or die "Couldn't execute $command";
       
   348  		}
       
   349  
       
   350  	# mmbuild [-k] [-g] build
       
   351  	$command = "mmbuild ". $keep. $gccxml. $skipSetup. "build" . $target . $iclTest;
       
   352  	(system ($command)==0 )or die "Couldn't execute $command";
       
   353  
       
   354  	# mmbuild -t [-k] build
       
   355  	$command = "mmbuild -t ". $keep. $skipSetup. "build" . $target . $iclTest;
       
   356  	(system ($command)==0 )or die "Couldn't execute $command";
       
   357  
       
   358  	# mmbuild -t -b [-k] build
       
   359  	$command = "mmbuild -t -b ". $keep. $skipSetup. "build" . $target . $iclTest;
       
   360  	(system ($command)==0 )or die "Couldn't execute $command";
       
   361  
       
   362 	if (!$optctl{"y"})
       
   363  		{
       
   364 		# DEF113945:DRM tests fail due to the change from DEF112928
       
   365 		if ($rtaUtilsExists)
       
   366 			{
       
   367 			$command = "testExtras_Rtautils";
       
   368 			chdir $rtaUtilsDir or die "Can't cd $rtaUtilsDir - $!";
       
   369 			(system ($command)==0 )or die "Couldn't execute $command";
       
   370 			chdir $testToolsDir or die "Can't cd $testToolsDir - $!";
       
   371 			}
       
   372 
       
   373 		# DEF113945:DRM tests fail due to the change from DEF112928
       
   374 		if($testExecuteExists)
       
   375 			{
       
   376 			$command = "testExtras_Testexecute";
       
   377 			chdir $testExecuteDir or die "Can't cd $testExecuteDir - $!";
       
   378 			(system ($command)==0 )or die "Couldn't execute $command";
       
   379 			chdir $testToolsDir or die "Can't cd $testToolsDir - $!";
       
   380 			}
       
   381 
       
   382 		# mmBuildRom [-x]
       
   383 		$command = "mmBuildRom -t -d " .$auto . $optional .$eabi;
       
   384 		print $command, "\n";
       
   385 		(system ($command)==0 )or die "Couldn't execute $command";
       
   386 		}
       
   387 
       
   388 	}