First public contribution.
2 @rem Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
3 @rem All rights reserved.
4 @rem This component and the accompanying materials are made available
5 @rem under the terms of the License "Eclipse Public License v1.0"
6 @rem which accompanies this distribution, and is available
7 @rem at the URL "http://www.eclipse.org/legal/epl-v10.html".
9 @rem Initial Contributors:
10 @rem Nokia Corporation - initial contribution.
17 @perl -x romlaunch.bat %*
22 my $KFilename="rom.bat";
26 # Discover the location of the devices API. They are expected to be found in an installed set of coresidency
31 # Returns: The path to the devices API (UNIX style path)
33 # Dies: If no devices API can be found in the path.
36 my $devicepath = undef;
37 my $paths = $ENV{PATH};
40 foreach my $path (split(";", $paths))
42 if (-e "$path/CDevicesCLAccessor.pm")
48 if (defined($devicepath))
54 die "The '$KFilename' launcher cannot be used without the tools coresidency stubs.\n".
55 "Alternatively, please set EPOCROOT before calling '$KFilename' directly.\n";
61 use lib getDevicesPath();
62 use lib getDevicesPath()."/perllib";
63 use CDevicesCLAccessor;
65 my $devicepath=getDevicesPath();
66 $devicepath=~s/[^\/]+\/?$//; # Remove last path element
67 my $deviceObject = New CDevicesCLAccessor($devicepath."/devices.xml");
69 if (!defined($ENV{EPOCROOT}))
71 # Need to set EPOCROOT
75 if (defined($EHV{EPOCDEVICE}))
77 # Use EPOCDEVICE as default device
78 $deviceName = $ENV{EPOCDEVICE};
80 elsif (($deviceObject->getDefaultDevice()) ne "")
82 # Use main default device
83 $deviceName = $deviceObject->getDefaultDevice($deviceObject);
87 die "Please set a default device (using 'devices -setdefault') before using\n".
88 "the '$KFilename' launcher. Alternatively, set EPOCROOT and run\n".
89 "'$KFilename' directly\n";
92 if ( ($deviceObject->isValidName($deviceName))
93 || ($deviceObject->isValidAlias($deviceName))
96 # Get path to the epoc32 tree from device
97 my $epocroot = $deviceObject->getEpocRoot($deviceName);
99 $epocroot =~ s/^[A-Za-z]://; # Remove leading drive letter
101 # Ensure the correct slashes are present
102 $epocroot =~ s/\//\\/g;
103 if ($epocroot !~ /\\$/)
105 $epocroot = $epocroot."\\";
109 $ENV{EPOCROOT} = $epocroot;
113 die "'$deviceName' is not a recognised device name.\n";
117 # Enclose arguments in quote marks if needed
120 my $index=scalar(@args);
126 if ($args[$index] =~ /\s/)
128 $args[$index] = '"'.$args[$index].'"';
132 # Call tool with arguments
134 system($KFilename." ".join(" ",@args));