tsrc/data/batcases.bat
changeset 0 14df0fbfcc4e
equal deleted inserted replaced
-1:000000000000 0:14df0fbfcc4e
       
     1 rem
       
     2 rem Copyright (c) 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 batcases.bat %1 %2 %3 %4 %5 %6 %7 %8 %9 
       
    18 @goto end
       
    19 
       
    20 #!perl
       
    21 use strict;
       
    22 use File::Find;
       
    23 use File::Copy;
       
    24 use Cwd;
       
    25 
       
    26 
       
    27 my $target = "winsspd";
       
    28 my $suite;
       
    29 my $install = "no";
       
    30 my $session = "no";
       
    31 my $combinedSession = "no";
       
    32 my $sdkversion="";
       
    33 my $noXmlsGenList = "play_new";
       
    34 
       
    35 my %DirHash;
       
    36 
       
    37 my $sendEmail = "no";
       
    38 my $rootDrive = substr(getcwd(), 0,2);
       
    39 my $templateRoot = getcwd();
       
    40 my	$ATSRoot = getcwd()."\\ATSINPUT";
       
    41 
       
    42 if($ENV{'ATS_SETUP'}  ne "")
       
    43 {
       
    44  $sendEmail = "yes";
       
    45  $rootDrive = $ENV{'ATS_INDRIVE'};
       
    46  $templateRoot = $ENV{'ATS_TEMPLATEROOT'};
       
    47  $ATSRoot = $ENV{'ATS_ATSOUTDRIVE'};
       
    48 }
       
    49 
       
    50 
       
    51 if(scalar @ARGV ==0 || $ARGV[0] =~ /[\-\\\/][h\?]/ || $ARGV[0] =~ /help/ )
       
    52 {
       
    53 	print <<EOHelp;
       
    54 genatsmodules.bat - hardcoded script to generate ATSINPUT folders for mobileruntime and ngi projects	
       
    55 Usage:
       
    56 	genatsmodules.bat
       
    57 		Create ATSINPUT for the default testsuite based on 
       
    58 		location it is executed from place in stdlibs/internal 
       
    59 		and run and it generates ATSINPUT for stdlibs
       
    60 		similiarly place it in ssl/internal or glib/internal or 
       
    61     ngi/internal and run to generate  ATSINPUT for ssl, glib  
       
    62     and ngi respectively	
       
    63   
       
    64   genatsmodules [libname]
       
    65 			where libname can be stdlibs, ssl, glib, etc. Creates 
       
    66 			ats test drop for given library. Valid from any internal
       
    67 			folder of mobileruntime.
       
    68 			
       
    69   
       
    70   genatsmodules ngi
       
    71 			create ngi testsuite. Valid inside ngi/internal only
       
    72 			
       
    73 genatsmodules play_new
       
    74 			create play_new testsuite. Valid inside play_new/internal only
       
    75 				
       
    76 	
       
    77       
       
    78 	genatsmodules ltp
       
    79 			create ltp testsuite. Valid inside stdlibs/internal only
       
    80 	
       
    81 	genatsmodules lsb
       
    82 			create lsb testsuite. Valid inside stdlibs/internal only
       
    83 			
       
    84 	genatsmodules stdcpp
       
    85 			create stdcpp testsuite. Valid inside stdcpp/internal only
       
    86 			
       
    87 	genatsmodules [libname] install 
       
    88 		 where libname can be stdlibs, ssl, glib, ltp, lsb to create a 
       
    89 		 ATSINPUT where the dependent mobileruntime libraries are also 
       
    90 		 copied and used (It copies the dependent libraries using the 
       
    91 		 ATS component files)
       
    92 		
       
    93 	genatsmodules session [libname] [target] 		
       
    94 		where libname is any of the standard libs as shown above and 
       
    95 		target can be winsspd, winscw, scarfe, zeus etc. to create 
       
    96 		session files for scarfe, winsspd etc. 
       
    97 		
       
    98 genatsmodules session combined [target] 				
       
    99       will look at the existing ATSINPUT(which can have any 
       
   100       combination of created components and create a combined 
       
   101       session file. This way you get increased flexibility in 
       
   102       the libraries you choose to combine into a single session 
       
   103       file. If the target is a hardware target(that is not winsspd
       
   104       or winscw), the script will first attempt to find a target 
       
   105       specific component file and if not found, the generic hw 
       
   106       component file. 
       
   107 	
       
   108 
       
   109 	Note:
       
   110 	ATSINPUT creation is a 2 stage process. First we create 
       
   111 	the components and then we run (for example) 
       
   112 	"genatsmodules session stdlibs winscw" and 
       
   113 	"genatsmodules session stdlibs scarfe" to create the 
       
   114 	session files.
       
   115 EOHelp
       
   116 		exit();
       
   117 }
       
   118 my $do_armv5 = 1;
       
   119 my $do_winscw = 1;
       
   120 
       
   121 if(scalar @ARGV == 1)
       
   122 {
       
   123 	if($ARGV[0] eq "session")
       
   124 	{
       
   125 		die("parameter session must be followed by libname and target platform");
       
   126 	}
       
   127 	else
       
   128 	{
       
   129 		$suite = $ARGV[0];
       
   130 	}
       
   131 }
       
   132 elsif(scalar @ARGV == 2)
       
   133 {
       
   134 	if($ARGV[0] eq  "session")
       
   135 	{
       
   136 		die("parameter session must be followed by libname and target platform");
       
   137 	}
       
   138 	elsif($ARGV[1] eq "install")
       
   139 	{
       
   140 		$suite = $ARGV[0];
       
   141 		$install = "yes";
       
   142 	}
       
   143 	elsif($ARGV[1] eq "armv5")
       
   144 	{
       
   145 		$do_winscw = 0;
       
   146 	}
       
   147 	elsif($ARGV[1] eq "winscw")
       
   148 	{
       
   149 		$do_armv5 = 0; 
       
   150 	}
       
   151 	else
       
   152 	{
       
   153 		die("second parameter after target platform $ARGV[0] can only be \"install\" ");
       
   154 	}
       
   155 }
       
   156 elsif(scalar @ARGV == 3)
       
   157 {
       
   158 		if($ARGV[0] ne "session")
       
   159 		{
       
   160 			die("invalid combination of parameters. Program expected 1st parameter to be \"session\" ");
       
   161 		}
       
   162 		else
       
   163 		{
       
   164 			$session = "yes";
       
   165 			$suite = $ARGV[1];
       
   166 			$target = $ARGV[2];
       
   167 	
       
   168 			if($suite eq "combined")
       
   169 			{		
       
   170 				$combinedSession = "yes";
       
   171 	  	}
       
   172 			
       
   173 		}
       
   174 }
       
   175 elsif(scalar @ARGV == 4)
       
   176 {
       
   177 		if($ARGV[0] ne "session")
       
   178 		{
       
   179 			die("invalid combination of parameters. Program expected 1st parameter to be \"session\" ");
       
   180 		}
       
   181 		else
       
   182 		{
       
   183 			$session = "yes";
       
   184 			$suite = $ARGV[1];
       
   185 			$target = $ARGV[2];
       
   186 			$sdkversion = $ARGV[3];
       
   187 			if($suite eq "combined")
       
   188 			{		
       
   189 				$combinedSession = "yes";
       
   190 	  	}
       
   191 		}
       
   192 }
       
   193 else
       
   194 {
       
   195 		die("program recieved too many parameters!");
       
   196 }#end of commandline processing
       
   197 
       
   198 
       
   199 	
       
   200 if( 0 )
       
   201 {
       
   202 	die("Please run the script from the appropriate internal folder in the mobileruntime /omerta project!!");
       
   203 }
       
   204 else
       
   205 {
       
   206 
       
   207 	 my $srcPrefix = getcwd();
       
   208 	 $srcPrefix =~ /(.*)internal.*/;
       
   209 	 $srcPrefix = $1;
       
   210 	 if(rindex($templateRoot, "stdlibs") != -1)
       
   211 	 {
       
   212 	 	$srcPrefix =~ /(.*)stdlibs.*/;
       
   213 	 	$srcPrefix = $1;
       
   214 	 	
       
   215 	 	if($suite eq "glib")
       
   216 	 	{
       
   217 	 		$templateRoot = $srcPrefix."/glib/internal/";
       
   218 	 	}
       
   219 	 	elsif($suite eq "ssl")
       
   220 	 	{
       
   221 	 		$templateRoot = $srcPrefix."/ssl/internal/";
       
   222 	 	}
       
   223 	 	elsif($suite eq "ngi" && $session ne "yes")
       
   224 	 	{
       
   225 	 		print "ngi atsinput creation not supported from mobileruntime\n";
       
   226 	 		exit();
       
   227 	 	}
       
   228 	 }
       
   229 	 
       
   230 	if(rindex($templateRoot, "glib") != -1)
       
   231 	{
       
   232 		$suite = "glib";
       
   233 	}
       
   234 	elsif(rindex($templateRoot, "ssl") != -1)
       
   235 	{
       
   236 		$suite = "ssl";
       
   237 	}
       
   238 	elsif(rindex($templateRoot, "ngi") != -1)
       
   239 	{
       
   240 		$suite = "ngi";
       
   241 	}
       
   242 }
       
   243 
       
   244 
       
   245 my $optsGroupPath = $templateRoot."/ts/ltp/opts/group/";
       
   246 #$optsGroupPath = getcwd()."/ts/ltp/opts/group/";
       
   247 my $ltpPath =$templateRoot."/ts/ltp/";
       
   248 my $stdcppPath =$templateRoot."/testapps/stlport/";
       
   249 my @stdexeList = ("tstdcpp","stdcxx/tstapps");
       
   250 #my $gnuPath =getcwd()."/testapps/gnu/";
       
   251 #my $tstdcppPath =getcwd()."/testapps/tstdcpp/";
       
   252 
       
   253 
       
   254 my @generatedModules;
       
   255 my %cfglocation;
       
   256 
       
   257 my $TDIR = "\\internal\\testapps\\";
       
   258 
       
   259 my @libcModules = ( "libc_loc_blr",  "libc_time_blr", "libc_db_blr","tctype", "tifioctls", "tinet",
       
   260                       "tlibcwchar", "tlink", "tmkfifo", "tmmap", "tmsgqueue",
       
   261 		      "tnetdb", "tpipe","tregex", "tsemaphore", "tshm","tsocket" ,
       
   262 		      "tstdio", "tstdlib", "tstring", "tsyscalls",
       
   263 		      "tsyssim", "twctype", "tselect", "tsysunistd", "twideapis", "twopen", "twchar",
       
   264 		      "twcharapi",
       
   265                );
       
   266 
       
   267 my @libdlModules = ("tlibdl");
       
   268 my @libmModules = ("libm_double_blr", "libm_float_blr","libm_ldouble_blr");
       
   269 
       
   270 
       
   271 my @pthreadModules = ( "testcondbroadcast", "testconddestroy", "testcondinit", "testcondsignal", "testcondtimedwait", "testcondwait",
       
   272 "tmutex", "tpthread", "testpthreadonce", "testsemclose", "testsemdestroy", "testsemgetvalue", "testseminit", "testsemopen", "testsempost",
       
   273 "testsemtimedwait", "testsemtrywait", "testsemunlink", "testsemwait");
       
   274 
       
   275 
       
   276 my @stdliblist = ( "libc", "libpthread", "libdl", "libm", "libz", "libcrypt");
       
   277 my @dllList = ("backend.dll", "libc.dll", "LibCIpcClient.dll", "LibCIpcServer.exe", "libdl.dll", "libm.dll", "libpthread.dll", "libcrypt.dll", "libz.dll", "libclogger.dll");
       
   278 
       
   279 
       
   280 my @stdcpplist = (
       
   281   				 ["fstream1_input.txt", "stlport_fstream", "/../internal/testapps/doc/", "/General/", "C:\\TestFramework\\tstdcpp"],
       
   282   				 ["nextperm1_good.txt", "stlport_nextprm", "/../internal/testapps/doc/", "/General/", "C:\\TestFramework\\tstdcpp"],
       
   283   				 ["nextperm2_good.txt", "stlport_nextprm", "/../internal/testapps/doc/", "/General/", "C:\\TestFramework\\tstdcpp"],
       
   284   				 ["ostmit_good.txt", "stlport_ostmit", "/../internal/testapps/doc/", "/General/", "C:\\TestFramework\\tstdcpp"],
       
   285   				 ["seek.txt", "stlport_seek", "/../internal/testapps/doc/", "/General/", "C:\\TestFramework\\tstdcpp"],
       
   286 );
       
   287 
       
   288 my @gliblist = (
       
   289   				 ["1.gmarkup", "markup_test", "/epoc32/winscw/c/", "/General/", "C:"],
       
   290    				 ["1.gmarkup", "markup-test", "/epoc32/winscw/c/", "/General/", "C:"],
       
   291   				 ["iochannel-test-infile", "iochannel_test",  "/epoc32/winscw/c/", "/General/", "C:"],
       
   292   				 ["iochannel-test-infile", "iochannel-test",  "/epoc32/winscw/c/", "/General/", "C:"],
       
   293 #  				 ["casemap.bin",  "unicode-caseconv",  "/epoc32/winscw/c/", "/General/", "C:"],
       
   294 #  				 ["casefold.bin", "unicode-caseconv",  "/epoc32/winscw/c/", "/General/", "C:"],
       
   295   				 ["utf8.txt", "unicode-encoding","/epoc32/winscw/c/", "/General/", "C:"],
       
   296   				 ["casecollate.txt", "unicode-collate","/epoc32/winscw/c/", "/General/", "C:"],
       
   297   				 ["utf8_hindi.txt", "tutf8","/epoc32/winscw/c/", "/General/", "C:"],
       
   298   				 ["scanfile.txt", "tscanner","/epoc32/winscw/c/", "/General/", "C:"],
       
   299   				 ["test.txt", "dir_test","/epoc32/winscw/c/temp/tmp/", "/General/", "C:\\temp\\tmp"],
       
   300   				 ["NormalizationTest.txt", "unicode-normalize","/epoc32/winscw/c/", "/General/", "C:"],
       
   301   				 
       
   302   				 ["helloworld.exe", "spawn_test","/epoc32/release/armv5/urel/", "/armv5_urel/", "C:\\sys\\bin"],
       
   303   				 ["helloworld.exe", "spawn_test","/epoc32/release/winscw/udeb/", "/winscw_udeb/", "Z:\\sys\\bin"],
       
   304   				 
       
   305   				 ["libmoduletestplugin_a.dll", "module-test","/epoc32/release/armv5/urel/", "/armv5_urel/", "C:\\sys\\bin"],
       
   306   				 ["libmoduletestplugin_a.dll", "module-test","/epoc32/release/winscw/udeb/", "/winscw_udeb/", "Z:\\sys\\bin"],
       
   307   				 
       
   308   				 ["libmoduletestplugin_b.dll", "module-test","/epoc32/release/armv5/urel/", "/armv5_urel/", "C:\\sys\\bin"],
       
   309   				 ["libmoduletestplugin_b.dll", "module-test","/epoc32/release/winscw/udeb/", "/winscw_udeb/", "Z:\\sys\\bin"],
       
   310   				 
       
   311   			  				 
       
   312   				 );
       
   313   				 
       
   314 my @ngilist = (
       
   315            ["Test.txt", "ngi_sa_runtimetester", "/EPOC32/winscw/c/Private/10202be9/", "/General/", ""],
       
   316   				 ["sa_input_repository.txt", "shared","/EPOC32/armv5/c/TestFramework/", "/armv5_urel/", ""],
       
   317   				 ["sa_input_repository.txt", "shared","/EPOC32/winscw/c/TestFramework/", "/winscw_udeb/", ""],
       
   318   				 ["audiomixingfiles.ini", "ngi_sa_audiomixing","/EPOC32/winscw/c/TestFramework/", "/general/", ""],
       
   319   				 ["sa_camera_supported.ini", "ngi_sa_camera","/EPOC32/armv5/c/TestFramework/", "/general/", ""],
       
   320   				 ["sa_clip.ini", "ngi_sa_clip","/EPOC32/winscw/c/TestFramework/", "/general/", ""],
       
   321   				 ["devicecapabilitiesdata.ini", "ngi_sa_devicecapabilities","/EPOC32/winscw/c/TestFramework/", "/general/", ""],
       
   322    				 ["highlevelaudiofiles.ini", "ngi_sa_highlevelaudio","/EPOC32/winscw/c/TestFramework/", "/general/", ""],
       
   323 					 ["lowlevelaudiofiles.ini", "ngi_sa_lowlevelaudio","/EPOC32/winscw/c/TestFramework/", "/general/", ""],
       
   324 					 ["runtimedata.ini", "ngi_sa_runtimetester","/EPOC32/winscw/c/TestFramework/", "/general/", ""],						
       
   325 					 ["sa_stream.ini", "ngi_sa_stream","/EPOC32/winscw/c/TestFramework/", "/general/", ""],						
       
   326 					 #["*", "ngi_sa_videoplayback","/../graphics/video/internal/sa_videoplayback/data/", "/general/", ""],
       
   327 					 ["test.*", "ngi_sa_images","/Epoc32/winscw/c/Data/", "/general/", ""]
       
   328 					);
       
   329 
       
   330   				 
       
   331 
       
   332 
       
   333 my $validexpansions = "all stdlibs combined";
       
   334 my $validLibraries = "ltp opts lsb glib ssl ngi pcts stdcpp gcce libc-locale play_new phall sapi";
       
   335 if(rindex($validexpansions, $suite)== -1 && rindex($validLibraries, $suite) == -1)
       
   336 {
       
   337 	die("$suite is not a valid library. Valid options are $validexpansions $validLibraries");
       
   338 }
       
   339 
       
   340 my $dontStrip = 1;
       
   341 my	@liblist;
       
   342 if($suite eq "all")
       
   343 {
       
   344 		@liblist = split " ", $validLibraries;
       
   345 		@liblist = (@liblist, @stdliblist);
       
   346 		
       
   347 }#suite all
       
   348 elsif($suite eq "ltp")
       
   349 {
       
   350 	 @liblist = ("ltp", "opts");
       
   351 }
       
   352 elsif($suite eq "stdlibs")
       
   353 {
       
   354 		@liblist = @stdliblist;
       
   355 }
       
   356 elsif($suite eq "ssl")
       
   357 {
       
   358 	@liblist = ("libcrypto", "libssl");
       
   359 }
       
   360 else
       
   361 {
       
   362 		@liblist = ("$suite");
       
   363 }
       
   364 
       
   365 #	foreach my $l(@liblist)
       
   366 #	{
       
   367 #			print "$l was there\n";
       
   368 #	}
       
   369 
       
   370 
       
   371 if($combinedSession eq "yes")
       
   372 {
       
   373 	GenerateSessionFile("combined", $target,"combined");
       
   374 	exit();
       
   375 }
       
   376 
       
   377 if($session eq "yes")
       
   378 {
       
   379 	my $file = $templateRoot."/testsession.xml";
       
   380 	opendir(DIRHANDLE, $ATSRoot) || die("Please try to create Session files only after ATSINPUT/components has been created!");
       
   381 	closedir(DIRHANDLE);
       
   382 	$dontStrip = 1;
       
   383 	
       
   384 	if($suite eq "stdlibs")
       
   385 	{
       
   386 		#my $dst = $ATSRoot."/$suite"."_testsession.xml";
       
   387 		#copy($file, $dst);
       
   388 		GenerateSessionFile("combined",$target,$suite);
       
   389 		exit();
       
   390 	}
       
   391 	elsif($suite eq "ssl")
       
   392 	{
       
   393 		my @componentFiles = GetSslXmls();
       
   394 		GenerateSessionFile("combined",$target,$suite,\@componentFiles);
       
   395 		exit();
       
   396 	}
       
   397 	else
       
   398 	{
       
   399 		@generatedModules = GenGenModules($suite);
       
   400 		my @componentFiles = GetXmls($suite);
       
   401 		GenerateSessionFile("combined",$target,$suite,\@componentFiles);
       
   402 		exit();
       
   403 	}
       
   404 	foreach my $lib(@liblist)
       
   405 	{          
       
   406 			@generatedModules = GenGenModules($lib);
       
   407 			if(scalar @generatedModules != 0)
       
   408 			{
       
   409 				#print "Generating for $lib\n";
       
   410 				GenerateSessionFile($lib, $target,$lib);
       
   411 			}
       
   412 	}
       
   413 	
       
   414 	#@generatedModules = GetAllModules();
       
   415 	#if(scalar @generatedModules != 0)
       
   416 	#{
       
   417 	#		GenerateSessionFile("combined",$target, "combined");
       
   418 	#}
       
   419 	exit();
       
   420 }#session generation code
       
   421 
       
   422 
       
   423 if ($suite eq "ltp" || $suite eq "all")
       
   424 {
       
   425 	my @ltpModules = GetLtpModules();
       
   426 	@generatedModules = @ltpModules;
       
   427 	DoGen("ltp", ".dll");
       
   428 	CopyLtpCfg("ltp");
       
   429 	
       
   430 	
       
   431 	my @saved = @dllList;
       
   432 	@dllList = ("ltplib.dll");
       
   433 	CopySharedDlls("ltp", \@dllList);
       
   434 	TransformXmls("ltp","shared");
       
   435 	@dllList = @saved;
       
   436 	
       
   437 	@generatedModules = GetCompiledModules($optsGroupPath."/bld.inf");
       
   438 	DoGen("opts",".dll");
       
   439 
       
   440 }
       
   441 if ($suite eq "glib")
       
   442 {
       
   443 	my $bldfile = $templateRoot."/testapps/group/bld.inf";
       
   444 	my @glibModules = GetCompiledModules($bldfile);
       
   445 	@generatedModules = @glibModules;
       
   446 	DoGen("glib",".exe");
       
   447 	my $gDataRef = \@gliblist;
       
   448 	CopyArbitDatFiles("glib",$gDataRef);
       
   449 	
       
   450 	if($install eq "yes")
       
   451 	{
       
   452 		my @saved = @dllList;
       
   453 		my @glib2dllList = ("glibbackend.dll", "Libgobject.dll", "libgmodule.dll", "libgthread.dll",
       
   454                 "libglib.dll");
       
   455                 
       
   456    my  @glib1List = ( "libgobject.dll", "libgmodule.dll", "libgthread.dll",  "libglib.dll", );
       
   457   @dllList = @glib2dllList;
       
   458   CopySharedDlls("glib",\@dllList);     	
       
   459   TransformXmls("glib", "shared");
       
   460    	
       
   461 		@dllList = @saved;
       
   462 	}#if install
       
   463 }#glib
       
   464 
       
   465 if ($suite eq "phall")
       
   466 {
       
   467 	my $bldfile = getcwd()."/group/bld.inf";
       
   468 	my @hallModules = GetCompiledModules($bldfile);
       
   469 	@generatedModules = @hallModules;
       
   470 	DoGen($suite,".exe");
       
   471 	#my $gDataRef = \@gliblist;
       
   472 	#CopyArbitDatFiles("glib",$gDataRef);
       
   473 	
       
   474 	if($install eq "yes")
       
   475 	{
       
   476 		my @saved = @dllList;
       
   477                 
       
   478    my  @phallList = ( "libstdcpp.dll" );
       
   479    @dllList = @phallList;
       
   480    CopySharedDlls($suite,\@dllList);     	
       
   481    TransformXmls($suite, "shared");
       
   482    @dllList = @saved;
       
   483    exit;
       
   484 	}#if install
       
   485 }#phall
       
   486 
       
   487 if ($suite eq "ssl")
       
   488 {
       
   489 	my $stripStatus = $dontStrip;
       
   490 	$dontStrip = 0;
       
   491 	GenCryptoTest();
       
   492 	if($install eq "yes")
       
   493 	{
       
   494 		@dllList = (@dllList, "libcrypto.dll", "libssl.dll");   
       
   495 	}#if install
       
   496 	$dontStrip = $stripStatus;
       
   497 }#ssl
       
   498 
       
   499 if($suite eq "ngi")
       
   500 {
       
   501 
       
   502 	GenNgiTest();
       
   503 	CopyNgiXmls();
       
   504 	CopyArbitDatFiles("",\@ngilist);
       
   505 
       
   506 }
       
   507 
       
   508 if($suite eq "play_new")
       
   509 {
       
   510 	my @play_newModules = ("fonttestmodule", "messagingtestmodule","locationtestmodule", "alertstestmodule", 
       
   511 	"libxmlstiff","ngisvgtestmodule");
       
   512 	@generatedModules = @play_newModules;
       
   513 	DoGen("play_new",".dll");
       
   514 	
       
   515 	 my @list = (
       
   516   				 			 ["*.cfg", "fonttestmodule", "/../fonts/internal/testmodules/fonttestmodule/group/","/General/", ""],
       
   517 	 				 			 ["*.xml", "fonttestmodule", "/../fonts/internal/testmodules/fonttestmodule/group/","/", ""],
       
   518 	 				 			 
       
   519 	 				 			 ["*.cfg", "messagingtestmodule", "/../ngimessaging/internal/testmodules/messagingtestmodule/group/","/General/", ""],
       
   520 	 				 			 ["*.xml", "messagingtestmodule", "/../ngimessaging/internal/testmodules/messagingtestmodule/group/","/", ""],
       
   521 	 				 			 ["*", "messagingtestmodule", "/EPOC32/winscw/c/messagingtestmodule/","/General/", ""],
       
   522 	 				 			 
       
   523 	 				 			 ["*.cfg", "locationtestmodule", "/../ngilocation/internal/testmodules/locationtestmodule/group/","/General/", ""],
       
   524 	 				 			 ["*.xml", "locationtestmodule", "/../ngilocation/internal/testmodules/locationtestmodule/group/","/", ""],
       
   525 	 				 			 
       
   526 	 				 			 ["*.cfg", "alertstestmodule", "/../ngialerts/internal/testmodules/alertstestmodule/group/","/General/", ""],
       
   527 								 ["*.xml", "alertstestmodule", "/../ngialerts/internal/testmodules/alertstestmodule/group/","/", ""],	 				 			 
       
   528 								 ["vertigo.wav", "alertstestmodule", "/Epoc32/winscw/c/alertstestmodule/","/General/", ""],	 				 			 	 				 			 
       
   529 	 		
       
   530 	 			 			  ["*.cfg", "libxmlstiff", "/../libxmlpp/internal/group/","/General/", ""],
       
   531 	 		 	 			  ["*.xml", "libxmlstiff", "/../libxmlpp/internal/group/","/", ""],
       
   532 	 		 	 			  ["*.*", "libxmlstiff", "/../libxmlpp/internal/data/","/General/", ""],
       
   533 	 		 	 			  
       
   534 	 		 	 			  ["*.cfg", "ngisvgtestmodule", "/../ngisvg/internal/testmodules/ngisvgtestmodule/group/","/General/", ""],
       
   535    		 	 			  ["*.xml", "ngisvgtestmodule", "/../ngisvg/internal/testmodules/ngisvgtestmodule/group/","/", ""],
       
   536 	 		 	 			  ["*.*", "ngisvgtestmodule", "/epoc32/winscw/c/ngisvgtest/","/General/", ""],
       
   537 	 				 			 
       
   538   				 );
       
   539  
       
   540   my $bDataRef = \@list;  				 
       
   541 	CopyArbitDatFiles("play_new",$bDataRef);  				 
       
   542 	if($install eq "yes")
       
   543 	{
       
   544 		@generatedModules = GenGenModules("play_new");
       
   545 		my @saved = @dllList;
       
   546 		my @playList = (
       
   547 "ngifonts.dll",
       
   548 "ngimessaging.dll",
       
   549 "ngisvg.dll",
       
   550 "ngilocation.dll",
       
   551 "ngialerts.dll",
       
   552 "libstdcpp.dll",
       
   553 "libxmlpp.dll",
       
   554 "FeedsLibXml2xmlpp.dll");
       
   555        @dllList = @playList;
       
   556 		CopySharedDlls("play_new",\@dllList);     
       
   557 	  TransformXmls("play_new", "shared");
       
   558 		@dllList = @saved;
       
   559 
       
   560 	}#end install
       
   561 
       
   562 
       
   563 }
       
   564 
       
   565 if($suite eq "stdcpp")
       
   566 {
       
   567 	@generatedModules = GetstdcppModules();
       
   568 	DoGen("stdcpp",".dll");
       
   569 	CopyLtpCfg("stdcpp");
       
   570 	@generatedModules = GetstdexeModules();
       
   571 	DoGen("stdcpp",".exe");
       
   572 	
       
   573 	my @saved = @dllList;
       
   574 	@dllList = ("stdcxxtestengine.dll");
       
   575 	CopySharedDlls("stdcpp", \@dllList);
       
   576 	TransformXmls("stdcpp","shared");
       
   577 	@dllList = @saved;
       
   578 	
       
   579 	CopyArbitDatFiles("stdcpp",\@stdcpplist);
       
   580 	
       
   581 	if($install eq "yes")
       
   582 	{
       
   583 		@generatedModules = GenGenModules("stdcpp");
       
   584 		my @saved = @dllList;
       
   585 		my @cppList = ("libstdcpp.dll");
       
   586        @dllList = @cppList;
       
   587 		CopySharedDlls("stdcpp",\@dllList);     
       
   588 	  TransformXmls("stdcpp", "shared");
       
   589 		@dllList = @saved;
       
   590 		exit;
       
   591 	}#if install
       
   592 }
       
   593 
       
   594 if($suite eq "sapi")
       
   595 {
       
   596 	my @sapiexelist = 
       
   597 	(
       
   598  "noofframes",
       
   599  "positivenoimage",
       
   600  "negativeimagecancel",
       
   601  "negativeimageformatnone",
       
   602  "Negativemultipleimages",
       
   603  
       
   604 );
       
   605 	@generatedModules = @sapiexelist;
       
   606 	DoGen("sapi",".exe");
       
   607 	my @sapidlllist = 
       
   608 	(
       
   609 	"sapi_batcases",
       
   610 	
       
   611   );
       
   612   
       
   613 	@generatedModules = @sapidlllist;
       
   614 	DoGen("sapi",".dll");
       
   615 	
       
   616 	my @mysapidependcies = 
       
   617 	(
       
   618 	#first the file to copy, next the test for which to copy, next is relative locate, 
       
   619 	#if cfg, General,
       
   620 	#last the location on the phone where the cfg should go
       
   621 	#for us c:\\TestFramework
       
   622 
       
   623   ["sapi_batcases.cfg", "sapi_batcases", "./", "/General/", "C:\\TestFramework"],							
       
   624    ["ant.jpg", "sapi_batcases", "/..messaging/internal/testing/data/", "/General/", "c:\\data\\Images"],
       
   625   ["dhoom2whis192701.mp3", "sapi_batcases", "/..messaging/internal/testing/data/", "/General/", "c:\\data\\sounds\\digital"],
       
   626    ["vcardimport.vcf", "sapi_batcases", "/..contacts_vpbk/internal/dev/tcontactprovidertest/data/", "/General/", "C:"],							
       
   627   ["vcardimportposbased.vcf", "sapi_batcases", "/..contacts_vpbk/internal/dev/tcontactprovidertest/data/", "/General/", "C:"],							
       
   628    ["Import.vcf", "sapi_batcases", "/..contacts_vpbk/internal/dev/tcontactprovidertest_sync/data/", "/General/", "C:\\data"],								
       
   629   
       
   630   
       
   631   
       
   632   
       
   633   );
       
   634 
       
   635 	CopyArbitDatFiles("sapi",\@mysapidependcies);   	#CopyArbitDatFiles("stdcpp",\@mysapidependcies);
       
   636 	if($install eq "yes")
       
   637 	{
       
   638 	
       
   639 		@generatedModules = (@sapidlllist);      #(@sapidlllist, @sapiexelist);
       
   640 		my @saved = @dllList;
       
   641 		#this list is where the libraries to be tested goes
       
   642 		my @cppList = ("tmediamgmtprovidertest.dll",
       
   643 										"tmediamgmttest.dll",
       
   644 										"tlmlandmarktests.dll",
       
   645 										"Tlmdatabasetests.dll",
       
   646 										"tlmcategorytests.dll",
       
   647 										"TLandmarkProvider.dll",
       
   648 										"tlmprovidercategorytests.dll",
       
   649 										"TSAPILocTest.dll",
       
   650 										"tlocationprovidertest.dll",
       
   651 										"change_status_message.dll",
       
   652 										"get_header_message.dll",
       
   653 										"send_message.dll",
       
   654 										"async_send_message.dll",
       
   655 										"delete_message.dll",	
       
   656 										"tcontacts_async.dll",
       
   657 										"tcontacts_sync.dll",
       
   658 										"tcontactprovidertest.dll",
       
   659 										"tcontactprovidertest_sync.dll",
       
   660 		               );
       
   661     @dllList = @cppList;
       
   662 		CopySharedDlls("sapi",\@dllList);     #CopySharedDlls("stdcpp",\@dllList); 
       
   663 	  TransformXmls("sapi", "shared");      #TransformXmls("stdcpp", "shared");
       
   664 		@dllList = @saved;
       
   665 		exit;
       
   666 	}#if install
       
   667 }
       
   668 	
       
   669 
       
   670 if($suite eq "lsb" || $suite eq "all")
       
   671 {
       
   672 	my @lsbModules = GetLsbModules();
       
   673 	@generatedModules = @lsbModules;
       
   674 	DoGen("lsb",".exe");
       
   675 	
       
   676 	my @depDlls;
       
   677 	my $dll;
       
   678 	
       
   679 	#copying the common dlls
       
   680 	@depDlls  = 
       
   681 	(
       
   682 	 "libapi.dll",
       
   683 	 "tcm.dll",
       
   684 	 "vlib.dll",
       
   685 	);
       
   686 		
       
   687 	foreach $dll (@depDlls)
       
   688 	{
       
   689 		CopyDeps("lsb",$dll);
       
   690 	}
       
   691 	#now copy the cfg files
       
   692 	CopyLsbCfg("lsb");	
       
   693 	#now copy the extra dependency dlls
       
   694 	
       
   695 	#dlopen
       
   696 	@generatedModules = ("dlopen");
       
   697 	
       
   698 	
       
   699 	
       
   700 	@depDlls  = 
       
   701 	(
       
   702 	 "dynlibtest.1.dll",
       
   703 	 "dynlibtest.11.1.dll",
       
   704 	 "dynlibtest.11.2.dll",
       
   705 	 "dynlibtest.12g.dll",
       
   706 	 "dynlibtest.12r.dll",
       
   707 	 "dynlibtest.14.1.dll",
       
   708 	 "dynlibtest.14.2.dll",
       
   709 	 "dynlibtest.14.3.dll",
       
   710 	 "dynlibtest.3.1.dll",
       
   711 	 "dynlibtest.3.2.dll",
       
   712 	 "dynlibtest.3.dll",
       
   713 	 "dynlibtest.4.dll",
       
   714 	 "dynlibtest.8.dll",
       
   715 	 "dynlibtest.9.dll",
       
   716 	 "dynlibtest.3.dll",
       
   717 	 "dynlibtest.8.dll",
       
   718 	);
       
   719 	
       
   720 	foreach $dll (@depDlls)
       
   721 	{
       
   722 		CopyDeps("lsb",$dll);
       
   723 	}
       
   724 	
       
   725 	#dlclose
       
   726 	@generatedModules = ("dlclose");
       
   727 	@depDlls = ("dynlibclose.1.dll");
       
   728 	foreach $dll (@depDlls)
       
   729 	{
       
   730 		CopyDeps("lsb",$dll);
       
   731 	}
       
   732 	
       
   733 	#dlerror
       
   734 	@generatedModules = ("dlerror");
       
   735 	@depDlls = ("dynlib.dll");
       
   736 	foreach $dll (@depDlls)
       
   737 	{
       
   738 		CopyDeps("lsb",$dll);
       
   739 	}
       
   740 	
       
   741 	#now copy the xmls!
       
   742 	my $srcDir = $templateRoot."/ts/lsbsuites/group/";
       
   743 	
       
   744 	my $dst;
       
   745 	
       
   746 	foreach my $dllib("dlopen", "dlclose", "dlerror")
       
   747 	{
       
   748 		$dst  = $ATSRoot."\\components\\lsb_".$dllib."\\";
       
   749 		copy($srcDir."/lsb_".$dllib."_module_blr_hw_component.xml", $dst) || die("DIED: unable to copy from $srcDir!\n");
       
   750 		copy($srcDir."/lsb_".$dllib."_module_blr_winsspd_component.xml", $dst) || die("DIED: unable to copy from $srcDir!\n");
       
   751 	}
       
   752 	
       
   753 }
       
   754 
       
   755 if($suite eq "gcce")
       
   756 {
       
   757 
       
   758 	mkdir $ATSRoot;
       
   759 	mkdir $ATSRoot."\\components" || die ("DIED: unable to create component dir");
       
   760 	
       
   761 	@generatedModules = ("gcce-validate", "gcce-load");
       
   762 		
       
   763 	my @depDlls  = 
       
   764 	(
       
   765 		"gcce-lib.dll",
       
   766 	);
       
   767 	
       
   768 	my $suffix = ".exe";
       
   769 	my $libname = "gcce";
       
   770 	
       
   771 	
       
   772 	my $src;
       
   773 	my $dst;
       
   774 	foreach my $module(@generatedModules)
       
   775 	{
       
   776 		my $relroot = $ATSRoot."\\components\\$libname"."_$module";
       
   777 		mkdir $relroot || die("DIED: unable to create dir $module\n");
       
   778 		mkdir $relroot."\\armv5_urel" || die("DIED: unable to create dir $relroot\\armv5_urel\n");
       
   779 		
       
   780 		#GenExeXmls($module,$libname);
       
   781 		
       
   782 		$src = $rootDrive."\\epoc32\\release\\gcce\\urel\\".$module.$suffix;
       
   783 		$dst = $ATSRoot."\\components\\".$libname."_".StripModulePrefix($module);
       
   784 		$dst = $dst."\\armv5_urel\\";
       
   785 		copy($src, $dst)  || warn("unable to copy $src to $dst");
       
   786 	}
       
   787 	$src = $rootDrive."\\epoc32\\release\\gcce\\urel\\"."gcce-lib.dll";
       
   788 	$dst = $ATSRoot."\\components\\gcce_gcce-load";
       
   789 	$dst = $dst."\\armv5_urel\\";
       
   790 	copy($src, $dst)  || warn("unable to copy $src to $dst");
       
   791 	
       
   792 	
       
   793 	my @list = (
       
   794   				 ["gcce_gcce-load_module_blr_hw_component.xml", "gcce-load", "./","/", ""],
       
   795   				 ["gcce_gcce-validate_module_blr_hw_component.xml", "gcce-validate", "./","/", ""],
       
   796   				 );
       
   797  
       
   798   my $bDataRef = \@list;  				 
       
   799 	CopyArbitDatFiles("gcce",$bDataRef);  				 
       
   800 
       
   801 	
       
   802 }#if gcce
       
   803 
       
   804 
       
   805 
       
   806 if($suite eq "libc-locale")
       
   807 {
       
   808 	$dontStrip = 0;
       
   809 	mkdir $ATSRoot;
       
   810 	mkdir $ATSRoot."\\components" || die ("DIED: unable to create component dir");
       
   811 	
       
   812 	@generatedModules = ("tstring");
       
   813 	DoGen("libc",".dll");
       
   814 	
       
   815 	my @localelist = (
       
   816 	  				 ["locales.txt", "string", "../libc/internal/testapps/tstring/data/", "/General/", ""],
       
   817 	  				 ["tstring_locale_component.xml", "string", "../libc/internal/testapps/tstring/group/", "/", ""],
       
   818 	 
       
   819 	  				 );
       
   820 		
       
   821   my $bDataRef = \@localelist;  				 
       
   822 	CopyArbitDatFiles("libc",$bDataRef);  				 
       
   823 	#delete($ATSRoot."/components/libc_string/"."libc_string_module_blr_hw_component.xml") || die("unable to delete");
       
   824 	my $my_src = $ATSRoot."/components/libc_string/"."tstring_locale_component.xml";
       
   825 	my $my_dst = $ATSRoot."/components/libc_string/"."libc_string_module_blr_hw_component.xml";
       
   826 	
       
   827 	unlink($my_dst) ||warn("unable to delete $my_dst");
       
   828 	rename($my_src,$my_dst) || move($my_src,$my_dst) || die("Unable to rename!");
       
   829 	
       
   830 }#if libc-locale
       
   831 
       
   832 
       
   833 if($suite eq "pcts")
       
   834 {
       
   835 	my $bldfile = $templateRoot."/group/bld.inf";
       
   836 	my @pctsModules = GetCompiledModules($bldfile);
       
   837 	@generatedModules = @pctsModules;
       
   838 	DoGen("pcts",".exe");
       
   839 	
       
   840 	my @depDlls;
       
   841 	my $dll;
       
   842 	
       
   843 	
       
   844 	#copying the common dlls
       
   845 	@depDlls  = 
       
   846 	(
       
   847 		"vsxlibapi.dll",
       
   848 		"rttm.exe",
       
   849 		"rtlibapi.dll",
       
   850 		"vsxvlib.dll",
       
   851 		"vsxgenlib.dll",
       
   852 		"vsxtsetlib.dll",
       
   853 		"vsxvport.dll",
       
   854 	);
       
   855 	
       
   856 	if($install eq "yes")
       
   857 	{
       
   858 		my @saved = @dllList; 
       
   859 		@dllList = @depDlls;	
       
   860 		CopySharedDlls("pcts", \@depDlls);
       
   861 		TransformXmls("pcts","shared");
       
   862 		@dllList = @saved;
       
   863 		
       
   864 		#now copy the cfg files
       
   865 		my $dst;
       
   866 		my $srcDir = "/epoc32/winscw/c/data/tet/";
       
   867 		my $file1 = $srcDir."tet_code";
       
   868 		my $file2 = $srcDir."tetexec.cfg";
       
   869 		foreach my $module(@generatedModules)
       
   870 		{
       
   871 			$dst = $ATSRoot."\\components\\pcts_".$module;
       
   872 			$dst = $dst."\\General\\";
       
   873 			copy($file1, $dst) or die "copy: $! $file1 $dst";
       
   874 			copy($file2,$dst) or die "copy: $! $file2 $dst";
       
   875 		}
       
   876 	}
       
   877 		
       
   878 	
       
   879 	
       
   880 	
       
   881 	my $dst;	
       
   882 	foreach my $module(@generatedModules)
       
   883 	{
       
   884 		my $file3 = "/epoc32/winscw/c/logs/tet/m.".$module;
       
   885 
       
   886 		$dst = $ATSRoot."\\components\\pcts_".$module;
       
   887 		$dst = $dst."\\General\\";
       
   888 		copy($file3, $dst) or die "copy: $! $file3 $dst";
       
   889 	}#module
       
   890 }
       
   891 
       
   892 
       
   893 
       
   894 $dontStrip = 0;
       
   895 
       
   896 if($suite eq "stdlibs" || $suite eq "all")
       
   897 {
       
   898 	@generatedModules = ("tzlib");
       
   899 	DoGen("libz", ".dll");
       
   900 
       
   901 	@generatedModules = ("tlibcrypt");
       
   902 	DoGen("libcrypt",".dll");
       
   903 
       
   904 	@generatedModules = @libcModules;
       
   905 	DoGen("libc",".dll");
       
   906 	GenBackendTest();
       
   907 	
       
   908 	@generatedModules = ("twchar");
       
   909 	CopyDeps("libc","twchar_helloworld.exe");
       
   910 	
       
   911 	@generatedModules = ("twopen");
       
   912 	CopyDeps("libc","twpopenwritechild.exe");
       
   913 	CopyDeps("libc","twpopenreadchild.exe");
       
   914 
       
   915 
       
   916 	@generatedModules = @libdlModules;
       
   917 	DoGen("libdl",".dll");
       
   918 	CopyDeps("libdl","Dll1.dll");
       
   919 	CopyDeps("libdl","Dll2.dll");
       
   920 	CopyDeps("libdl","DependencyTestDll.dll");
       
   921 
       
   922 	@generatedModules = @libmModules;
       
   923 	DoGen("libm",".dll");
       
   924 
       
   925 	$TDIR = "\\internal\\";
       
   926 	@generatedModules = @pthreadModules;
       
   927 	DoGen("libpthread",".dll");
       
   928 	CopyDeps("libpthread","testharness.dll");
       
   929 
       
   930 	CopyDatFiles();
       
   931 }
       
   932 
       
   933 if($install eq "yes")
       
   934 {
       
   935 	foreach my $lib(@liblist)
       
   936 	{   
       
   937 		#print "Transforming lib $lib\n";       
       
   938 		@generatedModules = GenGenModules($lib);
       
   939 		my @oldList = @dllList;
       
   940 		if($do_winscw)
       
   941   	{
       
   942   		@dllList = (@dllList, "wsdsoln.dll", "libestw32.dll");
       
   943   		CopySharedDlls($lib,\@dllList,"winscw");     	
       
   944 	  	TransformXmls($lib, "shared","winscw");
       
   945   	}
       
   946   	@dllList = @oldList;
       
   947   	if($do_armv5)
       
   948   	{
       
   949 	  	CopySharedDlls($lib,\@dllList,"armv5");     	
       
   950 	  	TransformXmls($lib, "shared","armv5");
       
   951   	}
       
   952 	}#FOREACH
       
   953 }#if install
       
   954 
       
   955 
       
   956 
       
   957 #function to generate ModuleList for a compiled bld.inf
       
   958 sub GetCompiledModules($)
       
   959 {
       
   960 	my $file = shift @_;
       
   961 	my @moduleList;
       
   962 	
       
   963 	
       
   964 	# Open input file
       
   965 	open (INFILE, "<".$file ) || die ("DIED: Can not find $file!");
       
   966 
       
   967 	while (<INFILE>)
       
   968 	{
       
   969 		if(/(.*)\.mmp/ && $1 !~ /^\/\//) 
       
   970 	  {
       
   971 	  		if($_ !~ /\/\/Not for ATS/)
       
   972 	  		{
       
   973 	  			push @moduleList, $1;
       
   974 	  		}
       
   975 	  }
       
   976 	}
       
   977 	close (INFILE);
       
   978 	return @moduleList;
       
   979 }
       
   980 
       
   981 my @groupList;
       
   982 sub GetLtpModules()
       
   983 {
       
   984         my $prevDir = getcwd();
       
   985         my @rootList = ("kernel", "misc");
       
   986         my @totalgroupList;
       
   987         foreach my $node(@rootList)
       
   988         {
       
   989         	chdir $ltpPath."/$node";
       
   990         	@groupList = ();
       
   991         	find(\&MakeGroupList, ".");
       
   992         	@totalgroupList = (@totalgroupList, @groupList);
       
   993         }
       
   994         chdir $prevDir;
       
   995         return @totalgroupList;
       
   996 }
       
   997 
       
   998 sub GetstdexeModules()
       
   999 {
       
  1000       my $prevDir = getcwd();
       
  1001       my @fullList = ();
       
  1002       foreach my $group(@stdexeList)
       
  1003       {
       
  1004       	my $groupPath = $templateRoot."/testapps/".$group. "/";
       
  1005       	chdir $groupPath;
       
  1006       	@groupList = ();
       
  1007       	find(\&grovelAllMmpFiles, ".");
       
  1008       	chdir $prevDir;
       
  1009       	@fullList = (@fullList,@groupList);
       
  1010       }
       
  1011       return @fullList;      
       
  1012 }
       
  1013 
       
  1014 sub grovelAllMmpFiles()
       
  1015 {
       
  1016 	if($_ =~ /(.*)\.mmp/ && ! ($_ =~ /manual/))
       
  1017 	{
       
  1018 		push @groupList, $1;#get name of module
       
  1019 	}
       
  1020 }
       
  1021 
       
  1022 sub GetstdcppModules()
       
  1023 {
       
  1024         my $prevDir = getcwd();
       
  1025         my @rootList = ("auto");
       
  1026         my @totalgroupList;
       
  1027         foreach my $node(@rootList)
       
  1028         {
       
  1029         	chdir $stdcppPath."/$node";
       
  1030         	@groupList = ();
       
  1031         	find(\&MakeGroupList, ".");
       
  1032         	@totalgroupList = (@totalgroupList, @groupList);
       
  1033         }
       
  1034         chdir $prevDir;
       
  1035         return @totalgroupList;
       
  1036 }
       
  1037 
       
  1038 sub GetTstdcppModules()
       
  1039 {
       
  1040       my $prevDir = getcwd();
       
  1041       #chdir $tstdcppPath;
       
  1042       @groupList = ();
       
  1043       find(\&grovelAllMmpFiles, ".");
       
  1044       chdir $prevDir;
       
  1045       return @groupList;
       
  1046 }
       
  1047 
       
  1048 sub MakeGroupList()
       
  1049 {
       
  1050 	my $currentDir = $File::Find::dir;
       
  1051 	
       
  1052 	#print "Current dir:$currentDir\n";
       
  1053 	if( $currentDir =~ /.*\/(.*)\/group/)
       
  1054 	{
       
  1055 		if($cfglocation{$1} eq "")
       
  1056 		{
       
  1057 			$cfglocation{$1} = getcwd()."\/$1.cfg";
       
  1058 			push @groupList, $1;#get name of module
       
  1059 		}#first time in group
       
  1060 	}#group found
       
  1061 }#subrtn end
       
  1062 
       
  1063 
       
  1064 #function that generates the ATS setup
       
  1065 sub DoGen($$)
       
  1066 {
       
  1067 	my $libname = shift @_;
       
  1068 	my $ext = shift @_;
       
  1069 	mkdir $ATSRoot;
       
  1070 	mkdir $ATSRoot."\\components" || die ("DIED: unable to create component dir");
       
  1071 	
       
  1072 	
       
  1073 	GenDirs($libname);
       
  1074 	my $module;
       
  1075 	foreach my $listed(@generatedModules)
       
  1076 	{
       
  1077 	my @filesToProcess =
       
  1078         (
       
  1079          "LibXXX_ATSTemplateXXX_module_blr_hw_component.xml",
       
  1080          "LibXXX_ATSTemplateXXX_module_blr_winsspd_component.xml",
       
  1081          "testframework.ini",
       
  1082         );
       
  1083 		if(rindex($noXmlsGenList, $libname) != -1 )	
       
  1084 		{
       
  1085 			@filesToProcess = ("testframework.ini",);
       
  1086 		}
       
  1087 
       
  1088 			if($ext eq ".exe")
       
  1089 			{
       
  1090 				GenExeXmls($listed,$libname);
       
  1091 			}
       
  1092 			else
       
  1093 			{
       
  1094 				#just in case no xml file was supplied
       
  1095 				
       
  1096         my $ref = \@filesToProcess;
       
  1097 				GenXmls($libname, $listed,$ref);
       
  1098 			}
       
  1099 	}#foreach
       
  1100 	
       
  1101 	CopyDlls($libname,$ext);
       
  1102 	#copy the provided cfg, ini and xmls
       
  1103 	if($libname eq "opts")
       
  1104 	{
       
  1105 		CopyOptsCfg($libname);
       
  1106 	}
       
  1107 	elsif($libname eq "ltp" || $libname eq "lsb" || $libname eq "glib")
       
  1108 	{
       
  1109 	  #copy latter and  dont copy respectively for ltp and lsb
       
  1110 	}
       
  1111 	else
       
  1112 	{
       
  1113 	  CopyCfgIniXmls($libname);
       
  1114 	}
       
  1115 }
       
  1116 
       
  1117 sub CopyCfgIniXmls()
       
  1118 {
       
  1119 	my $libname = pop @_;
       
  1120 	
       
  1121 	my $libRoot = $templateRoot;
       
  1122 	$libRoot =~ /(.*)internal.*/;
       
  1123 	$libRoot = $1;
       
  1124 
       
  1125 
       
  1126 	my $module;
       
  1127 	my $src;
       
  1128 	my $dst;
       
  1129 		
       
  1130 	foreach my $listed(@generatedModules)
       
  1131 	{
       
  1132 	  my $dirname = $listed;
       
  1133 	  $dirname =~ s/test/t/;
       
  1134 	  $module = StripModulePrefix($listed);
       
  1135 	    
       
  1136 		$src = $libRoot.$libname.$TDIR.$dirname."\\group\\";
       
  1137 				
       
  1138 		my $xmlCopied = "0";
       
  1139 		my @globpattern = ("*.ini", "*.xml","*.cfg");
       
  1140 		foreach my $pat(@globpattern)
       
  1141 		{
       
  1142 			$dst = $ATSRoot."\\components\\".$libname."_".$module;
       
  1143 			if($pat ne "*.xml")
       
  1144 			{
       
  1145 				$dst = $dst."\\General\\";
       
  1146 			}
       
  1147 			else
       
  1148 			{
       
  1149 				$dst = $dst."\\";
       
  1150 			}
       
  1151 			my @filesFound = glob($src."\\$pat");
       
  1152 			if(scalar @filesFound eq "0")
       
  1153 			{
       
  1154 				#print "No files found for module $module $pat!\n";
       
  1155 				#print $src;
       
  1156 			}
       
  1157 			
       
  1158 			#handcoded
       
  1159 			if($pat eq "*.cfg" && $xmlCopied eq "0")#rename only if xml not copied
       
  1160 			{
       
  1161 				if(scalar @filesFound > 1)
       
  1162 				{
       
  1163 					print "Multiple cfg files found. Copying all!\n";
       
  1164 				}
       
  1165 				else
       
  1166 				{
       
  1167 						$dst = $dst.$listed.".cfg";
       
  1168 				}
       
  1169 			}				
       
  1170 			elsif($pat eq "*.xml")
       
  1171 			{
       
  1172 				my $folder = $dst;
       
  1173 				foreach my $from (@filesFound) 
       
  1174 				{
       
  1175 					if($from =~ /winscw_component/)
       
  1176 					{
       
  1177 						$dst = $folder.$libname."_".$module."_module_blr_winscw_component.xml";
       
  1178 						copy($from, $dst) or die "DIED: copy: $! $from $dst";
       
  1179 						$xmlCopied = "1";
       
  1180 					}
       
  1181 					elsif($from =~ /winsspd_component/)
       
  1182 					{
       
  1183 						$dst = $folder.$libname."_".$module."_module_blr_winsspd_component.xml";
       
  1184 						copy($from, $dst) or die "DIED: copy: $! $from $dst";
       
  1185 						$xmlCopied = "1";
       
  1186 					}
       
  1187 					elsif($from =~ /hw_component/)
       
  1188 					{
       
  1189 						$dst = $folder.$libname."_".$module."_module_blr_hw_component.xml";
       
  1190 						copy($from, $dst) or die "DIED: copy: $! $from $dst";
       
  1191 						$xmlCopied = "1";
       
  1192 					}
       
  1193 				}#examine individually			
       
  1194 				if(scalar @filesFound > 2)
       
  1195 				{
       
  1196 					#print "Multiple xml files found!!!\n";
       
  1197 				}
       
  1198 				@filesFound = ();
       
  1199 			}	
       
  1200 				
       
  1201 			
       
  1202 			foreach my $from (@filesFound) 
       
  1203 			{
       
  1204 					copy($from, $dst) or die "DIED: copy: $! $from $dst";
       
  1205 			}#copy individually			
       
  1206 		}#globpattern
       
  1207 	}#module
       
  1208 }#fn
       
  1209 
       
  1210 #copy the cfg files for the opts test suite
       
  1211 sub CopyOptsCfg()
       
  1212 {
       
  1213 	my $libname = pop @_;
       
  1214 	
       
  1215 	my $libRoot = $optsGroupPath."\\";
       
  1216 	my $module;
       
  1217 	my $src;
       
  1218 	my $dst;
       
  1219 		
       
  1220 	foreach $module(@generatedModules)
       
  1221 	{
       
  1222 		$src = $libRoot.$module."\.cfg";
       
  1223 		$dst = $ATSRoot."\\components\\".$libname."_".$module;
       
  1224 		$dst = $dst."\\General\\";
       
  1225 		copy($src, $dst) or warn "copy: $! $src $dst";
       
  1226 	}#module
       
  1227 }#fn
       
  1228 
       
  1229 #copy the lsb cfg files
       
  1230 sub CopyLsbCfg()
       
  1231 {
       
  1232 	my $libname = pop @_;
       
  1233 	
       
  1234 	my $module;
       
  1235 	
       
  1236 	my $dst;
       
  1237 	
       
  1238 	my $srcDir = $templateRoot."/ts/lsbsuites/lsblib/data/";
       
  1239 		
       
  1240 	foreach $module(@generatedModules)
       
  1241 	{
       
  1242 		my $file1 = $srcDir."tet_code.cfg";
       
  1243 		my $file2 = $srcDir."tetexec.cfg";
       
  1244 		$dst = $ATSRoot."\\components\\".$libname."_".$module;
       
  1245 		$dst = $dst."\\General\\";
       
  1246 		copy($file1, $dst) or die "copy: $! $file1 $dst";
       
  1247 		copy($file2, $dst) or die "copy: $! $file2 $dst";
       
  1248 	}#module
       
  1249 }#fn
       
  1250 
       
  1251 
       
  1252 #copy the ltp cfg files
       
  1253 sub CopyLtpCfg($)
       
  1254 {
       
  1255 	my $libname = pop @_;
       
  1256 	
       
  1257 	my $module;
       
  1258 	my $src;
       
  1259 	my $dst;
       
  1260 		
       
  1261 	foreach $module(@generatedModules)
       
  1262 	{
       
  1263 		$src = $cfglocation{$module};
       
  1264 		$dst = $ATSRoot."\\components\\".$libname."_".$module;
       
  1265 		$dst = $dst."\\General\\";
       
  1266 		copy($src, $dst) or warn "copy: $! $src $dst";
       
  1267 	}#module
       
  1268 }#fn
       
  1269 
       
  1270 
       
  1271 sub CopyDlls($$)
       
  1272 {
       
  1273 	my $libname = shift @_;
       
  1274 	my $suffix = shift @_;
       
  1275 	
       
  1276 	my $module;
       
  1277 	my $src;
       
  1278 	my $dst;
       
  1279 	
       
  1280 	
       
  1281 	foreach $module(@generatedModules)
       
  1282 	{
       
  1283 	  if($do_winscw == 1)
       
  1284 	  { 	  
       
  1285 			$src = $rootDrive."\\epoc32\\release\\winscw\\udeb\\".$module.$suffix;
       
  1286 			$dst = $ATSRoot."\\components\\".$libname."_".StripModulePrefix($module);
       
  1287 			$dst = $dst."\\winscw_udeb\\";
       
  1288 			copy($src, $dst)  || warn("unable to copy $src to $dst");
       
  1289 		}
       
  1290 	  if($do_armv5 == 1)
       
  1291 	  {
       
  1292 			$src = $rootDrive."\\epoc32\\release\\armv5\\urel\\".$module.$suffix;
       
  1293 			$dst = $ATSRoot."\\components\\".$libname."_".StripModulePrefix($module);
       
  1294 			$dst = $dst."\\armv5_urel\\";
       
  1295 			copy($src, $dst)  || warn("unable to copy $src to $dst");
       
  1296 		}
       
  1297 	}#foreach
       
  1298 }
       
  1299 #fn to generate the session file
       
  1300 sub GenerateSessionFile($$$$)
       
  1301 {
       
  1302 	my $libname = shift @_;
       
  1303 	my $target = shift @_;
       
  1304 	my $name = shift @_;
       
  1305 	my $listptr = shift @_;
       
  1306 	my $outdir = $ATSRoot;
       
  1307 	my $infile = $templateRoot."\\testsession.xml";
       
  1308 	chdir $outdir || die("DIED: Unable to chdir!"); 
       
  1309 	#open INFILE, $infile || die ("DIED: Can not open input file $infile");
       
  1310 	my $prefix = $name."_".$target;
       
  1311 	if($sdkversion ne "")
       
  1312 	{
       
  1313 		$prefix = $prefix."_".$sdkversion;
       
  1314 	}
       
  1315 	
       
  1316 	open OUTFILE, ">".$outdir."\\".$prefix."_testsession.xml" || die ("DIED: Can not open output file");
       
  1317 	my $line;
       
  1318   my $snippet = $target;
       
  1319   if($target ne "winscw" && $target ne "winsspd")
       
  1320   {
       
  1321   	$snippet = "hw";
       
  1322   }
       
  1323 
       
  1324 print OUTFILE "<?xml version=\"1.0\"?>\n";
       
  1325 print OUTFILE "<testsession>\n";
       
  1326 #print OUTFILE "<symbian-version>$libname"."_".$snippet."_TestDrop_blr_component</symbian-version>\n";	
       
  1327 print OUTFILE "<symbian-version>sapi_dev_combined_test_session</symbian-version>\n";	
       
  1328 print OUTFILE "<testitem>at</testitem>\n";	
       
  1329 print OUTFILE "<resultfile>ATSOUTPUT\\".$prefix."_testsession_results.xml</resultfile>\n";		
       
  1330 if($sendEmail eq "yes")
       
  1331 {
       
  1332 print OUTFILE <<EOEmailNote;
       
  1333 <email_notification>
       
  1334 <include_test_cases>false</include_test_cases>
       
  1335 <message_file>C:\\\\lm.txt </message_file>
       
  1336 <send_after_rerun>false</send_after_rerun>
       
  1337 <subject>Stdcpp-Plumhall $snippet testreport</subject>
       
  1338 <from>swbuild\@nokia.com</from>
       
  1339 <to>ajith.narayanan\@nokia.com</to>
       
  1340 <to>hrishikesh.brahmakal\@nokia.com</to>
       
  1341 <to>santosh.ks\@nokia.com</to>
       
  1342 <to>shilpa.sharma\@nokia.com</to>
       
  1343 <to>kasthuri.n-s\@nokia.com</to>
       
  1344 <to>hema.1.s\@nokia.com</to>
       
  1345 <to>vineetha.hari-pai\@nokia.com</to>
       
  1346 <to>madhusudhan.p.reddy\@nokia.com</to>
       
  1347 </email_notification>
       
  1348 EOEmailNote
       
  1349 }
       
  1350 
       
  1351 	if($libname ne "combined")
       
  1352 	{
       
  1353 		AddAssumedIncludes($libname,$snippet);
       
  1354 	}
       
  1355 	else
       
  1356 	{
       
  1357 		if($listptr ne "")
       
  1358 		{
       
  1359 			AddFileList($libname,$listptr);
       
  1360 		}
       
  1361 		else
       
  1362 		{
       
  1363 			AddActualIncludes($libname);
       
  1364 		}
       
  1365 	}
       
  1366    				
       
  1367 	print OUTFILE "</testsession>\n";
       
  1368 
       
  1369 	close(OUTFILE);
       
  1370 	#close(INFILE);
       
  1371 }#fn
       
  1372 
       
  1373 
       
  1374 sub AddAssumedIncludes($$)
       
  1375 {
       
  1376 	my $libname = shift @_; 
       
  1377 	my $snippet = shift @_;
       
  1378 	
       
  1379 	my $APITest;
       
  1380 	foreach my $listed(@generatedModules)
       
  1381 						{
       
  1382 							$APITest = StripModulePrefix($listed);
       
  1383 							print OUTFILE  "\n";
       
  1384 							print OUTFILE "	<!--Inclusion of $target xml for $APITest -->\n";
       
  1385 							print OUTFILE "	<component>\n";
       
  1386 							print OUTFILE "		<factory>Symbian</factory>\n";
       
  1387 							if($libname eq "all")
       
  1388 							{
       
  1389 									print OUTFILE "		 <testplan>ATSINPUT\\components\\$listed\\$listed"."_module_blr_".$snippet."_component.xml</testplan>\n";	 
       
  1390 							}
       
  1391 							else
       
  1392 							{
       
  1393 									print OUTFILE "		 <testplan>ATSINPUT\\components\\$libname"."_"."$APITest\\$libname"."_$APITest"."_module_blr_".$snippet."_component.xml</testplan>\n";	 
       
  1394 							}
       
  1395 							if($target eq "winscw")
       
  1396 							{
       
  1397 									print OUTFILE "		<target hardware=\"winscw\" build=\"udeb\" />\n";
       
  1398 							}
       
  1399 							elsif($target eq "winsspd")
       
  1400 							{
       
  1401 								print OUTFILE " <target hardware=\"winsspd\" platform=\"winscw\" build=\"udeb\" />\n"; 
       
  1402 							}
       
  1403 							else
       
  1404 							{
       
  1405 										print OUTFILE "		<target hardware=\"$target\" build=\"urel\" />\n";
       
  1406 							}
       
  1407 							print OUTFILE "	</component>\n";
       
  1408 							print OUTFILE "\n";
       
  1409 	           }#foreach @generatedModules
       
  1410 }
       
  1411 
       
  1412 
       
  1413 sub AddFileList($$)
       
  1414 {
       
  1415 	my $libname = shift @_; 
       
  1416 	my $listptr = shift @_;
       
  1417 	my @componentfiles = @$listptr;
       
  1418 	
       
  1419 			foreach my $listed(@componentfiles)
       
  1420 						{
       
  1421 								print OUTFILE  "\n";
       
  1422 							print OUTFILE "	<!--Inclusion of $target xml -->\n";
       
  1423 							print OUTFILE "	<component>\n";
       
  1424 							print OUTFILE "		<factory>Symbian</factory>\n";
       
  1425 							print OUTFILE "		 <testplan>ATSINPUT\\components\\$listed</testplan>\n";	 
       
  1426 							if($target eq "winscw")
       
  1427 							{
       
  1428 									print OUTFILE "		<target hardware=\"winscw\" build=\"udeb\" />\n";
       
  1429 							}
       
  1430 							elsif($target eq "winsspd")
       
  1431 							{
       
  1432 								print OUTFILE " <target hardware=\"winsspd\" platform=\"winscw\" build=\"udeb\" />\n"; 
       
  1433 							}
       
  1434 							else
       
  1435 							{
       
  1436 										print OUTFILE "		<target hardware=\"$target\" build=\"urel\" />\n";
       
  1437 							}
       
  1438 							print OUTFILE "	</component>\n";
       
  1439 							print OUTFILE "\n";
       
  1440 	           }#foreach @componentfiles
       
  1441 }
       
  1442 
       
  1443 
       
  1444 
       
  1445 sub GetSslXmls()
       
  1446 {
       
  1447 	my $APITest;
       
  1448 	my @componentfiles;
       
  1449 	
       
  1450 	my @emulatorfiles = 
       
  1451 	(
       
  1452 	"libssl_ssltest\\libssl_blr_winsspd_component.xml",
       
  1453 	"libcrypto_crypto_test\\libcrypto_blr_winsspd_component.xml",
       
  1454 	"libcrypto_openssl\\libcrypto_topenssltestss_blr_winsspd_component.xml",
       
  1455 	"libcrypto_openssl\\libcrypto_topenssltestverify_blr_winsspd_component.xml",
       
  1456 	"libcrypto_openssl\\libcrypto_topenssltestenc_blr_winsspd_component.xml",
       
  1457 	"libcrypto_openssl\\libcrypto_topenssltestgen_blr_winsspd_component.xml",
       
  1458 	"libcrypto_openssl\\libcrypto_topenssltpkcs7_blr_winsspd_component.xml",
       
  1459 	"libcrypto_openssl\\libcrypto_topenssltpkcs7d_blr_winsspd_component.xml",
       
  1460 	"libcrypto_openssl\\libcrypto_topenssltreq_blr_winsspd_component.xml",
       
  1461 	"libcrypto_openssl\\libcrypto_topenssltreq2_blr_winsspd_component.xml",
       
  1462 	"libcrypto_openssl\\libcrypto_topenssltrsa_blr_winsspd_component.xml",
       
  1463 	"libcrypto_openssl\\libcrypto_topenssltcrl_blr_winsspd_component.xml",
       
  1464 	"libcrypto_openssl\\libcrypto_topenssltsid_blr_winsspd_component.xml",
       
  1465 	"libcrypto_openssl\\libcrypto_topenssltx509_blr_winsspd_component.xml",
       
  1466 	"libcrypto_openssl\\libcrypto_topenssltx5091_blr_winsspd_component.xml",
       
  1467 	"libcrypto_openssl\\libcrypto_topenssltx5092_blr_winsspd_component.xml",
       
  1468 	 );
       
  1469 	 
       
  1470 	my @hwfiles =
       
  1471 	(
       
  1472 		"libcrypto_openssl\\libcrypto_topenssltestss_blr_hw_component.xml",
       
  1473 		"libcrypto_openssl\\libcrypto_topenssltestverify_blr_hw_component.xml",
       
  1474 		"libcrypto_openssl\\libcrypto_topenssltestenc_blr_hw_component.xml",
       
  1475 		"libcrypto_openssl\\libcrypto_topenssltestgen_blr_hw_component.xml",
       
  1476 		"libcrypto_openssl\\libcrypto_topenssltpkcs7_blr_hw_component.xml",
       
  1477 		"libcrypto_openssl\\libcrypto_topenssltpkcs7d_blr_hw_component.xml",
       
  1478 		"libcrypto_openssl\\libcrypto_topenssltreq_blr_hw_component.xml",
       
  1479 		"libcrypto_openssl\\libcrypto_topenssltreq2_blr_hw_component.xml",
       
  1480 		"libcrypto_openssl\\libcrypto_topenssltrsa_blr_hw_component.xml",
       
  1481 		"libcrypto_openssl\\libcrypto_topenssltcrl_blr_hw_component.xml",
       
  1482 		"libcrypto_openssl\\libcrypto_topenssltsid_blr_hw_component.xml",
       
  1483 		"libcrypto_openssl\\libcrypto_topenssltx509_blr_hw_component.xml",
       
  1484 		"libcrypto_openssl\\libcrypto_topenssltx5091_blr_hw_component.xml",
       
  1485 		"libcrypto_openssl\\libcrypto_topenssltx5092_blr_hw_component.xml",		
       
  1486 		"libssl_ssltest\\libssl_blr_hw_component.xml",
       
  1487 		"libcrypto_crypto_test\\libcrypto_blr_hw_component.xml",
       
  1488 	);
       
  1489 	if($target eq "winsspd" || $target eq "winscw")
       
  1490 	{
       
  1491 		@componentfiles = @emulatorfiles;
       
  1492 	}
       
  1493 	else
       
  1494 	{
       
  1495 		@componentfiles = @hwfiles;
       
  1496 	}
       
  1497 	return @componentfiles;
       
  1498 }
       
  1499 
       
  1500 
       
  1501 
       
  1502 sub AddActualIncludes($)
       
  1503 {
       
  1504 	my $libname = shift @_; 
       
  1505 	find(\&XmlComponentFiles, ".");
       
  1506 	my $key;
       
  1507 	my $value;
       
  1508 	while(($key, $value) = each(%DirHash)) 
       
  1509 	{
       
  1510 							$value =~ s/\//\\/g;
       
  1511 							print OUTFILE  "\n";
       
  1512 							print OUTFILE "	<!--Inclusion of dynamically found $target xml -->\n";
       
  1513 							print OUTFILE "	<component>\n";
       
  1514 							print OUTFILE "		<factory>Symbian</factory>\n";
       
  1515 							print OUTFILE "		 <testplan>$value</testplan>\n";	 
       
  1516 							if($target eq "winscw")
       
  1517 							{
       
  1518 									print OUTFILE "		<target hardware=\"winscw\" build=\"udeb\" />\n";
       
  1519 							}
       
  1520 							elsif($target eq "winsspd")
       
  1521 							{
       
  1522 								print OUTFILE " <target hardware=\"winsspd\" platform=\"winscw\" build=\"udeb\" />\n"; 
       
  1523 							}
       
  1524 							else
       
  1525 							{
       
  1526 										print OUTFILE "		<target hardware=\"$target\" build=\"urel\" />\n";
       
  1527 							}
       
  1528 							print OUTFILE "	</component>\n";
       
  1529 							print OUTFILE "\n";
       
  1530 	
       
  1531 	}#while
       
  1532 }#fn
       
  1533 
       
  1534 sub XmlComponentFiles()
       
  1535 {
       
  1536 	if($_ !~ /\.xml/ || $_ =~ /manual/)
       
  1537 	{
       
  1538 		return;
       
  1539 	}
       
  1540 	#print "Processing $_\n";
       
  1541 	my $dir = getcwd();
       
  1542 	if($dir =~ /.*(ATSINPUT.*)/)
       
  1543 	{
       
  1544 			$dir = $1;
       
  1545 			if($dir !~ /.*components.*/)
       
  1546 			{
       
  1547 				return;
       
  1548 			}
       
  1549 			#print "The dir is $dir\n";
       
  1550 	}
       
  1551 	else
       
  1552 	{
       
  1553 		return;
       
  1554 	}
       
  1555 	
       
  1556 	if($target eq "winsspd" )
       
  1557 	{
       
  1558 		if($_ =~ /winsspd/)
       
  1559 		{
       
  1560 			#print "Adding $target file $_ for $dir\n";
       
  1561 			$DirHash{$dir} = $dir."/".$_;
       
  1562 		}
       
  1563 	}
       
  1564 	elsif($target eq "winscw")
       
  1565 	{
       
  1566 		if($_ =~ /winscw/)
       
  1567 		{
       
  1568 			#print "Adding $target file $_ for $dir\n";
       
  1569 			$DirHash{$dir} = $dir."/".$_;
       
  1570 		}
       
  1571 	}
       
  1572 	elsif($_ =~ /$target/)
       
  1573 	{
       
  1574 		#print "$_ matched $target \n";
       
  1575 		#print "Adding $target file $_ for $dir\n";
       
  1576 		$DirHash{$dir} = $dir."/".$_;
       
  1577 	}
       
  1578 	elsif($_ =~/hw/)
       
  1579 	{
       
  1580 		#print "$_ matched hw";
       
  1581 		if(scalar $DirHash{$dir} == 0)
       
  1582 		{
       
  1583 			#print "Adding hw file $_ for $dir\n";
       
  1584 			$DirHash{$dir} = $dir."/".$_;
       
  1585 			#print " and added\n"
       
  1586 		}
       
  1587 		else
       
  1588 		{
       
  1589 			#print " and not added\n";
       
  1590 		}
       
  1591 	}
       
  1592 }
       
  1593 
       
  1594 
       
  1595 
       
  1596 sub emptyArray()
       
  1597 {
       
  1598 	@generatedModules = ();
       
  1599 }
       
  1600 
       
  1601 sub GenDirs($)
       
  1602 {
       
  1603  my $libname = shift @_;
       
  1604  my $dirname;
       
  1605  foreach my $module(@generatedModules)
       
  1606  {
       
  1607   $dirname = StripModulePrefix($module);
       
  1608 	my $relroot = $ATSRoot."\\components\\$libname"."_$dirname";
       
  1609 	mkdir $relroot || die("DIED: unable to create dir $dirname\n");
       
  1610 	mkdir $relroot."\\General" || die("DIED: unable to create dir $relroot\\General\n");
       
  1611 	if($do_armv5 == 1)
       
  1612 	{
       
  1613 		mkdir $relroot."\\armv5_urel" || die("DIED: unable to create dir $relroot\\armv5_urel\n");
       
  1614 	}
       
  1615 	if($do_winscw == 1)
       
  1616 	{
       
  1617 		mkdir $relroot."\\winscw_udeb" || die("DIED: unable to create dir $relroot\\winscw_udeb\n");
       
  1618 	}
       
  1619  }
       
  1620 }
       
  1621 
       
  1622 sub GenXmls($$$)
       
  1623 {
       
  1624 	my $libname = shift @_;
       
  1625 	my $listedName = shift @_;
       
  1626 	my $bref = shift @_;
       
  1627 	my @filesToProcess = @$bref;
       
  1628 	
       
  1629 	#strip leading test and t names from module
       
  1630 	my $moduleName = StripModulePrefix($listedName);
       
  1631 
       
  1632       my $toPath = $ATSRoot."\\components\\$libname"."_$moduleName\\"; 
       
  1633         
       
  1634 
       
  1635        my $dst;
       
  1636        my $src;
       
  1637        foreach $src(@filesToProcess)
       
  1638        {
       
  1639                $dst = $src;
       
  1640                $dst =~ s/ATSTemplateXXX/$moduleName/;
       
  1641                $dst =~ s/LibXXX/$libname/;
       
  1642              
       
  1643 
       
  1644                if($src eq "testframework.ini")
       
  1645                {
       
  1646 					$dst =  $toPath."General\\".$dst;
       
  1647                }
       
  1648                else
       
  1649                {
       
  1650 					$dst =  $toPath.$dst;
       
  1651                }
       
  1652                copy($templateRoot."\\".$src, $dst) || die("DIED: Unable to copy $src to $dst\n");
       
  1653                ExpandModuleMacros($dst, $libname, $listedName);
       
  1654        }#foreach file
       
  1655 }
       
  1656 
       
  1657 
       
  1658 sub GenExeXmls()
       
  1659 {
       
  1660 	my $moduleName = shift @_;
       
  1661 	my $libname = shift @_;
       
  1662 			
       
  1663 	my $toPath = $ATSRoot."\\components\\$libname"."_$moduleName\\"; 
       
  1664   my @filesToProcess =
       
  1665   (
       
  1666      "LibXXX_ATSTemplateXXX_exemodule_blr_hw_component.xml",
       
  1667      "LibXXX_ATSTemplateXXX_exemodule_blr_winsspd_component.xml",
       
  1668   );
       
  1669 	
       
  1670 	my $dst;
       
  1671   my $src;
       
  1672   foreach $src(@filesToProcess)
       
  1673   {
       
  1674         $dst = $src;
       
  1675         $dst =~ s/ATSTemplateXXX/$moduleName/;
       
  1676         $dst =~ s/LibXXX/$libname/;
       
  1677         $dst =~ s/_exemodule_/_module_/;
       
  1678 				$dst =  $toPath.$dst;
       
  1679         copy($templateRoot."\\".$src, $dst) || die("DIED: Unable to copy to $dst\n");
       
  1680         ExpandModuleMacros($dst, $libname, $moduleName);
       
  1681    }#foreach file
       
  1682 }
       
  1683 
       
  1684 #function to expand the macros existing in a file
       
  1685 #file is replaced by new version
       
  1686 #args are relativePath. filename and  $moduleName
       
  1687 sub ExpandModuleMacros()
       
  1688 {
       
  1689 	# Take module name
       
  1690 	my $moduleName = pop @_;
       
  1691 	my $libname = pop @_;
       
  1692 	my $filename = pop @_;
       
  1693 
       
  1694 	my $MODULENAME = $moduleName;
       
  1695 	$MODULENAME =~ tr/[a-z]/[A-Z]/;
       
  1696 
       
  1697 	# Open input file
       
  1698 	open (INFILE, $filename ) || die ("DIED: Can not find $filename");
       
  1699 
       
  1700 	#Open output file
       
  1701 	my $newOutput = $filename."new";
       
  1702 	open (OUTFILE, ">".$newOutput ) || die ("DIED: Can not open $newOutput");
       
  1703 
       
  1704 	# Replace text in files
       
  1705 	while (<INFILE>)
       
  1706 	{
       
  1707 	  s/ATSTemplateXXX/$moduleName/g;
       
  1708 	  s/LibXXX/$libname/g;
       
  1709     	  print OUTFILE $_;
       
  1710 	}
       
  1711 
       
  1712 	# Close filehandles
       
  1713 	close (INFILE);
       
  1714 	close (OUTFILE);
       
  1715 
       
  1716 	# Rename result file
       
  1717 	unlink $filename;
       
  1718 	rename $newOutput,$filename;
       
  1719 }
       
  1720 
       
  1721 
       
  1722 
       
  1723 sub CopyDeps($$)
       
  1724 {
       
  1725   my $libname = shift @_;
       
  1726   my $copyDll = shift @_;
       
  1727 	my $src;
       
  1728 	my $dst;
       
  1729 	foreach my $listed(@generatedModules)
       
  1730 	{
       
  1731 		
       
  1732 		#		my $module = StripModulePrefix($listed);
       
  1733 		#		if($do_winscw == 1)
       
  1734 		#		{
       
  1735 		#			$src = $rootDrive."\\epoc32\\release\\winscw\\udeb\\".$copyDll;
       
  1736 		#			$dst = $ATSRoot."\\components\\$libname"."_$module";
       
  1737 		#			$dst = $dst."\\winscw_udeb\\";
       
  1738 		#			copy($src, $dst)  || warn("unable to copy $src to $dst");
       
  1739 			#	}
       
  1740 	#			if($do_armv5 == 1)
       
  1741 			#	{
       
  1742 		#			$src = $rootDrive."\\epoc32\\release\\armv5\\urel\\".$copyDll;
       
  1743 		#			$dst = $ATSRoot."\\components\\$libname"."_$module";
       
  1744 		#			$dst = $dst."\\armv5_urel\\";
       
  1745 		#			copy($src, $dst)  || warn("unable to copy $src to $dst");
       
  1746 		#		}
       
  1747 	}#foreach
       
  1748 }#fn
       
  1749 
       
  1750 #dat file copy
       
  1751 sub CopyDatFiles()
       
  1752 {
       
  1753 	my $libRoot = $templateRoot;
       
  1754 	$libRoot =~ /(.*)internal.*/;
       
  1755 	$libRoot = $1;
       
  1756 
       
  1757  my @list = (
       
  1758   				 ["libcrypt", "tlibcrypt", "group/Test_Data.dat"],
       
  1759   				 ["libc", "tnetdb", "data/services.txt"],
       
  1760   				 ["libc", "tstring", "data/locales.txt"],
       
  1761   				 ["libc", "libc_loc_blr", "data/locales.txt"],
       
  1762   				 ["libz", "tzlib", "data/*.*"],
       
  1763   				 ["libc", "tlink", "data/*.*"],
       
  1764   				 ["libc", "tmmap", "data/*.*"],
       
  1765            );
       
  1766 
       
  1767 	 my $libname;
       
  1768 	 my $dirname;
       
  1769 	 my $glob;
       
  1770 	foreach my $ref(@list)
       
  1771 	{
       
  1772 			my @inarr = @$ref;
       
  1773 			($libname, $dirname, $glob) = @inarr;
       
  1774 			my $modulename = StripModulePrefix($dirname);
       
  1775 			my $src = "$libRoot/$libname/internal/testapps/$dirname/$glob";
       
  1776 			my $dst = $ATSRoot."\\components\\$libname"."_"."$modulename\\General\\";
       
  1777   		if($dirname eq "libc_loc_blr")
       
  1778   		{
       
  1779   			$src = "$libRoot/libc/src/locales.txt";
       
  1780   		}
       
  1781   		my @filesFound = glob($src);
       
  1782   		if(scalar @filesFound == 0)
       
  1783   		{
       
  1784   			die("DIED: no Dat file found to copy!");
       
  1785   		}
       
  1786   		foreach my $file(@filesFound)
       
  1787   		{
       
  1788   			copy($file, $dst) || die("DIED: unable to copy $file to $dst");
       
  1789   		}
       
  1790   }#ref processing
       
  1791 }#fn
       
  1792 
       
  1793 
       
  1794 #glib dat file copy
       
  1795 sub CopyArbitDatFiles($$)
       
  1796 {
       
  1797 	
       
  1798 	 my $libname = shift @_;
       
  1799 	 my $refArr = shift @_;
       
  1800 	 my @list = @$refArr;
       
  1801 	 
       
  1802  	
       
  1803 	my $fname;
       
  1804 	my $modulename;
       
  1805 	my $location;
       
  1806 	my $atsDst;
       
  1807 	my $targetDst;
       
  1808 	
       
  1809 	#now copy the files appropriately
       
  1810 	foreach my $ref(@list)
       
  1811 	{
       
  1812 			my @inarr = @$ref;
       
  1813 			($fname, $modulename, $location, $atsDst, $targetDst) = @inarr;
       
  1814 			#print "[$fname, $modulename, $location, $atsDst, $targetDst]\n";
       
  1815 			if($location =~ /(.*)\.\.(.*)/)
       
  1816 			{
       
  1817 				$location = GetPathPrefix().$2;
       
  1818 			}
       
  1819 			else
       
  1820 			{
       
  1821 				$location = $rootDrive.$location;
       
  1822 			}
       
  1823 			my $src = $location.$fname;
       
  1824 			my $dst = $ATSRoot."\\components\\$libname"."_".$modulename.$atsDst;
       
  1825 			if($libname eq "")
       
  1826 			{
       
  1827 				$dst = $ATSRoot."\\components\\".$modulename.$atsDst;
       
  1828 				#print "$dst CHANGED!\n"
       
  1829 			}
       
  1830   		
       
  1831   		my @filesFound = glob($src);
       
  1832   		if(scalar @filesFound == 0)
       
  1833   		{
       
  1834   			die("DIED: no Dat file  $src found to copy!");
       
  1835   		}
       
  1836   		foreach my $file(@filesFound)
       
  1837   		{
       
  1838   			copy($file, $dst) || die("DIED: unable to copy $file to $dst");
       
  1839   		}
       
  1840   		
       
  1841   		if($targetDst ne "")
       
  1842   		{
       
  1843   			 		my @filesToChange = ();
       
  1844 			  		if($atsDst =~ "armv5")
       
  1845 			  		{
       
  1846 			  			#armv5 component file
       
  1847 			  			unshift @filesToChange, $libname."_".$modulename."_module_blr_hw_component.xml";
       
  1848 			  			
       
  1849 			  		}
       
  1850 			  		elsif($atsDst =~ "winscw")
       
  1851 			  		{
       
  1852 			  			#winscw component file
       
  1853 			  			unshift @filesToChange, $libname."_".$modulename."_module_blr_winsspd_component.xml";
       
  1854 			  		}
       
  1855 			  		else
       
  1856 			  		{
       
  1857 			  			#add entry to both xmls
       
  1858 			  			unshift @filesToChange, $libname."_".$modulename."_module_blr_hw_component.xml";
       
  1859 			  			unshift @filesToChange, $libname."_".$modulename."_module_blr_winsspd_component.xml";
       
  1860 			  		}
       
  1861 			  		foreach my $file(@filesToChange)
       
  1862 			  		{
       
  1863 			  			$src = $ATSRoot."/components/".$libname."_"."$modulename/".$file;
       
  1864 			  			ModifyXml($src,$libname,$fname,$atsDst,$targetDst);
       
  1865 			  		}
       
  1866 			  }#updating the xmls
       
  1867     		
       
  1868   }#ref processing
       
  1869  
       
  1870   
       
  1871 }#fn
       
  1872 
       
  1873 sub ModifyXml($$$$$)
       
  1874 {
       
  1875 	my $filename = shift @_;
       
  1876 	my $lib = shift @_;
       
  1877 	my $fname = shift @_;
       
  1878 	my $atsDst = shift @_;
       
  1879 	my $targetDst = shift @_;
       
  1880 	
       
  1881 	
       
  1882 	#printf("Modifying $filename with lib= $lib fname= $fname atsDst = $atsDst targetDst = $targetDst\n");
       
  1883 	
       
  1884 	# Open input file
       
  1885 	open (INFILE, $filename ) || die ("Can not find $filename");
       
  1886 
       
  1887 	#Open output file
       
  1888 	my $newOutput = $filename."new";
       
  1889 	open (OUTFILE, ">".$newOutput ) || die ("Can not open $newOutput");
       
  1890 
       
  1891 		
       
  1892 	# Replace text in files
       
  1893 	while (<INFILE>)
       
  1894 	{
       
  1895 	  if(/\<stif\>/ || /\<execute\>/)
       
  1896 	  {
       
  1897 	  	if(/\<stif\>/)
       
  1898 	  	{
       
  1899 	  		print OUTFILE "\<stif\>\n";
       
  1900 	  	}
       
  1901 	  	else
       
  1902 	  	{
       
  1903 	  		print OUTFILE "\<execute\>\n";
       
  1904 	  	}
       
  1905 	  	my $type = "data";
       
  1906 	  	if($atsDst !~ "General")
       
  1907 			{
       
  1908 				$type = "binary";
       
  1909 			}
       
  1910 			print OUTFILE <<EObinary;
       
  1911 				
       
  1912 	  		<install type=\"$type\">
       
  1913 				<src>$fname</src>
       
  1914 				<dst>$targetDst\\$fname</dst>
       
  1915  				</install>
       
  1916 EObinary
       
  1917 	  }#stif or execute tag found
       
  1918 	  else
       
  1919 	  {
       
  1920 	  	  print OUTFILE $_;
       
  1921 	  }
       
  1922 	}#while
       
  1923 	# Close filehandles
       
  1924 	close (INFILE);
       
  1925 	close (OUTFILE);
       
  1926 
       
  1927 	# Rename result file
       
  1928 	unlink $filename;
       
  1929 	rename $newOutput,$filename;
       
  1930 	
       
  1931 }#fn
       
  1932 sub GenGenModules($)
       
  1933 {
       
  1934 	my $libname = shift @_;
       
  1935 	
       
  1936 		
       
  1937 	my $src = $ATSRoot."/components/";
       
  1938 	my @fileList = ();
       
  1939 	opendir(DIRHANDLE, "$src") || die "Cannot opendir $src";
       
  1940   foreach my $name (readdir(DIRHANDLE)) 
       
  1941   {
       
  1942     if($name =~ /^$libname/)
       
  1943     {
       
  1944     	if($libname ne "libc" || $name !~ /^libcrypt/) 
       
  1945     	{
       
  1946     		$name =~ s/^$libname//;
       
  1947     		$name =~ s/^_//;
       
  1948     		unshift @fileList, $name;
       
  1949     	}#excluded libcrypt from libc list
       
  1950     }#libname match
       
  1951   }#foreach
       
  1952   closedir(DIRHANDLE);
       
  1953 	return @fileList;
       
  1954 }
       
  1955 
       
  1956 
       
  1957 sub GetAllModules()
       
  1958 {
       
  1959 	
       
  1960 	my $src = $ATSRoot."/components/";
       
  1961 	my @fileList = ();
       
  1962 	opendir(DIRHANDLE, "$src") || die "Cannot opendir $src";
       
  1963   foreach my $name (readdir(DIRHANDLE)) 
       
  1964   {
       
  1965     	if($name ne "." && $name ne ".." && $name ne "shared")
       
  1966 			{
       
  1967 				unshift @fileList, $name;
       
  1968 			}
       
  1969 
       
  1970   }#foreach
       
  1971   closedir(DIRHANDLE);
       
  1972 	return @fileList;
       
  1973 }
       
  1974 
       
  1975 
       
  1976 
       
  1977 sub TransformXmls($$)
       
  1978 {
       
  1979 	my $libname = shift @_;
       
  1980 	my $shared = shift @_;
       
  1981 	my $target = shift @_;
       
  1982 	my $module;
       
  1983 	my $src;
       
  1984 	my $dst;
       
  1985 
       
  1986 	my $armv5 = 0;
       
  1987 	my $winscw = 0;
       
  1988 	if($target eq "armv5")
       
  1989 	{
       
  1990 			$armv5 = 1;
       
  1991   }	
       
  1992   elsif($target eq "winscw")
       
  1993   {
       
  1994   		$winscw = 1;
       
  1995   }
       
  1996   else
       
  1997   {
       
  1998   	$armv5  = $do_armv5;
       
  1999   	$winscw = $do_winscw;
       
  2000 	}
       
  2001 		
       
  2002 
       
  2003 	foreach $module(@generatedModules)
       
  2004 	{
       
  2005 	  if($armv5 == 1 && $winscw == 1)
       
  2006 	  {
       
  2007 			$src = $ATSRoot."/components/".$libname."_"."$module/*.xml";
       
  2008 		}
       
  2009 		elsif($armv5 == 1)
       
  2010 		{
       
  2011 			$src = $ATSRoot."/components/".$libname."_"."$module/*_hw_component.xml";
       
  2012 		}
       
  2013 		elsif($winscw == 1)
       
  2014 		{
       
  2015 			$src = $ATSRoot."/components/".$libname."_"."$module/*_winsspd_component.xml";
       
  2016 		}
       
  2017 		my @fileList = glob($src);
       
  2018 		foreach my $file(@fileList)
       
  2019 		{
       
  2020 		 	#print"$file to  be transformed!\n";
       
  2021 			AddLibsInXml($libname,$file,$shared);
       
  2022 		}
       
  2023    }
       
  2024 }#fn
       
  2025 
       
  2026 sub AddLibsInXml($$$)
       
  2027 {
       
  2028 	my $libname = shift @_;
       
  2029 	my $filename = shift @_;
       
  2030 	my $shared = shift @_;
       
  2031 	
       
  2032 	# Open input file
       
  2033 	open (INFILE, $filename ) || die ("Can not find $filename");
       
  2034 
       
  2035 	#Open output file
       
  2036 	my $newOutput = $filename."new";
       
  2037 	open (OUTFILE, ">".$newOutput ) || die ("Can not open $newOutput");
       
  2038 
       
  2039 	my $drive = "c:";
       
  2040 	
       
  2041 	# Replace text in files
       
  2042 	while (<INFILE>)
       
  2043 	{
       
  2044 	  if(/\<stif\>/ || /\<execute\>/)
       
  2045 	  {
       
  2046 	  	if(/\<stif\>/)
       
  2047 	  	{
       
  2048 	  		print OUTFILE "\<stif\>\n";
       
  2049 	  	}
       
  2050 	  	else
       
  2051 	  	{
       
  2052 	  		print OUTFILE "\<execute\>\n";
       
  2053 	  		if($filename =~ /winsspd/)
       
  2054 				{
       
  2055 					$drive = "z:";
       
  2056 				}
       
  2057 	  	}
       
  2058 	  	foreach my $installable(@dllList)
       
  2059 			{
       
  2060 				print OUTFILE <<EOLine;
       
  2061 				
       
  2062 	  		<install type=\"$shared binary\">
       
  2063 				<src>$installable</src>
       
  2064 				<dst>$drive\\sys\\bin\\$installable</dst>
       
  2065  				</install>
       
  2066 EOLine
       
  2067 			}
       
  2068 
       
  2069 	  }
       
  2070 	  else
       
  2071 	  {
       
  2072 	  	  print OUTFILE $_;
       
  2073 	  }
       
  2074 	}#while
       
  2075 	# Close filehandles
       
  2076 	close (INFILE);
       
  2077 	close (OUTFILE);
       
  2078 
       
  2079 	# Rename result file
       
  2080 	unlink $filename;
       
  2081 	rename $newOutput,$filename;
       
  2082 }
       
  2083 
       
  2084 sub CopySharedDlls()
       
  2085 {
       
  2086   my $libname = shift @_;
       
  2087   my $ref = shift @_;
       
  2088   my @ListOfDlls = @$ref;
       
  2089   my $target = shift @_;
       
  2090 	my $module;
       
  2091 	my $src;
       
  2092 	my $dst;
       
  2093 	
       
  2094 	my $do_armv5 = 0;
       
  2095 	my $do_winscw = 0;
       
  2096 	if($target eq "armv5")
       
  2097 	{
       
  2098 		$do_armv5 = 1;
       
  2099 	}
       
  2100 	elsif($target eq "winscw")
       
  2101 	{
       
  2102 		$do_winscw =  1;
       
  2103 	}
       
  2104 	else
       
  2105 	{
       
  2106 		$do_armv5  = 1;
       
  2107 		$do_winscw = 1;
       
  2108 	}
       
  2109 	
       
  2110 	
       
  2111 	mkdir  $ATSRoot."\\components\\shared" || die("Wouldn't make shared folder in $ATSRoot\\components");
       
  2112 	if($do_winscw == 1)
       
  2113 	{
       
  2114 		mkdir  $ATSRoot."\\components\\shared\\winscw_udeb" || die("Wouldn't make shared folder in $ATSRoot\\components\winscw_udeb");
       
  2115 	}
       
  2116 	if($do_armv5 == 1)
       
  2117 	{
       
  2118 		mkdir  $ATSRoot."\\components\\shared\\armv5_urel" || die("Wouldn't make shared folder in $ATSRoot\\components\armv5_urel");
       
  2119 	}
       
  2120 	
       
  2121 	foreach my $copyDll(@ListOfDlls)
       
  2122 	{
       
  2123 		if($do_winscw == 1)
       
  2124 		{
       
  2125 			$src = $rootDrive."\\epoc32\\release\\winscw\\udeb\\".$copyDll;
       
  2126 			$dst = $ATSRoot."\\components\\shared";
       
  2127 			$dst = $dst."\\winscw_udeb\\";
       
  2128 			copy($src, $dst)  || warn("unable to copy $src to $dst");
       
  2129 		}	
       
  2130 		if($do_armv5 == 1)
       
  2131 		{	
       
  2132 			$src = $rootDrive."\\epoc32\\release\\armv5\\urel\\".$copyDll;
       
  2133 			$dst = $ATSRoot."\\components\\shared";
       
  2134 			$dst = $dst."\\armv5_urel\\";
       
  2135 			copy($src, $dst)  || warn("unable to copy $src to $dst");
       
  2136 		}
       
  2137 	}#foreach
       
  2138 }#fn
       
  2139 
       
  2140 
       
  2141 sub CopyMultiDlls($)
       
  2142 {
       
  2143   my $libname = shift @_;
       
  2144 	my $module;
       
  2145 	my $src;
       
  2146 	my $dst;
       
  2147 	foreach my $listed(@generatedModules)
       
  2148 	{
       
  2149 		foreach my $copyDll(@dllList)
       
  2150 		{
       
  2151 			if($do_winscw == 1)
       
  2152 			{
       
  2153 				$src = $rootDrive."\\epoc32\\release\\winscw\\udeb\\".$copyDll;
       
  2154 				$dst = $ATSRoot."\\components\\$libname"."_$listed";
       
  2155 				$dst = $dst."\\winscw_udeb\\";
       
  2156 				copy($src, $dst)  || warn("unable to copy $src to $dst");
       
  2157 			}
       
  2158 			if($do_armv5 == 1)
       
  2159 			{
       
  2160 				$src = $rootDrive."\\epoc32\\release\\armv5\\urel\\".$copyDll;
       
  2161 				$dst = $ATSRoot."\\components\\$libname"."_$listed";
       
  2162 				$dst = $dst."\\armv5_urel\\";
       
  2163 				copy($src, $dst)  || warn("unable to copy $src to $dst");
       
  2164 			}
       
  2165 		}#foreach
       
  2166 	}
       
  2167 }#fn
       
  2168 
       
  2169 sub StripModulePrefix($)
       
  2170 {
       
  2171 	my $listed = pop @_;
       
  2172 	my $module = $listed;
       
  2173 	if($dontStrip == 0)
       
  2174 	{
       
  2175 		$module =~ s/^test//;
       
  2176 		$module =~ s/^t//;
       
  2177 		$module =~ s/^libc_//;
       
  2178 		$module =~ s/^libm_//;
       
  2179   }
       
  2180   return $module;
       
  2181   	
       
  2182 }
       
  2183 
       
  2184 sub GetLsbModules()
       
  2185 {
       
  2186 	my @lsbList = 
       
  2187 	(
       
  2188 	 "abs",
       
  2189 "acos",
       
  2190 "asctime",
       
  2191 "asin",
       
  2192 "atan",
       
  2193 "atan2",
       
  2194 "atof",
       
  2195 "atoi",
       
  2196 "atol",
       
  2197 "bsearch",
       
  2198 "calloc",
       
  2199 "ceil",
       
  2200 "chdir",
       
  2201 "clearerr",
       
  2202 "close",
       
  2203 "closedir",
       
  2204 "cos",
       
  2205 "cosh",
       
  2206 "creat",
       
  2207 "lsb_ctime",
       
  2208 "lsb_difftime",
       
  2209 "dlclose",
       
  2210 "dlerror",
       
  2211 "dlopen",
       
  2212 "dup",
       
  2213 "dup2",
       
  2214 "exp",
       
  2215 "fabs",
       
  2216 "fclose",
       
  2217 "fcntl_x",
       
  2218 "fdopen",
       
  2219 "feof",
       
  2220 "ferror",
       
  2221 "fflush",
       
  2222 "fgetpos",
       
  2223 "fgets",
       
  2224 "fileno",
       
  2225 "floor",
       
  2226 "fmod",
       
  2227 "fopen",
       
  2228 "fopen_X",
       
  2229 "fprintf",
       
  2230 "fputs",
       
  2231 "fread",
       
  2232 "free",
       
  2233 "freopen",
       
  2234 "freopen_X",
       
  2235 "frexp",
       
  2236 "fseek",
       
  2237 "fsetpos",
       
  2238 "fstat",
       
  2239 "ftell",
       
  2240 "ftok",
       
  2241 "ftok_l",
       
  2242 "fwrite",
       
  2243 "getc",
       
  2244 "getcwd",
       
  2245 "gets",
       
  2246 "lsb_gmtime",
       
  2247 "ldexp",
       
  2248 "link",
       
  2249 "lsb_localtime",
       
  2250 "log",
       
  2251 "log10",
       
  2252 "longjmp",
       
  2253 "lseek",
       
  2254 "malloc",
       
  2255 "memchr_X",
       
  2256 "memcmp_X",
       
  2257 "memcpy_X",
       
  2258 "memmove",
       
  2259 "memset_X",
       
  2260 "mkdir",
       
  2261 "mkfifo",
       
  2262 "lsb_mktime",
       
  2263 "modf",
       
  2264 "msgctl",
       
  2265 "msgget",
       
  2266 "msgsnd",
       
  2267 "open",
       
  2268 "opendir",
       
  2269 "open_x",
       
  2270 "perror",
       
  2271 "pipe",
       
  2272 "pow",
       
  2273 "printf",
       
  2274 "qsort",
       
  2275 "rand",
       
  2276 "read",
       
  2277 "readdir",
       
  2278 "readv_l",
       
  2279 "realloc",
       
  2280 "remove",
       
  2281 "rename",
       
  2282 "rewind",
       
  2283 "rewinddir",
       
  2284 "rmdir",
       
  2285 "scanf",
       
  2286 "scanf_X",
       
  2287 "seekdir",
       
  2288 "semctl",
       
  2289 "semget",
       
  2290 "semop",
       
  2291 "setbuf",
       
  2292 "setjmp",
       
  2293 "shmat",
       
  2294 "shmdt",
       
  2295 "shmget",
       
  2296 "sin",
       
  2297 "sinh",
       
  2298 "sqrt",
       
  2299 "srand",
       
  2300 "stat",
       
  2301 "strcat",
       
  2302 "strchr",
       
  2303 "strcmp",
       
  2304 "strcoll_X",
       
  2305 "strcpy",
       
  2306 "strcspn",
       
  2307 "strerror_X",
       
  2308 "strftime",
       
  2309 "strftime_X",
       
  2310 "strlen",
       
  2311 "strncat",
       
  2312 "strncmp",
       
  2313 "strncpy",
       
  2314 "strpbrk",
       
  2315 "strptime",
       
  2316 "strrchr",
       
  2317 "strspn",
       
  2318 "strstr",
       
  2319 "strtod_X",
       
  2320 "strtok",
       
  2321 "strtol_X",
       
  2322 "strxfrm_X",
       
  2323 "tan",
       
  2324 "tanh",
       
  2325 "telldir",
       
  2326 "telldir_l",
       
  2327 "lsb_time",
       
  2328 "tmpfile",
       
  2329 "tmpnam",
       
  2330 "ungetc",
       
  2331 "unlink",
       
  2332 "utime",
       
  2333 "vfprintf",
       
  2334 "vprintf",
       
  2335 "write",
       
  2336 "writev_l",
       
  2337 
       
  2338 	);
       
  2339   return @lsbList;
       
  2340 }
       
  2341 
       
  2342 
       
  2343 
       
  2344 sub GenBackendTest()
       
  2345 {
       
  2346 
       
  2347 	my @datList = 
       
  2348 	(
       
  2349 	["libc", "tlibcbackend"],
       
  2350 	);
       
  2351 	
       
  2352 	mkdir $ATSRoot;
       
  2353 	mkdir $ATSRoot."\\components" || die ("DIED: unable to create component dir");
       
  2354 		
       
  2355 	my $lib;
       
  2356 	my $module;
       
  2357 	my $ext;
       
  2358 	foreach my $ref(@datList)
       
  2359 	{
       
  2360 			my @inarr = @$ref;
       
  2361 			($lib, $module,$ext) = @inarr;
       
  2362 			@generatedModules = ($module);
       
  2363 			GenDirs($lib);
       
  2364 			CopyDlls($lib,".dll");
       
  2365 	}
       
  2366  #now copy xmls			
       
  2367  CopyAtsSetup();
       
  2368  #extra exes
       
  2369  @generatedModules = ("tlibcbackend");
       
  2370  CopyDeps("libc","TPopenReadChild.exe");
       
  2371  CopyDeps("libc","TPopenWriteChild.exe");
       
  2372 			
       
  2373 }#fn
       
  2374 
       
  2375 sub CopyAtsSetup()
       
  2376 {
       
  2377 	 my $libname = "libc"; 
       
  2378 	 my @list = (
       
  2379   				 ["*.xml", "libcbackend", "/../backend/internal/tlibcbackend/group/","/", ""],
       
  2380   				 ["*.cfg", "libcbackend", "/../backend/internal/tlibcbackend/group/","/General/", ""],
       
  2381   				 ["*.ini", "libcbackend", "/../backend/internal/tlibcbackend/group/","/General/", ""],
       
  2382   				 );
       
  2383  
       
  2384   my $bDataRef = \@list;  				 
       
  2385 	CopyArbitDatFiles("libc",$bDataRef);  				 
       
  2386 
       
  2387 }#fn
       
  2388 sub GetPathPrefix()
       
  2389 {
       
  2390 	 my $srcPrefix = $templateRoot;
       
  2391 	 $srcPrefix =~ /(.*)internal.*/;
       
  2392 	 $srcPrefix = $1;
       
  2393 	 return $srcPrefix;
       
  2394 }
       
  2395 	
       
  2396 
       
  2397 #dat file copy
       
  2398 sub CopyCryptoDat()
       
  2399 {
       
  2400 	my $libRoot = $templateRoot;
       
  2401 	$libRoot =~ /(.*)internal.*/;
       
  2402 	$libRoot = $1;
       
  2403 
       
  2404  my @list = (
       
  2405  								 ["libssl", "ssltest", "libssl/internal/testapps/ssl_test/data/*"],
       
  2406  								 ["libcrypto", "topenssl", "/libcrypto/internal/testapps/topenssl/data/*"],
       
  2407            );
       
  2408 
       
  2409 	 my $libname;
       
  2410 	 my $dirname;
       
  2411 	 my $glob;
       
  2412 	foreach my $ref(@list)
       
  2413 	{
       
  2414 			my @inarr = @$ref;
       
  2415 			($libname, $dirname, $glob) = @inarr;
       
  2416 			my $modulename = StripModulePrefix($dirname);
       
  2417 			my	$srcPrefix = GetPathPrefix();
       
  2418 			
       
  2419 			my $src = "$srcPrefix"."$glob";
       
  2420 			
       
  2421 			my $dst = $ATSRoot."\\components\\$libname"."_"."$modulename\\General\\";
       
  2422   		my @filesFound = glob($src);
       
  2423   		if(scalar @filesFound == 0)
       
  2424   		{
       
  2425   			die("DIED: no Dat file found to copy!");
       
  2426   		}
       
  2427   		foreach my $file(@filesFound)
       
  2428   		{
       
  2429   			copy($file, $dst) || die("DIED: unable to copy $file to $dst");
       
  2430   		}
       
  2431   }#ref processing
       
  2432 }#fn
       
  2433 
       
  2434 #Crypto xmls copy
       
  2435 sub CopyCryptoXmls()
       
  2436 {
       
  2437 	  my @list = (
       
  2438   				 ["*.xml", "libssl_ssltest/", "/libssl/internal/testapps/ssl_test/group/"],
       
  2439    				 ["*.xml", "libcrypto_crypto_test/", "/libcrypto/internal/testapps/crypto_test/group/"],
       
  2440    				 ["*.xml", "libcrypto_openssl/", "/libcrypto/internal/testapps/topenssl/group/"],   				    				 			 
       
  2441   				 );
       
  2442 
       
  2443 	
       
  2444 	my $fname;
       
  2445 	my $moduleDst;
       
  2446 	my $location;
       
  2447 	
       
  2448 	#now copy the files appropriately
       
  2449 	foreach my $ref(@list)
       
  2450 	{
       
  2451 			my @inarr = @$ref;
       
  2452 			($fname, $moduleDst, $location) = @inarr;
       
  2453 			my $src = GetPathPrefix().$location.$fname;
       
  2454 			my $dst = $ATSRoot."\\components\\$moduleDst";
       
  2455   		
       
  2456   		my @filesFound = glob($src);
       
  2457   		if(scalar @filesFound == 0)
       
  2458   		{
       
  2459   			die("DIED: no xml file found to copy!");
       
  2460   		}
       
  2461   		foreach my $file(@filesFound)
       
  2462   		{
       
  2463   			copy($file, $dst) || die("DIED: unable to copy $file to $dst");
       
  2464   		}
       
  2465   	}#ref
       
  2466   	
       
  2467   	my @crypto_copyList = ("*.txt", "*cfg", "*.ini");
       
  2468   	
       
  2469   	foreach my $item(@crypto_copyList)
       
  2470   	{
       
  2471   			$location = "/libcrypto/internal/testapps/crypto_test/group/";
       
  2472   			$fname = GetPathPrefix().$location.$item;
       
  2473   			my @filesFound = glob($fname);
       
  2474   			foreach my $file(@filesFound)
       
  2475   			{
       
  2476     			$moduleDst = "libcrypto_crypto_test/";	
       
  2477   				my $dst = $ATSRoot."\\components\\".$moduleDst."/General/";
       
  2478   				copy($file, $dst);
       
  2479   			}
       
  2480   	}
       
  2481 }#fn
       
  2482 
       
  2483 sub GenCryptoTest()
       
  2484 {
       
  2485 
       
  2486 	my @datList = 
       
  2487 	(
       
  2488 	["libssl", "ssltest", ".exe"],
       
  2489 	["libcrypto", "crypto_test",".dll"],
       
  2490 	["libcrypto", "openssl",".exe"],
       
  2491 	);
       
  2492 	
       
  2493 	mkdir $ATSRoot;
       
  2494 	mkdir $ATSRoot."\\components" || die ("DIED: unable to create component dir");
       
  2495 		
       
  2496 	my $lib;
       
  2497 	my $module;
       
  2498 	my $ext;
       
  2499 	foreach my $ref(@datList)
       
  2500 	{
       
  2501 			my @inarr = @$ref;
       
  2502 			($lib, $module,$ext) = @inarr;
       
  2503 			@generatedModules = ($module);
       
  2504 			GenDirs($lib);
       
  2505 			CopyDlls($lib,$ext);
       
  2506 	}
       
  2507 	CopyCryptoDat();
       
  2508 	CopyCryptoXmls();
       
  2509 	
       
  2510 			
       
  2511 }#fn
       
  2512 
       
  2513 
       
  2514 #ngi xml copy
       
  2515 sub CopyNgiXmls()
       
  2516 {
       
  2517 	  my @list = (
       
  2518    				 ["*.xml", "ngi_sa_amrrecording", "/audio/lowlevelaudio/internal/sa_amrrecording/group/"],
       
  2519    				 ["*.xml", "ngi_sa_highlevelaudio", "/audio/highlevelaudio/internal/sa_highlevelaudio/group/"],
       
  2520   				 ["*.xml", "ngi_sa_audiomixing", "/audio/lowlevelaudio/internal/sa_audiomixing/group/"],
       
  2521   				 ["*.xml", "ngi_sa_audiorecording", "/audio/lowlevelaudio/internal/sa_audiorecording/group/"],
       
  2522   				 ["*.xml", "ngi_sa_clip", "/audio/lowlevelaudio/internal/sa_clip/group/"],
       
  2523   				 ["*.xml", "ngi_sa_lowlevelaudio", "/audio/lowlevelaudio/internal/sa_lowlevelaudio/group/"],
       
  2524   				 ["*.xml", "ngi_sa_stream", "/audio/lowlevelaudio/internal/sa_stream/group/"],
       
  2525   				 
       
  2526   				 ["*.xml", "ngi_sa_backbuffer", "/graphics/backbuffer/internal/sa_bb_antitearing/group/"],
       
  2527   				 ["*.xml", "ngi_sa_backbuffer", "/graphics/backbuffer/internal/sa_bb_colortranslation/group/"],
       
  2528   				 ["*.xml", "ngi_sa_backbuffer", "/graphics/backbuffer/internal/sa_bb_createfb565/group/"],
       
  2529   				 ["*.xml", "ngi_sa_backbuffer", "/graphics/backbuffer/internal/sa_bb_createfb888/group/"],
       
  2530   				 ["*.xml", "ngi_sa_backbuffer", "/graphics/backbuffer/internal/sa_bb_heapusage/group/"],
       
  2531   				 ["*.xml", "ngi_sa_backbuffer", "/graphics/backbuffer/internal/sa_bb_multibb/group/"],
       
  2532   				 ["*.xml", "ngi_sa_backbuffer", "/graphics/backbuffer/internal/sa_bb_performance/group/"],
       
  2533            ["*.xml", "ngi_sa_backbuffer", "/graphics/backbuffer/internal/sa_bb_plswitching/group/"],
       
  2534            ["*.xml", "ngi_sa_backbuffer", "/graphics/backbuffer/internal/sa_bb_misc/group/"],
       
  2535   				 ["*.xml", "ngi_sa_bitmap", "/graphics/bitmap/internal/sa_bitmap/group/"],
       
  2536   				 ["*.xml", "ngi_sa_camera", "/graphics/camera/internal/sa_camera/group/"],
       
  2537   				 ["*.xml", "ngi_sa_images", "/graphics/images/internal/sa_images/group/"],
       
  2538   				 ["*.xml", "ngi_sa_display", "/graphics/display/internal/sa_display/group/"],
       
  2539   				 ["*.xml", "ngi_sa_lights", "/graphics/lights/internal/sa_lights/group/"],
       
  2540   				 ["*.xml", "ngi_sa_videoplayback", "/graphics/video/internal/sa_videoplayback/group/"],
       
  2541   				 
       
  2542   				 ["*.xml", "ngi_sa_input", "/input/input/internal/sa_input/group/"],
       
  2543   				 ["*.xml", "ngi_sa_textinput", "/input/textinput/internal/sa_textinput/group/"],
       
  2544   				 ["*.xml", "ngi_sa_devicecapabilities", "/system/devicecapabilities/internal/sa_devicecapabilities/group/"],
       
  2545   				 ["*.xml", "ngi_sa_devicestatus", "/system/devicestatus/internal/sa_phone/group/"],
       
  2546   				 ["*.xml", "ngi_sa_runtimetester", "/system/runtime/internal/sa_runtimetester/group/"],
       
  2547   				 ["*.xml", "ngi_sa_timing", "/timing/internal/sa_timing/group/"],
       
  2548 	  				 );
       
  2549 
       
  2550 	
       
  2551 	my $fname;
       
  2552 	my $moduleDst;
       
  2553 	my $location;
       
  2554 	
       
  2555 	#now copy the files appropriately
       
  2556 	foreach my $ref(@list)
       
  2557 	{
       
  2558 			my @inarr = @$ref;
       
  2559 			($fname, $moduleDst, $location) = @inarr;
       
  2560 			my $src = GetPathPrefix().$location.$fname;
       
  2561 			my $dst = $ATSRoot."\\components\\$moduleDst";
       
  2562 			
       
  2563 			#print "My src is $src\n";
       
  2564 			#print "My dst is $dst\n";
       
  2565 			  		
       
  2566   		my @filesFound = glob($src);
       
  2567   		if(scalar @filesFound == 0)
       
  2568   		{
       
  2569   			warn("warning: no xml file found to copy from $src!");
       
  2570   		}
       
  2571   		foreach my $file(@filesFound)
       
  2572   		{
       
  2573   			copy($file, $dst) || die("DIED: unable to copy $file to $dst");
       
  2574   		}
       
  2575   	}#ref
       
  2576     	
       
  2577 }#fn
       
  2578 
       
  2579 
       
  2580 sub GenNgiTest()
       
  2581 {
       
  2582 
       
  2583 	my @datList = 
       
  2584 	(
       
  2585 	["ngi", "sa_amrrecording", ".dll"],
       
  2586 	["ngi", "sa_highlevelaudio", ".dll"],
       
  2587 	["ngi", "sa_audiomixing", ".dll"],
       
  2588 	["ngi", "sa_audiorecording", ".dll"],
       
  2589 	["ngi", "sa_clip", ".dll"],
       
  2590 	["ngi", "sa_lowlevelaudio", ".dll"],
       
  2591 	["ngi", "sa_stream", ".dll"],
       
  2592 	["ngi", "sa_bitmap", ".dll"],
       
  2593 	["ngi", "sa_camera", ".dll"],
       
  2594 	["ngi", "sa_images", ".dll"],
       
  2595 	["ngi", "sa_display", ".dll"],
       
  2596 	["ngi", "sa_lights", ".dll"],	
       
  2597 	["ngi", "sa_videoplayback", ".dll"],	
       
  2598 	["ngi", "sa_input", ".dll"],	
       
  2599 	["ngi", "sa_textinput", ".dll"],
       
  2600 	["ngi", "sa_devicecapabilities", ".dll"],	
       
  2601 	["ngi", "sa_devicestatus", ".dll"],	
       
  2602 	["ngi", "sa_runtimetester", ".dll"],	
       
  2603 	["ngi", "sa_timing", ".dll"],	
       
  2604 		
       
  2605 	);
       
  2606 	
       
  2607 	mkdir $ATSRoot;
       
  2608 	mkdir $ATSRoot."\\components" || die ("DIED: unable to create component dir");
       
  2609 
       
  2610 		
       
  2611 	my $lib;
       
  2612 	my $module;
       
  2613 	my $ext;
       
  2614 	foreach my $ref(@datList)
       
  2615 	{
       
  2616 			my @inarr = @$ref;
       
  2617 			($lib, $module,$ext) = @inarr;
       
  2618 			@generatedModules = ($module);
       
  2619 			GenDirs($lib);
       
  2620 			CopyDlls($lib,$ext);
       
  2621 	}
       
  2622 	
       
  2623    @generatedModules =("sa_backbuffer");
       
  2624    GenDirs($lib);
       
  2625    @dllList = 
       
  2626    (
       
  2627    	"sa_bb_antitearing.dll",
       
  2628    	"sa_bb_colortranslation.dll",
       
  2629    	"sa_bb_createfb444.dll",
       
  2630    	"sa_bb_createfb565.dll",
       
  2631    	"sa_bb_createfb888.dll",
       
  2632    	"sa_bb_misc.dll",
       
  2633    	"sa_bb_heapusage.dll",
       
  2634    	"sa_bb_multibb.dll",
       
  2635    	"sa_bb_performance.dll",
       
  2636    	"sa_bb_plswitch.dll",
       
  2637    	"sa_bb_testenv.dll"
       
  2638    );
       
  2639    CopyMultiDlls("ngi");
       
  2640 
       
  2641 	
       
  2642  	mkdir  $ATSRoot."\\components\\shared" || die("Wouldn't make shared folder in $ATSRoot\\components");
       
  2643   mkdir  $ATSRoot."\\components\\shared\\winscw_udeb" || die("Wouldn't make shared folder in $ATSRoot\\components\winscw_udeb");
       
  2644   mkdir  $ATSRoot."\\components\\shared\\armv5_urel" || die("Wouldn't make shared folder in $ATSRoot\\components\armv5_urel");
       
  2645 			
       
  2646 }#fn
       
  2647 
       
  2648 
       
  2649 sub GetXmls()
       
  2650 {
       
  2651   my @foundList;
       
  2652   my $libname = shift @_;
       
  2653 	my @globlist = ();
       
  2654 	if($target eq "winsspd" && $sdkversion ne "")
       
  2655 	{
       
  2656 		@globlist = ("winsspd_".$sdkversion);
       
  2657 		#print "winsspd ".$sdkversion." selected\n";
       
  2658 	}
       
  2659 	elsif($target eq "winsspd")
       
  2660 	{
       
  2661 		@globlist = ("winsspd");
       
  2662 		#print "winsspd selected\n";
       
  2663 	}
       
  2664 	elsif($sdkversion ne "")
       
  2665 	{
       
  2666 		@globlist = ($target,"hw_".$sdkversion);
       
  2667 		#print "$target $sdkversion selected\n";
       
  2668 	}
       
  2669 	else
       
  2670 	{
       
  2671 		@globlist = ($target,"hw");
       
  2672 		#print "$target $sdkversion selected\n";
       
  2673 	}
       
  2674 	
       
  2675 	foreach my $module(@generatedModules)
       
  2676 	{
       
  2677 	  my $glob_to_use = "";
       
  2678 	  my @fileList;
       
  2679 	  foreach my $glob(@globlist)
       
  2680 	  {
       
  2681 			my $src = $ATSRoot."/components/".$libname."_"."$module/*.xml";
       
  2682 			#print "Analysing $module and  $glob\n";
       
  2683 			@fileList = glob($src);
       
  2684 			foreach my $file(@fileList)
       
  2685 			{
       
  2686 			 my $pat = $glob."\_component\.xml";
       
  2687 			 #print "[$file - $glob"."_component.xml"."]\n";
       
  2688 				if($file =~ /$pat/)
       
  2689 				{
       
  2690 					$glob_to_use = $pat;
       
  2691 					#print "[$file - $glob"."_component.xml"."]\n";
       
  2692 					last
       
  2693 				}
       
  2694 			}#foreach FILE
       
  2695 			if($glob_to_use ne "")
       
  2696 			{
       
  2697 				last;
       
  2698 			}
       
  2699 		}#finding glob	
       
  2700 		if($glob_to_use ne "")
       
  2701 		{
       
  2702 				#print "Using the glob $glob_to_use\n";
       
  2703 				my $src = $ATSRoot."/components/".$libname."_"."$module/*.xml";
       
  2704 				@fileList = glob($src);
       
  2705 				foreach my $file(@fileList)
       
  2706 				{
       
  2707 					#print "[$file - $glob_to_use]\n";
       
  2708 					if($file =~ /$glob_to_use/)
       
  2709 					{
       
  2710 				  	$file =~ /.*components[\\\/](.*)/;
       
  2711 				  	my $value = $1;
       
  2712 				  	$value =~ s/\//\\/g;
       
  2713 				  	#print "adding $value for $module with $glob_to_use\n";
       
  2714 						unshift @foundList,$value;
       
  2715 				  }#if
       
  2716 				}#foreach
       
  2717 		}#glob is present
       
  2718 		else
       
  2719 		{
       
  2720 			warn("Unable to figure out glob to use for $module. Skipping...\n");
       
  2721 		}
       
  2722 	}#each module
       
  2723   return @foundList;
       
  2724  }#fn
       
  2725 
       
  2726 __END__
       
  2727 :end
       
  2728 
       
  2729 
       
  2730 
       
  2731