os/mm/mmtestenv/mmtesttools/Build/mmbuild.pl
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
# Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
# All rights reserved.
sl@0
     3
# This component and the accompanying materials are made available
sl@0
     4
# under the terms of "Eclipse Public License v1.0"
sl@0
     5
# which accompanies this distribution, and is available
sl@0
     6
# at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
#
sl@0
     8
# Initial Contributors:
sl@0
     9
# Nokia Corporation - initial contribution.
sl@0
    10
#
sl@0
    11
# Contributors:
sl@0
    12
#
sl@0
    13
# Description:
sl@0
    14
#
sl@0
    15
sl@0
    16
use strict;
sl@0
    17
use Env qw(EPOCROOT);
sl@0
    18
sl@0
    19
# literals
sl@0
    20
my $icl_param  =  "-i";
sl@0
    21
my $misc_param =  "-c";
sl@0
    22
my $mmf_param  =  "-m";
sl@0
    23
my $all_param  =  "-f";
sl@0
    24
my $test_param =  "-t";
sl@0
    25
my $testBuild_param = "-b";
sl@0
    26
my $extra_param = "-x";
sl@0
    27
my $keep_param =  "-k";
sl@0
    28
my $gccxml_param = "-g";
sl@0
    29
my $skipMake_param = "-s";
sl@0
    30
sl@0
    31
my $setup_comm = "setup";
sl@0
    32
my $clean_comm = "clean";
sl@0
    33
my $build_comm = "build";
sl@0
    34
sl@0
    35
my @known_targets = ("wins", "winscw", "arm4", "armi","armv5", "gccxml", "thumb", "mcot", "misa", "mint");
sl@0
    36
sl@0
    37
my @Cedar_targets = ("winscw", "armv5");    # gccxml must be added explicitly with -g and even then only build gccxml on main code
sl@0
    38
my @Beech_targets = ("wins", "winscw", "thumb", "mcot");
sl@0
    39
sl@0
    40
my @default_targets = @Cedar_targets;
sl@0
    41
sl@0
    42
my @physical_targets = ("mcot", "misa", "mint"); # those we just re-build sound drivers for
sl@0
    43
my $gccxml_target = "gccxml";
sl@0
    44
my $x86gcc_target = "x86gcc";
sl@0
    45
my @stages = ("export", "makefile", "library", "resource", "target", "final");
sl@0
    46
my @tbstages = ("test export", "test makefile", "test library", "test resource", "test target", "test final");
sl@0
    47
my @stagesTakingTarget = ("makefile", "library", "resource", "target", "final",
sl@0
    48
                          "test makefile", "test library", "test resource", "test target", "test final");
sl@0
    49
my $eka2IdentifyFile  = "$ENV{EPOCROOT}epoc32\\release\\winscw\\udeb\\winsgui.dll"; # if file present, is EKA2 build
sl@0
    50
my $x86gccIdentifyFile  = "$ENV{EPOCROOT}epoc32\\release\\x86gcc\\udeb\\euser.dll"; # if dir present, x86 environment present
sl@0
    51
sl@0
    52
my @targets;
sl@0
    53
my $component = ""; # default added later
sl@0
    54
my $extras = "";
sl@0
    55
my $test = "";
sl@0
    56
my $testBuild = "";
sl@0
    57
my $command = "";
sl@0
    58
my $keep = "";
sl@0
    59
my $use_gccxml = "";
sl@0
    60
my $skipMake = "";
sl@0
    61
sl@0
    62
my $main_mbc = "__main.mbc";
sl@0
    63
my $test_mbc = "__test.mbc";
sl@0
    64
my $testBuild_mbc = "__testBuild.mbc";
sl@0
    65
my $phys_mbc = "__phys.mbc";
sl@0
    66
my $metabld = "metabld";
sl@0
    67
sl@0
    68
my $targetToolsDir = "..\\..\\..\\..\\..\\TargetTools\\Build";
sl@0
    69
my $TargetToolsExists = 0;
sl@0
    70
if (-d $targetToolsDir)
sl@0
    71
	{
sl@0
    72
	$TargetToolsExists = 1;
sl@0
    73
	print "TargetTools directory exists: $targetToolsDir\n"
sl@0
    74
	}
sl@0
    75
sl@0
    76
# main:
sl@0
    77
	{
sl@0
    78
	# Process command-line
sl@0
    79
sl@0
    80
	unless (@ARGV)
sl@0
    81
		{
sl@0
    82
		&Usage();
sl@0
    83
		}
sl@0
    84
sl@0
    85
	&ReadArgs();
sl@0
    86
sl@0
    87
	die "EPOCROOT is not set" unless ($EPOCROOT ne "");
sl@0
    88
sl@0
    89
	$| = 1; # autoflush stdout.
sl@0
    90
sl@0
    91
	if ($command eq $setup_comm)
sl@0
    92
		{
sl@0
    93
		&Setup();
sl@0
    94
		}
sl@0
    95
	elsif ($command eq $clean_comm)
sl@0
    96
		{
sl@0
    97
		&Clean();
sl@0
    98
		}
sl@0
    99
	elsif ($command eq $build_comm)
sl@0
   100
		{
sl@0
   101
		&Build();
sl@0
   102
		}
sl@0
   103
	else
sl@0
   104
		{
sl@0
   105
		die "Unknown command";
sl@0
   106
		}
sl@0
   107
	exit 0;
sl@0
   108
	}
sl@0
   109
sl@0
   110
#
sl@0
   111
# Subroutines
sl@0
   112
#
sl@0
   113
sl@0
   114
sub ReadArgs()
sl@0
   115
	{
sl@0
   116
	while (@ARGV)
sl@0
   117
		{
sl@0
   118
		my $param = @ARGV[0]; shift @ARGV; # grab first param and shift along
sl@0
   119
		
sl@0
   120
		if ($param eq "") # ignore blank parameters
sl@0
   121
			{
sl@0
   122
			next;
sl@0
   123
			}
sl@0
   124
sl@0
   125
		if ($param eq $icl_param || $param eq $misc_param ||
sl@0
   126
		    $param eq $mmf_param || $param eq $all_param)
sl@0
   127
			{
sl@0
   128
			$component = $param;
sl@0
   129
			}
sl@0
   130
		elsif ($param eq $test_param)
sl@0
   131
			{
sl@0
   132
			$test = $param;
sl@0
   133
			}
sl@0
   134
		elsif ($param eq $testBuild_param)
sl@0
   135
			{
sl@0
   136
			$testBuild = $param;
sl@0
   137
			}
sl@0
   138
		elsif ($param eq $extra_param)
sl@0
   139
			{
sl@0
   140
			$extras = $param;
sl@0
   141
			}
sl@0
   142
		elsif ($param eq $keep_param)
sl@0
   143
			{
sl@0
   144
			$keep = $param;
sl@0
   145
			}
sl@0
   146
		elsif ($param eq $gccxml_param)
sl@0
   147
			{
sl@0
   148
			$use_gccxml = $param;
sl@0
   149
			}
sl@0
   150
		elsif ($param eq $skipMake_param)
sl@0
   151
			{
sl@0
   152
			$skipMake = $param;
sl@0
   153
			}
sl@0
   154
		elsif ($param eq $setup_comm || $param eq $clean_comm ||
sl@0
   155
		       $param eq $build_comm)
sl@0
   156
			{
sl@0
   157
			if ($command ne "")
sl@0
   158
				{
sl@0
   159
				&Usage; # scream if we try to state more than one command
sl@0
   160
				}
sl@0
   161
			$command = $param;
sl@0
   162
			}
sl@0
   163
		elsif ($command eq $build_comm)
sl@0
   164
			{
sl@0
   165
			# see if the parameter is one of the list of arguments
sl@0
   166
			my $match = 0;
sl@0
   167
			foreach my $target (@known_targets)
sl@0
   168
				{
sl@0
   169
				if ($target eq $param)
sl@0
   170
					{
sl@0
   171
					$match = 1;
sl@0
   172
					last; # exit loop
sl@0
   173
					}
sl@0
   174
				}
sl@0
   175
			if ($match != 0)
sl@0
   176
				{
sl@0
   177
				$targets[++$#targets] = $param; # append
sl@0
   178
				}
sl@0
   179
			else
sl@0
   180
				{
sl@0
   181
				# was not a valid target
sl@0
   182
				Usage();
sl@0
   183
				}
sl@0
   184
			}
sl@0
   185
		else
sl@0
   186
			{
sl@0
   187
			# unknown setting
sl@0
   188
			&Usage();
sl@0
   189
			}
sl@0
   190
		}
sl@0
   191
	&CheckArgs();
sl@0
   192
	}
sl@0
   193
sl@0
   194
sub CheckArgs()
sl@0
   195
	{
sl@0
   196
	# check that the arguments make sense
sl@0
   197
	if ($command eq $clean_comm || $command eq $build_comm)
sl@0
   198
		{
sl@0
   199
		# for build and cleanup, can't set the required module
sl@0
   200
		if ($component ne "" || $extras ne "")
sl@0
   201
			{
sl@0
   202
			&Usage;
sl@0
   203
			}
sl@0
   204
		}
sl@0
   205
	# for setup, check -t has not been given
sl@0
   206
	if ($command eq $setup_comm)
sl@0
   207
		{
sl@0
   208
		if ($test ne "")
sl@0
   209
			{
sl@0
   210
			&Usage;
sl@0
   211
			}
sl@0
   212
		}
sl@0
   213
	if ($command eq "")
sl@0
   214
		{
sl@0
   215
		# need to state some command
sl@0
   216
		&Usage;
sl@0
   217
		}
sl@0
   218
	}
sl@0
   219
sl@0
   220
sub Setup
sl@0
   221
	{
sl@0
   222
	# default settings
sl@0
   223
	if ($component eq "")
sl@0
   224
		{
sl@0
   225
		$component = $all_param;
sl@0
   226
		}
sl@0
   227
	# some boolean values
sl@0
   228
	my $want_mmf = $component eq $mmf_param | $component eq $all_param;
sl@0
   229
	my $want_icl = $component eq $icl_param | $component eq $all_param;
sl@0
   230
	my $want_misc = $component eq $misc_param | $component eq $all_param;
sl@0
   231
	my $want_extra = $extras ne "";
sl@0
   232
	# generate .mbc files and then do bldmake
sl@0
   233
	open(OUTFILE, ">".$main_mbc) or die "Can't create file: $!";
sl@0
   234
	print OUTFILE "//\n//Auto-generated - do not edit!!\n//\n\n";
sl@0
   235
	print OUTFILE "#include \"mmf.mbc\"\n" if ($want_mmf);
sl@0
   236
	print OUTFILE "#include \"icl.mbc\"\n" if ($want_icl);
sl@0
   237
	print OUTFILE "#include \"Misc.mbc\"\n" if ($want_misc);
sl@0
   238
	print OUTFILE "#include \"mmfOpt.mbc\"\n" if ($want_mmf && $want_extra);
sl@0
   239
	print OUTFILE "#include \"iclOpt.mbc\"\n" if ($want_icl && $want_extra);
sl@0
   240
	print OUTFILE "#include \"MiscOpt.mbc\"\n" if ($want_misc && $want_extra);
sl@0
   241
	close OUTFILE;
sl@0
   242
sl@0
   243
	if ($want_mmf)
sl@0
   244
		{
sl@0
   245
		open(OUTFILE, ">".$phys_mbc) or die "Can't create file: $!";
sl@0
   246
		print OUTFILE "//\n//Auto-generated - do not edit!!\n//\n\n";
sl@0
   247
		print OUTFILE "#include \"mmfPhys.mbc\"\n";
sl@0
   248
		print OUTFILE "#include \"mmfOptPhys.mbc\"\n" if ($want_extra);
sl@0
   249
		close OUTFILE;
sl@0
   250
		}
sl@0
   251
	else
sl@0
   252
		{
sl@0
   253
		# only applicable for mmf - otherwise just delete the file
sl@0
   254
		if (-f $phys_mbc)
sl@0
   255
			{
sl@0
   256
			unlink $phys_mbc or die "Couldn't delete $phys_mbc";
sl@0
   257
			}
sl@0
   258
		}
sl@0
   259
sl@0
   260
	open(OUTFILE, ">".$test_mbc) or die "Can't create file: $!";
sl@0
   261
	print OUTFILE "//\n//Auto-generated - do not edit!!\n//\n\n";
sl@0
   262
	print OUTFILE "#include \"AllTests.mbc\"\n";
sl@0
   263
	print OUTFILE "#include \"TestFrameworkTest.mbc\"\n";
sl@0
   264
	print OUTFILE "#include \"mmfTest.mbc\"\n" if ($want_mmf);
sl@0
   265
	print OUTFILE "#include \"mmfNotOptTest.mbc\"\n" if ($want_mmf && !$want_extra);
sl@0
   266
	print OUTFILE "#include \"iclTest.mbc\"\n" if ($want_icl);
sl@0
   267
	print OUTFILE "#include \"MiscTest.mbc\"\n" if ($want_misc);
sl@0
   268
	print OUTFILE "#include \"mmfOptTest.mbc\"\n" if ($want_mmf && $want_extra);
sl@0
   269
	print OUTFILE "#include \"iclOptTest.mbc\"\n" if ($want_icl && $want_extra);
sl@0
   270
	print OUTFILE "#include \"MiscOptTest.mbc\"\n" if ($want_misc && $want_extra);
sl@0
   271
	if ($TargetToolsExists)
sl@0
   272
		{
sl@0
   273
		print OUTFILE "#include \"TargetTools.mbc\"\n";
sl@0
   274
		}
sl@0
   275
	close OUTFILE;
sl@0
   276
sl@0
   277
	open(OUTFILE, ">".$testBuild_mbc) or die "Can't create file: $!";
sl@0
   278
	print OUTFILE "//\n//Auto-generated - do not edit!!\n//\n\n";
sl@0
   279
	print OUTFILE "#include \"mmfTestBuild.mbc\"\n" if ($want_mmf);
sl@0
   280
	print OUTFILE "#include \"iclTestBuild.mbc\"\n" if ($want_icl);
sl@0
   281
	print OUTFILE "#include \"MiscTestBuild.mbc\"\n" if ($want_misc);
sl@0
   282
	print OUTFILE "#include \"mmfOptTestBuild.mbc\"\n" if ($want_mmf && $want_extra);
sl@0
   283
	print OUTFILE "#include \"iclOptTestBuild.mbc\"\n" if ($want_icl && $want_extra);
sl@0
   284
	print OUTFILE "#include \"MiscOptTestBuild.mbc\"\n" if ($want_misc && $want_extra);
sl@0
   285
	close OUTFILE;
sl@0
   286
sl@0
   287
	# first getmake does bldmake on the main entries
sl@0
   288
	my $sysComm = $metabld . " " . $main_mbc . " bldmake " . $keep . " bldfiles";
sl@0
   289
	my $result = system($sysComm);
sl@0
   290
	if ($result != 0 && $keep eq "")
sl@0
   291
		{
sl@0
   292
		print "Error '$sysComm' failed: $result\n";
sl@0
   293
		exit ($result);
sl@0
   294
		}
sl@0
   295
	my $error = $result;
sl@0
   296
	# second metabld goes through physical
sl@0
   297
	if (-f $phys_mbc)
sl@0
   298
		{
sl@0
   299
		$sysComm = $metabld . " " . $phys_mbc . " bldmake " . $keep . " bldfiles";
sl@0
   300
		$result = system($sysComm);
sl@0
   301
		if ($result != 0 && $keep eq "")
sl@0
   302
			{
sl@0
   303
			print "Error '$sysComm' failed: $result\n";
sl@0
   304
			exit ($result);
sl@0
   305
			}
sl@0
   306
		$error |= $result;
sl@0
   307
		}
sl@0
   308
	# third metabld goes through tests
sl@0
   309
	$sysComm = $metabld . " " . $test_mbc . " bldmake " . $keep . " bldfiles";
sl@0
   310
	$result = system($sysComm);
sl@0
   311
	if ($result != 0 && $keep eq "")
sl@0
   312
		{
sl@0
   313
		print "Error '$sysComm' failed: $result\n";
sl@0
   314
		exit ($result);
sl@0
   315
		}
sl@0
   316
	$error |= $result;
sl@0
   317
	# fourth metabld goes through test build tests - ignore any dups with the above. Does not make any difference
sl@0
   318
	$sysComm = $metabld . " " . $testBuild_mbc . " bldmake " . $keep . " bldfiles";
sl@0
   319
	$result = system($sysComm);
sl@0
   320
	if ($result != 0 && $keep eq "")
sl@0
   321
		{
sl@0
   322
		print "Error '$sysComm' failed: $result\n";
sl@0
   323
		exit ($result);
sl@0
   324
		}
sl@0
   325
	$error |= $result;
sl@0
   326
	if ($error)
sl@0
   327
		{
sl@0
   328
  		print "Errors found during run\n";
sl@0
   329
		exit ($error)
sl@0
   330
		}
sl@0
   331
	}
sl@0
   332
sl@0
   333
sub Clean
sl@0
   334
	{
sl@0
   335
	# first getmake does makefiles on the main entries
sl@0
   336
	# note we generally ignore any errors on this
sl@0
   337
	my $sysComm = $metabld . " " . $main_mbc . " abld " . $keep . " makefile";
sl@0
   338
	system($sysComm);
sl@0
   339
	if (-f $phys_mbc)
sl@0
   340
		{
sl@0
   341
		my $sysComm = $metabld . " " . $phys_mbc . " abld " . $keep . " makefile";
sl@0
   342
		system($sysComm);
sl@0
   343
		}
sl@0
   344
	if ($test eq $test_param)
sl@0
   345
		{
sl@0
   346
		# also do for test files
sl@0
   347
		$sysComm = $metabld . " " . $test_mbc . " abld " . $keep . " makefile";
sl@0
   348
		system($sysComm);
sl@0
   349
		$sysComm = $metabld . " " . $testBuild_mbc . " abld " . $keep . " test makefile";
sl@0
   350
		system($sysComm);
sl@0
   351
		}
sl@0
   352
	my $sysComm = $metabld . " " . $main_mbc . " abld " . $keep . " reallyclean";
sl@0
   353
	system($sysComm);
sl@0
   354
	if (-f $phys_mbc)
sl@0
   355
		{
sl@0
   356
		my $sysComm = $metabld . " " . $phys_mbc . " abld " . $keep . " reallyclean";
sl@0
   357
		system($sysComm);
sl@0
   358
		}
sl@0
   359
	if ($test eq $test_param)
sl@0
   360
		{
sl@0
   361
		# also do for test file
sl@0
   362
		$sysComm = $metabld . " " . $test_mbc . " abld " . $keep . " reallyclean";
sl@0
   363
		system($sysComm);
sl@0
   364
		$sysComm = $metabld . " " . $testBuild_mbc . " abld " . $keep . " test reallyclean";
sl@0
   365
		system($sysComm);
sl@0
   366
		}
sl@0
   367
sl@0
   368
	}
sl@0
   369
sl@0
   370
sub Build
sl@0
   371
	{
sl@0
   372
	# defaults
sl@0
   373
	if (!(-f $eka2IdentifyFile)) 
sl@0
   374
	    {
sl@0
   375
		@default_targets = @Beech_targets;
sl@0
   376
	    }
sl@0
   377
sl@0
   378
	if (@targets == 0)
sl@0
   379
		{
sl@0
   380
		@targets = @default_targets;
sl@0
   381
		}
sl@0
   382
	if ($use_gccxml ne "")
sl@0
   383
		{
sl@0
   384
		$targets[++$#targets] = $gccxml_target; # append		
sl@0
   385
		}
sl@0
   386
	if ((-f $x86gccIdentifyFile)) 
sl@0
   387
	        {
sl@0
   388
		$targets[++$#targets] = $x86gcc_target; # append x86gcc target since Build env present.
sl@0
   389
		}	
sl@0
   390
	# for each target we need to go through each stage
sl@0
   391
	# if -k was given, we make all calls and give error at the end
sl@0
   392
	my $error = 0;
sl@0
   393
	foreach my $target (@targets)
sl@0
   394
		{
sl@0
   395
		# work out which .mbc files to use. Key is as follows
sl@0
   396
		#    in physical targets and not test, __test.mbc
sl@0
   397
		#    in physical targets and test, skip - not currently supported
sl@0
   398
		#    not in physical targets and not test, __main.mbc
sl@0
   399
		#    not in physical targets and test, __test.mbc
sl@0
   400
		my $build_test = $test ne ""; # -t has been given
sl@0
   401
		my $build_testBuild = $test ne "" && $testBuild ne ""; # -t and -b has been given
sl@0
   402
		my $physical_target = 0;
sl@0
   403
		foreach my $phys (@physical_targets)
sl@0
   404
			{
sl@0
   405
			if ($phys eq $target)
sl@0
   406
				{
sl@0
   407
				$physical_target = 1;
sl@0
   408
				last; # exit loop
sl@0
   409
				}
sl@0
   410
			}
sl@0
   411
		my $mbc;
sl@0
   412
		if ($physical_target && !$test)
sl@0
   413
			{
sl@0
   414
			if (-f $phys_mbc)
sl@0
   415
				{
sl@0
   416
				$mbc = $phys_mbc;
sl@0
   417
				}
sl@0
   418
			else
sl@0
   419
				{
sl@0
   420
				# we don't want to do anything - skip to next target
sl@0
   421
				next; 
sl@0
   422
				}
sl@0
   423
			}
sl@0
   424
		elsif ($physical_target && $test)
sl@0
   425
			{
sl@0
   426
			next; # skip to next target
sl@0
   427
			}
sl@0
   428
		elsif (($target eq "gccxml") && $test) # Build GCCXML on the production code only
sl@0
   429
			{
sl@0
   430
			next; # skip to next target
sl@0
   431
			}
sl@0
   432
		elsif (!$physical_target && !$test)
sl@0
   433
			{
sl@0
   434
			$mbc = $main_mbc;
sl@0
   435
			}		
sl@0
   436
		elsif ($test ne "")
sl@0
   437
			{
sl@0
   438
			if (!$testBuild)
sl@0
   439
				{
sl@0
   440
				$mbc = $test_mbc;
sl@0
   441
				}
sl@0
   442
			else
sl@0
   443
				{
sl@0
   444
				$mbc = $testBuild_mbc;
sl@0
   445
				}
sl@0
   446
			}
sl@0
   447
			
sl@0
   448
		# if the target is "wins", then check to see if wins is installed and otherwise just do export
sl@0
   449
		# this is intended to get around Cedar builds not having wins. Really out to check for VC++ too,
sl@0
   450
		# but not clear how
sl@0
   451
		my @reqStages = @stages;
sl@0
   452
		@reqStages = @tbstages if $build_testBuild;
sl@0
   453
		if ($target eq "wins")
sl@0
   454
			{
sl@0
   455
			my $euser_lib = $EPOCROOT . "epoc32\\release\\wins\\udeb\\euser.lib";
sl@0
   456
			if (! -f $euser_lib)
sl@0
   457
				{
sl@0
   458
				print "no WINS installation found - just export\n";
sl@0
   459
				@reqStages = ( "export" );
sl@0
   460
				}
sl@0
   461
			}
sl@0
   462
sl@0
   463
sl@0
   464
			
sl@0
   465
		# now the main loop
sl@0
   466
		foreach my $stage (@reqStages)
sl@0
   467
			{
sl@0
   468
			# export does not take target as parameter, others do
sl@0
   469
			my $takesTarget = 0;
sl@0
   470
			foreach my $stage2 (@stagesTakingTarget)
sl@0
   471
				{
sl@0
   472
				if ($stage eq $stage2)
sl@0
   473
					{
sl@0
   474
					$takesTarget = 1;
sl@0
   475
					last; # exit loop
sl@0
   476
					}
sl@0
   477
				}
sl@0
   478
			if (($stage eq "makefile" || $stage eq "test makefile") && $skipMake ne "")
sl@0
   479
				{
sl@0
   480
				print "Skip makefile\n"; 
sl@0
   481
				next; # skip the makefile stage
sl@0
   482
				}
sl@0
   483
			# the command - metabld xxx.mbc command
sl@0
   484
			my $sysComm = $metabld . " " . $mbc .
sl@0
   485
			    " abld " . $keep . " " . $stage;
sl@0
   486
			if ($takesTarget)
sl@0
   487
				{
sl@0
   488
				$sysComm .= " " . $target;
sl@0
   489
				}
sl@0
   490
			my $result = system($sysComm);
sl@0
   491
			if ($result != 0)
sl@0
   492
				{
sl@0
   493
				if ($keep ne "")
sl@0
   494
					{
sl@0
   495
					# remember error and keep going
sl@0
   496
					$error |= $result;
sl@0
   497
					}
sl@0
   498
				else
sl@0
   499
					{
sl@0
   500
					print "Error '$sysComm' failed: $result\n";
sl@0
   501
					exit ($result);
sl@0
   502
					}
sl@0
   503
				}
sl@0
   504
			}
sl@0
   505
		}
sl@0
   506
	if ($error)
sl@0
   507
		{
sl@0
   508
  		print "Errors found during run\n";
sl@0
   509
		exit ($error)
sl@0
   510
		}
sl@0
   511
	}
sl@0
   512
sl@0
   513
sub Usage
sl@0
   514
	{
sl@0
   515
	# print usage statement and exit
sl@0
   516
	print <<ENDHERESTRING;
sl@0
   517
usage:
sl@0
   518
	mmbuild {-i|-e|-m|-f} [-x] [-k] setup
sl@0
   519
	mmbuild [-t] [-k] clean
sl@0
   520
	mmbuild [-t [-b]] [-k] [-g] [-s] build [targets]
sl@0
   521
sl@0
   522
mmbuild is intended to do a full build of the Multimedia source area, both for
sl@0
   523
use in test builds and by team engineers. The effect will be similar to that
sl@0
   524
achieved for overnight builds, although the mechanism is slight different.
sl@0
   525
sl@0
   526
In typical usage, the various forms of the command - as given above - are used
sl@0
   527
in turn. "setup" equates roughly to "bldmake bldfiles". It is called to setup
sl@0
   528
the various files prior to the build proper. The parameters are as follows:
sl@0
   529
sl@0
   530
-i) Build ICL only
sl@0
   531
-m) Build MMF only
sl@0
   532
-c) Build Misc only (other than ICL or MMF)
sl@0
   533
-f) Build all Multimedia components (default)
sl@0
   534
sl@0
   535
-x) Additionally build any optional components - default is non-optional only
sl@0
   536
sl@0
   537
"clean" effectively does a reallyclean operation.
sl@0
   538
sl@0
   539
-t) Clean test code, *as well as* main code - default is to clean main code only
sl@0
   540
sl@0
   541
"build" does a build operation. Optional parameters give the target list - the
sl@0
   542
default is "wins", "winscw", "arm4" and "mcot". For physical targets, like mcot,
sl@0
   543
only the SoundDev mmf folder is built.
sl@0
   544
sl@0
   545
-t) Build test code (including testframework), *instead of* main code - default
sl@0
   546
is to build main code only
sl@0
   547
sl@0
   548
-t) Build test code (including testframework), *instead of* main code 
sl@0
   549
    Note: without -b this is test code built via "abld build"
sl@0
   550
sl@0
   551
-b) When given with -t, build test code that is built via "abld test build"
sl@0
   552
sl@0
   553
-g) Build code additionally for gccxml. Null operation when used with -t. 
sl@0
   554
sl@0
   555
-s) Skip the make stage. Use with care - should not be used if any include, 
sl@0
   556
source list or library list have been changed, and never on the first time 
sl@0
   557
called. However, it can save time on a subsequent call.
sl@0
   558
sl@0
   559
A typical usage sequence would be:
sl@0
   560
	mmbuild setup
sl@0
   561
	mmbuild -t clean
sl@0
   562
	mmbuild build
sl@0
   563
	mmbuild -t build
sl@0
   564
	mmbuild -t -b build
sl@0
   565
sl@0
   566
which would do a reallyclean and rebuild of the whole Multimedia sub-system,
sl@0
   567
except the mcot sound drivers on EKA1.
sl@0
   568
sl@0
   569
For each command, the -k flag will try and keep going as much as possible -
sl@0
   570
setup and build, by default, will stop with the first error.
sl@0
   571
ENDHERESTRING
sl@0
   572
	exit 1;
sl@0
   573
	}
sl@0
   574