author | brendand@symbian.org |
Wed, 30 Jun 2010 07:53:54 +0100 | |
changeset 1136 | c8f72b84a75f |
parent 1059 | 41e4f69f652f |
child 1158 | 739036c00f80 |
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"; |
1058
e9abe5226301
Add tool envinfo2diamonds.pl
Dario Sestito <darios@symbian.org>
parents:
diff
changeset
|
21 |
my $help = 0; |
e9abe5226301
Add tool envinfo2diamonds.pl
Dario Sestito <darios@symbian.org>
parents:
diff
changeset
|
22 |
GetOptions(( |
e9abe5226301
Add tool envinfo2diamonds.pl
Dario Sestito <darios@symbian.org>
parents:
diff
changeset
|
23 |
'in=s' => \$input, |
e9abe5226301
Add tool envinfo2diamonds.pl
Dario Sestito <darios@symbian.org>
parents:
diff
changeset
|
24 |
'out=s' => \$output, |
e9abe5226301
Add tool envinfo2diamonds.pl
Dario Sestito <darios@symbian.org>
parents:
diff
changeset
|
25 |
'help!' => \$help |
e9abe5226301
Add tool envinfo2diamonds.pl
Dario Sestito <darios@symbian.org>
parents:
diff
changeset
|
26 |
)); |
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 |
if ($help) |
e9abe5226301
Add tool envinfo2diamonds.pl
Dario Sestito <darios@symbian.org>
parents:
diff
changeset
|
29 |
{ |
e9abe5226301
Add tool envinfo2diamonds.pl
Dario Sestito <darios@symbian.org>
parents:
diff
changeset
|
30 |
print "Translates envinfo report to a Diamonds file\n"; |
e9abe5226301
Add tool envinfo2diamonds.pl
Dario Sestito <darios@symbian.org>
parents:
diff
changeset
|
31 |
print "Usage: perl envinfo2diamonds.pl [-i INFILE] [-o OUTFILE]\n"; |
e9abe5226301
Add tool envinfo2diamonds.pl
Dario Sestito <darios@symbian.org>
parents:
diff
changeset
|
32 |
print "\n"; |
e9abe5226301
Add tool envinfo2diamonds.pl
Dario Sestito <darios@symbian.org>
parents:
diff
changeset
|
33 |
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
|
34 |
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
|
35 |
exit(0); |
e9abe5226301
Add tool envinfo2diamonds.pl
Dario Sestito <darios@symbian.org>
parents:
diff
changeset
|
36 |
} |
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 |
my @environment_info = (); |
e9abe5226301
Add tool envinfo2diamonds.pl
Dario Sestito <darios@symbian.org>
parents:
diff
changeset
|
39 |
|
e9abe5226301
Add tool envinfo2diamonds.pl
Dario Sestito <darios@symbian.org>
parents:
diff
changeset
|
40 |
open(INFILE, $input) or die "Can't open $input for reading"; |
e9abe5226301
Add tool envinfo2diamonds.pl
Dario Sestito <darios@symbian.org>
parents:
diff
changeset
|
41 |
while (<INFILE>) |
e9abe5226301
Add tool envinfo2diamonds.pl
Dario Sestito <darios@symbian.org>
parents:
diff
changeset
|
42 |
{ |
e9abe5226301
Add tool envinfo2diamonds.pl
Dario Sestito <darios@symbian.org>
parents:
diff
changeset
|
43 |
my $line = $_; |
e9abe5226301
Add tool envinfo2diamonds.pl
Dario Sestito <darios@symbian.org>
parents:
diff
changeset
|
44 |
if ($line =~ /([^\t]*)\t([^\t]*)/) |
e9abe5226301
Add tool envinfo2diamonds.pl
Dario Sestito <darios@symbian.org>
parents:
diff
changeset
|
45 |
{ |
e9abe5226301
Add tool envinfo2diamonds.pl
Dario Sestito <darios@symbian.org>
parents:
diff
changeset
|
46 |
my $name = $1; |
e9abe5226301
Add tool envinfo2diamonds.pl
Dario Sestito <darios@symbian.org>
parents:
diff
changeset
|
47 |
my $version = $2; |
e9abe5226301
Add tool envinfo2diamonds.pl
Dario Sestito <darios@symbian.org>
parents:
diff
changeset
|
48 |
chomp $name; |
e9abe5226301
Add tool envinfo2diamonds.pl
Dario Sestito <darios@symbian.org>
parents:
diff
changeset
|
49 |
chomp $version; |
e9abe5226301
Add tool envinfo2diamonds.pl
Dario Sestito <darios@symbian.org>
parents:
diff
changeset
|
50 |
push @environment_info, {name=>$name, version=>$version}; |
e9abe5226301
Add tool envinfo2diamonds.pl
Dario Sestito <darios@symbian.org>
parents:
diff
changeset
|
51 |
} |
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 |
close(INFILE); |
e9abe5226301
Add tool envinfo2diamonds.pl
Dario Sestito <darios@symbian.org>
parents:
diff
changeset
|
54 |
|
e9abe5226301
Add tool envinfo2diamonds.pl
Dario Sestito <darios@symbian.org>
parents:
diff
changeset
|
55 |
# write diamonds file |
e9abe5226301
Add tool envinfo2diamonds.pl
Dario Sestito <darios@symbian.org>
parents:
diff
changeset
|
56 |
@environment_info = reverse(@environment_info); |
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 = ''; |
e9abe5226301
Add tool envinfo2diamonds.pl
Dario Sestito <darios@symbian.org>
parents:
diff
changeset
|
69 |
for my $tool_info (@environment_info) |
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 |
} |
e9abe5226301
Add tool envinfo2diamonds.pl
Dario Sestito <darios@symbian.org>
parents:
diff
changeset
|
73 |
|
e9abe5226301
Add tool envinfo2diamonds.pl
Dario Sestito <darios@symbian.org>
parents:
diff
changeset
|
74 |
$xml_content =~ s/_HERE_TOOLS_LINES_/$tools_lines/; |
e9abe5226301
Add tool envinfo2diamonds.pl
Dario Sestito <darios@symbian.org>
parents:
diff
changeset
|
75 |
|
e9abe5226301
Add tool envinfo2diamonds.pl
Dario Sestito <darios@symbian.org>
parents:
diff
changeset
|
76 |
if (open(ENVINFO, ">$output")) |
e9abe5226301
Add tool envinfo2diamonds.pl
Dario Sestito <darios@symbian.org>
parents:
diff
changeset
|
77 |
{ |
e9abe5226301
Add tool envinfo2diamonds.pl
Dario Sestito <darios@symbian.org>
parents:
diff
changeset
|
78 |
print ENVINFO $xml_content; |
e9abe5226301
Add tool envinfo2diamonds.pl
Dario Sestito <darios@symbian.org>
parents:
diff
changeset
|
79 |
close(ENVINFO); |
e9abe5226301
Add tool envinfo2diamonds.pl
Dario Sestito <darios@symbian.org>
parents:
diff
changeset
|
80 |
print "Wrote Diamonds file: $output\n"; |
e9abe5226301
Add tool envinfo2diamonds.pl
Dario Sestito <darios@symbian.org>
parents:
diff
changeset
|
81 |
} |
e9abe5226301
Add tool envinfo2diamonds.pl
Dario Sestito <darios@symbian.org>
parents:
diff
changeset
|
82 |
else |
e9abe5226301
Add tool envinfo2diamonds.pl
Dario Sestito <darios@symbian.org>
parents:
diff
changeset
|
83 |
{ |
e9abe5226301
Add tool envinfo2diamonds.pl
Dario Sestito <darios@symbian.org>
parents:
diff
changeset
|
84 |
warn "Could not write to file: $output\n"; |
e9abe5226301
Add tool envinfo2diamonds.pl
Dario Sestito <darios@symbian.org>
parents:
diff
changeset
|
85 |
} |