common/tools/envinfo2diamonds.pl
author Dario Sestito <darios@symbian.org>
Fri, 09 Jul 2010 17:55:07 +0100
changeset 1158 739036c00f80
parent 1059 41e4f69f652f
child 1161 3a17ff141d92
permissions -rw-r--r--
Add bitops.pl. Dump start info and envinfo to bitinfo.txt
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
@environment_info = reverse(@environment_info);
e9abe5226301 Add tool envinfo2diamonds.pl
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    58
e9abe5226301 Add tool envinfo2diamonds.pl
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    59
my $xml_content = <<_EOX;
e9abe5226301 Add tool envinfo2diamonds.pl
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    60
<?xml version=\"1.0\" encoding=\"UTF-8\"?>
e9abe5226301 Add tool envinfo2diamonds.pl
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    61
<diamonds-build>
e9abe5226301 Add tool envinfo2diamonds.pl
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    62
<schema>10</schema>
e9abe5226301 Add tool envinfo2diamonds.pl
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    63
<tools>        
e9abe5226301 Add tool envinfo2diamonds.pl
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    64
_HERE_TOOLS_LINES_
e9abe5226301 Add tool envinfo2diamonds.pl
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    65
</tools>
e9abe5226301 Add tool envinfo2diamonds.pl
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    66
</diamonds-build>
e9abe5226301 Add tool envinfo2diamonds.pl
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    67
_EOX
e9abe5226301 Add tool envinfo2diamonds.pl
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    68
e9abe5226301 Add tool envinfo2diamonds.pl
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    69
my $tools_lines = '';
e9abe5226301 Add tool envinfo2diamonds.pl
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    70
for my $tool_info (@environment_info)
e9abe5226301 Add tool envinfo2diamonds.pl
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    71
{
e9abe5226301 Add tool envinfo2diamonds.pl
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    72
	$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
    73
}
1158
739036c00f80 Add bitops.pl. Dump start info and envinfo to bitinfo.txt
Dario Sestito <darios@symbian.org>
parents: 1059
diff changeset
    74
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
    75
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
    76
{
739036c00f80 Add bitops.pl. Dump start info and envinfo to bitinfo.txt
Dario Sestito <darios@symbian.org>
parents: 1059
diff changeset
    77
	$bit_tools_lines .= "envinfo\t$tool_info->{name},$tool_info->{version}\n";
739036c00f80 Add bitops.pl. Dump start info and envinfo to bitinfo.txt
Dario Sestito <darios@symbian.org>
parents: 1059
diff changeset
    78
} 
1058
e9abe5226301 Add tool envinfo2diamonds.pl
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    79
e9abe5226301 Add tool envinfo2diamonds.pl
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    80
$xml_content =~ s/_HERE_TOOLS_LINES_/$tools_lines/;
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
if (open(ENVINFO, ">$output"))
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
	print ENVINFO $xml_content;
e9abe5226301 Add tool envinfo2diamonds.pl
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    85
	close(ENVINFO);
e9abe5226301 Add tool envinfo2diamonds.pl
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    86
	print "Wrote Diamonds file: $output\n";
e9abe5226301 Add tool envinfo2diamonds.pl
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    87
}
e9abe5226301 Add tool envinfo2diamonds.pl
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    88
else
e9abe5226301 Add tool envinfo2diamonds.pl
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    89
{
e9abe5226301 Add tool envinfo2diamonds.pl
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    90
	warn "Could not write to file: $output\n";
e9abe5226301 Add tool envinfo2diamonds.pl
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    91
}
1158
739036c00f80 Add bitops.pl. Dump start info and envinfo to bitinfo.txt
Dario Sestito <darios@symbian.org>
parents: 1059
diff changeset
    92
739036c00f80 Add bitops.pl. Dump start info and envinfo to bitinfo.txt
Dario Sestito <darios@symbian.org>
parents: 1059
diff changeset
    93
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
    94
{
739036c00f80 Add bitops.pl. Dump start info and envinfo to bitinfo.txt
Dario Sestito <darios@symbian.org>
parents: 1059
diff changeset
    95
	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
    96
	close(BITINFO);
739036c00f80 Add bitops.pl. Dump start info and envinfo to bitinfo.txt
Dario Sestito <darios@symbian.org>
parents: 1059
diff changeset
    97
}