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