kernel/eka/rombuild/romlaunch.bat
changeset 0 a41df078684a
equal deleted inserted replaced
-1:000000000000 0:a41df078684a
       
     1 @rem
       
     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".
       
     8 @rem
       
     9 @rem Initial Contributors:
       
    10 @rem Nokia Corporation - initial contribution.
       
    11 @rem
       
    12 @rem Contributors:
       
    13 @rem
       
    14 @rem Description:
       
    15 @rem
       
    16 
       
    17 @perl -x romlaunch.bat %*
       
    18 @goto end
       
    19 
       
    20 #! usr\bin\perl
       
    21 
       
    22 my $KFilename="rom.bat";
       
    23 
       
    24 # getDevicesPath()
       
    25 #
       
    26 # Discover the location of the devices API. They are expected to be found in an installed set of coresidency
       
    27 # stubs, in the path.
       
    28 #
       
    29 # Parameters: None
       
    30 #
       
    31 # Returns: The path to the devices API (UNIX style path)
       
    32 # 
       
    33 # Dies: If no devices API can be found in the path. 
       
    34 sub getDevicesPath()
       
    35 	{
       
    36 	my $devicepath = undef;
       
    37 	my $paths = $ENV{PATH};
       
    38 	$paths =~ s/\\/\//g;
       
    39 	
       
    40 	foreach my $path (split(";", $paths))
       
    41 		{
       
    42 		if (-e "$path/CDevicesCLAccessor.pm")
       
    43 			{
       
    44 			$devicepath=$path;
       
    45 			}
       
    46 		}
       
    47 	
       
    48 	if (defined($devicepath))
       
    49 		{
       
    50 		return $devicepath;
       
    51 		}
       
    52 	else
       
    53 		{
       
    54 		die "The '$KFilename' launcher cannot be used without the tools coresidency stubs.\n".
       
    55 		  "Alternatively, please set EPOCROOT before calling '$KFilename' directly.\n";
       
    56 		}
       
    57 	}
       
    58 
       
    59 # Main
       
    60 	
       
    61 use lib getDevicesPath();
       
    62 use lib getDevicesPath()."/perllib";
       
    63 use CDevicesCLAccessor;
       
    64 
       
    65 my $devicepath=getDevicesPath();
       
    66 $devicepath=~s/[^\/]+\/?$//; # Remove last path element
       
    67 my $deviceObject = New CDevicesCLAccessor($devicepath."/devices.xml");
       
    68 
       
    69 if (!defined($ENV{EPOCROOT}))
       
    70 	{
       
    71 	# Need to set EPOCROOT
       
    72 	
       
    73 	my $deviceName;
       
    74 
       
    75 	if (defined($EHV{EPOCDEVICE}))
       
    76 		{
       
    77 		# Use EPOCDEVICE as default device
       
    78 		$deviceName = $ENV{EPOCDEVICE};
       
    79 		}
       
    80 	elsif (($deviceObject->getDefaultDevice()) ne "")
       
    81 		{
       
    82 		# Use main default device
       
    83 		$deviceName = $deviceObject->getDefaultDevice($deviceObject);
       
    84 		}
       
    85 	else
       
    86 		{
       
    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";
       
    90 		}
       
    91 	
       
    92 	if ( ($deviceObject->isValidName($deviceName))
       
    93 	  || ($deviceObject->isValidAlias($deviceName))
       
    94 	  )
       
    95 		{
       
    96 		# Get path to the epoc32 tree from device
       
    97 		my $epocroot = $deviceObject->getEpocRoot($deviceName);
       
    98 
       
    99 		$epocroot =~ s/^[A-Za-z]://; # Remove leading drive letter
       
   100 
       
   101 		# Ensure the correct slashes are present
       
   102 		$epocroot =~ s/\//\\/g;
       
   103 		if ($epocroot !~ /\\$/)
       
   104 			{
       
   105 			$epocroot = $epocroot."\\";
       
   106 			}
       
   107 		
       
   108 		# Set EPOCROOT
       
   109 		$ENV{EPOCROOT} = $epocroot;
       
   110 		}
       
   111 	else
       
   112 		{
       
   113 		die "'$deviceName' is not a recognised device name.\n";
       
   114 		}
       
   115 	}
       
   116 
       
   117 # Enclose arguments in quote marks if needed
       
   118 
       
   119 my @args=@ARGV;
       
   120 my $index=scalar(@args);
       
   121 
       
   122 while ($index > 0)
       
   123 	{
       
   124 	$index--;
       
   125 
       
   126 	if ($args[$index] =~ /\s/)
       
   127 		{
       
   128 		$args[$index] = '"'.$args[$index].'"';
       
   129 		}
       
   130 	}
       
   131 
       
   132 # Call tool with arguments
       
   133 
       
   134 system($KFilename." ".join(" ",@args));
       
   135 
       
   136 __END__
       
   137 :end