tsrc/testing/tools/builder.pl
branchRCL_3
changeset 57 befca0ec475f
child 70 375929f879c2
equal deleted inserted replaced
56:839377eedc2b 57:befca0ec475f
       
     1 #
       
     2 # Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
       
     3 # All rights reserved.
       
     4 # This component and the accompanying materials are made available
       
     5 # under the terms of "Eclipse Public License v1.0"
       
     6 # which accompanies this distribution, and is available
       
     7 # at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 #
       
     9 # Initial Contributors:
       
    10 # Nokia Corporation - initial contribution.
       
    11 #
       
    12 # Contributors:
       
    13 #
       
    14 # Description: 
       
    15 #
       
    16 
       
    17 
       
    18 use Cwd; # for cwd
       
    19 
       
    20 my $debug = 0;
       
    21 my $allowRun = 1;
       
    22 my $optionClean = 1;
       
    23 my $optionBuild = 1;
       
    24 my $optionFusion = 1;
       
    25 my $optionEngineTests = 1;
       
    26 my $optionUnitTests = 1;
       
    27 my $optionPlatform = "";
       
    28 
       
    29 ########################################
       
    30 # BUILD LISTS
       
    31 #
       
    32 
       
    33 my @fusionComponents = ( 
       
    34 		"videoutils\\group",
       
    35 		"videoplayer\\group"
       
    36 	);
       
    37 
       
    38 my @engineTests = (
       
    39 		"videoutils\\tsrc\\group",
       
    40 		"videoplayer\\tsrc\\group"
       
    41 	);
       
    42 
       
    43 my @unitTests = (
       
    44 		"videoplayer\\videoplayback\\videohelix\\tsrc\\ut_videohelixtest\\group",
       
    45 		"videoplayer\\videoplayback\\videoplaybackcontrols\\tsrc\\videoplaybackcontrols_test\\group",
       
    46 		"videoplayer\\videoplayback\\videoplaybackviews\\tsrc\\ut_userinputhandlertest\\group",
       
    47 		"videoplayer\\videoplayerapp\\mpxvideoplayer\\tsrc\\ut_mpxvideoplayertest\\group",
       
    48 		"videoplayer\\videocollection\\hgmyvideos\\tsrc\\ut_vcxhgmyvideosmainview\\group"
       
    49 	);
       
    50 
       
    51 ########################################
       
    52 # PARSE ARGUMENTS
       
    53 #
       
    54 
       
    55 while(scalar(@ARGV) >= 1)
       
    56 {
       
    57 	my $argument = shift(@ARGV);
       
    58 
       
    59 	if($argument eq "-nobuild")
       
    60 	{
       
    61 		$optionBuild = 0;
       
    62 	}
       
    63 
       
    64 	elsif($argument eq "-noclean")
       
    65 	{
       
    66 		$optionClean = 0;
       
    67 	}
       
    68 
       
    69 	elsif($argument eq "-nounit")
       
    70 	{
       
    71 		$optionUnitTests = 0;
       
    72 	}
       
    73 	
       
    74 	elsif($argument eq "-noengine")
       
    75 	{
       
    76 		$optionEngineTests = 0;
       
    77 	}
       
    78 
       
    79 	elsif($argument eq "-nofusion")
       
    80 	{
       
    81 		$optionFusion = 0;
       
    82 	}
       
    83 	
       
    84 	elsif($argument eq "-platform")
       
    85 	{
       
    86 		$optionPlatform = shift(@ARGV);
       
    87 	}
       
    88 
       
    89 	elsif($argument eq "-debug")
       
    90 	{
       
    91 		$debug = 1;
       
    92 	}
       
    93 
       
    94 	elsif($argument eq "-norun")
       
    95 	{
       
    96 		$allowRun = 0;
       
    97 	}
       
    98 	
       
    99 	elsif($argument eq "-help")
       
   100 	{
       
   101 		ShowHelp();
       
   102 	}
       
   103 	
       
   104 	else
       
   105 	{
       
   106 		ShowHelp();
       
   107 	}
       
   108 }
       
   109 
       
   110 ########################################
       
   111 # MAIN FUNCTION
       
   112 #
       
   113 
       
   114 my $basepath = FindBasePath();
       
   115 exit("NO VIDEOAPP_DOMAIN FOLDER FOUND") if $basepath eq "";
       
   116 
       
   117 if ( $optionClean )
       
   118 {
       
   119 	if ( $optionFusion )
       
   120 	{
       
   121 		foreach my $component ( @fusionComponents )
       
   122 		{
       
   123 		    Clean( $basepath, $component, $optionPlatform, 0 );
       
   124 		}
       
   125 	}
       
   126 		
       
   127 	if ( $optionEngineTests )
       
   128 	{
       
   129 		foreach my $component ( @engineTests )
       
   130 		{
       
   131 		    Clean( $basepath, $component, $optionPlatform, 1 );
       
   132 		}
       
   133 	}
       
   134 		
       
   135 	if ( $optionUnitTests )
       
   136 	{
       
   137 		# Clean all unit tests
       
   138 		foreach my $component ( @unitTests )
       
   139 		{
       
   140 		    Clean( $basepath, $component, $optionPlatform, 1 );
       
   141 		}
       
   142 	}
       
   143 }
       
   144 
       
   145 if ( $optionBuild )
       
   146 {
       
   147 	if ( $optionFusion )
       
   148 	{
       
   149 		foreach my $component ( @fusionComponents )
       
   150 		{
       
   151 		    Build( $basepath, $component, $optionPlatform, 0 );
       
   152 		}
       
   153 	}
       
   154 		
       
   155 	if ( $optionEngineTests )
       
   156 	{
       
   157 		# Clean all engine tests
       
   158 		foreach my $component ( @engineTests )
       
   159 		{
       
   160 		    Build( $basepath, $component, $optionPlatform, 1 );
       
   161 		}
       
   162 	}
       
   163 		
       
   164 	if ( $optionUnitTests )
       
   165 	{
       
   166 		# Clean all unit tests
       
   167 		foreach my $component ( @unitTests )
       
   168 		{
       
   169 		    Build( $basepath, $component, $optionPlatform, 1 );
       
   170 		}
       
   171 	}
       
   172 }
       
   173 
       
   174 ########################################
       
   175 # FindBasePath
       
   176 #
       
   177 
       
   178 sub FindBasePath
       
   179 {
       
   180 	print ">> FindBasePath\n" if $debug;
       
   181 	$currpath = cwd;
       
   182 	$basepath = "";
       
   183 	my $domain = "VideoApp_Domain";
       
   184 	
       
   185 	my $pos = rindex( $currpath, $domain );
       
   186 	
       
   187 	if( $pos != -1 )
       
   188 	{
       
   189 		$basepath = "\\" . substr( $currpath, 3, $pos + length( $domain ) - 3 );
       
   190 		$basepath =~ s/\//\\/g;
       
   191 	  print "BASEPATH FOUND: $basepath\n" if $debug;
       
   192 	}
       
   193 	
       
   194 	print "<< FindBasePath (" . $basepath . ")\n" if $debug;
       
   195 	return $basepath;
       
   196 }
       
   197 
       
   198 ########################################
       
   199 # Clean
       
   200 #
       
   201 
       
   202 sub Clean
       
   203 {
       
   204 	my ( $baseDir, $destDir, $optionPlatform, $isTestComponent ) = @_;
       
   205 	print ">>> CLEAN ${baseDir}\\${destDir}\\bld.inf FOR $optionPlatform\n" if $debug;
       
   206 	print "##\n#\n# CLEANING ${baseDir}\\${destDir}\n#\n##\n";
       
   207 	
       
   208 	my $cmd = "";
       
   209 	
       
   210 	if( $isTestComponent )
       
   211 	{
       
   212 		if( $optionPlatform eq "" ) # platform not given, clean armv5.test and winscw.test
       
   213 		{
       
   214 			$cmd = "sbs reallyclean -b ${baseDir}\\${destDir}\\bld.inf -c winscw.test";
       
   215 			print $cmd . "\n" if $debug;
       
   216 			system($cmd) if $allowRun;
       
   217 			$cmd = "sbs reallyclean -b ${baseDir}\\${destDir}\\bld.inf -c armv5.test";
       
   218 			print $cmd . "\n" if $debug;
       
   219 			system($cmd) if $allowRun;
       
   220 		}
       
   221 		else # platform is given, run clean only for that
       
   222 		{
       
   223 			$cmd .= "sbs reallyclean -b ${baseDir}\\${destDir}\\bld.inf -c ${optionPlatform}\.test";
       
   224 			print $cmd . "\n" if $debug;
       
   225 			system($cmd) if $allowRun;
       
   226 		}
       
   227 	}
       
   228 	else # is not testcomponent
       
   229 	{
       
   230 		$cmd .= "sbs reallyclean -b ${baseDir}\\${destDir}\\bld.inf";
       
   231 		$cmd .= " -c $optionPlatform" if $optionPlatform ne "";
       
   232 		print $cmd . "\n" if $debug;
       
   233 		system($cmd) if $allowRun;
       
   234 	}
       
   235 	print "<<< CLEAN\n" if $debug;
       
   236 }
       
   237 
       
   238 ########################################
       
   239 # Build
       
   240 #
       
   241 
       
   242 sub Build
       
   243 {
       
   244 	my ( $baseDir, $destDir, $optionPlatform, $isTestComponent ) = @_;
       
   245 	print ">>> BUILD ${baseDir}\\${destDir}\\bld.inf FOR $optionPlatform\n" if $debug;
       
   246 	print "##\n#\n# BUILDING ${baseDir}\\${destDir}\n#\n##\n";
       
   247 	#my $cmd = "sbs -b ${baseDir}\\${destDir}\\bld.inf";
       
   248 	#$cmd .= " -c $optionPlatform" if $optionPlatform ne "";
       
   249 	#$cmd .= ".test" if $isTestComponent;
       
   250 	#print $cmd . "\n" if $debug;
       
   251 	#system($cmd) if $allowRun;
       
   252 	
       
   253 	my $cmd = "";
       
   254 	
       
   255 	if( $isTestComponent )
       
   256 	{
       
   257 		if( $optionPlatform eq "" ) # platform not given, clean armv5.test and winscw.test
       
   258 		{
       
   259 			$cmd = "sbs -b ${baseDir}\\${destDir}\\bld.inf -c winscw.test";
       
   260 			print $cmd . "\n" if $debug;
       
   261 			system($cmd) if $allowRun;
       
   262 			$cmd = "sbs -b ${baseDir}\\${destDir}\\bld.inf -c armv5.test";
       
   263 			print $cmd . "\n" if $debug;
       
   264 			system($cmd) if $allowRun;
       
   265 		}
       
   266 		else # platform is given, run clean only for that
       
   267 		{
       
   268 			$cmd .= "sbs -b ${baseDir}\\${destDir}\\bld.inf -c ${optionPlatform}\.test";
       
   269 			print $cmd . "\n" if $debug;
       
   270 			system($cmd) if $allowRun;
       
   271 		}
       
   272 	}
       
   273 	else # is not testcomponent
       
   274 	{
       
   275 		$cmd .= "sbs -b ${baseDir}\\${destDir}\\bld.inf";
       
   276 		$cmd .= " -c $optionPlatform" if $optionPlatform ne "";
       
   277 		print $cmd . "\n" if $debug;
       
   278 		system($cmd) if $allowRun;
       
   279 	}
       
   280 	
       
   281 	print "<<< BUILD\n" if $debug;
       
   282 }
       
   283 
       
   284 #------------------------------------------------------------------------------------
       
   285 # ShowHelp
       
   286 #------------------------------------------------------------------------------------
       
   287 sub ShowHelp {
       
   288 
       
   289 print <<USAGE_EOF;
       
   290 builder.pl
       
   291 
       
   292 This script will search the VideoApp_Domain root folder from current path.
       
   293 if the root folder is not found, the script will exit. In any other case,
       
   294 it builds all components.
       
   295 
       
   296 Options:
       
   297 
       
   298 -platform   wanted platform
       
   299 -noclean    no clean.
       
   300 -nobuild    no build.
       
   301 -nofusion   exclude fusion components.
       
   302 -noengine   exclude engine tests.
       
   303 -nounit     exclude unit tests.
       
   304 -debug      show debug message
       
   305 -norun      do not run, for debugging purposes
       
   306 -help       You're reading it.
       
   307 
       
   308 Examples:
       
   309 
       
   310 builder.pl -nobuild -platform armv5_udeb
       
   311 	This will clean all the armv5_udeb components without building them.
       
   312 
       
   313 builder.pl -noclean -nofusion -noengine -platform armv5_udeb
       
   314 	This will build only unit tests without cleaning them first.
       
   315 
       
   316 USAGE_EOF
       
   317 
       
   318 	exit();
       
   319 
       
   320 };