imgtools/buildrom/tools/buildrom.pm
changeset 626 ac03b93ca9c4
parent 609 f76e0f94b7ab
child 633 a4eca1f021ac
equal deleted inserted replaced
625:a1925fb7753a 626:ac03b93ca9c4
    54 	getObyCommand
    54 	getObyCommand
    55 	process_dlldata
    55 	process_dlldata
    56 	featurefile_creation_phase
    56 	featurefile_creation_phase
    57 	processData
    57 	processData
    58 	create_smrimage
    58 	create_smrimage
       
    59 	getWorkdir
    59 );
    60 );
    60 
    61 
    61 my $useinterpretsis = 1;
    62 my $useinterpretsis = 1;
    62 if ($^O !~ /^MSWin32$/i){
    63 if ($^O !~ /^MSWin32$/i){
    63 	$useinterpretsis = 0;
    64 	$useinterpretsis = 0;
    64 }
    65 }
    65 my $enforceFeatureManager = 0; # Flag to make Feature Manager mandatory if SYMBIAN_FEATURE_MANAGER macro is defined. 
    66 my $enforceFeatureManager = 0; # Flag to make Feature Manager mandatory if SYMBIAN_FEATURE_MANAGER macro is defined. 
    66 
    67 
    67 my $BuildromMajorVersion = 3 ;
    68 my $BuildromMajorVersion = 3 ;
    68 my $BuildromMinorVersion = 26;
    69 my $BuildromMinorVersion = 27;
    69 my $BuildromPatchVersion = 0;
    70 my $BuildromPatchVersion = 2;
    70 
    71 
    71 
    72 
    72 sub print_usage
    73 sub print_usage
    73 {
    74 {
    74 
    75 
   129    -noimage                         -- disable creation of ROM/ROFS/DataDrive Image
   130    -noimage                         -- disable creation of ROM/ROFS/DataDrive Image
   130    -j<digit>                        -- do the main job with <digit> threads
   131    -j<digit>                        -- do the main job with <digit> threads
   131    -cache                           -- allow the ROFSBUILD to reuse/generate cached executable files
   132    -cache                           -- allow the ROFSBUILD to reuse/generate cached executable files
   132    -nocache                         -- force the ROFSBUILD not to reuse/generate cached executable files
   133    -nocache                         -- force the ROFSBUILD not to reuse/generate cached executable files
   133    -cleancache                      -- permanently remove all cached executable files
   134    -cleancache                      -- permanently remove all cached executable files
       
   135    -oby-charset=<charset>	        -- used character set in which OBY was written
   134    -loglevel<level>                 -- Level of information logging where loglevel is 0,1,2
   136    -loglevel<level>                 -- Level of information logging where loglevel is 0,1,2
   135                                        0 default level of information
   137                                        0 default level of information
   136                                        1 host/ROM filenames, file size and the hidden attribute along with level0 log
   138                                        1 host/ROM filenames, file size and the hidden attribute along with level0 log
   137                                        2 E32 file header attributes along with level1 log
   139                                        2 E32 file header attributes along with level1 log
   138    -z=xxx or -zdrivepath=xxx        -- specify a location to create Z drive directory. 
   140    -z=xxx or -zdrivepath=xxx        -- specify a location to create Z drive directory. 
   152    -lowmem                          -- use memory-mapped file for image build to reduce physical memory consumption   
   154    -lowmem                          -- use memory-mapped file for image build to reduce physical memory consumption   
   153    -checkcase                       -- check character case of path/name in oby/iby files, 
   155    -checkcase                       -- check character case of path/name in oby/iby files, 
   154                                     the result will be checkcase.log, this option is only valid on windows.
   156                                     the result will be checkcase.log, this option is only valid on windows.
   155    -workdir=xxx                     -- specify a directory to contain generated files. 
   157    -workdir=xxx                     -- specify a directory to contain generated files. 
   156    -prependepocroot                 -- if there is no EPOCROOT## before /epoc32/, prepend EPOCROOT## to epoc32.
   158    -prependepocroot                 -- if there is no EPOCROOT## before /epoc32/, prepend EPOCROOT## to epoc32.
   157 
   159    -stdcpp                          -- ignore symbian customized cpp and try to find another cpp in the PATH.(for Windows only)
       
   160    -cpp=xxx                         -- specify a CPP preprocessor used by Buildrom.
       
   161    
   158 Popular -D defines to use include
   162 Popular -D defines to use include
   159 
   163 
   160    -D_DEBUG         -- select debug versions of some files
   164    -D_DEBUG         -- select debug versions of some files
   161    -D_FULL_DEBUG    -- select debug versions of all files
   165    -D_FULL_DEBUG    -- select debug versions of all files
   162    -D_ARM4          -- specify the target platform
   166    -D_ARM4          -- specify the target platform
   342 my $checkcase = 0;
   346 my $checkcase = 0;
   343 my $checkcase_platform = "";
   347 my $checkcase_platform = "";
   344 my $checkcase_test = 0;
   348 my $checkcase_test = 0;
   345 my $opt_workdir = 0;
   349 my $opt_workdir = 0;
   346 my $prependepocroot = 0;
   350 my $prependepocroot = 0;
       
   351 my $stdcpp = 0;
       
   352 my $obycharset;
       
   353 my $cppoption = 0;
       
   354 my $preprocessor = "cpp";
   347 
   355 
   348 sub match_obyfile
   356 sub match_obyfile
   349 {
   357 {
   350 	my ($obyfile) = @_;
   358 	my ($obyfile) = @_;
   351 	if (-f $obyfile)
   359 	if (-f $obyfile)
   495 {
   503 {
   496 	if($dataImageCount)
   504 	if($dataImageCount)
   497 	{
   505 	{
   498 		# set the default path for Z drive and Data drive directory,
   506 		# set the default path for Z drive and Data drive directory,
   499 		# if and only if, path is not specified by the user. 
   507 		# if and only if, path is not specified by the user. 
   500 		$ZDirloc = &datadriveimage::setPath("zdrive") unless ($ZDirloc);
   508 		$ZDirloc = $thisdir."zdrive" unless ($ZDirloc);
   501 		$DataDriveDirloc = &datadriveimage::setPath("datadrive") unless ($DataDriveDirloc);
   509 		$DataDriveDirloc = $thisdir."datadrive" unless ($DataDriveDirloc);
   502 		#delete any existing Z drive directory.
   510 		#delete any existing Z drive directory.
   503 		my $retVal = &datadriveimage::deleteDirectory($ZDirloc,$opt_v)if(!$opt_r);
   511 		my $retVal = &datadriveimage::deleteDirectory($ZDirloc,$opt_v)if(!$opt_r);
   504 		if($retVal)
   512 		if($retVal)
   505 		{
   513 		{
   506 			exit(1) if(!$opt_k);
   514 			exit(1) if(!$opt_k);
   533 					# final location of prototype data drive.
   541 					# final location of prototype data drive.
   534 					my $proDataDriveDirloc;
   542 					my $proDataDriveDirloc;
   535 					# Location of stub-sis file(s) inside Z Drive folder.
   543 					# Location of stub-sis file(s) inside Z Drive folder.
   536 					my $zDriveSisFileLoc;
   544 					my $zDriveSisFileLoc;
   537 					# check if more than one data drive image needs to be generated. 
   545 					# check if more than one data drive image needs to be generated. 
       
   546 					if ($datadrivename =~ /.*[\\\/]([^\\\/]+)$/)
       
   547 					{
       
   548 						$datadrivename = $1;
       
   549 					}
   538 					if( $dataImageCount > 1 )
   550 					if( $dataImageCount > 1 )
   539 					{
   551 					{
   540 						# if yes, then set the location of prototype data drive folder as 
   552 						# if yes, then set the location of prototype data drive folder as 
   541 						# DataDriveDirloc + datadrivename
   553 						# DataDriveDirloc + datadrivename
   542 						$proDataDriveDirloc = $DataDriveDirloc."\/".$datadrivename;
   554 						$proDataDriveDirloc = $DataDriveDirloc."\/".$datadrivename;
   600 							}
   612 							}
   601 						}
   613 						}
   602 						# invoke INTERPRETSIS tool with z drive folder location.
   614 						# invoke INTERPRETSIS tool with z drive folder location.
   603 						if ($useinterpretsis)
   615 						if ($useinterpretsis)
   604 						{
   616 						{
   605 							&datadriveimage::invokeInterpretsis( \@sisfilelist,$proDataDriveDirloc,$opt_v,$zDriveSisFileLoc,$paraFile,$opt_k,\@interpretsisOptList)if($sisfilepresent);
   617 							&datadriveimage::invokeInterpretsis( \@sisfilelist,$proDataDriveDirloc,$opt_v,$zDriveSisFileLoc,$paraFile,$opt_k,\@interpretsisOptList,$thisdir)if($sisfilepresent);
   606 						}else
   618 						}else
   607 						{
   619 						{
   608 							print "Warning: interpretsis is not ready on linux.\n";
   620 							print "Warning: interpretsis is not ready on linux.\n";
   609 						}	
   621 						}	
   610 					}
   622 					}
   761 	# first searching argList for keepgoing option
   773 	# first searching argList for keepgoing option
   762 	foreach my $arg (@argList) {
   774 	foreach my $arg (@argList) {
   763 		if ( $arg =~ /^-k$/i || $arg =~ /^-keepgoing$/i )
   775 		if ( $arg =~ /^-k$/i || $arg =~ /^-keepgoing$/i )
   764 	  {
   776 	  {
   765 			$opt_k = 1;		
   777 			$opt_k = 1;		
   766   		last;	
   778   		next;	
       
   779 		}
       
   780 		if ($arg =~ /^-workdir=(.*)/)
       
   781 		{
       
   782 			my $workdir = $1;
       
   783 			if (!-d $workdir)
       
   784 			{
       
   785 				die "directory $workdir does not exist\n";
       
   786 			}
       
   787 			my $currentdir = cwd;
       
   788 			chdir "$workdir" or die "cannot change to directory $workdir\n";
       
   789 			$thisdir=cwd;
       
   790 			$thisdir=~s-\\-\/-go;		    # separator from Perl 5.005_02+ is forward slash
       
   791 			$thisdir.= "\/" unless $thisdir =~ /\/$/;
       
   792 			if(&is_windows)
       
   793 			{
       
   794 				$thisdir =~ s-\/-\\-g;
       
   795 			}
       
   796 			$opt_workdir = 1;
       
   797 			chdir "$currentdir";
       
   798 			next;	
   767 		}
   799 		}
   768 	}
   800 	}
   769 	foreach my $arg (@argList)
   801 	foreach my $arg (@argList)
   770 	{
   802 	{
   771 	    if ($arg =~ /^-argfile=(.*)/) 
   803 	    if ($arg =~ /^-argfile=(.*)/) 
   812 			}
   844 			}
   813 			addDrivesToFeatureVariantPaths();
   845 			addDrivesToFeatureVariantPaths();
   814 		}
   846 		}
   815 		next;
   847 		next;
   816 	    }
   848 	    }
   817 	    if ($arg =~ /^-o(.*)/i)
   849 	    if ($arg =~/^-oby-charset=(.*)$/i)
       
   850 	    {
       
   851 		$obycharset = $1;
       
   852 		next;
       
   853 	    }
       
   854 	    if (($arg =~ /^-o(.*)/i) && ($arg !~ /^-oby-charset/i))
   818 	    {
   855 	    {
   819 		$opt_o = $1;
   856 		$opt_o = $1;
   820 		next;
   857 		next;
   821 	    }
   858 	    }
   822 	    if ($arg =~ /^-j(\d+)$/i)
   859 	    if ($arg =~ /^-j(\d+)$/i)
  1001 			$checkcase_test=1;
  1038 			$checkcase_test=1;
  1002 			next;	
  1039 			next;	
  1003 		}
  1040 		}
  1004 		if ($arg =~ /^-workdir=(.*)/)
  1041 		if ($arg =~ /^-workdir=(.*)/)
  1005 		{
  1042 		{
  1006 			my $workdir = $1;
  1043 			next;
  1007 			if (!-d $workdir)
  1044 		}
  1008 			{
  1045 		if ($arg =~ /^-stdcpp$/)
  1009 				die "directory $workdir does not exist\n";
  1046 		{
  1010 			}
  1047 			if (&is_linux)
  1011 			my $currentdir = cwd;
  1048 			{
  1012 			chdir "$workdir" or die "cannot change to directory $workdir\n";
  1049 				print "Warning: option -stdcpp only apply for Windows\n";
  1013 			$thisdir=cwd;
  1050 				next;
  1014 			$thisdir=~s-\\-\/-go;		    # separator from Perl 5.005_02+ is forward slash
  1051 			}
  1015 			$thisdir.= "\/" unless $thisdir =~ /\/$/;
  1052 			if ($cppoption)
  1016 			if(&is_windows)
  1053 			{
  1017 			{
  1054 				die "Error: -stdcpp option and -cpp=xxx option cannot be used at the same time.\n";
  1018 				$thisdir =~ s-\/-\\-g;
  1055 			}
  1019 			}
  1056 			$stdcpp = 1;
  1020 			$opt_workdir = 1;
  1057 			next;
  1021 			chdir "$currentdir";
  1058 		}
  1022 			next;	
  1059 		if ($arg =~ /^-cpp=(.*)/)
  1023 		}
  1060 		{
       
  1061 			if ($stdcpp)
       
  1062 			{
       
  1063 				die "Error: -stdcpp option and -cpp=xxx option cannot be used at the same time.\n";
       
  1064 			}
       
  1065 			if ($cppoption)
       
  1066 			{
       
  1067 				print "Warning: -cpp option has been set before. The previous configuration will be overwritten!\n";
       
  1068 			}
       
  1069 			$cppoption = 1;
       
  1070 			$preprocessor = $1;
       
  1071 			$preprocessor =~ s-\\-\/-g;
       
  1072 			$preprocessor =~ s-EPOCROOT##\/?-$epocroot-g;
       
  1073 			if (-d $preprocessor)
       
  1074 			{
       
  1075 				$preprocessor .= "\/" unless $preprocessor =~ /\/$/;
       
  1076 				$preprocessor .= "cpp";
       
  1077 			}
       
  1078 			next;
       
  1079 		}
       
  1080 
  1024 		if ($arg =~ /^-prependepocroot$/)
  1081 		if ($arg =~ /^-prependepocroot$/)
  1025 		{
  1082 		{
  1026 			$prependepocroot = 1;
  1083 			$prependepocroot = 1;
  1027 			next;
  1084 			next;
  1028 		}
  1085 		}
  1072 					$ZDirloc .= "\/"; 
  1129 					$ZDirloc .= "\/"; 
  1073 				}
  1130 				}
  1074 				if( $ZDirloc !~ m/:/)
  1131 				if( $ZDirloc !~ m/:/)
  1075 				{
  1132 				{
  1076 					print "drive letter not specified\n";
  1133 					print "drive letter not specified\n";
  1077 					$ZDirloc = &datadriveimage::setPath($ZDirloc);
  1134 					$ZDirloc = $thisdir.$ZDirloc;
  1078 				}
  1135 				}
  1079 				print "Z Drive directory location = $ZDirloc\n";
  1136 				print "Z Drive directory location = $ZDirloc\n";
  1080 				#set the location of Z Drive directory.
  1137 				#set the location of Z Drive directory.
  1081 				$ZDirloc .= "zdrive";
  1138 				$ZDirloc .= "zdrive";
  1082 			}
  1139 			}
  1102 					$DataDriveDirloc .= "\/"; 
  1159 					$DataDriveDirloc .= "\/"; 
  1103 				}
  1160 				}
  1104 				if( $DataDriveDirloc !~ m/:/)
  1161 				if( $DataDriveDirloc !~ m/:/)
  1105 				{
  1162 				{
  1106 					print "drive not specified\n";
  1163 					print "drive not specified\n";
  1107 					$DataDriveDirloc = &datadriveimage::setPath($DataDriveDirloc);
  1164 					$DataDriveDirloc = $thisdir.$DataDriveDirloc;
  1108 				}
  1165 				}
  1109 				print "Data Drive directory location = $DataDriveDirloc\n";
  1166 				print "Data Drive directory location = $DataDriveDirloc\n";
  1110 				#set the location of Data Drive directory.
  1167 				#set the location of Data Drive directory.
  1111 				$DataDriveDirloc .= "datadrive";
  1168 				$DataDriveDirloc .= "datadrive";
  1112 			}
  1169 			}
  1197 	if (@obyfiles<1)
  1254 	if (@obyfiles<1)
  1198 	{
  1255 	{
  1199 	    print "Missing obyfile argument\n";
  1256 	    print "Missing obyfile argument\n";
  1200 	    $errors++ if(!$opt_k);
  1257 	    $errors++ if(!$opt_k);
  1201 	}
  1258 	}
       
  1259 	if(defined($obycharset))
       
  1260 	{
       
  1261 		unless($obycharset =~ /utf-?8/i)
       
  1262 		{
       
  1263 			print "Warning: Ignoring not supportted charset $obycharset, local charset will be used as default!\n";
       
  1264 		}
       
  1265 	}
  1202 
  1266 
  1203 	if ($errors)
  1267 	if ($errors)
  1204 	{
  1268 	{
  1205 	    print_usage();
  1269 	    print_usage();
  1206 	    exit 1;
  1270 	    exit 1;
  1285 	{
  1349 	{
  1286 		# no feature variant so use the standard includes
  1350 		# no feature variant so use the standard includes
  1287 		$cppargs .= " -I. -I \"$rominclude\"";
  1351 		$cppargs .= " -I. -I \"$rominclude\"";
  1288 	}
  1352 	}
  1289 
  1353 
  1290 	print "* cpp -Wno-endif-labels -o $temp1OBYFile $cppargs\n" if ($opt_v);
  1354 	if ($stdcpp)
       
  1355 	{
       
  1356 		$preprocessor = find_stdcpp();
       
  1357 	}
       
  1358 	print "* $preprocessor -Wno-endif-labels -o $temp1OBYFile $cppargs\n" if ($opt_v);
  1291 	
  1359 	
  1292 	is_existinpath("cpp", romutl::DIE_NOT_FOUND);
  1360 	is_existinpath("$preprocessor", romutl::DIE_NOT_FOUND);
  1293 	$errors = 0;
  1361 	$errors = 0;
  1294 	open CPP, "| cpp -Wno-endif-labels -o $temp1OBYFile $cppargs" or die "* Can't execute cpp";
  1362 	open CPP, "| $preprocessor -Wno-endif-labels -o $temp1OBYFile $cppargs" or die "* Can't execute cpp";
  1295 	foreach my $arg (@obyfiles)
  1363 	foreach my $arg (@obyfiles)
  1296 	{
  1364 	{
  1297 		print CPP "\n#line 1 \"$arg\"\n";
  1365 		print CPP "\n#line 1 \"$arg\"\n";
  1298 	
  1366 	
  1299 		if(open(OBY, $arg)) {
  1367 		if(open(OBY, $arg)) {
  1327 		&ImageContentHandler::GenObyFile($temp1OBYFile);
  1395 		&ImageContentHandler::GenObyFile($temp1OBYFile);
  1328 	}
  1396 	}
  1329 
  1397 
  1330 	# Setup default rom configuration
  1398 	# Setup default rom configuration
  1331 	$romimage[0] = {xip=>1, compress=>0, extension=>0, composite=>"none",uncompress=>0 };
  1399 	$romimage[0] = {xip=>1, compress=>0, extension=>0, composite=>"none",uncompress=>0 };
       
  1400 	if($obycharset =~ /utf-?8/i)
       
  1401 	{
       
  1402 		my $utf8file = $thisdir."tmp1utf8.oby";
       
  1403 		open INFILE, "<$temp1OBYFile" or die "* Can't open file $temp1OBYFile";
       
  1404 		open CHARSETTRAN, "| charsettran -to=hostcharset > $utf8file" or die "* Can't execute charsetran";
       
  1405 		while(<INFILE>)
       
  1406 		{
       
  1407 			print CHARSETTRAN $_;
       
  1408 		}
       
  1409 		close CHARSETTRAN;
       
  1410 		close INFILE;	
       
  1411 		unlink $temp1OBYFile  or die "* Can't remove file $temp1OBYFile";
       
  1412 		rename 	$utf8file, $temp1OBYFile or die "* Can't rename file $utf8file to file $temp1OBYFile";
       
  1413 	}
  1332 }
  1414 }
  1333 
  1415 
  1334 sub ReadPreprocessedFile
  1416 sub ReadPreprocessedFile
  1335 {
  1417 {
  1336 #	Read the OBY file that was generated by the pre-processor. This OBY is a conglomeration of all the OBYs
  1418 #	Read the OBY file that was generated by the pre-processor. This OBY is a conglomeration of all the OBYs
  2122 				push @linesArray, $modifiedLine;
  2204 				push @linesArray, $modifiedLine;
  2123 				$line = "REM handled $line";
  2205 				$line = "REM handled $line";
  2124 			}
  2206 			}
  2125 			elsif($smrImageStartRegion && !$smrImageEndRegion)
  2207 			elsif($smrImageStartRegion && !$smrImageEndRegion)
  2126 			{
  2208 			{
  2127 				if($line =~ /^\s*IMAGENAME\s*=\s*(\S+)/i)
  2209 				if($line =~ /^(\s*IMAGENAME\s*=\s*)(\S+)/i)
  2128 				{
  2210 				{
  2129 					my $smrimagename = $1;
  2211 					my $front = $1;
       
  2212 					my $smrimagename = $2;
       
  2213 					if ($smrimagename !~ /^.:/ && $smrimagename !~ /^[\\\/]/)
       
  2214 					{
       
  2215 						$smrimagename = $thisdir.$smrimagename;
       
  2216 					}
  2130 					$smrimagename =~s/(\.img)//i;
  2217 					$smrimagename =~s/(\.img)//i;
  2131 					if(exists($smrNameInfo{$smrimagename}))
  2218 					if(exists($smrNameInfo{$smrimagename}))
  2132 					{
  2219 					{
  2133 						$smrNameInfo{$smrimagename}++;
  2220 						$smrNameInfo{$smrimagename}++;
  2134 					}
  2221 					}
  2135 					else
  2222 					else
  2136 					{
  2223 					{
  2137 						$smrNameInfo{$smrimagename} = 1;
  2224 						$smrNameInfo{$smrimagename} = 1;
  2138 					}
  2225 					}
  2139 					$line =~s/(\.img)//i;
  2226 					push @linesArray, "$front$smrimagename\n";
  2140 				}
  2227 				}else
  2141 				push @linesArray, $line;
  2228 				{
       
  2229 					push @linesArray, $line;
       
  2230 				}
  2142 				$line = "REM handled $line";
  2231 				$line = "REM handled $line";
  2143 			}
  2232 			}
  2144 		}
  2233 		}
  2145 		elsif (scalar @currentpartition)
  2234 		elsif (scalar @currentpartition)
  2146 		{
  2235 		{
  3162 			{
  3251 			{
  3163    				# No suitable alternative was found, so comment out the line unless
  3252    				# No suitable alternative was found, so comment out the line unless
  3164 				# it is a manatory ROMBUILD keyword, in which case it is better
  3253 				# it is a manatory ROMBUILD keyword, in which case it is better
  3165 				# to let ROMBUILD report the missing file rather than report the
  3254 				# to let ROMBUILD report the missing file rather than report the
  3166 				# missing keyword.
  3255 				# missing keyword.
  3167    				if ($what !~ /^bootbinary|variant|primary|secondary|hide|dir/i)
  3256    				if ($what !~ /^bootbinary|variant|primary|secondary|hide|dir|imagename/i)
  3168 				{
  3257 				{
  3169    					$line = "REM MISSING " . $line;
  3258    					$line = "REM MISSING " . $line;
  3170    					print_source_error("Missing file: '$filename' in statement '$what='");
  3259    					print_source_error("Missing file: '$filename' in statement '$what='");
  3171 					print "\ttried @alternatives\n"  if ($opt_v && @alternatives > 1);
  3260 					print "\ttried @alternatives\n"  if ($opt_v && @alternatives > 1);
  3172    					# treat as an error if the strict option is selected.
  3261    					# treat as an error if the strict option is selected.
  4101 		# write data drive oby file.
  4190 		# write data drive oby file.
  4102 		elsif ($line =~ /^\s*REM DATA_IMAGE\[(\d+)\]\s+(.*)$/i)
  4191 		elsif ($line =~ /^\s*REM DATA_IMAGE\[(\d+)\]\s+(.*)$/i)
  4103 		{
  4192 		{
  4104 				my $dataimageidx=$1;
  4193 				my $dataimageidx=$1;
  4105 				close DUMPFILE;
  4194 				close DUMPFILE;
       
  4195 				my $name = $datadriveimage[$dataimageidx]{name};
       
  4196 				if ($name !~ /^.:/ && $name !~ /^[\\\/]/)
       
  4197 				{
       
  4198 					$datadriveimage[$dataimageidx]{name} = $thisdir.$name;
       
  4199 				}
  4106 				$dumpfile="$datadriveimage[$dataimageidx]{name}";
  4200 				$dumpfile="$datadriveimage[$dataimageidx]{name}";
  4107 				$datadriveimage[$dataimageidx]{obeyfile}=$dumpfile;
  4201 				$datadriveimage[$dataimageidx]{obeyfile}=$dumpfile;
  4108 				$dumpfile .= ".oby";
  4202 				$dumpfile .= ".oby";
  4109 				open DUMPFILE, ">$dumpfile" or die("* Can't create $dumpfile\n");		
  4203 				open DUMPFILE, ">$dumpfile" or die("* Can't create $dumpfile\n");		
  4110 				print "* Writing $dumpfile - intermediate OBY file\n";
  4204 				print "* Writing $dumpfile - intermediate OBY file\n";
  4183 #
  4277 #
  4184 
  4278 
  4185 sub run_rombuilder
  4279 sub run_rombuilder
  4186 {
  4280 {
  4187 	my ($command, $obeyfile, $logfile) = @_;
  4281 	my ($command, $obeyfile, $logfile) = @_;
  4188 	$command .= " $obeyfile.oby";
  4282 	$command .= " -logfile=$logfile $obeyfile.oby";
  4189 	#CR1258 test cases are depending on the following output.
  4283 	#CR1258 test cases are depending on the following output.
  4190 	print "* Executing $command\n" if ($opt_v);
  4284 	print "* Executing $command\n" if ($opt_v);
  4191 
  4285 
  4192 	open DATA, "$command 2>&1 |"   or die "Couldn't execute command: $command";
  4286 	open DATA, "$command 2>&1 |"   or die "Couldn't execute command: $command";
  4193 	while ( defined( my $line = <DATA> ) ) {
  4287 	while ( defined( my $line = <DATA> ) ) {
  4304 			}                        
  4398 			}                        
  4305 			if ($xip)
  4399 			if ($xip)
  4306 			{
  4400 			{
  4307 				is_existinpath("rombuild", romutl::DIE_NOT_FOUND);
  4401 				is_existinpath("rombuild", romutl::DIE_NOT_FOUND);
  4308 				$rombuild .= " -symbols" unless($nosymbols) ;
  4402 				$rombuild .= " -symbols" unless($nosymbols) ;
  4309 				run_rombuilder($rombuild.$compress, $obeyfile, "ROMBUILD.LOG");
  4403 				run_rombuilder($rombuild.$compress, $obeyfile, $thisdir."ROMBUILD.LOG");
  4310 			}
  4404 			}
  4311 			else
  4405 			else
  4312 			{
  4406 			{
  4313 				# efficient_rom_paging.pm can move everything to core rom.
  4407 				# efficient_rom_paging.pm can move everything to core rom.
  4314 				# If that is the case, don't run rofsbuild at all to avoid errors.
  4408 				# If that is the case, don't run rofsbuild at all to avoid errors.
  4331 					is_existinpath("rofsbuild", romutl::DIE_NOT_FOUND);
  4425 					is_existinpath("rofsbuild", romutl::DIE_NOT_FOUND);
  4332 					if(!$nosymbols)
  4426 					if(!$nosymbols)
  4333 					{
  4427 					{
  4334 						$rofsbuild .= " -symbols";
  4428 						$rofsbuild .= " -symbols";
  4335 					}			
  4429 					}			
  4336 					run_rombuilder($rofsbuild.$compress, $obeyfile, "ROFSBUILD.LOG");
  4430 					run_rombuilder($rofsbuild.$compress, $obeyfile, $thisdir."ROFSBUILD.LOG");
  4337 				}
  4431 				}
  4338 			}
  4432 			}
  4339 			unlink "rombuild.log";
  4433 			unlink "rombuild.log";
  4340 			unlink "maksym.out";
  4434 			unlink "maksym.out";
  4341 		}
  4435 		}
  4800 	{
  4894 	{
  4801 		print "\n SMR image creating error for empty image name!\n";
  4895 		print "\n SMR image creating error for empty image name!\n";
  4802 	}
  4896 	}
  4803 }
  4897 }
  4804 
  4898 
       
  4899 sub getWorkdir
       
  4900 {
       
  4901 	return $thisdir;
       
  4902 }
       
  4903 
       
  4904 sub find_stdcpp
       
  4905 {
       
  4906     return "cpp" if (!$stdcpp);
       
  4907     return "cpp" if (&is_linux);
       
  4908     
       
  4909     my $delimiter = &env_delimiter;
       
  4910 		$ENV{PATH}="${epocroot}epoc32\/gcc_mingw\/bin$delimiter".$ENV{PATH};
       
  4911     my @paths;
       
  4912  		@paths = split(/$delimiter/, $ENV{PATH});
       
  4913     unshift @paths, "\.";
       
  4914     
       
  4915     foreach my $path (@paths)
       
  4916     {
       
  4917         next if ($path =~ /^\s*$/);
       
  4918         chomp $path;
       
  4919         $path =~ s/\\/\//g;
       
  4920         $path .= "\/" unless ($path =~ /\/$/);
       
  4921         $path = $path."cpp.exe";
       
  4922         if (-e $path)
       
  4923         {
       
  4924 		        $path = "\"$path\"";
       
  4925         		my $command = "$path --version 2>&1";
       
  4926 						open DATA, "$command |"   or die "Couldn't execute command: $command\n";
       
  4927 						my $line = <DATA>;
       
  4928 						chomp($line);
       
  4929 						print "$line\n" if($opt_v);
       
  4930 						if ($line =~ /cpp\.exe \(GCC\) .* \(mingw special\)/)
       
  4931 						{
       
  4932 							print "found stdcpp in $path\n" if($opt_v);
       
  4933 							close DATA;
       
  4934 							return $path;
       
  4935 						}
       
  4936 						close DATA;
       
  4937         }
       
  4938     }
       
  4939     die "Error: Cannot found standard cpp.exe in the PATH.\n";
       
  4940 } 
       
  4941 
  4805 sub checkcase()
  4942 sub checkcase()
  4806 {
  4943 {
  4807 	if (&is_windows)
  4944 	if (&is_windows)
  4808 	{
  4945 	{
  4809 		my @checkcase_obydatatemp = @obydata;
  4946 		my @checkcase_obydatatemp = @obydata;