deprecated/buildtools/emulatorlauncher/perl/epoc.pl
changeset 662 60be34e1b006
parent 655 3f65fd25dfd4
equal deleted inserted replaced
654:7c11c3d8d025 662:60be34e1b006
       
     1 # Copyright (c) 1999-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 # All rights reserved.
       
     3 # This component and the accompanying materials are made available
       
     4 # under the terms of "Eclipse Public License v1.0"
       
     5 # which accompanies this distribution, and is available
       
     6 # at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 #
       
     8 # Initial Contributors:
       
     9 # Nokia Corporation - initial contribution.
       
    10 #
       
    11 # Contributors:
       
    12 #
       
    13 # Description:
       
    14 # Launcher for the Symbian Emulator, including
       
    15 # functionality to read the $ENV{EPOCROOT}epoc32\data\BuildInfo.txt
       
    16 # file to find out information regarding the current Emulator.
       
    17 # Depends on the current working directory providing
       
    18 # the drive of the currently used SDK.
       
    19 # 
       
    20 #
       
    21 
       
    22 use Cwd;
       
    23 
       
    24 #
       
    25 # Check the argument(s), if any.
       
    26 #
       
    27 $numArgs = $#ARGV + 1;
       
    28 
       
    29 if($numArgs == 0) 
       
    30 	{
       
    31     	&launchEmulator("udeb","winscw");
       
    32     	exit(0);
       
    33 	}
       
    34 
       
    35 if($numArgs > 2) 
       
    36 	{
       
    37     	&printHelp;
       
    38     	die "ERROR: Too many arguments.\n";
       
    39 	}
       
    40 
       
    41 if($numArgs == 1)
       
    42 	{ 
       
    43 	if(lc($ARGV[0]) eq "-rel") 
       
    44 		{
       
    45     		&launchEmulator("urel","winscw");
       
    46     		exit(0);
       
    47 		}
       
    48 
       
    49 	if (lc($ARGV[0]) eq "-version") 
       
    50 		{
       
    51     		&printVersion;
       
    52     		exit(0);
       
    53 		}
       
    54 
       
    55 	if(lc($ARGV[0]) eq "-wins") 
       
    56 		{
       
    57     		&launchEmulator("udeb", "wins");
       
    58     		exit(0);
       
    59 		}
       
    60 
       
    61 	if(lc($ARGV[0]) eq "-winscw") 
       
    62 		{
       
    63     		&launchEmulator("udeb", "winscw");
       
    64     		exit(0);
       
    65 		}
       
    66 
       
    67 	if(lc($ARGV[0]) eq "-help") 
       
    68 		{
       
    69     		&printHelp;
       
    70     		exit(0);
       
    71 		}
       
    72 	}
       
    73 
       
    74 if ($numArgs == 2)
       
    75 	{
       
    76 	if(lc($ARGV[0]) eq "-rel") 
       
    77 		{
       
    78 		if (lc($ARGV[1]) eq "-wins")
       
    79 			{
       
    80     			&launchEmulator("urel","wins");
       
    81     			exit(0);
       
    82 			}
       
    83 
       
    84 		if (lc($ARGV[1]) eq "-winscw")
       
    85 			{
       
    86     			&launchEmulator("urel","winscw");
       
    87     			exit(0);
       
    88 			}
       
    89 		}	
       
    90 	
       
    91 	if (lc($ARGV[0]) eq "-winscw")
       
    92 		{
       
    93 		if (lc($ARGV[1] eq "-rel"))
       
    94 			{
       
    95 			&launchEmulator("urel","winscw");
       
    96 			exit(0);	
       
    97 			}
       
    98 		}
       
    99 	
       
   100 	if (lc($ARGV[0]) eq "-wins")
       
   101 		{
       
   102 		if (lc($ARGV[1] eq "-rel"))
       
   103 			{
       
   104 			&launchEmulator("urel","wins");
       
   105 			exit(0);	
       
   106 			}
       
   107 		}	
       
   108 	}
       
   109 
       
   110 # Error, unknown argument.
       
   111 &printHelp;
       
   112 die "ERROR: Unknown argument " . "\"" . $ARGV[0] . "\".\n";
       
   113 
       
   114 sub launchEmulator
       
   115 {
       
   116     my ($type,$win) = @_;
       
   117 
       
   118     my $epocroot = &getEpocroot;
       
   119     my $drive = &getDrive;
       
   120     my $emu = $drive . $epocroot . "epoc32" . "\\" 
       
   121 	      . "release\\" . $win . "\\" . $type . "\\" . "epoc.exe";
       
   122     -e $emu ||
       
   123 	die "ERROR: File \"$emu\" not found.\n\n" .
       
   124 	    "The EPOCROOT environment variable does not identify\n" .
       
   125 	    "a valid Symbian emulator installation on this drive.\n" . 
       
   126 		"EPOCROOT must be an absolute path to an existing\n" .
       
   127 		    "directory - it should have no drive qualifier and\n" .
       
   128 			"must end with a backslash.\n";
       
   129     # If the execute is successful, this never returns.
       
   130     exec("\"" . $emu . "\"") || die "Failed to execute the emulator \"$emu\": $!";
       
   131 }
       
   132 
       
   133 sub printHelp
       
   134 {
       
   135     print "Symbian Platform Emulator Launcher\n";
       
   136     print "Syntax :\tepoc [-rel] [-wins|-winscw] [-version] [-help]\n";
       
   137     print "(no options)\tLaunch active winscw debug emulator\n";
       
   138     print "-rel\t\tLaunch active release emulator\n";
       
   139     print "-wins\t\tLaunch active wins emulator\n";
       
   140     print "-winscw\t\tLaunch active winscw emulator\n";
       
   141     print "-version\tDisplay active emulator details\n";
       
   142     print "-help\tOutput this help message\n";
       
   143 }
       
   144 
       
   145 sub printVersion
       
   146 {
       
   147     my $epocroot = &getEpocroot;
       
   148     my $drive = &getDrive;
       
   149 
       
   150     my $binfo = $drive . $epocroot . "epoc32" . "\\" 
       
   151 	        . "data" . "\\" . "BuildInfo.txt";
       
   152 
       
   153     -e $binfo || die "ERROR: File \"" . $binfo . "\" does not exist.\n";
       
   154     open(IFILE, $binfo) ||
       
   155 	die "ERROR: Failed to open file \"" . $binfo . "\": $!";
       
   156 
       
   157     my $DeviceFamily = "";
       
   158     my $DeviceFamilyRev = "";
       
   159     my $ManufacturerSoftwareRev = "";
       
   160     my $ManufacturerSoftwareBuild = "";
       
   161 
       
   162     while(<IFILE>) {
       
   163 	if(/DeviceFamily\s+(.*\S)\s*$/i) {
       
   164 	    $DeviceFamily = $1;
       
   165 	}
       
   166 	if(/DeviceFamilyRev\s+(.*\S)\s*$/i) {
       
   167 	    $DeviceFamilyRev = $1;
       
   168 	}
       
   169 	if(/ManufacturerSoftwareRev\s+(.*\S)\s*$/i) {
       
   170 	    $ManufacturerSoftwareRev = $1;
       
   171 	}
       
   172 	if(/ManufacturerSoftwareBuild\s+(.*\S)\s*$/i) {
       
   173 	    $ManufacturerSoftwareBuild = $1;
       
   174 	}
       
   175     }
       
   176 
       
   177     close(IFILE);
       
   178 
       
   179     #
       
   180     # Verify that we got everything we should have.
       
   181     #
       
   182     $DeviceFamily ne "" ||
       
   183 	die "ERROR: Device family not specified in file \"" . $binfo .
       
   184 	    "\".\n";
       
   185     $DeviceFamilyRev ne "" ||
       
   186 	die "ERROR: Device family revision not specified in file \"" . $binfo .
       
   187 	    "\".\n";
       
   188     $ManufacturerSoftwareBuild ne "" ||
       
   189 	die "ERROR: Manufacturer software build not specified in file \"" .
       
   190 	    $binfo . "\".\n";
       
   191 
       
   192     $Revision = (($ManufacturerSoftwareRev eq "")?($DeviceFamilyRev):
       
   193 		 ($ManufacturerSoftwareRev));
       
   194 
       
   195     $DeviceFamily = getDFRDName($DeviceFamily);
       
   196 
       
   197     #
       
   198     # Make the standard revision representation prettier,
       
   199     # but leave other representations untouched.
       
   200     #
       
   201     if($Revision =~ /^0x([0-9])([0-9][0-9])$/) {
       
   202 	$Revision = $1 . "." . $2;
       
   203     }
       
   204    
       
   205     print $DeviceFamily . " " .
       
   206 	"version " . $Revision . " " .
       
   207 	    "build " . $ManufacturerSoftwareBuild . "\n";
       
   208 }
       
   209 
       
   210 #
       
   211 # Determines, validates, and returns EPOCROOT.
       
   212 #
       
   213 sub getEpocroot
       
   214 {
       
   215     my $epocroot = $ENV{EPOCROOT};
       
   216     die "ERROR: Must set the EPOCROOT environment variable.\n"
       
   217 	if (!defined($epocroot));
       
   218     $epocroot =~ s-/-\\-go;	# for those working with UNIX shells
       
   219     die "ERROR: EPOCROOT must be an absolute path, " .
       
   220 	"not containing a drive letter.\n" if ($epocroot !~ /^\\/);
       
   221     die "ERROR: EPOCROOT must not be a UNC path.\n" if ($epocroot =~ /^\\\\/);
       
   222     die "ERROR: EPOCROOT must end with a backslash.\n" if ($epocroot !~ /\\$/);
       
   223     die "ERROR: EPOCROOT must specify an existing directory.\n" 
       
   224 	if (!-d $epocroot);
       
   225     return $epocroot;
       
   226 }
       
   227 
       
   228 #
       
   229 # Determines and returns the current drive, if any.
       
   230 #
       
   231 sub getDrive
       
   232 {
       
   233     my $wd = cwd;
       
   234     my $drive;
       
   235     if($wd =~ /^([a-zA-Z]:)/) {
       
   236 	$drive = $1;
       
   237     } else {
       
   238 	# Perhaps we're on a machine that has no drives.
       
   239 	$drive = "";
       
   240     }
       
   241     return $drive;
       
   242 }
       
   243 
       
   244 #
       
   245 # The DFRD may be represented by a numeric value, as defined by HAL.
       
   246 # Changes known numeric values to the name of the DFRD,
       
   247 # and leaves all other values untouched.
       
   248 #
       
   249 sub getDFRDName
       
   250 {
       
   251     my $dfrd = shift;
       
   252     return "Crystal" if $dfrd eq "0";
       
   253     return "Pearl" if $dfrd eq "1";
       
   254     return "Quartz" if $dfrd eq "2";
       
   255     return $dfrd; # as fallback
       
   256 }