common/tools/envinfo.pl
author Dario Sestito <darios@symbian.org>
Wed, 14 Jul 2010 12:29:45 +0100
changeset 1181 4bdc287cd2c7
parent 931 5a526b63fb08
permissions -rw-r--r--
Add uh parser info to BIT db
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
884
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
     1
# Copyright (c) 2009 Symbian Foundation Ltd
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
     2
# This component and the accompanying materials are made available
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
     3
# under the terms of the License "Eclipse Public License v1.0"
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
     4
# which accompanies this distribution, and is available
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
     5
# at the URL "http://www.eclipse.org/legal/epl-v10.html".
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
     6
#
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
     7
# Initial Contributors:
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
     8
# Symbian Foundation Ltd - initial contribution.
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
     9
#
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    10
# Contributors:
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    11
#
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    12
# Description:
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    13
# Dumps environment info such as tools version to cmdline then to a Diamonds file
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    14
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    15
use strict;
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    16
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    17
use Getopt::Long;
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    18
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    19
my $output = "\\output\\logs\\diamonds_envinfo.xml";
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    20
my $help = 0;
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    21
GetOptions((
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    22
	'out=s' => \$output,
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    23
	'help!' => \$help
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    24
));
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    25
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    26
if ($help)
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    27
{
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    28
	print "Dumps environment info such as tools version to cmdline then to a Diamonds file\n";
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    29
	print "Usage: perl envinfo.pl --out=XMLFILE\n";
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    30
	print "\n";
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    31
	print "XMLFILE is optional, its default is \\output\\logs\\diamonds_envinfo.xml\n";
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    32
	exit(0);
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    33
}
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    34
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    35
my @environment_info = ();
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    36
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    37
# Machine name
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    38
push @environment_info, {name=>'Machine', version=>$ENV{'COMPUTERNAME'}};
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    39
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    40
# OS Name and Version
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    41
my $os_name = 'N.A.';
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    42
my $os_ver = 'N.A.';
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    43
my $os_out = `systeminfo`;
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    44
$os_name = $1 if ($os_out =~ /^OS Name:\s+(.*)/m);
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    45
$os_ver = $1 if ($os_out =~ /^OS Version:\s+(.*)/m);
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    46
push @environment_info, {name=>'OS Name', version=>$os_name};
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    47
push @environment_info, {name=>'OS Version', version=>$os_ver};
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    48
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    49
# Perl
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    50
my $perl_ver = 'N.A.';
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    51
my $perl_out = `perl -v`;
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    52
$perl_ver = $1 if ($perl_out =~ /This is perl, v(\S+)/m);
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    53
push @environment_info, {name=>'Perl', version=>$perl_ver};
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    54
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    55
# Python
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    56
my $python_ver = 'N.A.';
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    57
my $python_out = `python -V 2>&1`;
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    58
$python_ver = $1 if ($python_out =~ /^Python\s+(\S+)/m);
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    59
push @environment_info, {name=>'Python', version=>$python_ver};
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    60
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    61
# Mercurial
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    62
my $hg_ver = 'N.A.';
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    63
my $hg_out = `hg --version`;
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    64
$hg_ver = $1 if ($hg_out =~ /^Mercurial Distributed SCM \(version ([^)]+)\)/m);
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    65
push @environment_info, {name=>'Mercurial', version=>$hg_ver};
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    66
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    67
# 7-Zip
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    68
my $zip_ver = 'N.A.';
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    69
my $zip_out = `7z`;
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    70
$zip_ver = $1 if ($zip_out =~ /^7-Zip\s+(\S+)\s+Copyright/m);
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    71
push @environment_info, {name=>'7-Zip', version=>$zip_ver};
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    72
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    73
# Raptor
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    74
my $sbs_ver = 'N.A.';
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    75
my $sbs_out = `sbs -v`;
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    76
$sbs_ver = $1 if ($sbs_out =~ /^sbs version (.*)/m);
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    77
push @environment_info, {name=>'sbs', version=>$sbs_ver};
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    78
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    79
# Metrowerk Compiler
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    80
my $mwcc_ver = 'N.A.';
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    81
my $mwcc_out = `mwccsym2 -version`;
888
5cd45cbf7622 Fix version of new mwccsym2 is reported as N.A.
Dario Sestito <darios@symbian.org>
parents: 884
diff changeset
    82
$mwcc_ver = $1 if ($mwcc_out =~ /^Version (.*)/m);
884
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    83
push @environment_info, {name=>'mwccsym2', version=>$mwcc_ver};
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    84
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    85
# RVCT 2.2
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    86
my $rvct22_ver = 'N.A.';
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    87
my $rvct22_path = '';
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    88
if (defined $ENV{'SBS_RVCT22BIN'})
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    89
{
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    90
	$rvct22_path = $ENV{'SBS_RVCT22BIN'};
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    91
}
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    92
elsif (defined $ENV{'RVCT22BIN'})
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    93
{
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    94
	$rvct22_path = $ENV{'RVCT22BIN'};
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    95
}
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    96
my $rvct22_cmd = 'armcc 2>&1';
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    97
$rvct22_cmd = "$rvct22_path\\$rvct22_cmd" if ($rvct22_path);
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    98
my $rvct22_out = `$rvct22_cmd`;
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    99
$rvct22_ver = $1 if ($rvct22_out =~ m#ARM/Thumb C/C\+\+ Compiler, RVCT2.2 (.*)#m);
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   100
push @environment_info, {name=>'RVCT2.2', version=>$rvct22_ver};
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   101
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   102
# RVCT 4.0
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   103
my $rvct40_ver = 'N.A.';
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   104
my $rvct40_path = '';
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   105
if (defined $ENV{'SBS_RVCT40BIN'})
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   106
{
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   107
	$rvct40_path = $ENV{'SBS_RVCT40BIN'};
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   108
}
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   109
elsif (defined $ENV{'RVCT40BIN'})
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   110
{
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   111
	$rvct40_path = $ENV{'RVCT40BIN'};
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   112
}
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   113
my $rvct40_cmd = 'armcc 2>&1';
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   114
$rvct40_cmd = "$rvct40_path\\$rvct40_cmd" if ($rvct40_path);
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   115
my $rvct40_out = `$rvct40_cmd`;
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   116
$rvct40_ver = $1 if ($rvct40_out =~ m#ARM C/C\+\+ Compiler, RVCT4.0 (.*)#m);
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   117
push @environment_info, {name=>'RVCT4.0', version=>$rvct40_ver};
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   118
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   119
# GCCE 4.4.1
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   120
my $gcc441_ver = 'N.A.';
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   121
my $gcc441_path = '';
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   122
if (defined $ENV{'SBS_GCCE441BIN'})
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   123
{
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   124
	$gcc441_path = $ENV{'SBS_GCCE441BIN'};
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   125
}
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   126
elsif (defined $ENV{'GCCE441BIN'})
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   127
{
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   128
	$gcc441_path = $ENV{'GCCE441BIN'};
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   129
}
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   130
if ($gcc441_path)
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   131
{
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   132
	my $gcc441_cmd = "$gcc441_path\\arm-none-symbianelf-g++ -dumpversion";
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   133
	my $gcc441_out = `$gcc441_cmd`;
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   134
	$gcc441_ver = "4.4.1" if ($gcc441_out =~ /4.4.1/);
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   135
}
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   136
push @environment_info, {name=>'GCC4.4.1', version=>$gcc441_ver};
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   137
905
9ed73a51c728 Add Helium and java to the enironment info
Dario Sestito <darios@symbian.org>
parents: 888
diff changeset
   138
# Helium
9ed73a51c728 Add Helium and java to the enironment info
Dario Sestito <darios@symbian.org>
parents: 888
diff changeset
   139
my $helium_ver = 'N.A.';
9ed73a51c728 Add Helium and java to the enironment info
Dario Sestito <darios@symbian.org>
parents: 888
diff changeset
   140
if ($ENV{'HELIUM_HOME'} && -f "$ENV{'HELIUM_HOME'}\\config\\version.txt")
9ed73a51c728 Add Helium and java to the enironment info
Dario Sestito <darios@symbian.org>
parents: 888
diff changeset
   141
{
9ed73a51c728 Add Helium and java to the enironment info
Dario Sestito <darios@symbian.org>
parents: 888
diff changeset
   142
	open(VERSION, "$ENV{'HELIUM_HOME'}\\config\\version.txt");
9ed73a51c728 Add Helium and java to the enironment info
Dario Sestito <darios@symbian.org>
parents: 888
diff changeset
   143
	my $line = '';
9ed73a51c728 Add Helium and java to the enironment info
Dario Sestito <darios@symbian.org>
parents: 888
diff changeset
   144
	while ($line = <VERSION>)
9ed73a51c728 Add Helium and java to the enironment info
Dario Sestito <darios@symbian.org>
parents: 888
diff changeset
   145
	{
9ed73a51c728 Add Helium and java to the enironment info
Dario Sestito <darios@symbian.org>
parents: 888
diff changeset
   146
		$helium_ver = $1 if ($line =~ /^helium\.version=(.*)/);
9ed73a51c728 Add Helium and java to the enironment info
Dario Sestito <darios@symbian.org>
parents: 888
diff changeset
   147
	}
9ed73a51c728 Add Helium and java to the enironment info
Dario Sestito <darios@symbian.org>
parents: 888
diff changeset
   148
	close(VERSION);
9ed73a51c728 Add Helium and java to the enironment info
Dario Sestito <darios@symbian.org>
parents: 888
diff changeset
   149
}
9ed73a51c728 Add Helium and java to the enironment info
Dario Sestito <darios@symbian.org>
parents: 888
diff changeset
   150
push @environment_info, {name=>'helium', version=>$helium_ver};
9ed73a51c728 Add Helium and java to the enironment info
Dario Sestito <darios@symbian.org>
parents: 888
diff changeset
   151
9ed73a51c728 Add Helium and java to the enironment info
Dario Sestito <darios@symbian.org>
parents: 888
diff changeset
   152
# java
9ed73a51c728 Add Helium and java to the enironment info
Dario Sestito <darios@symbian.org>
parents: 888
diff changeset
   153
my $java_ver = 'N.A.';
931
5a526b63fb08 Fix java version is not available
Dario Sestito <darios@symbian.org>
parents: 905
diff changeset
   154
my $java_out = `java -version 2>&1`;
5a526b63fb08 Fix java version is not available
Dario Sestito <darios@symbian.org>
parents: 905
diff changeset
   155
$java_ver = $1 if ($java_out =~ /^java version (.*)/m);
905
9ed73a51c728 Add Helium and java to the enironment info
Dario Sestito <darios@symbian.org>
parents: 888
diff changeset
   156
push @environment_info, {name=>'java', version=>$java_ver};
884
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   157
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   158
for my $tool_info (@environment_info)
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   159
{
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   160
	print $tool_info->{name} . ": " . $tool_info->{version} . "\n";
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   161
}
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   162
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   163
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   164
# write diamonds file
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   165
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   166
@environment_info = reverse(@environment_info);
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   167
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   168
my $xml_content = <<_EOX;
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   169
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   170
<?xml version=\"1.0\" encoding=\"UTF-8\"?>
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   171
<diamonds-build>
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   172
 <schema>10</schema>
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   173
  <tools>        
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   174
_HERE_TOOLS_LINES_
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   175
  </tools>
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   176
</diamonds-build>
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   177
_EOX
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   178
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   179
my $tools_lines = '';
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   180
for my $tool_info (@environment_info)
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   181
{
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   182
	$tools_lines .= "   <tool><name>$tool_info->{name}</name><version>$tool_info->{version}</version></tool>\n";
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   183
}
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   184
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   185
$xml_content =~ s/_HERE_TOOLS_LINES_/$tools_lines/;
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   186
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   187
if (open(ENVINFO, ">$output"))
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   188
{
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   189
	print ENVINFO $xml_content;
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   190
	close(ENVINFO);
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   191
	print "Wrote Diamonds file: $output\n";
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   192
}
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   193
else
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   194
{
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   195
	warn "Could not write to file: $output\n";
18fc0e69c5b8 Dump environment info to Diamonds
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   196
}