# HG changeset patch # User Dario Sestito # Date 1275666208 -3600 # Node ID e9abe522630137759d5ab3d02b15d21f6b0a4c07 # Parent 1302574aca03f6d26ecbd1a13873d61815d0c132 Add tool envinfo2diamonds.pl diff -r 1302574aca03 -r e9abe5226301 common/tools/envinfo2diamonds.pl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/common/tools/envinfo2diamonds.pl Fri Jun 04 16:43:28 2010 +0100 @@ -0,0 +1,85 @@ +# 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: +# Translates envinfo report to a Diamonds file + +use strict; + +use Getopt::Long; + +my $input = "\\output\\logs\\envinfo.txt"; +my $output = "\\output\\logs\\envinfo_diamonds.xml"; +my $help = 0; +GetOptions(( + 'in=s' => \$input, + 'out=s' => \$output, + 'help!' => \$help +)); + +if ($help) +{ + print "Translates envinfo report to a Diamonds file\n"; + print "Usage: perl envinfo2diamonds.pl [-i INFILE] [-o OUTFILE]\n"; + print "\n"; + print "INFILE is optional, its default is \\output\\logs\\envinfo.txt\n"; + print "OUTFILE is optional, its default is \\output\\logs\\envinfo_diamonds.xml\n"; + exit(0); +} + +my @environment_info = (); + +open(INFILE, $input) or die "Can't open $input for reading"; +while () +{ + my $line = $_; + if ($line =~ /([^\t]*)\t([^\t]*)/) + { + my $name = $1; + my $version = $2; + chomp $name; + chomp $version; + push @environment_info, {name=>$name, version=>$version}; + } +} +close(INFILE); + +# write diamonds file +@environment_info = reverse(@environment_info); + +my $xml_content = <<_EOX; + + +10 + +_HERE_TOOLS_LINES_ + + +_EOX + +my $tools_lines = ''; +for my $tool_info (@environment_info) +{ + $tools_lines .= " $tool_info->{name}$tool_info->{version}\n"; +} + +$xml_content =~ s/_HERE_TOOLS_LINES_/$tools_lines/; + +if (open(ENVINFO, ">$output")) +{ + print ENVINFO $xml_content; + close(ENVINFO); + print "Wrote Diamonds file: $output\n"; +} +else +{ + warn "Could not write to file: $output\n"; +}