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