First public contribution.
2 # Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
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".
9 # Initial Contributors:
10 # Nokia Corporation - initial contribution.
18 $KFilename =~ s/\\romlaunch\.pl$/\\rom.pl/i;
19 my $KEnvironment="perl";
20 my $KLauncher="rom.bat";
24 if (!defined($ENV{EPOCROOT}))
26 # Need to set EPOCROOT
28 my $devicepath=getDevicesPath();
30 if (!defined($devicepath))
32 die "Please set EPOCROOT before launching $KLauncher. Alternatively, install\n".
33 "a the coresidency tools (tools stubs) and set a default device.\n";
36 push @INC, $devicepath;
37 push @INC, $devicepath."/perllib";
38 require CDevicesCLAccessor;
40 $devicepath=~s/[^\/]+\/?$//; # Remove last path element
41 my $deviceObject = New CDevicesCLAccessor($devicepath."/devices.xml");
45 if (defined($ENV{EPOCDEVICE}))
47 # Use EPOCDEVICE as default device
48 $deviceName = $ENV{EPOCDEVICE};
50 elsif (($deviceObject->getDefaultDevice()) ne "")
52 # Use main default device
53 $deviceName = $deviceObject->getDefaultDevice($deviceObject);
57 die "Please set a default device (using 'devices -setdefault') before using\n".
58 "$KLauncher. Alternatively, you can set EPOCROOT yourself.\n";
61 if ( ($deviceObject->isValidName($deviceName))
62 || ($deviceObject->isValidAlias($deviceName))
65 # Get path to the epoc32 tree from device
66 my $epocroot = $deviceObject->getEpocRoot($deviceName);
68 $epocroot =~ s/^[A-Za-z]://; # Remove leading drive letter
70 # Ensure the correct slashes are present
71 $epocroot =~ s/\//\\/g;
72 if ($epocroot !~ /\\$/)
74 $epocroot = $epocroot."\\";
78 $ENV{EPOCROOT} = $epocroot;
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";
87 # Enclose arguments in quote marks if needed
90 my $index=scalar(@args);
96 if ($args[$index] =~ /\s/)
98 $args[$index] = '"'.$args[$index].'"';
102 # Call tool with arguments
104 system($KEnvironment." ".$KFilename." ".join(" ",@args));
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.
113 # Returns: The path to the devices API (UNIX style path)
115 # Dies: If no devices API can be found in the path.
118 my $devicepath = undef;
119 my $paths = $ENV{PATH};
122 foreach my $path (split(";", $paths))
124 if (-e "$path/CDevicesCLAccessor.pm")