imgtools/buildrom/tools/buildrom.pm
changeset 651 0d0d83e3702d
parent 647 53d1ab72f5bc
equal deleted inserted replaced
650:8f038057ffa5 651:0d0d83e3702d
   265 
   265 
   266 my $sourcefile;
   266 my $sourcefile;
   267 my $sourceline;
   267 my $sourceline;
   268 #my $line;
   268 #my $line;
   269 my %romfiles;
   269 my %romfiles;
       
   270 my %ibyfiles; # record the iby file for each ROM file
   270 
   271 
   271 # To handle BINARY_SELECTION_ORDER macro.
   272 # To handle BINARY_SELECTION_ORDER macro.
   272 my $firstDIR;
   273 my $firstDIR;
   273 my $binarySelectionOrderFlag = 0;
   274 my $binarySelectionOrderFlag = 0;
   274 
   275 
   766 
   767 
   767 	if (!defined $paramFileFlag) 
   768 	if (!defined $paramFileFlag) 
   768 	{
   769 	{
   769 		# Enforce Feature Manager if macro SYMBIAN_FEATURE_MANAGER is defined in the HRH file.
   770 		# Enforce Feature Manager if macro SYMBIAN_FEATURE_MANAGER is defined in the HRH file.
   770 		my @hrhMacros = &get_variantmacrolist;	
   771 		my @hrhMacros = &get_variantmacrolist;	
       
   772 		die("No system-wide #defines??!") if (scalar @hrhMacros == 0);	
   771 		if (grep /^SYMBIAN_FEATURE_MANAGER\s*$/, @hrhMacros)
   773 		if (grep /^SYMBIAN_FEATURE_MANAGER\s*$/, @hrhMacros)
   772 		{
   774 		{
   773 			$enforceFeatureManager = 1;
   775 			$enforceFeatureManager = 1;
   774 		}
   776 		}
   775 		
   777 		
  1647  			# If the line matches with above syntax, just add the line into oby file.
  1649  			# If the line matches with above syntax, just add the line into oby file.
  1648  			if($new_line !~ /^\s*(\S+)\s+addr\s+(\S+)\s+(\S+)\s+(\S+)\s*$/i)
  1650  			if($new_line !~ /^\s*(\S+)\s+addr\s+(\S+)\s+(\S+)\s+(\S+)\s*$/i)
  1649  			{
  1651  			{
  1650  				if(AddDllDataInfo($new_line))
  1652  				if(AddDllDataInfo($new_line))
  1651  				{
  1653  				{
  1652  					$line = "REM $line";
  1654  					# wasn't a valid line, so comment it out
       
  1655 					$line = "REM $line";
       
  1656  				}
       
  1657  				else
       
  1658  				{
       
  1659  					# valid patchdata command, retain it for final processing (during reformat_line!)
       
  1660  					# In expectation that it will be OK later, emit the "REM processed" marker here
       
  1661  					push @obydata, "REM processed $line";
       
  1662  					push @obydata, reassert_sourceline();
  1653  				}
  1663  				}
  1654  			}
  1664  			}
       
  1665  			push @obydata, "$line";
       
  1666  			next;
  1655 		}
  1667 		}
  1656 
  1668 
  1657 		if($line =~ /^\s*FEATURE\s*(.*)/i || $line =~ /^\s*EXCLUDE_FEATURE\s*(.*)/i)
  1669 		if($line =~ /^\s*FEATURE\s*(.*)/i || $line =~ /^\s*EXCLUDE_FEATURE\s*(.*)/i)
  1658 		{
  1670 		{
  1659 			# Process the feature keywords only when "-f|fr" or "-fm" is passed to buildrom
  1671 			# Process the feature keywords only when "-f|fr" or "-fm" is passed to buildrom
  1812 		}
  1824 		}
  1813 		
  1825 		
  1814 		if ($line=~/^\s*ROMBUILD_OPTION\s+(\S+)\s*/i)
  1826 		if ($line=~/^\s*ROMBUILD_OPTION\s+(\S+)\s*/i)
  1815 		{
  1827 		{
  1816 			$rombuildOptions{$1} = 1;
  1828 			$rombuildOptions{$1} = 1;
  1817 			push @obydata, "REM handled $line";
  1829 			push @obydata, "REM processed $line";
  1818 			next;
  1830 			next;
  1819 		}
  1831 		}
  1820 		
  1832 		
  1821 		if ($line=~/^\s*enable_spi\s*$/i)
  1833 		if ($line=~/^\s*enable_spi\s*$/i)
  1822 		{
  1834 		{
  1823 			if(!($spiset)) {
  1835 			if(!($spiset)) {
  1824 				$createspi=1;
  1836 				$createspi=1;
  1825 			}
  1837 			}
  1826 			push @obydata, "REM handled $line";
  1838 			push @obydata, "REM processed $line";
  1827 			next;
  1839 			next;
  1828 		}
  1840 		}
  1829 		
  1841 		
  1830 		if ($line=~/^\s*disable_spi\s*/i)
  1842 		if ($line=~/^\s*disable_spi\s*/i)
  1831 		{
  1843 		{
  2318 			}
  2330 			}
  2319 			# a partition is specified
  2331 			# a partition is specified
  2320 			# push this line into the currently selected partition
  2332 			# push this line into the currently selected partition
  2321 			my $partition=$currentpartition[-1];
  2333 			my $partition=$currentpartition[-1];
  2322 			push @$partition, $modifiedLine;
  2334 			push @$partition, $modifiedLine;
  2323 			$line="REM handled $line";
  2335 			next; 
  2324 		}
  2336 		}
  2325 		elsif ($line =~ /^\s*SPI_POSITION/i)
  2337 		elsif ($line =~ /^\s*SPI_POSITION/i)
  2326 		{
  2338 		{
  2327 			if(!($createspi && $spiplacement))
  2339 			if(!($createspi && $spiplacement))
  2328 			{
  2340 			{
  2465 		      print_source_error("Invalid Resource name: $pluginResourceName in " . $plugintype . "_PLUGIN :$line");
  2477 		      print_source_error("Invalid Resource name: $pluginResourceName in " . $plugintype . "_PLUGIN :$line");
  2466 		      #treat as error if strict option selected;
  2478 		      #treat as error if strict option selected;
  2467 		      $errors++ if ($strict);
  2479 		      $errors++ if ($strict);
  2468 		    }
  2480 		    }
  2469 
  2481 
       
  2482 		    push @newobydata, "REM expanded $line";
  2470 		    if ($spidatahide)
  2483 		    if ($spidatahide)
  2471 		    {
  2484 		    {
  2472 			push @newobydata, "hide=$fileRomDir\/$pluginFileName\n";
  2485 			push @newobydata, "hide=$fileRomDir\/$pluginFileName\n";
  2473 		    }
  2486 		    }
  2474 		    else
  2487 		    else
  2955 	&FlexLoad_ModuleL("featuresutil");
  2968 	&FlexLoad_ModuleL("featuresutil");
  2956 			
  2969 			
  2957 	# Parse the feature database XML file
  2970 	# Parse the feature database XML file
  2958 	if(!&featuresutil::parseXMLDatabase($featureXml, $featuremanager, $strict))
  2971 	if(!&featuresutil::parseXMLDatabase($featureXml, $featuremanager, $strict))
  2959 	{
  2972 	{
       
  2973 	  print STDERR "Failed to parse feature database XML file $featureXml\n";
  2960 		$featureXml = undef;
  2974 		$featureXml = undef;
  2961 		exit(1) if($strict);
  2975 		exit(1) if($strict);
  2962 	}
  2976 	}
  2963 }
  2977 }
  2964 
  2978 
  3115 			while(defined $featurefilearray[$i][$j])
  3129 			while(defined $featurefilearray[$i][$j])
  3116 			{
  3130 			{
  3117 				my $targetfeaturefile = $thisdir.$featurefilearray[$i][$j]{cfgfile};
  3131 				my $targetfeaturefile = $thisdir.$featurefilearray[$i][$j]{cfgfile};
  3118 				if (!(&featuresutil::createFeatureFile($i,$j,$targetfeaturefile,\@featureslist,$featuremanager))) 
  3132 				if (!(&featuresutil::createFeatureFile($i,$j,$targetfeaturefile,\@featureslist,$featuremanager))) 
  3119 				{
  3133 				{
       
  3134 					print STDERR "Failed to create Feature file $targetfeaturefile\n";
  3120 					$featurefilearray[$i][$j]{cfgfile}= undef;
  3135 					$featurefilearray[$i][$j]{cfgfile}= undef;
  3121 					exit(1) if($strict);					
  3136 					exit(1) if($strict);					
  3122 				}
  3137 				}
  3123 				$j++;
  3138 				$j++;
  3124 			}
  3139 			}
  3729 		my $value = $4;
  3744 		my $value = $4;
  3730 		my ($index, $elementSize);		# For when the symbol is an array, and we're patching one element
  3745 		my ($index, $elementSize);		# For when the symbol is an array, and we're patching one element
  3731 		my $scalarSize;
  3746 		my $scalarSize;
  3732 		
  3747 		
  3733 		if(!defined $DllDataMap{$patchdlldatamap_key}->{dstpath}){
  3748 		if(!defined $DllDataMap{$patchdlldatamap_key}->{dstpath}){
  3734 			print_source_error(" File $romfilename has not been included into ROM image");
  3749 			print_source_error(" Bad patchdata statement: $romfilename has not been included into ROM image");
  3735 			$errors++ if($strict);
  3750 			$errors++ if($strict);
  3736 			$line = "REM $line\n";
  3751 			$line = "REM $line\n";
  3737 			return $line;
  3752 			return $line;
  3738 		}
  3753 		}
  3739 	
  3754 	
  3890 		if ($type =~ /^(alias)$/i
  3905 		if ($type =~ /^(alias)$/i
  3891 			&& $romfile !~ /^sys\\bin\\/i
  3906 			&& $romfile !~ /^sys\\bin\\/i
  3892 			&& $romfile !~ /^sys\/bin/i)
  3907 			&& $romfile !~ /^sys\/bin/i)
  3893 		{
  3908 		{
  3894 			# for multilinguify 'alias'es (generally resource files) 'MustBeSysBin' should not be enforced.
  3909 			# for multilinguify 'alias'es (generally resource files) 'MustBeSysBin' should not be enforced.
  3895 			if(defined($multiLinguifyAlias{$pcfile})) {
  3910 			if($romfile =~ /\.rsc$/i || defined($multiLinguifyAlias{$pcfile})) {
  3896 				return $line;  
  3911 				return $line;  
  3897 			}
  3912 			}
  3898 
  3913 
  3899 			my $filename = "\/$romfile";	# in case no path is specified
  3914 			my $filename = "\/$romfile";	# in case no path is specified
  3900 			$filename = substr $filename, rindex($filename, "\/");
  3915 			$filename = substr $filename, rindex($filename, "\/");
  3929 			# Return the line as it is for non-MustBeSysBin 'alias'es.
  3944 			# Return the line as it is for non-MustBeSysBin 'alias'es.
  3930 			return $line;
  3945 			return $line;
  3931 		}
  3946 		}
  3932 	}
  3947 	}
  3933 	$romfiles{$romfile} = $variant.$pcfile;
  3948 	$romfiles{$romfile} = $variant.$pcfile;
       
  3949 	$ibyfiles{$romfile} = $sourcefile;
  3934 	return "$type$variant=$pcfile \t\"$romfile\"$tail\n";
  3950 	return "$type$variant=$pcfile \t\"$romfile\"$tail\n";
  3935 }
  3951 }
  3936 
  3952 
  3937 my @hidearray;
  3953 my @hidearray;
  3938 
  3954 
  4325 				$prevdir = $dir;
  4341 				$prevdir = $dir;
  4326 				print DIRFILE "\n";
  4342 				print DIRFILE "\n";
  4327 			}
  4343 			}
  4328 	
  4344 	
  4329 			my @sources = split /\n/,$romfiles{$file};
  4345 			my @sources = split /\n/,$romfiles{$file};
  4330 			printf DIRFILE "%-40s\t%s\n", $file, shift @sources;
  4346 			my @ibyfiles = split /\n/,$ibyfiles{$file};
       
  4347 			printf DIRFILE "%-40s\t%s\t%s\n", $file, shift @sources, shift @ibyfiles;
  4331 			while (@sources)
  4348 			while (@sources)
  4332 			{
  4349 			{
  4333 				printf DIRFILE "%39s+\t%s\n", "", shift @sources;
  4350 				printf DIRFILE "%39s+\t%s\t%s\n", "", shift @sources, shift @ibyfiles;
  4334 			}
  4351 			}
  4335 		}
  4352 		}
  4336 		close DIRFILE;
  4353 		close DIRFILE;
  4337 	}
  4354 	}
  4338 }
  4355 }
  4732 		}
  4749 		}
  4733 		elsif($intVal =~ /^(-\d+)$/ or $intVal =~ /^(\d+)$/){		
  4750 		elsif($intVal =~ /^(-\d+)$/ or $intVal =~ /^(\d+)$/){		
  4734 			$newVal = $1;
  4751 			$newVal = $1;
  4735 		}
  4752 		}
  4736 		else{
  4753 		else{
  4737  			print "ERROR: Invalid patchable value at \"$line\"\n";
  4754  			print_source_error("ERROR: Invalid patchable value : $line");
  4738  			$errors++ if($strict);
  4755  			$errors++ if($strict);
  4739  			return 1;
  4756  			return 1;
  4740 		}
  4757 		}
  4741 		$symbolname =~ s/:(\d+)\[(0x)?[0-9a-f]+\]$//i;	# Remove array element specification (:ELEMENT_BIT_SIZE[INDEX]) to get symbol name
  4758 		$symbolname =~ s/:(\d+)\[(0x)?[0-9a-f]+\]$//i;	# Remove array element specification (:ELEMENT_BIT_SIZE[INDEX]) to get symbol name
  4742 
  4759