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