# HG changeset patch # User Brendan Donegan brendand@symbian.org # Date 1254910340 -3600 # Node ID f2e526e44405f199b9a142e9ba334e53686ca3b8 # Parent 78ccc60a13b1a4218db9d94c9a0df91a49a28339# Parent 4a27eba1d297b4674dd360aca5b14558dea0cda9 merge diff -r 78ccc60a13b1 -r f2e526e44405 build.xml --- a/build.xml Wed Oct 07 11:09:46 2009 +0100 +++ b/build.xml Wed Oct 07 11:12:20 2009 +0100 @@ -6,7 +6,11 @@ - + + + + + diff -r 78ccc60a13b1 -r f2e526e44405 common/build.postbuild.xml --- a/common/build.postbuild.xml Wed Oct 07 11:09:46 2009 +0100 +++ b/common/build.postbuild.xml Wed Oct 07 11:12:20 2009 +0100 @@ -283,7 +283,8 @@ - + + @@ -296,6 +297,7 @@ + @@ -306,9 +308,10 @@ - + + @@ -484,8 +487,67 @@ files: csv(${build.drive}/output/logs/analysis/tmp_yarp_files.csv,{separator:',',headers:[name,path,localpath]}) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -638,6 +700,46 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff -r 78ccc60a13b1 -r f2e526e44405 common/build.test.xml --- a/common/build.test.xml Wed Oct 07 11:09:46 2009 +0100 +++ b/common/build.test.xml Wed Oct 07 11:12:20 2009 +0100 @@ -159,7 +159,7 @@ - + diff -r 78ccc60a13b1 -r f2e526e44405 common/build.xml --- a/common/build.xml Wed Oct 07 11:09:46 2009 +0100 +++ b/common/build.xml Wed Oct 07 11:12:20 2009 +0100 @@ -23,6 +23,7 @@ + @@ -30,23 +31,14 @@ - - - - - - - - - - - + + @@ -118,7 +110,7 @@ - + @@ -126,6 +118,25 @@ + + + + + + + + + + + + + + + + + +Build Environment Check failed. To stop this failure aborting the build set property sf.suppress.buildenv.check to any value. + @@ -199,23 +210,35 @@ - + [SF-PREBUILD] + + + + + + [SF-DIAMONDS-CONNECT] + + + + + + [SF-DIAMONDS-TAG-BUILD] - - - - ant: antProperties() - - + + + + + + @@ -436,6 +459,14 @@ + + + + + + + + diff -r 78ccc60a13b1 -r f2e526e44405 common/common_props.ant.xml --- a/common/common_props.ant.xml Wed Oct 07 11:09:46 2009 +0100 +++ b/common/common_props.ant.xml Wed Oct 07 11:12:20 2009 +0100 @@ -41,6 +41,7 @@ + @@ -97,8 +98,8 @@ - - + + diff -r 78ccc60a13b1 -r f2e526e44405 common/diamonds/sf-run-analysis.xml.ftl --- a/common/diamonds/sf-run-analysis.xml.ftl Wed Oct 07 11:09:46 2009 +0100 +++ b/common/diamonds/sf-run-analysis.xml.ftl Wed Oct 07 11:12:20 2009 +0100 @@ -34,9 +34,9 @@ log - Build Summary - file:///${ant['sf.spec.publish.networkdrive']}\${ant['sf.spec.job.name']}\builds\${ant['sf.spec.job.codeline']}\${ant['build.id']}\build_summary.html + BRAG Summary + file:///${ant['sf.spec.publish.networkdrive']}\${ant['sf.spec.job.name']}\builds\${ant['sf.spec.job.codeline']}\${ant['build.id']}\summary\_brag.xml - + \ No newline at end of file diff -r 78ccc60a13b1 -r f2e526e44405 common/diamonds/sf-tag-build.xml.ftl --- a/common/diamonds/sf-tag-build.xml.ftl Wed Oct 07 11:09:46 2009 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,8 +0,0 @@ - - - - 10 - - ${ant['sf.spec.publish.diamonds.tag']} - - \ No newline at end of file diff -r 78ccc60a13b1 -r f2e526e44405 common/templates/source-spec.ant.xml.ftl --- a/common/templates/source-spec.ant.xml.ftl Wed Oct 07 11:09:46 2009 +0100 +++ b/common/templates/source-spec.ant.xml.ftl Wed Oct 07 11:12:20 2009 +0100 @@ -17,6 +17,17 @@ <#assign fast_sync = false /> +<#if ("${ant['sf.spec.sourcesync.bug419']}")??> + <#if "${ant['sf.spec.sourcesync.bug419']}" == "true"> + <#assign bug419 = true /> + <#else> + <#assign bug419 = false /> + +<#else> + <#assign bug419 = false /> + + + @@ -55,6 +66,19 @@ + <#if bug419 > + + + + + + + + + + + + <#else> <#if "${pkg_detail.type}"=="tag" > @@ -71,6 +95,7 @@ + diff -r 78ccc60a13b1 -r f2e526e44405 common/tools/ats/bctest/contacts/phonebook/phonebook.xml --- a/common/tools/ats/bctest/contacts/phonebook/phonebook.xml Wed Oct 07 11:09:46 2009 +0100 +++ b/common/tools/ats/bctest/contacts/phonebook/phonebook.xml Wed Oct 07 11:12:20 2009 +0100 @@ -65,7 +65,7 @@ - + @@ -836,7 +836,7 @@ - + @@ -1013,7 +1013,7 @@ - + @@ -1131,7 +1131,7 @@ - + @@ -1367,7 +1367,7 @@ - + @@ -1621,7 +1621,7 @@ - + @@ -1944,7 +1944,7 @@ - + diff -r 78ccc60a13b1 -r f2e526e44405 common/tools/ats/bctest/messaging/messaging.xml --- a/common/tools/ats/bctest/messaging/messaging.xml Wed Oct 07 11:09:46 2009 +0100 +++ b/common/tools/ats/bctest/messaging/messaging.xml Wed Oct 07 11:12:20 2009 +0100 @@ -142,7 +142,7 @@ - + diff -r 78ccc60a13b1 -r f2e526e44405 common/tools/ats/bctest/multimedia/multimediasvs.pl --- a/common/tools/ats/bctest/multimedia/multimediasvs.pl Wed Oct 07 11:09:46 2009 +0100 +++ b/common/tools/ats/bctest/multimedia/multimediasvs.pl Wed Oct 07 11:12:20 2009 +0100 @@ -21,7 +21,7 @@ use File::Path; unlink "multimediatest.zip"; -rmtree "temp" or die "failed : $!"; +rmtree "temp"; mkpath "temp/multimediatest/general/multimedia/t_imagedecoder"; mkpath "temp/multimediatest/general/multimedia/t_imageencoder"; diff -r 78ccc60a13b1 -r f2e526e44405 common/tools/ats/bctest/package_definition.xml --- a/common/tools/ats/bctest/package_definition.xml Wed Oct 07 11:09:46 2009 +0100 +++ b/common/tools/ats/bctest/package_definition.xml Wed Oct 07 11:12:20 2009 +0100 @@ -1,17 +1,50 @@ - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -276,40 +315,41 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff -r 78ccc60a13b1 -r f2e526e44405 common/tools/ats/bctest/syslibs/syslibstest.xml diff -r 78ccc60a13b1 -r f2e526e44405 common/tools/brag/brag.xsl --- a/common/tools/brag/brag.xsl Wed Oct 07 11:09:46 2009 +0100 +++ b/common/tools/brag/brag.xsl Wed Oct 07 11:12:20 2009 +0100 @@ -1,24 +1,52 @@ - + xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fn="http://www.w3.org/2005/xpath-functions"> + + + + + + + - - - Build Status -

Build Status

+

Build Status

+ + + + + + +

+ Overall BRAGG staus: + + BLACK + RED + AMBER + GREEN + GOLD! + +

+ +

Breakdown by severity

+ + + + + + +
Critical
Major
Minor
Unknown
Grand total
+ +

Breakdown by phase/step

- + - + - + @@ -31,26 +59,18 @@
Stage: Phase:
Step: Step:
- - - - - -

Total number of critical errors =

-

Total number of major errors =

-

Total number of minor errors =

-

Total number of unknown errors =

- -

- Final BRAG staus: - - BLACK - RED - AMBER - GREEN - GOLD! - -

+ + +

Breakdown by package

+ + + + + + + +
PackageTotal failures
+
diff -r 78ccc60a13b1 -r f2e526e44405 common/tools/brag/bragForDiamonds.xsl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/common/tools/brag/bragForDiamonds.xsl Wed Oct 07 11:12:20 2009 +0100 @@ -0,0 +1,27 @@ + + + + + + + + + + + 13 + + + + Black + Red + Amber + Green + Gold + + + + + + + + diff -r 78ccc60a13b1 -r f2e526e44405 common/tools/brag/logToBRAG.pl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/common/tools/brag/logToBRAG.pl Wed Oct 07 11:12:20 2009 +0100 @@ -0,0 +1,183 @@ +#!perl -w +# +# Copyright (c) 2009 Symbian Foundation Ltd +# This component and the accompanying materials are made available +# under the terms of the License "Eclipse Public License v1.0" +# which accompanies this distribution, and is available +# at the URL "http://www.eclipse.org/legal/epl-v10.html". +# +# Initial Contributors: +# Symbian Foundation Ltd - initial contribution. +# +# Contributors: +# +# Description: +# Identifies failures in a log file (as determined by a set of rules) and produces a BRAG XML summary + +use strict; + +use Getopt::Long; + +my $phaseName; +my $stepName; +my $rulesFile; +my $help = 0; +GetOptions(( + 'phase=s' => \$phaseName, + 'step=s' => \$stepName, + 'rules=s' => \$rulesFile, + 'help!' => \$help, +)); + +my $wrongArgs = 0; +unless ($help) +{ + $wrongArgs += warn "No phase specified to indicate the phase that the failures fall under\n" unless defined $phaseName; + $wrongArgs += warn "No step specified to indicate the step that the failures fall under\n" unless defined $stepName; + $wrongArgs += warn "No file of rules specified to interpret the log file\n" unless defined $rulesFile; + $wrongArgs += warn "No log files to process\n" unless @ARGV; +} +if ($help || $wrongArgs) +{ + print <<"EOT"; + +logToBRAG.pl --phase=prebuild --step=syncsource --rules=syncsourceRules.tsv presync.log [doSync.log ...] > output.xml +EOT + exit(0 + !$help); +} + +# Do the wild-carding thing +@ARGV = map { glob $_ } @ARGV; + +# Start to build structure to be output as XML (same format as XML::Parser would create for us) +my $xmlNewline = bless { Text => "\n" }, "Characters"; +my $step = bless { + name => $stepName, + Kids => [ $xmlNewline ] +}, "step"; +my $phase = bless { + name => $phaseName, + Kids => [ $xmlNewline, $step, $xmlNewline ] +}, "phase"; +my $buildStatus = [ bless { + Kids => + [ + $xmlNewline, + $phase, + $xmlNewline, + ] +}, "buildStatus"]; + +# Also create empty tags with severities in a sensible order +# And shortcuts to those items +my $severityShortcut = {}; +foreach my $severity (qw{critical major minor}) +{ + my $failureSet = bless { level => $severity, Kids => [ $xmlNewline ] }, "failures"; + push @{$step->{Kids}}, $failureSet, $xmlNewline; + $severityShortcut->{$severity} = $failureSet; +} + +# Read rules file +my @rules; +open(TSV, $rulesFile) or die "Unable to open rules file '$rulesFile'\n"; +while (my $line = ) +{ + chomp $line; + next unless $line; + my @terms = split m{\t+}, $line; + die "Rules file not formatted as expected at line $.\n" unless scalar @terms == 2; + push @rules, { regexp => qr{$terms[0]}, severity => $terms[1] }; +} + +# Iterate through all the lines of all the files in @ARGV +while (my $line = <>) +{ + chomp $line; + foreach my $rule (@rules) + { + if ($line =~ m[$rule->{regexp}]) + { + last if $rule->{severity} eq "ignore"; + # We found a match + my $failure = bless{ Kids => [ bless { Text => $line }, "Characters" ] }, "failure"; + # Ensure we have a tag for this severity + if (!exists $severityShortcut->{$rule->{severity}}) + { + # Create the failure set and add it to the shortcut list too + my $failureSet = bless { level => $rule->{severity}, Kids => [ $xmlNewline ] }, "failures"; + push @{$step->{Kids}}, $failureSet, $xmlNewline; + $severityShortcut->{$rule->{severity}} = $failureSet; + } + push @{$severityShortcut->{$rule->{severity}}->{Kids}}, $failure, $xmlNewline; + # Do not consider any more rules + last; + } + } +} + +# Print XML +print "\n"; +print "\n"; +printTree($buildStatus->[0]); +print "\n"; + +exit(0); + +sub printTree +{ + my $tree = shift or die; + die unless ref $tree; + + my $tagName = ref $tree; + $tagName =~ s{^main::}{}; + if ($tagName eq "Characters") + { + print escapeForXML($tree->{Text}); + return; + } + + print "<$tagName"; + + foreach my $attr ( + sort { + my $order = "name level start stop href"; + my $ixA = index $order, $a; + my $ixB = index $order, $b; + die "$a $b" if $ixA + $ixB == -2; + $ixA - $ixB; + } + grep { + ! ref $tree->{$_} + } + keys %$tree) + { + print " $attr=\"$tree->{$attr}\""; + } + + my $children = $tree->{Kids} || []; + if (scalar @$children) + { + print ">"; + foreach my $child (@$children) + { + printTree($child); + } + print ""; +} + +sub escapeForXML +{ + $_ = shift; + s{&}{&}g; + s{<}{<}g; + s{>}{>}g; + return $_; +} diff -r 78ccc60a13b1 -r f2e526e44405 common/tools/brag/raptorToBRAG.pl --- a/common/tools/brag/raptorToBRAG.pl Wed Oct 07 11:09:46 2009 +0100 +++ b/common/tools/brag/raptorToBRAG.pl Wed Oct 07 11:12:20 2009 +0100 @@ -37,9 +37,23 @@ # Start to build structure to be output as XML (same format as XML::Parser would create for us) my $xmlNewline = bless { Text => "\n" }, "Characters"; -my $data = [bless {name => "build", Kids => [ $xmlNewline ] }, "stage"]; +my $buildStatus = +[ + bless + { + Kids => + [ + $xmlNewline, + bless + { + name => "Build", + Kids => [ $xmlNewline ] + }, "phase", + ] + }, "buildStatus" +]; # Get a shortcut reference to the bit we will use a lot -my $buildStage = $data->[0]; +my $buildPhase = $buildStatus->[0]->{Kids}->[-1]; # READ SUMMARY.CSV FILE open(CSV, $raptorSummary); @@ -63,6 +77,7 @@ next; } + # Populate the hash using a hash slice my $failure = {}; @{$failure}{@keys} = @values; @@ -82,7 +97,7 @@ # Look through the steps to see if we already have one to match this config my $step; - foreach (@{$buildStage->{Kids}}) + foreach (@{$buildPhase->{Kids}}) { next unless ref $_ eq "step"; if ($_->{name} eq $failure->{config}) @@ -95,7 +110,13 @@ { # First item found in this step - create step entry $step = bless { name => $failure->{config}, Kids => [ $xmlNewline ] }, "step"; - push @{$buildStage->{Kids}}, $step, $xmlNewline; + push @{$buildPhase->{Kids}}, $step, $xmlNewline; + # Also create empty tags with severities in a sensible order + foreach my $severity (qw{critical major minor}) + { + my $failureSet = bless { level => $severity, Kids => [ $xmlNewline ] }, "failures"; + push @{$step->{Kids}}, $failureSet, $xmlNewline; + } } # Look through the sets of failures in this step to see if we hve one which matches this severity @@ -117,7 +138,15 @@ } # Now create the failure itself, and add it to this failure set - my $failureItem = bless { href => "", Kids => [ bless { Text => $failure->{subcategory} }, "Characters" ] }, "failure"; + my $failureItem = bless { +# href => "", + Kids => [ bless { Text => $failure->{subcategory} }, "Characters" ] + }, "failure"; + if ($failure->{component}) + { + $failure->{component} =~ s{^(/sf/.*?/.*?)/.*$}{$1}; + $failureItem->{package} = $failure->{component}; + } push @{$failureSet->{Kids}}, $failureItem, $xmlNewline; } close(CSV); @@ -125,7 +154,7 @@ # Print XML print "\n"; print "\n"; -printTree($data->[0]); +printTree($buildStatus->[0]); print "\n"; exit(0); diff -r 78ccc60a13b1 -r f2e526e44405 common/tools/brag/rules.BuildEnvironmentCheck.tsv --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/common/tools/brag/rules.BuildEnvironmentCheck.tsv Wed Oct 07 11:12:20 2009 +0100 @@ -0,0 +1,3 @@ +^SHOWSTOPPER RAISED: critical +^ERROR: major +^WARNING: minor diff -r 78ccc60a13b1 -r f2e526e44405 common/tools/brag/rules.PreprocessPackageConfig.tsv --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/common/tools/brag/rules.PreprocessPackageConfig.tsv Wed Oct 07 11:12:20 2009 +0100 @@ -0,0 +1,1 @@ +^Warning: minor diff -r 78ccc60a13b1 -r f2e526e44405 common/tools/brag/send_xml_to_diamonds.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/common/tools/brag/send_xml_to_diamonds.py Wed Oct 07 11:12:20 2009 +0100 @@ -0,0 +1,162 @@ +command_help = """ +Send XML data from file to Diamonds. v.1.23 +Use: + send_xml_to_diamonds.py options + + Mandatory options: + -s Server address + -u Url + -f path of XML file + + Optional options: + -m Send only mail, without POST connection. Recommend only, + when direct POST connection is not available. + -o mail server. Not needed inside Nokia intranet. + -h help + + Examples: + Sending only by mail, without POST. (not recommended) + send_xml_to_diamonds.py -s diamonds.nmp.nokia.com -u /diamonds/builds/ -f c:\\build.xml -m buildtoolsautomation@nokia.com + + Sending a new build to release instance of Diamonds + send_xml_to_diamonds.py -s diamonds.nmp.nokia.com -u /diamonds/builds/ -f c:\\build.xml + + Updating test results to existing build + send_xml_to_diamonds.py -s diamonds.nmp.nokia.com -u /diamonds/builds/123/ -f c:\\test.xml + + Sending data for Relative Change in SW Asset metrics + send_xml_to_diamonds.py -s diamonds.nmp.nokia.com -u /diamonds/metrics/ -f c:\\relative.xml + + Sending data for Function Coverage + send_xml_to_diamonds.py -s diamonds.nmp.nokia.com -u /diamonds/tests/coverage/ -f c:\\coverage.xml + + Note: If you want to send XML to development version of Diamonds in testing purposes, use + address: trdeli02.nmp.nokia.com:9001 in the server address: + send_xml_to_diamonds.py -s trdeli02.nmp.nokia.com:9001 -u /diamonds/builds/ -f c:\\build.xml +""" + +from httplib import * +import os, sys, time, re + + +def send_email(subject, body, sender, receivers, encoding, mail_server): + """ + Create an email message as MIMEText instance. + """ + from email.Header import Header + from email.MIMEText import MIMEText + from email.Utils import parseaddr, formataddr + import smtplib + + msg = MIMEText(body, "plain", encoding) + msg["To"] = Header(u", ".join(receivers), encoding) + msg["Subject"] = Header(subject, encoding) + + smtp = smtplib.SMTP() + smtp.connect(mail_server) + smtp.sendmail(sender, receivers, msg.as_string()) + smtp.close() + +def get_username(): + platform = sys.platform + if platform == "win32": + return os.getenv("USERNAME") + else: + return os.getlogin() + +def get_mail_subject(sender, server, url): + return "[DIAMONDS_DATA] %s>>>%s>>>%s" % (sender, server, url) + +def get_response_message(response): + return "Response status:%s \ + \nResponse reason:%s\n" \ + % (response.status, response.reason) + +def get_process_time(total_time): + if total_time<=60: + return "%s seconds" % round(total_time, 1) + else: + return "%s minutes and %s seconds" % (int(total_time/60), round((total_time%60), 1)) + +def main(): + start_time = time.time() + server_valid = False + url_valid = False + sfile_valid = False + mail_address = None + mail_server_address = "smtp.nokia.com" + _ = sys.argv.pop(0) + + while sys.argv: + parameter = sys.argv.pop(0) + if re.search('^-', parameter): + if parameter == '-s': + server = sys.argv.pop(0) + server_valid = True + elif parameter == '-u': + url = sys.argv.pop(0) + url_valid = True + elif parameter == '-f': + source_file = sys.argv.pop(0) + sfile_valid = True + try: + xml = open(source_file).read() + except: + sys.exit("Can not open the file %s" % source_file) + elif parameter == '-m': + mail_address = sys.argv.pop(0) + elif parameter == '-o': + mail_server_address = sys.argv.pop(0) + elif parameter == '-h': + sys.exit("HELP:\n %s" % (command_help)) + else: + sys.exit("Incorrect parameter! %s" % (parameter) + command_help ) + else: + sys.exit("Incorrect parameter! %s" % (parameter) + command_help) + if not server_valid or not url_valid or not sfile_valid: + sys.exit("Too few parameters: Use -h for help") + + diamonds_mail_box = "diamonds@diamonds.nmp.nokia.com" + import_failed_message = "XML was not sent successfully to Diamonds via REST interface!\n" + import_succeed_message = "XML was sent successfully to Diamonds via REST interface.\n" + mail_sent_message = "XML was sent to Diamonds by mail. Scheduled script will try to import it to Diamonds. If you can not see data soon in Diamonds, please contact to Diamonds developers.\n" + + if not mail_address: + connection = HTTPConnection(server) + + try: + connection.request("POST", url, xml) + except: + print "Can not connect to the server %s\n" % server + sender = get_username() + send_email(get_mail_subject(sender, server, url), xml, sender, [diamonds_mail_box], "latin-1", mail_server_address) + sys.exit(mail_sent_message) + + response = connection.getresponse() + + # More info about httplib + # http://docs.python.org/lib/module-httplib.html + if response.status == 200: + print import_succeed_message + print get_response_message(response) + print "Server response:%s\n" % response.read() + else: + print import_failed_message + print get_response_message(response) + sender = get_username() + send_email(get_mail_subject(sender, server, url), xml, sender, [diamonds_mail_box], "latin-1", mail_server_address) + print mail_sent_message + + connection.close() + + else: + print 'Sending only mail' + sender = get_username() + send_email(get_mail_subject(sender, server, url), xml, sender, [mail_address], "latin-1", mail_server_address) + + print "------------------------" + print "Processed in %s" % get_process_time(time.time()-start_time) + print "------------------------" + +if __name__ == "__main__": + main() diff -r 78ccc60a13b1 -r f2e526e44405 common/tools/generate_diamonds_tags_xml.pl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/common/tools/generate_diamonds_tags_xml.pl Wed Oct 07 11:12:20 2009 +0100 @@ -0,0 +1,54 @@ +#! perl -w +# Copyright (c) 2009 Symbian Foundation Ltd +# This component and the accompanying materials are made available +# under the terms of the License "Eclipse Public License v1.0" +# which accompanies this distribution, and is available +# at the URL "http://www.eclipse.org/legal/epl-v10.html". +# +# Initial Contributors: +# Symbian Foundation Ltd - initial contribution. +# +# Contributors: +# +# Description: +# Generate an XML file in the Diamonds format to upload build tags to Diamonds + +use strict; + +use Getopt::Long; + +my $taglist = 0; +my $outputfile = 0; +my $help = 0; +GetOptions(( + 'tags:s' => \$taglist, + 'output:s' => \$outputfile, + 'help!' => \$help, +)); + +if ($help or !$outputfile) +{ + print "Usage: perl generate_diamonds_tags_xml.pl --tags COMMA_SEPARATED_TAG_LIST --output OUTPUT_FILE\n"; +} + +open(FILE, ">$outputfile"); + +print FILE <<_END_HEADER; + + + 13 + +_END_HEADER + +my @tags = split(/,/, $taglist); +for (@tags) +{ + print FILE " $_\n"; +} + +print FILE <<_END_TRAILER; + + +_END_TRAILER + +close(FILE); diff -r 78ccc60a13b1 -r f2e526e44405 common/tools/mergeXML.pl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/common/tools/mergeXML.pl Wed Oct 07 11:12:20 2009 +0100 @@ -0,0 +1,193 @@ +#!perl -w +# Copyright (c) 2009 Symbian Foundation Ltd +# This component and the accompanying materials are made available +# under the terms of the License "Eclipse Public License v1.0" +# which accompanies this distribution, and is available +# at the URL "http://www.eclipse.org/legal/epl-v10.html". +# +# Initial Contributors: +# Symbian Foundation Ltd - initial contribution. +# +# Contributors: +# +# Description: +# Merge a set of XML files + +use strict; + +use XML::Parser; +use Getopt::Long; + +# Read option arguments +my $howtoString; +my $xslLink; +my $help; +GetOptions(( + 'xsl=s' => \$xslLink, + 'merge=s' => \$howtoString, + 'help!' => \$help, +)); + +my $wrongArgs = 0; +unless ($help) +{ + $wrongArgs += warn "No merge string specified to indicate how the files should be merged\n" unless defined $howtoString; + $wrongArgs += warn "No files to be merged\n" unless scalar @ARGV; +} +if ($help || $wrongArgs) +{ + print <<"EOT"; + +mergeXML.pl --xsl=brag.xsl --merge=SystemDefinition,systemModel,layer(name),block(name),package(name) sysModel1.xml [model*.xml ...] > output.xml +EOT + exit(0 + !$help); +} + +# Hash of tags that should be merged, with optional attribute consideration +my $mergeTags; +foreach my $term (split m{\s*,\s*}, $howtoString) +{ + my ($tag, $attribute) = $term =~ m{(\w+)\((\w+)\)}; + $tag ||= $term; + $mergeTags->{$tag} = $attribute; +} + +# Expand wildcards +@ARGV = map { glob $_ } @ARGV; + +# Merge all the trees together +my $outTree = mergeMultipleTrees($mergeTags, @ARGV); + +# Output total tree +print "\n"; +print "\n" if $xslLink; +printTree($outTree->[0]); +print "\n"; + +exit(0); + +sub mergeMultipleTrees +{ + my $mergeTags = shift or die; + + # Create an XML parser + my $parser = new XML::Parser(Style => "Objects") or die; + + my $outTree; + # For each XML file to merge... + foreach my $xmlFile (@_) + { + my $tree = eval { $parser->parsefile($xmlFile) } or die "Failed to parse $xmlFile : $@"; + if (!$outTree) + { + # The first file is taken verbatim + $outTree = $tree; + } + else + { + # Merge into output Tree + mergeTwoTrees($outTree->[0], $tree->[0], $mergeTags); + } + } + + return $outTree; +} + +sub mergeTwoTrees +{ + my $baseTree = shift or die; + my $extrasTree = shift or die; + my $mergeTags = shift or die; + + die ("Trees do not match: ".(ref $baseTree)." vs ".(ref $extrasTree)) unless ref $baseTree eq ref $extrasTree; + return if ref $baseTree eq "main::Characters"; + + foreach my $extraChild (@{$extrasTree->{Kids}}) + { + # Work out whether this child should be merged with a namesake, or appended + my $mergeIt; + + my $extraChildTag = ref $extraChild; + $extraChildTag =~ s{^main::}{}; + + if (exists $mergeTags->{$extraChildTag}) + { + # Should be merged if there's already one there + # Look for a namesake in the base + $mergeIt = matchTag($baseTree->{Kids}, $extraChild, $mergeTags->{$extraChildTag}); + } + + if ($mergeIt) + { + # Merge children + mergeTwoTrees($mergeIt, $extraChild, $mergeTags); + } + else + { + # Add this child + push @{$baseTree->{Kids}}, $extraChild; + } + } +} + +sub matchTag +{ + my $peers = shift; + my $outsider = shift; + my $attr = shift; + + foreach my $peer (@$peers) + { + if (ref $peer eq ref $outsider && (!defined $attr || $peer->{$attr} eq $outsider->{$attr})) + { + return $peer; + } + } + + return undef; +} + +sub printTree +{ + my $tree = shift or die; + die unless ref $tree; + + my $tagName = ref $tree; + $tagName =~ s{^main::}{}; + if ($tagName eq "Characters") + { + print $tree->{Text}; + return; + } + + print "<$tagName"; + + foreach my $attr ( + sort + grep { + ! ref $tree->{$_} + } + keys %$tree) + { + print " $attr=\"$tree->{$attr}\""; + } + + my $children = $tree->{Kids}; + if (scalar @$children) + { + print ">"; + foreach my $child (@$children) + { + printTree($child); + } + print ""; +} + + diff -r 78ccc60a13b1 -r f2e526e44405 sf-package/build.xml --- a/sf-package/build.xml Wed Oct 07 11:09:46 2009 +0100 +++ b/sf-package/build.xml Wed Oct 07 11:12:20 2009 +0100 @@ -3,6 +3,9 @@ + + + diff -r 78ccc60a13b1 -r f2e526e44405 sf-package/symbian2_props.ant.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sf-package/symbian2_props.ant.xml Wed Oct 07 11:12:20 2009 +0100 @@ -0,0 +1,6 @@ + + + + + + diff -r 78ccc60a13b1 -r f2e526e44405 sf-package/symbian3_props.ant.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sf-package/symbian3_props.ant.xml Wed Oct 07 11:12:20 2009 +0100 @@ -0,0 +1,6 @@ + + + + + + diff -r 78ccc60a13b1 -r f2e526e44405 sf-platform/build.xml --- a/sf-platform/build.xml Wed Oct 07 11:09:46 2009 +0100 +++ b/sf-platform/build.xml Wed Oct 07 11:12:20 2009 +0100 @@ -41,7 +41,7 @@ - +