More extensive error reporting in sysdef perl tools. Allow sysdef merging with an empty upstream model.
authorBob Rosenberg <bob.rosenberg@nokia.com>
Thu, 12 Aug 2010 15:59:45 +0100
changeset 636 29e6a24e9521
parent 635 945d232265c4
child 637 61e7d5b4a187
More extensive error reporting in sysdef perl tools. Allow sysdef merging with an empty upstream model.
metatools/sysdeftools/joinsysdef.pl
metatools/sysdeftools/lib/mergesysdef-module.xsl
metatools/sysdeftools/rootsysdef.pl
--- a/metatools/sysdeftools/joinsysdef.pl	Fri Aug 06 10:52:54 2010 +0100
+++ b/metatools/sysdeftools/joinsysdef.pl	Thu Aug 12 15:59:45 2010 +0100
@@ -38,6 +38,7 @@
 my @excludeMetaList;
 my @cannotExclude= ('link-mapping', 'config');
 my %ID;	# list of all IDs
+my $errCount=0;
 
 my @newarg;
 foreach my $a (@ARGV)
@@ -86,7 +87,11 @@
 foreach (@excludeMetaList) {$excludeMeta{$_}=1}	# make list a hash table
 foreach (@cannotExclude)
 	{
-	$excludeMeta{$_} && print STDERR "Error: Cannot exclude meta rel=\"$_\"\n";
+	if($excludeMeta{$_})
+		{
+		print STDERR "Error: Cannot exclude meta rel=\"$_\"\n";
+		$errCount++;
+		}
 	$excludeMeta{$_}=0
 	}	# cannot exclude any of these rel types
 
@@ -167,6 +172,7 @@
 	$sysdefdoc->printToFile($output);
 	}
 
+$errCount && die "Fatal syntax errors";
  
 sub abspath
 	{ 	# normalize the path into an absolute one
@@ -256,6 +262,7 @@
 			if(defined $ID{$id})
 				{
 				print STDERR "Error: duplicate ID: $tag \"$id\" in $ptext matches $ID{$id}\n";
+				$errCount++;
 				}
 			else 
 				{
@@ -320,6 +327,7 @@
 			if(!$item)
 				{
 				print STDERR "Error: Could not process metadata file: $link\n";
+				$errCount++;
 				next; # do not alter children
 				}
 			$node->removeAttribute('href');
@@ -582,6 +590,7 @@
 	if($file=~m,^([a-z0-9][a-z0-9]+):,i)
 		{
 		print STDERR "ERROR: $1 scheme not supported\n";
+		$errCount++;
 		return;  # return empty string if not supported.
 		} 
 	return $file
@@ -661,7 +670,7 @@
 	{ # configure in or out the units in a component
 	my $cmp = shift;	# the component node
 	my @unversioned;	# list of all units with no version attribute (if more than one, they should all have filters defined)
-	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
+	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
 	foreach my $item (@{$cmp->getChildNodes})
 		{ # populate %versioned and @unversioned to save processsing later
 		if($item->getNodeType==1 && $item->getTagName eq 'unit')
@@ -793,7 +802,7 @@
 		else {die "cannot process $_";}
 		}
 	close CPP;
-	$? && die "Call to cpp produced an error";
+	$? && die "Error: Call to cpp produced an error";
 	}
 
 sub  checkSyntaxVersion
--- a/metatools/sysdeftools/lib/mergesysdef-module.xsl	Fri Aug 06 10:52:54 2010 +0100
+++ b/metatools/sysdeftools/lib/mergesysdef-module.xsl	Thu Aug 12 15:59:45 2010 +0100
@@ -11,7 +11,7 @@
 	Contributors:
 	Description:
 	XSLT module for merging only two sysdef files according to the 3.0.1 rules. 
-		2.x and older syntax not supported and must be converetd before calling.
+		2.x and older syntax not supported and must be converted before calling.
 
 		Requires the including XSLT to also include path-module.xsl
 -->
@@ -212,6 +212,15 @@
 			<xsl:with-param name="down" select="$down"/>
 			<xsl:with-param name="replaces" select="$replaces"/>
 		</xsl:apply-templates>
+
+
+		<!-- tack on any remaining layers -->
+		<xsl:apply-templates mode="merge-copy-of" select="$other/systemModel/layer[not(@before) and not(following-sibling::*[@id=current()/layer/@id]) and not(@id=current()/layer/@id)]">
+			<xsl:with-param name="origin" select="$down"/>
+			<xsl:with-param name="root" select="current()/.."/>
+			<xsl:with-param name="replaces" select="$replaces"/>
+		</xsl:apply-templates>		
+
 	</xsl:copy>
 </xsl:template>
 
@@ -490,15 +499,6 @@
 
 		</xsl:otherwise>
 	</xsl:choose>
-	
-	<xsl:if test="self::layer and not(following-sibling::layer)">	
-		<!-- for the last layer, tack on any remaining layers -->
-		<xsl:apply-templates mode="merge-copy-of" select="$other/layer[not(@before) and not(following-sibling::*[@id=$this/../layer/@id]) and not(@id=$this/../layer/@id)]">
-			<xsl:with-param name="origin" select="$down"/>
-			<xsl:with-param name="root" select="$this/ancestor::SystemDefinition"/>			
-			<xsl:with-param name="replaces" select="$replaces"/>
-		</xsl:apply-templates>		
-	</xsl:if>
 </xsl:template>
 
 
--- a/metatools/sysdeftools/rootsysdef.pl	Fri Aug 06 10:52:54 2010 +0100
+++ b/metatools/sysdeftools/rootsysdef.pl	Thu Aug 12 15:59:45 2010 +0100
@@ -55,7 +55,7 @@
 		"  -w [Note|Warning|Error]\tspecifies prefix text for any notifications. Defautls to Error\n\n",
 		"  -root [dir]\tspecifies the root directory of the filesystem. All globbing will be done relative to this path\n\n",
 
-		"  -glob [wildcard path]\tThe wildcard search to look for pkgdef files. eg  \"\\*\\*\package_definition.xml\". Can specify any number of these.\n",
+		"  -glob [wildcard path]\tThe wildcard search to look for pkgdef files. eg  \"\\*\\*\\package_definition.xml\". Can specify any number of these.\n",
 		"  -placeholders [bool]\tif set, all packages not found in the template will be left in as empty placeholders\n";
 		"  -name [text]\tthe name in <systemModel> to use for the generated root sysdef. If not present, this will use the name from the templat\n";
 	exit(1);
@@ -164,7 +164,13 @@
 
 foreach(keys %add)
 	{
-	my   $fragment = $parser->parsefile ($_);
+
+	my   $fragment;
+	
+	eval {
+		$fragment  = $parser->parsefile ($_);
+	};
+	$fragment || die "could not parse $_";
 	my $fdoc = $fragment->getDocumentElement();
 	my $topmost =&firstElement($fdoc);
 	if(!$topmost) {