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