metatools/sysdeftools/joinsysdef.pl
changeset 636 29e6a24e9521
parent 624 f70b728ea30c
child 657 5720fe8b820c
equal deleted inserted replaced
635:945d232265c4 636:29e6a24e9521
    36 my %defines;
    36 my %defines;
    37 my $defaultns = 'http://www.symbian.org/system-definition';	# needed if no DTD
    37 my $defaultns = 'http://www.symbian.org/system-definition';	# needed if no DTD
    38 my @excludeMetaList;
    38 my @excludeMetaList;
    39 my @cannotExclude= ('link-mapping', 'config');
    39 my @cannotExclude= ('link-mapping', 'config');
    40 my %ID;	# list of all IDs
    40 my %ID;	# list of all IDs
       
    41 my $errCount=0;
    41 
    42 
    42 my @newarg;
    43 my @newarg;
    43 foreach my $a (@ARGV)
    44 foreach my $a (@ARGV)
    44 	{ #extract all -I parameters from the parameter list 
    45 	{ #extract all -I parameters from the parameter list 
    45 	if($a=~s/^-I//)
    46 	if($a=~s/^-I//)
    84 
    85 
    85 my %excludeMeta;
    86 my %excludeMeta;
    86 foreach (@excludeMetaList) {$excludeMeta{$_}=1}	# make list a hash table
    87 foreach (@excludeMetaList) {$excludeMeta{$_}=1}	# make list a hash table
    87 foreach (@cannotExclude)
    88 foreach (@cannotExclude)
    88 	{
    89 	{
    89 	$excludeMeta{$_} && print STDERR "Error: Cannot exclude meta rel=\"$_\"\n";
    90 	if($excludeMeta{$_})
       
    91 		{
       
    92 		print STDERR "Error: Cannot exclude meta rel=\"$_\"\n";
       
    93 		$errCount++;
       
    94 		}
    90 	$excludeMeta{$_}=0
    95 	$excludeMeta{$_}=0
    91 	}	# cannot exclude any of these rel types
    96 	}	# cannot exclude any of these rel types
    92 
    97 
    93 
    98 
    94 # rootmap is a mapping from the filesystem to the paths in the doc
    99 # rootmap is a mapping from the filesystem to the paths in the doc
   165 else
   170 else
   166 	{
   171 	{
   167 	$sysdefdoc->printToFile($output);
   172 	$sysdefdoc->printToFile($output);
   168 	}
   173 	}
   169 
   174 
       
   175 $errCount && die "Fatal syntax errors";
   170  
   176  
   171 sub abspath
   177 sub abspath
   172 	{ 	# normalize the path into an absolute one
   178 	{ 	# normalize the path into an absolute one
   173 	my  ($name,$path) = fileparse($_[0]);
   179 	my  ($name,$path) = fileparse($_[0]);
   174 	$path=~tr,\\,/,;
   180 	$path=~tr,\\,/,;
   254 			my $p = $node->getParentNode();
   260 			my $p = $node->getParentNode();
   255 			my $ptext = $p->getTagName()." \"".$p->getAttribute('id')."\"";
   261 			my $ptext = $p->getTagName()." \"".$p->getAttribute('id')."\"";
   256 			if(defined $ID{$id})
   262 			if(defined $ID{$id})
   257 				{
   263 				{
   258 				print STDERR "Error: duplicate ID: $tag \"$id\" in $ptext matches $ID{$id}\n";
   264 				print STDERR "Error: duplicate ID: $tag \"$id\" in $ptext matches $ID{$id}\n";
       
   265 				$errCount++;
   259 				}
   266 				}
   260 			else 
   267 			else 
   261 				{
   268 				{
   262 				my $p = $node->getParentNode();
   269 				my $p = $node->getParentNode();
   263 				$ID{$id}="$tag in $ptext";
   270 				$ID{$id}="$tag in $ptext";
   318 				$item = $metadoc->getDocumentElement;
   325 				$item = $metadoc->getDocumentElement;
   319 			};
   326 			};
   320 			if(!$item)
   327 			if(!$item)
   321 				{
   328 				{
   322 				print STDERR "Error: Could not process metadata file: $link\n";
   329 				print STDERR "Error: Could not process metadata file: $link\n";
       
   330 				$errCount++;
   323 				next; # do not alter children
   331 				next; # do not alter children
   324 				}
   332 				}
   325 			$node->removeAttribute('href');
   333 			$node->removeAttribute('href');
   326 			&blindCopyInto($node,$item);
   334 			&blindCopyInto($node,$item);
   327 			}
   335 			}
   580 	if($file=~s,file:///([a-zA-Z]:/),$1,) {return $file } # file URI with drive letter
   588 	if($file=~s,file:///([a-zA-Z]:/),$1,) {return $file } # file URI with drive letter
   581 	if($file=~m,file://,) {return $file } # file URI with no drive letter (unit-style). Just pass on as is with leading / and let OS deal with it
   589 	if($file=~m,file://,) {return $file } # file URI with no drive letter (unit-style). Just pass on as is with leading / and let OS deal with it
   582 	if($file=~m,^([a-z0-9][a-z0-9]+):,i)
   590 	if($file=~m,^([a-z0-9][a-z0-9]+):,i)
   583 		{
   591 		{
   584 		print STDERR "ERROR: $1 scheme not supported\n";
   592 		print STDERR "ERROR: $1 scheme not supported\n";
       
   593 		$errCount++;
   585 		return;  # return empty string if not supported.
   594 		return;  # return empty string if not supported.
   586 		} 
   595 		} 
   587 	return $file
   596 	return $file
   588 	}
   597 	}
   589 
   598 
   659 
   668 
   660 sub doCmpConfig
   669 sub doCmpConfig
   661 	{ # configure in or out the units in a component
   670 	{ # configure in or out the units in a component
   662 	my $cmp = shift;	# the component node
   671 	my $cmp = shift;	# the component node
   663 	my @unversioned;	# list of all units with no version attribute (if more than one, they should all have filters defined)
   672 	my @unversioned;	# list of all units with no version attribute (if more than one, they should all have filters defined)
   664 	my %versioned;		# hash table of all units with a specified version, it's a fatal error to hav the same verison twice in one component
   673 	my %versioned;		# hash table of all units with a specified version, it's a fatal error to have the same verison twice in one component
   665 	foreach my $item (@{$cmp->getChildNodes})
   674 	foreach my $item (@{$cmp->getChildNodes})
   666 		{ # populate %versioned and @unversioned to save processsing later
   675 		{ # populate %versioned and @unversioned to save processsing later
   667 		if($item->getNodeType==1 && $item->getTagName eq 'unit')
   676 		if($item->getNodeType==1 && $item->getTagName eq 'unit')
   668 			{
   677 			{
   669 			my $ver = $item->getAttribute('version');
   678 			my $ver = $item->getAttribute('version');
   791 			$defines{$1}=$_;
   800 			$defines{$1}=$_;
   792 			}
   801 			}
   793 		else {die "cannot process $_";}
   802 		else {die "cannot process $_";}
   794 		}
   803 		}
   795 	close CPP;
   804 	close CPP;
   796 	$? && die "Call to cpp produced an error";
   805 	$? && die "Error: Call to cpp produced an error";
   797 	}
   806 	}
   798 
   807 
   799 sub  checkSyntaxVersion
   808 sub  checkSyntaxVersion
   800 	{ # check if supplied version number is greater than $maxschema
   809 	{ # check if supplied version number is greater than $maxschema
   801 	my $schema = shift;
   810 	my $schema = shift;