1058
|
1 |
# Copyright (c) 2009 Symbian Foundation Ltd
|
|
2 |
# This component and the accompanying materials are made available
|
|
3 |
# under the terms of the License "Eclipse Public License v1.0"
|
|
4 |
# which accompanies this distribution, and is available
|
|
5 |
# at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
6 |
#
|
|
7 |
# Initial Contributors:
|
|
8 |
# Symbian Foundation Ltd - initial contribution.
|
|
9 |
#
|
|
10 |
# Contributors:
|
|
11 |
#
|
|
12 |
# Description:
|
|
13 |
# Translates envinfo report to a Diamonds file
|
|
14 |
|
|
15 |
use strict;
|
|
16 |
|
|
17 |
use Getopt::Long;
|
|
18 |
|
|
19 |
my $input = "\\output\\logs\\envinfo.txt";
|
1059
|
20 |
my $output = "\\output\\logs\\diamonds_envinfo.xml";
|
1146
|
21 |
my $bit_output = "\\output\\logs\\bitinfo.txt";
|
1058
|
22 |
my $help = 0;
|
|
23 |
GetOptions((
|
|
24 |
'in=s' => \$input,
|
|
25 |
'out=s' => \$output,
|
|
26 |
'help!' => \$help
|
|
27 |
));
|
|
28 |
|
|
29 |
if ($help)
|
|
30 |
{
|
|
31 |
print "Translates envinfo report to a Diamonds file\n";
|
|
32 |
print "Usage: perl envinfo2diamonds.pl [-i INFILE] [-o OUTFILE]\n";
|
|
33 |
print "\n";
|
|
34 |
print "INFILE is optional, its default is \\output\\logs\\envinfo.txt\n";
|
1059
|
35 |
print "OUTFILE is optional, its default is \\output\\logs\\diamonds_envinfo.xml\n";
|
1058
|
36 |
exit(0);
|
|
37 |
}
|
|
38 |
|
|
39 |
my @environment_info = ();
|
|
40 |
|
|
41 |
open(INFILE, $input) or die "Can't open $input for reading";
|
|
42 |
while (<INFILE>)
|
|
43 |
{
|
|
44 |
my $line = $_;
|
|
45 |
if ($line =~ /([^\t]*)\t([^\t]*)/)
|
|
46 |
{
|
|
47 |
my $name = $1;
|
|
48 |
my $version = $2;
|
|
49 |
chomp $name;
|
|
50 |
chomp $version;
|
|
51 |
push @environment_info, {name=>$name, version=>$version};
|
|
52 |
}
|
|
53 |
}
|
|
54 |
close(INFILE);
|
|
55 |
|
|
56 |
# write diamonds file
|
|
57 |
|
|
58 |
my $xml_content = <<_EOX;
|
|
59 |
<?xml version=\"1.0\" encoding=\"UTF-8\"?>
|
|
60 |
<diamonds-build>
|
|
61 |
<schema>10</schema>
|
|
62 |
<tools>
|
|
63 |
_HERE_TOOLS_LINES_
|
|
64 |
</tools>
|
|
65 |
</diamonds-build>
|
|
66 |
_EOX
|
|
67 |
|
|
68 |
my $tools_lines = '';
|
1151
|
69 |
for my $tool_info (reverse(@environment_info))
|
1058
|
70 |
{
|
|
71 |
$tools_lines .= " <tool><name>$tool_info->{name}</name><version>$tool_info->{version}</version></tool>\n";
|
|
72 |
}
|
1146
|
73 |
my $bit_tools_lines = '';
|
|
74 |
for my $bit_tool_info (@environment_info)
|
|
75 |
{
|
1149
|
76 |
$bit_tools_lines .= "envinfo\t$bit_tool_info->{name},$bit_tool_info->{version}\n";
|
1146
|
77 |
}
|
1058
|
78 |
|
|
79 |
$xml_content =~ s/_HERE_TOOLS_LINES_/$tools_lines/;
|
|
80 |
|
|
81 |
if (open(ENVINFO, ">$output"))
|
|
82 |
{
|
|
83 |
print ENVINFO $xml_content;
|
|
84 |
close(ENVINFO);
|
|
85 |
print "Wrote Diamonds file: $output\n";
|
|
86 |
}
|
|
87 |
else
|
|
88 |
{
|
|
89 |
warn "Could not write to file: $output\n";
|
|
90 |
}
|
1146
|
91 |
|
|
92 |
if (open(BITINFO, ">>$bit_output"))
|
|
93 |
{
|
|
94 |
print BITINFO $bit_tools_lines;
|
|
95 |
close(BITINFO);
|
|
96 |
}
|