os/kernelhwsrv/kernel/eka/rombuild/romlaunch.bat
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/kernelhwsrv/kernel/eka/rombuild/romlaunch.bat	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,137 @@
     1.4 +@rem
     1.5 +@rem Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.6 +@rem All rights reserved.
     1.7 +@rem This component and the accompanying materials are made available
     1.8 +@rem under the terms of the License "Eclipse Public License v1.0"
     1.9 +@rem which accompanies this distribution, and is available
    1.10 +@rem at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.11 +@rem
    1.12 +@rem Initial Contributors:
    1.13 +@rem Nokia Corporation - initial contribution.
    1.14 +@rem
    1.15 +@rem Contributors:
    1.16 +@rem
    1.17 +@rem Description:
    1.18 +@rem
    1.19 +
    1.20 +@perl -x romlaunch.bat %*
    1.21 +@goto end
    1.22 +
    1.23 +#! usr\bin\perl
    1.24 +
    1.25 +my $KFilename="rom.bat";
    1.26 +
    1.27 +# getDevicesPath()
    1.28 +#
    1.29 +# Discover the location of the devices API. They are expected to be found in an installed set of coresidency
    1.30 +# stubs, in the path.
    1.31 +#
    1.32 +# Parameters: None
    1.33 +#
    1.34 +# Returns: The path to the devices API (UNIX style path)
    1.35 +# 
    1.36 +# Dies: If no devices API can be found in the path. 
    1.37 +sub getDevicesPath()
    1.38 +	{
    1.39 +	my $devicepath = undef;
    1.40 +	my $paths = $ENV{PATH};
    1.41 +	$paths =~ s/\\/\//g;
    1.42 +	
    1.43 +	foreach my $path (split(";", $paths))
    1.44 +		{
    1.45 +		if (-e "$path/CDevicesCLAccessor.pm")
    1.46 +			{
    1.47 +			$devicepath=$path;
    1.48 +			}
    1.49 +		}
    1.50 +	
    1.51 +	if (defined($devicepath))
    1.52 +		{
    1.53 +		return $devicepath;
    1.54 +		}
    1.55 +	else
    1.56 +		{
    1.57 +		die "The '$KFilename' launcher cannot be used without the tools coresidency stubs.\n".
    1.58 +		  "Alternatively, please set EPOCROOT before calling '$KFilename' directly.\n";
    1.59 +		}
    1.60 +	}
    1.61 +
    1.62 +# Main
    1.63 +	
    1.64 +use lib getDevicesPath();
    1.65 +use lib getDevicesPath()."/perllib";
    1.66 +use CDevicesCLAccessor;
    1.67 +
    1.68 +my $devicepath=getDevicesPath();
    1.69 +$devicepath=~s/[^\/]+\/?$//; # Remove last path element
    1.70 +my $deviceObject = New CDevicesCLAccessor($devicepath."/devices.xml");
    1.71 +
    1.72 +if (!defined($ENV{EPOCROOT}))
    1.73 +	{
    1.74 +	# Need to set EPOCROOT
    1.75 +	
    1.76 +	my $deviceName;
    1.77 +
    1.78 +	if (defined($EHV{EPOCDEVICE}))
    1.79 +		{
    1.80 +		# Use EPOCDEVICE as default device
    1.81 +		$deviceName = $ENV{EPOCDEVICE};
    1.82 +		}
    1.83 +	elsif (($deviceObject->getDefaultDevice()) ne "")
    1.84 +		{
    1.85 +		# Use main default device
    1.86 +		$deviceName = $deviceObject->getDefaultDevice($deviceObject);
    1.87 +		}
    1.88 +	else
    1.89 +		{
    1.90 +		die "Please set a default device (using 'devices -setdefault') before using\n".
    1.91 +		  "the '$KFilename' launcher. Alternatively, set EPOCROOT and run\n".
    1.92 +		  "'$KFilename' directly\n";
    1.93 +		}
    1.94 +	
    1.95 +	if ( ($deviceObject->isValidName($deviceName))
    1.96 +	  || ($deviceObject->isValidAlias($deviceName))
    1.97 +	  )
    1.98 +		{
    1.99 +		# Get path to the epoc32 tree from device
   1.100 +		my $epocroot = $deviceObject->getEpocRoot($deviceName);
   1.101 +
   1.102 +		$epocroot =~ s/^[A-Za-z]://; # Remove leading drive letter
   1.103 +
   1.104 +		# Ensure the correct slashes are present
   1.105 +		$epocroot =~ s/\//\\/g;
   1.106 +		if ($epocroot !~ /\\$/)
   1.107 +			{
   1.108 +			$epocroot = $epocroot."\\";
   1.109 +			}
   1.110 +		
   1.111 +		# Set EPOCROOT
   1.112 +		$ENV{EPOCROOT} = $epocroot;
   1.113 +		}
   1.114 +	else
   1.115 +		{
   1.116 +		die "'$deviceName' is not a recognised device name.\n";
   1.117 +		}
   1.118 +	}
   1.119 +
   1.120 +# Enclose arguments in quote marks if needed
   1.121 +
   1.122 +my @args=@ARGV;
   1.123 +my $index=scalar(@args);
   1.124 +
   1.125 +while ($index > 0)
   1.126 +	{
   1.127 +	$index--;
   1.128 +
   1.129 +	if ($args[$index] =~ /\s/)
   1.130 +		{
   1.131 +		$args[$index] = '"'.$args[$index].'"';
   1.132 +		}
   1.133 +	}
   1.134 +
   1.135 +# Call tool with arguments
   1.136 +
   1.137 +system($KFilename." ".join(" ",@args));
   1.138 +
   1.139 +__END__
   1.140 +:end