0
|
1 |
#! usr\bin\perl
|
|
2 |
# Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
# All rights reserved.
|
|
4 |
# This component and the accompanying materials are made available
|
|
5 |
# under the terms of the License "Eclipse Public License v1.0"
|
|
6 |
# which accompanies this distribution, and is available
|
|
7 |
# at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
#
|
|
9 |
# Initial Contributors:
|
|
10 |
# Nokia Corporation - initial contribution.
|
|
11 |
#
|
|
12 |
# Contributors:
|
|
13 |
#
|
|
14 |
# Description:
|
|
15 |
#
|
|
16 |
|
|
17 |
my $KFilename = $0;
|
|
18 |
$KFilename =~ s/\\romlaunch\.pl$/\\rom.pl/i;
|
|
19 |
my $KEnvironment="perl";
|
|
20 |
my $KLauncher="rom.bat";
|
|
21 |
|
|
22 |
# Main
|
|
23 |
|
|
24 |
if (!defined($ENV{EPOCROOT}))
|
|
25 |
{
|
|
26 |
# Need to set EPOCROOT
|
|
27 |
|
|
28 |
my $devicepath=getDevicesPath();
|
|
29 |
|
|
30 |
if (!defined($devicepath))
|
|
31 |
{
|
|
32 |
die "Please set EPOCROOT before launching $KLauncher. Alternatively, install\n".
|
|
33 |
"a the coresidency tools (tools stubs) and set a default device.\n";
|
|
34 |
}
|
|
35 |
|
|
36 |
push @INC, $devicepath;
|
|
37 |
push @INC, $devicepath."/perllib";
|
|
38 |
require CDevicesCLAccessor;
|
|
39 |
|
|
40 |
$devicepath=~s/[^\/]+\/?$//; # Remove last path element
|
|
41 |
my $deviceObject = New CDevicesCLAccessor($devicepath."/devices.xml");
|
|
42 |
|
|
43 |
my $deviceName;
|
|
44 |
|
|
45 |
if (defined($ENV{EPOCDEVICE}))
|
|
46 |
{
|
|
47 |
# Use EPOCDEVICE as default device
|
|
48 |
$deviceName = $ENV{EPOCDEVICE};
|
|
49 |
}
|
|
50 |
elsif (($deviceObject->getDefaultDevice()) ne "")
|
|
51 |
{
|
|
52 |
# Use main default device
|
|
53 |
$deviceName = $deviceObject->getDefaultDevice($deviceObject);
|
|
54 |
}
|
|
55 |
else
|
|
56 |
{
|
|
57 |
die "Please set a default device (using 'devices -setdefault') before using\n".
|
|
58 |
"$KLauncher. Alternatively, you can set EPOCROOT yourself.\n";
|
|
59 |
}
|
|
60 |
|
|
61 |
if ( ($deviceObject->isValidName($deviceName))
|
|
62 |
|| ($deviceObject->isValidAlias($deviceName))
|
|
63 |
)
|
|
64 |
{
|
|
65 |
# Get path to the epoc32 tree from device
|
|
66 |
my $epocroot = $deviceObject->getEpocRoot($deviceName);
|
|
67 |
|
|
68 |
$epocroot =~ s/^[A-Za-z]://; # Remove leading drive letter
|
|
69 |
|
|
70 |
# Ensure the correct slashes are present
|
|
71 |
$epocroot =~ s/\//\\/g;
|
|
72 |
if ($epocroot !~ /\\$/)
|
|
73 |
{
|
|
74 |
$epocroot = $epocroot."\\";
|
|
75 |
}
|
|
76 |
|
|
77 |
# Set EPOCROOT
|
|
78 |
$ENV{EPOCROOT} = $epocroot;
|
|
79 |
}
|
|
80 |
else
|
|
81 |
{
|
|
82 |
die "'$deviceName' is not a recognised device name. If EPOCDEVICE is set, ensure\n".
|
|
83 |
"it is set to a valid device name.\n";
|
|
84 |
}
|
|
85 |
}
|
|
86 |
|
|
87 |
# Enclose arguments in quote marks if needed
|
|
88 |
|
|
89 |
my @args=@ARGV;
|
|
90 |
my $index=scalar(@args);
|
|
91 |
|
|
92 |
while ($index > 0)
|
|
93 |
{
|
|
94 |
$index--;
|
|
95 |
|
|
96 |
if ($args[$index] =~ /\s/)
|
|
97 |
{
|
|
98 |
$args[$index] = '"'.$args[$index].'"';
|
|
99 |
}
|
|
100 |
}
|
|
101 |
|
|
102 |
# Call tool with arguments
|
|
103 |
|
|
104 |
system($KEnvironment." ".$KFilename." ".join(" ",@args));
|
|
105 |
|
|
106 |
# getDevicesPath()
|
|
107 |
#
|
|
108 |
# Discover the location of the devices API. They are expected to be found in an installed set of coresidency
|
|
109 |
# stubs, in the path.
|
|
110 |
#
|
|
111 |
# Parameters: None
|
|
112 |
#
|
|
113 |
# Returns: The path to the devices API (UNIX style path)
|
|
114 |
#
|
|
115 |
# Dies: If no devices API can be found in the path.
|
|
116 |
sub getDevicesPath()
|
|
117 |
{
|
|
118 |
my $devicepath = undef;
|
|
119 |
my $paths = $ENV{PATH};
|
|
120 |
$paths =~ s/\\/\//g;
|
|
121 |
|
|
122 |
foreach my $path (split(";", $paths))
|
|
123 |
{
|
|
124 |
if (-e "$path/CDevicesCLAccessor.pm")
|
|
125 |
{
|
|
126 |
$devicepath=$path;
|
|
127 |
}
|
|
128 |
}
|
|
129 |
|
|
130 |
return $devicepath;
|
|
131 |
}
|