deprecated/buildtools/emulatorlauncher/perl/eshell.pl
author Zheng Shen <zheng.shen@nokia.com>
Wed, 27 Oct 2010 19:35:19 +0800
changeset 664 44b0e894b7ab
parent 655 3f65fd25dfd4
permissions -rw-r--r--
Merge again
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
655
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
     1
# Copyright (c) 1999-2009 Nokia Corporation and/or its subsidiary(-ies).
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
     2
# All rights reserved.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
     3
# This component and the accompanying materials are made available
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
     4
# under the terms of "Eclipse Public License v1.0"
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
     5
# which accompanies this distribution, and is available
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
     6
# at the URL "http://www.eclipse.org/legal/epl-v10.html".
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
     7
#
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
     8
# Initial Contributors:
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
     9
# Nokia Corporation - initial contribution.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    10
#
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    11
# Contributors:
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    12
#
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    13
# Description:
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    14
# Eshell Launcher
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    15
# Depends on the current working directory providing
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    16
# the drive of the currently used SDK.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    17
# 
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    18
#
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    19
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    20
use Cwd;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    21
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    22
#
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    23
# Check the argument(s), if any.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    24
#
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    25
$numArgs = $#ARGV + 1;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    26
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    27
if($numArgs == 0) 
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    28
	{
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    29
    	&launchEshell("udeb","winscw");
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    30
    	exit(0);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    31
	}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    32
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    33
if($numArgs > 2) 
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    34
	{
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    35
    	&printHelp;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    36
    	die "ERROR: Too many arguments.\n";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    37
	}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    38
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    39
if($numArgs == 1)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    40
	{ 
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    41
	if(lc($ARGV[0]) eq "-rel") 
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    42
		{
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    43
    		&launchEshell("urel","winscw");
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    44
    		exit(0);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    45
		}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    46
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    47
	if(lc($ARGV[0]) eq "-wins") 
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    48
		{
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    49
    		&launchEshell("udeb", "wins");
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    50
    		exit(0);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    51
		}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    52
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    53
	if(lc($ARGV[0]) eq "-winscw") 
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    54
		{
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    55
    		&launchEshell("udeb", "winscw");
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    56
    		exit(0);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    57
		}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    58
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    59
	if(lc($ARGV[0]) eq "-help") 
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    60
		{
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    61
    		&printHelp;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    62
    		exit(0);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    63
		}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    64
	}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    65
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    66
if ($numArgs == 2)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    67
	{
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    68
	if(lc($ARGV[0]) eq "-rel") 
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    69
		{
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    70
		if (lc($ARGV[1]) eq "-wins")
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    71
			{
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    72
    			&launchEshell("urel","wins");
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    73
    			exit(0);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    74
			}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    75
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    76
		if (lc($ARGV[1]) eq "-winscw")
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    77
			{
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    78
    			&launchEshell("urel","winscw");
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    79
    			exit(0);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    80
			}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    81
		}	
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    82
	
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    83
	if (lc($ARGV[0]) eq "-winscw")
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    84
		{
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    85
		if (lc($ARGV[1] eq "-rel"))
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    86
			{
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    87
			&launchEshell("urel","winscw");
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    88
			exit(0);	
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    89
			}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    90
		}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    91
	
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    92
	if (lc($ARGV[0]) eq "-wins")
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    93
		{
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    94
		if (lc($ARGV[1] eq "-rel"))
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    95
			{
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    96
			&launchEshell("urel","wins");
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    97
			exit(0);	
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    98
			}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    99
		}	
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   100
	}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   101
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   102
# Error, unknown argument.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   103
&printHelp;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   104
die "ERROR: Unknown argument " . "\"" . $ARGV[0] . "\".\n";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   105
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   106
sub launchEshell
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   107
{
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   108
    my ($type,$win) = @_;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   109
    $epocroot = &getEpocroot;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   110
    $drive = &getDrive;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   111
    $emu = $drive . $epocroot . "epoc32" . "\\" 
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   112
	. "release\\" . $win . "\\" . $type . "\\" . "eshell.exe";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   113
    -e $emu ||
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   114
	die "ERROR: File \"$emu\" not found.\n\n" .
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   115
	    "The EPOCROOT environment variable does not identify\n" .
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   116
	    "a valid eshell installation on this drive.\n" . 
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   117
		"EPOCROOT must be an absolute path to an existing\n" .
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   118
		    "directory - it should have no drive qualifier and\n" .
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   119
			"must end with a backslash.\n";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   120
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   121
	#add the stuff to use the console
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   122
	$emu.=" -MConsole --";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   123
			
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   124
    # If the execute is successful, this never returns.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   125
    exec($emu) || die "Failed to execute eshell \"$emu\": $!";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   126
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   127
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   128
sub printHelp
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   129
{
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   130
    print "Eshell Launcher\n";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   131
    print "Syntax :\teshell [-rel] [-wins|-winscw] [-help]\n";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   132
    print "(no options)\tLaunch active winscw debug eshell\n";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   133
    print "-rel\t\tLaunch active release eshell\n";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   134
    print "-wins\t\tLaunch active wins eshell\n";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   135
    print "-winscw\t\tLaunch active winscw eshell\n";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   136
    print "-help\t\tOutput this help message\n";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   137
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   138
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   139
#
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   140
# Determines, validates, and returns EPOCROOT.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   141
#
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   142
sub getEpocroot
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   143
{
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   144
    my $epocroot = $ENV{EPOCROOT};
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   145
    die "ERROR: Must set the EPOCROOT environment variable.\n"
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   146
	if (!defined($epocroot));
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   147
    $epocroot =~ s-/-\\-go;	# for those working with UNIX shells
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   148
    die "ERROR: EPOCROOT must be an absolute path, " .
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   149
	"not containing a drive letter.\n" if ($epocroot !~ /^\\/);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   150
    die "ERROR: EPOCROOT must not be a UNC path.\n" if ($epocroot =~ /^\\\\/);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   151
    die "ERROR: EPOCROOT must end with a backslash.\n" if ($epocroot !~ /\\$/);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   152
    die "ERROR: EPOCROOT must specify an existing directory.\n" 
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   153
	if (!-d $epocroot);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   154
    return $epocroot;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   155
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   156
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   157
#
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   158
# Determines and returns the current drive, if any.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   159
#
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   160
sub getDrive
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   161
{
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   162
    my $wd = cwd;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   163
    if($wd =~ /^([a-zA-Z]:)/) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   164
	$drive = $1;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   165
    } else {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   166
	# Perhaps we're on a machine that has no drives.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   167
	$drive = "";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   168
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   169
    return $drive;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   170
}