imgtools/buildrom/tools/ImageContentHandler.pm
changeset 629 541af5ee3ed9
parent 590 360bd6b35136
equal deleted inserted replaced
628:7c4a911dc066 629:541af5ee3ed9
    13 #
    13 #
    14 # Description: 
    14 # Description: 
    15 #
    15 #
    16 
    16 
    17 # This package processes the Image Content XML, and creates an OBY file to create a Rom image.
    17 # This package processes the Image Content XML, and creates an OBY file to create a Rom image.
    18 package ImageContentHandler;
    18 package imagecontenthandler;
    19 
    19 
    20 
    20 
    21 require Exporter;
    21 require Exporter;
    22 @ISA=qw(Exporter);
    22 @ISA=qw(Exporter);
    23 @EXPORT=qw(
    23 @EXPORT=qw(
    35 );
    35 );
    36 
    36 
    37 use strict;
    37 use strict;
    38 use genericparser;
    38 use genericparser;
    39 use cdfparser;
    39 use cdfparser;
    40 use Dep_Lister;
    40 use dep_lister;
       
    41 use romutl;
    41 
    42 
    42 #Error list
    43 #Error list
    43 my @errors;
    44 my @errors;
    44 
    45 
    45 my %ImageContent=();		#Image details are stored in this tree
    46 my %ImageContent=();		#Image details are stored in this tree
   592 #		The default ABI directory is armv5 unless specified otherwise in the buildrom command-line.
   593 #		The default ABI directory is armv5 unless specified otherwise in the buildrom command-line.
   593 #		The default build directory is urel unless specified otherwise in the buildrom command-line.
   594 #		The default build directory is urel unless specified otherwise in the buildrom command-line.
   594 		$DefaultDirs{ABI_DIR} = 'ARMV5';
   595 		$DefaultDirs{ABI_DIR} = 'ARMV5';
   595 		$DefaultDirs{BUILD_DIR}='urel';
   596 		$DefaultDirs{BUILD_DIR}='urel';
   596 
   597 
   597 		$DefaultDirs{DEST_DIR}= "\\sys\\bin";
   598 		$DefaultDirs{DEST_DIR}= "\/sys\/bin";
   598 
   599 
   599 	}
   600 	}
   600 	else
   601 	else
   601 	{
   602 	{
   602 #		trim the value for leading/trailing whitespace
   603 #		trim the value for leading/trailing whitespace
   654 	open (OBYFH, ">>$ObyFileName") or die("* Can't open $ObyFileName\n");
   655 	open (OBYFH, ">>$ObyFileName") or die("* Can't open $ObyFileName\n");
   655 	my $binRef;
   656 	my $binRef;
   656 	my $line;
   657 	my $line;
   657 	my $index;
   658 	my $index;
   658 	my $new_src_path;
   659 	my $new_src_path;
   659 	my $exec_src_path = $ENV{EPOCROOT};#This is the Executable source path
   660 	my $exec_src_path = &get_epocroot;#This is the Executable source path
   660 	$exec_src_path .= "epoc32\\release\\";
   661 	$exec_src_path .= "epoc32\/release\/";
   661 	my $abidir = $DefaultDirs{ABI_DIR};
   662 	my $abidir = $DefaultDirs{ABI_DIR};
   662 	my $blddir = $DefaultDirs{BUILD_DIR};
   663 	my $blddir = $DefaultDirs{BUILD_DIR};
   663 
   664 
   664 	GenObyHeader(*OBYFH);
   665 	GenObyHeader(*OBYFH);
   665 
   666 
   779 					elsif( exists $binRef->{type} and $binRef->{type} eq "plugin")
   780 					elsif( exists $binRef->{type} and $binRef->{type} eq "plugin")
   780 					{
   781 					{
   781 						if (exists $binRef->{plugin_name})
   782 						if (exists $binRef->{plugin_name})
   782 						{
   783 						{
   783 							$isEcomPlugin=1;
   784 							$isEcomPlugin=1;
   784 							$line = "__$binRef->{plugin_name}_PLUGIN(ABI_DIR\\BUILD_DIR,ECOM_BIN_DIR,DATAZ_,ECOM_RSC_DIR,$binRef->{id},$binRef->{id})\n";
   785 							$line = "__$binRef->{plugin_name}_PLUGIN(ABI_DIR\/BUILD_DIR,ECOM_BIN_DIR,DATAZ_,ECOM_RSC_DIR,$binRef->{id},$binRef->{id})\n";
   785 						}
   786 						}
   786 					}
   787 					}
   787 					else
   788 					else
   788 					{
   789 					{
   789 						$isEcomPlugin=0;
   790 						$isEcomPlugin=0;
   899 			{
   900 			{
   900 				#Check if the binary is from ImageContent XML file.
   901 				#Check if the binary is from ImageContent XML file.
   901 				my $imagecontentbin = 0;
   902 				my $imagecontentbin = 0;
   902 				foreach my $bin (@ImageContentBinaries) {
   903 				foreach my $bin (@ImageContentBinaries) {
   903 					my $source;
   904 					my $source;
   904 					if( $bin->{source} =~ /.*\\(\S+)/)
   905 					if( $bin->{source} =~ /.*[\\\/](\S+)/)
   905 					{
   906 					{
   906 						$source = $1;
   907 						$source = $1;
   907 					}
   908 					}
   908 					if (grep /$binary/i, $source) {#Skip the binary that is already included in the OBY Header
   909 					if (grep /$binary/i, $source) {#Skip the binary that is already included in the OBY Header
   909 						$imagecontentbin = 1;
   910 						$imagecontentbin = 1;
   915 					next;
   916 					next;
   916 				}
   917 				}
   917 				my $obyInfo = &ImageContentHandler::GetObyBinaryInfo($binary);
   918 				my $obyInfo = &ImageContentHandler::GetObyBinaryInfo($binary);
   918 				if(!defined $obyInfo)
   919 				if(!defined $obyInfo)
   919 				{
   920 				{
   920 					$line = "file=" . $exec_src_path. $DefaultDirs{ABI_DIR}. "\\" . $DefaultDirs{BUILD_DIR}. "\\". $binary. " ";
   921 					$line = "file=" . $exec_src_path. $DefaultDirs{ABI_DIR}. "\/" . $DefaultDirs{BUILD_DIR}. "\/". $binary. " ";
   921 					$line .= $DefaultDirs{DEST_DIR}. "\\". $binary;
   922 					$line .= $DefaultDirs{DEST_DIR}. "\/". $binary;
   922 					$line .= "\n";
   923 					$line .= "\n";
   923 					print OBYFH $line;
   924 					print OBYFH $line;
   924 				}
   925 				}
   925 			}
   926 			}
   926 		}
   927 		}
   935 	
   936 	
   936 	my ($abidir, $abiFileRef) = @_;
   937 	my ($abidir, $abiFileRef) = @_;
   937 	my $foundFile=0;
   938 	my $foundFile=0;
   938 	foreach my $BpabiPlat (@BPABIPlats)
   939 	foreach my $BpabiPlat (@BPABIPlats)
   939 	{
   940 	{
   940 		if ($$abiFileRef =~ /^(.*)\\$BpabiPlat\\(.*)$/)
   941 		if ($$abiFileRef =~ /^(.*)[\/\\]$BpabiPlat[\/\\](.*)$/)
   941 		{
   942 		{
   942 			$$abiFileRef =~ s/$abidir/ARMV5/i;
   943 			$$abiFileRef =~ s/$abidir/ARMV5/i;
   943 			if(-f $$abiFileRef)
   944 			if(-f $$abiFileRef)
   944 			{
   945 			{
   945 				$foundFile = 1;
   946 				$foundFile = 1;
  1429 	my ($aBinary) = @_;
  1430 	my ($aBinary) = @_;
  1430 
  1431 
  1431 	my $aAbsFile;
  1432 	my $aAbsFile;
  1432 #	Include the static dependencies.
  1433 #	Include the static dependencies.
  1433 
  1434 
  1434 	my $dir = "$ENV{EPOCROOT}epoc32\\release\\";
  1435 	my $dir = &get_epocroot()."epoc32\/release\/";
  1435 	my $abidir = &ImageContentHandler::GetBldRomOpts("ABI_DIR");
  1436 	my $abidir = &ImageContentHandler::GetBldRomOpts("ABI_DIR");
  1436 	my $blddir = &ImageContentHandler::GetBldRomOpts("BUILD_DIR"); 
  1437 	my $blddir = &ImageContentHandler::GetBldRomOpts("BUILD_DIR"); 
  1437 
  1438 
  1438 	if($aBinary =~ /(.*)\\.*/)
  1439 	if($aBinary =~ /(.*)[\\\/].*/)
  1439 	{
  1440 	{
  1440 		$aBinary =~ s/ABI_DIR/$abidir/i;
  1441 		$aBinary =~ s/ABI_DIR/$abidir/i;
  1441 		$aBinary =~ s/BUILD_DIR/$blddir/i;
  1442 		$aBinary =~ s/BUILD_DIR/$blddir/i;
  1442 		$aBinary =~ s/DEBUG_DIR/udeb/i;
  1443 		$aBinary =~ s/DEBUG_DIR/udeb/i;
  1443 	}
  1444 	}
  1444 	else
  1445 	else
  1445 	{
  1446 	{
  1446 		$dir .= $abidir . "\\";
  1447 		$dir .= $abidir . "\/";
  1447 		$dir .= $blddir. "\\";
  1448 		$dir .= $blddir. "\/";
  1448 	}
  1449 	}
  1449 	$aAbsFile = $dir. $aBinary;
  1450 	$aAbsFile = $dir. $aBinary;
  1450 
  1451 
  1451 	if(!-f $aAbsFile)
  1452 	if(!-f $aAbsFile)
  1452 	{
  1453 	{
  1482 
  1483 
  1483 #	Remove the path portion from the file name if found to get the filename.
  1484 #	Remove the path portion from the file name if found to get the filename.
  1484 #	This is the key into the BinaryInfo map maintained by cdfparser.
  1485 #	This is the key into the BinaryInfo map maintained by cdfparser.
  1485 	my $filename;
  1486 	my $filename;
  1486 
  1487 
  1487 	if( $aBinary =~ /.*\\(\S+)/)
  1488 	if( $aBinary =~ /.*[\\\/](\S+)/)
  1488 	{
  1489 	{
  1489 		$filename = $1;
  1490 		$filename = $1;
  1490 	}
  1491 	}
  1491 	else
  1492 	else
  1492 	{
  1493 	{