# HG changeset patch # User Bob Rosenberg # Date 1273159898 -3600 # Node ID 280dc2a9385bc799b68bc524381ee0bfac05b5c5 # Parent 6337e330f518e5e51ccdbad43609f829cd00e881 Extra warnings, help and bug fixes in sysdeftools perl scripts. Support for 3.0.1 sysdef syntax (replacing when merging) diff -r 6337e330f518 -r 280dc2a9385b sysdeftools/joinsysdef-module.xsl --- a/sysdeftools/joinsysdef-module.xsl Thu May 06 16:24:41 2010 +0100 +++ b/sysdeftools/joinsysdef-module.xsl Thu May 06 16:31:38 2010 +0100 @@ -23,8 +23,9 @@ ERROR: Cannot process this document + - + @@ -48,7 +49,7 @@ Cannot set "", already set - + @@ -90,7 +91,7 @@ - + @@ -108,7 +109,7 @@ - + @@ -193,6 +194,74 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -371,7 +440,7 @@ - + diff -r 6337e330f518 -r 280dc2a9385b sysdeftools/joinsysdef.pl --- a/sysdeftools/joinsysdef.pl Thu May 06 16:24:41 2010 +0100 +++ b/sysdeftools/joinsysdef.pl Thu May 06 16:31:38 2010 +0100 @@ -74,8 +74,9 @@ if($path eq '') {$path = '/os/deviceplatformrelease/foundation_system/system_model/system_definition.xml'} +($#ARGV == -1 ) && &help(); +my $sysdef = &abspath(shift); # resolve the location of the root sysdef -my $sysdef = &abspath(shift); # resolve the location of the root sysdef @@ -93,6 +94,9 @@ my $sysdefdoc = $parser->parsefile ($sysdef); +my $maxschema = $sysdefdoc->getDocumentElement()->getAttribute('schema'); # don't check value, just store it. + + # find all the namespaces used in all trhe fragments and use that # to set the namespaces ni the root element of the created doc # should be able to optimise by only parsing each doc once and @@ -129,6 +133,10 @@ { $docroot->setAttribute('id-namespace',$nsmap{''}); } + +$docroot->setAttribute('schema',$maxschema); # output has the largest syntax version of all includes + + while(my($pre,$uri) = each(%nsmap)) { $pre ne '' || next ; @@ -220,7 +228,7 @@ my $file = &resolvePath($file,$link); if(-e $file) { - &combineLink($node,&resolveURI($file,$link)); + &combineLink($node,$file); } else { @@ -271,11 +279,14 @@ } # if we're here we can just embed the file # no processing logic is done! It's just embedded blindly - my $metadoc = $parser->parsefile ($link); - my $item = $metadoc->getDocumentElement; + my $item; + eval { + my $metadoc = $parser->parsefile ($link); + $item = $metadoc->getDocumentElement; + }; if(!$item) { - print STDERR "Warning: Could not process metadata file: $link\n"; + print STDERR "Error: Could not process metadata file: $link\n"; next; # do not alter children } $node->removeAttribute('href'); @@ -319,7 +330,7 @@ $getfromfile eq '' && return; # already raised warning, no need to repeat my $doc = $parser->parsefile ($getfromfile); my $item =&firstElement($doc->getDocumentElement); - $item || die "badly formatted $file"; + $item || die "badly formatted $file"; &fixIDs($item); my %up = &atts($node); my %down = &atts($item); @@ -567,6 +578,7 @@ if(-e $link) { my $doc = $parser->parsefile ($link); + &checkSyntaxVersion($doc->getDocumentElement->getAttribute('schema')); # ensure we track we highest syntax number my @docns = &namespaces($link,$doc->getDocumentElement); undef $doc; return (@res,@docns); @@ -743,3 +755,43 @@ close CPP; $? && die "Call to cpp produced an error"; } + +sub checkSyntaxVersion + { # check if supplied version number is greater than $maxschema + my $schema = shift; + my @max=split(/\./,$maxschema); + my @cur=split(/\./,$schema); + while(@max) + { + ($max[0] > $cur[0]) && return; # max is bigger, do nothing + if($cur[0] > $max[0]) + { + $maxschema=$schema; + return; + } + shift @max; + shift @cur; + } + # they are equal - do nothing + } + +sub help + { + my $name= $0; $name=~s,^.*[\\/],,; + print STDERR "usage: $name [options...] sysdef\n\nvalid options are:\n", + " -path\tspecifies the full system-model path to the file which is being processed. By default this is \"/os/deviceplatformrelease/foundation_system/system_model/system_definition.xml\"\n", + "\t\tThis must be an absolute path if you're processing a root sysdef.\n", + "\t\tIf processing a pkgdef file, you can use \"./package_definition.xml\" to leave all links relative.\n\n", + + " -output\tspecifies the file to save the output to. If not specified this will write to stdout\n\n", + + " -config\tspecifies the name of an .hrh file in which the configuration data is acquired from. If not set, no confguration will be done.\n", + "\t\tIf it is set, all configuration metadata will be processed and stripped from the output, even if the confguration data is empty\n\n", + " -I[path]\tspecifies the include paths to use when resolving #includes in the .hrh file. This uses the same syntax as cpp command uses: a captial \"I\" followed by the path with no space in between. Any number of these can be provided.\n"; + + + exit(1); + } + + + diff -r 6337e330f518 -r 280dc2a9385b sysdeftools/mergesysdef-module.xsl --- a/sysdeftools/mergesysdef-module.xsl Thu May 06 16:24:41 2010 +0100 +++ b/sysdeftools/mergesysdef-module.xsl Thu May 06 16:31:38 2010 +0100 @@ -42,7 +42,7 @@ - + @@ -59,8 +59,8 @@ - - + + @@ -77,7 +77,7 @@ - + @@ -93,7 +93,7 @@ - + @@ -121,7 +121,7 @@ - + @@ -135,7 +135,13 @@ - + + + + + + + @@ -183,6 +189,7 @@ + @@ -192,6 +199,7 @@ + @@ -199,6 +207,7 @@ + @@ -357,12 +366,28 @@ + - + - - + + + + Note: "" + overridden in downstream sysdef + replaced by "" + + + + + + + + + + + @@ -410,9 +435,16 @@ - + + + + + + + + @@ -435,6 +467,7 @@ + @@ -448,8 +481,11 @@ + + + - + @@ -489,12 +525,10 @@ - - - - - - + + + + @@ -508,11 +542,27 @@ + + + + + + + + + + + + + + + + - + @@ -522,12 +572,10 @@ - - - - - - + + + + diff -r 6337e330f518 -r 280dc2a9385b sysdeftools/mergesysdef.xsl --- a/sysdeftools/mergesysdef.xsl Thu May 06 16:24:41 2010 +0100 +++ b/sysdeftools/mergesysdef.xsl Thu May 06 16:31:38 2010 +0100 @@ -77,7 +77,21 @@ - + + + + + + + + + + + + + + + diff -r 6337e330f518 -r 280dc2a9385b sysdeftools/rootsysdef.pl --- a/sysdeftools/rootsysdef.pl Thu May 06 16:24:41 2010 +0100 +++ b/sysdeftools/rootsysdef.pl Thu May 06 16:31:38 2010 +0100 @@ -118,6 +118,10 @@ my $fragment = $parser->parsefile ($_); my $fdoc = $fragment->getDocumentElement(); my $topmost =&firstElement($fdoc); + if(!$topmost) { + print STDERR "$warning: $_ has no content. Skipping\n"; + next; + } my $type = $topmost->getTagName; my $id = $topmost->getAttribute('id'); my ($localid,$ns) = &idns($topmost,$id); @@ -356,6 +360,7 @@ elsif($tag eq 'meta') { &fixHref($node,$file); + foreach my $child (@{$node->getChildNodes}) {$node->removeChild($child)} # can't have children &processMeta($node); next; } @@ -524,7 +529,7 @@ sub guessIdInPath { my $id = shift; - my @path = reverse(split(/\//,shift)); + my @path = reverse(split(/\//,$_[0])); while(@path) { my $dir = shift(@path); @@ -533,6 +538,12 @@ return ($id,@path); } } + print STDERR "$warning: Non-standard ID $id in $_[0]\n"; + @path = reverse(split(/\//,$_[0])); + if($path[0] eq 'package_definition.xml') + { + return @path[1..$#path]; + } } @@ -567,6 +578,7 @@ my $node = shift; my $doc = $node->getOwnerDocument; my $id = shift; + if($id eq '') {return} my $fullid=$id; my $contents = shift; my $tag = &childTag($node->getTagName()); @@ -638,7 +650,7 @@ my $pre = $a; if($pre=~s/^xmlns://) { - if($node->getAttribute ($a) eq $ns) {return $pre} + if($root->getAttribute ($a) eq $ns) {return $pre} } } die "ERROR: no namespace prefix defined for $ns"; @@ -672,6 +684,7 @@ $node->getParentNode->removeChild($node); return; } + foreach my $child (@{$node->getChildNodes}) {$node->removeChild($child)} # can't have children if($output eq '') { $path=~s,^/?,file:///,; @@ -695,6 +708,7 @@ { $node->setAttribute('href',&relativeTo(&abspath($output),$file,'file')); } + while(my $child = $node->getFirstChild ) {$node->removeChild($child)} }