kernel/eka/rombuild/rom_sbs.pl
changeset 7 0a6fb11f0655
parent 5 4ab060f25417
child 8 8d0f562530b6
equal deleted inserted replaced
6:248107124823 7:0a6fb11f0655
    48 						 "kerneltrace=s",
    48 						 "kerneltrace=s",
    49 						 "rombuilder=s",
    49 						 "rombuilder=s",
    50 						 "define=s@",
    50 						 "define=s@",
    51 						 "rofsbuilder=s",
    51 						 "rofsbuilder=s",
    52 						 "compress",
    52 						 "compress",
    53 						 "epocroot=s"
       
    54 						 );
    53 						 );
    55 
    54 
    56 my (@assps, @builds, %variants, @templates, %flags, %insts, %zip, %builder);
    55 my (@assps, @builds, %variants, @templates, %flags, %insts, %zip, %builder);
    57 my $main;
    56 my $main;
    58 my $kmain;
    57 my $kmain;
    79 my $EpocRoot;
    78 my $EpocRoot;
    80 my $drive;
    79 my $drive;
    81 my $BasePath;
    80 my $BasePath;
    82 
    81 
    83 BEGIN {
    82 BEGIN {
       
    83 
       
    84 	$EpocRoot = $ENV{EPOCROOT};
       
    85 	die "ERROR: Must set the EPOCROOT environment variable.\n" if (!defined($EpocRoot));
       
    86 	print "Environmental epocroot - >$EpocRoot<\n";
       
    87 	$EpocRoot =~ s-/-\\-go;	# for those working with UNIX shells
       
    88 	if ($EpocRoot =~ /^([a-z]:)(.*)$/i)
       
    89 	{
       
    90 		# Raptor style: Drive letter and trailing \\ removed
       
    91 		$drive = $1;
       
    92 		$EpocRoot = "$2\\";
       
    93 		$ENV{EPOCROOT} = $EpocRoot;
       
    94 	}
       
    95 	die "ERROR: EPOCROOT must be an absolute path, " .
       
    96 		"not containing a drive letter.\n" if ($EpocRoot !~ /^\\/);
       
    97 	die "ERROR: EPOCROOT must not be a UNC path.\n" if ($EpocRoot =~ /^\\\\/);
       
    98 	die "ERROR: EPOCROOT must end with a backslash.\n" if ($EpocRoot !~ /\\$/);
       
    99 	die "ERROR: EPOCROOT must specify an existing directory.\n" if (!-d $EpocRoot);
       
   100 
       
   101 	# The cpp needed a drive apparently
    84 	my $cwd = Cwd::cwd();
   102 	my $cwd = Cwd::cwd();
    85 	$EpocRoot = $ENV{'EPOCROOT'};
   103 	$cwd =~ /^(.)/;
    86 	print "epocroot - >$EpocRoot<\n";
   104 	$drive = "$1:" unless $drive;
    87 	if ($EpocRoot =~ /^[a-z]:/i)
   105 	print "epocroot = >$EpocRoot<\n";
    88 	{
   106 	print "drive = >$drive<\n";
    89 	# Raptor style: Drive letter and trailing \\ removed
   107 
    90 	$drive = substr($EpocRoot, 0, 2);
       
    91 	$EpocRoot = substr($EpocRoot, 2) . "\\";
       
    92 	}
       
    93 	else
       
    94 	{
       
    95 	# old style - no drive letter, so deduce it from $cwd
       
    96 	$drive = substr($cwd, 0, 2);
       
    97 	}
       
    98 	print "drive, epocroot = >$drive<, >$EpocRoot<\n";
       
    99 	
       
   100 	my $fp0 = $0;
   108 	my $fp0 = $0;
   101 	$cwd =~ s/\//\\/g;
   109 	$cwd =~ s/\//\\/g;
   102 	$fp0 =~ s/\//\\/g;
   110 	$fp0 =~ s/\//\\/g;
   103 	unless ($fp0 =~ /^([A-Za-z]:)?\\/) {
   111 	unless ($fp0 =~ /^([A-Za-z]:)?\\/) {
   104 		if ($cwd =~ /\\$/) {
   112 		if ($cwd =~ /\\$/) {
   127 {
   135 {
   128         Plat_Init($toolpath);
   136         Plat_Init($toolpath);
   129 }
   137 }
   130 
   138 
   131 if ($debug) {
   139 if ($debug) {
   132 	print "\n";
       
   133 	print "EpocRoot = $EpocRoot\n";
   140 	print "EpocRoot = $EpocRoot\n";
   134 	print "Epoc32Path = $Epoc32Path\n";
   141 	print "Epoc32Path = $Epoc32Path\n";
   135 	print "drive = $drive\n";
   142 	print "drive = $drive\n";
   136 	print "toolpath = $toolpath\n";
   143 	print "toolpath = $toolpath\n";
   137 	print "toroot = $toroot\n";
   144 	print "toroot = $toroot\n";
   138 	print "e32path = $e32path\n";
   145 	print "e32path = $e32path\n";
   139 	print "rombuildpath = $rombuildpath\n";
   146 	print "rombuildpath = $rombuildpath\n";
   140 	print "BasePath = $BasePath\n";
   147 	print "BasePath = $BasePath\n";
   141 	print "\n";
       
   142 }
   148 }
   143 
   149 
   144 my $cppflags="-P -undef -traditional -lang-c++ -nostdinc -iwithprefixbefore $rombuildpath -I $rombuildpath -I $Epoc32Path ";
   150 my $cppflags="-P -undef -traditional -lang-c++ -nostdinc -iwithprefixbefore $rombuildpath -I $rombuildpath -I $Epoc32Path ";
   145 
   151 
   146 # Include variant hrh file defines when processing oby and ibys with cpp
   152 # Include variant hrh file defines when processing oby and ibys with cpp
   147 # (Code copied from \\EPOC\master\cedar\generic\tools\romkit\tools\buildrom.pm -
   153 # (Code copied from \\EPOC\master\cedar\generic\tools\romkit\tools\buildrom.pm -
   148 # it used relative path to the working dir but we are using absolute path seems neater)
   154 # it used relative path to the working dir but we are using absolute path seems neater)
   149 use E32Variant;
   155 use E32Variant;
   150 use Pathutl;
   156 use Pathutl;
   151 my $variantMacroHRHFile = Variant_GetMacroHRHFile();
   157 my $variantMacroHRHFile = Variant_GetMacroHRHFile();
   152 
       
   153 if($variantMacroHRHFile){
   158 if($variantMacroHRHFile){
   154 	# Using absolute paths so must include drive letter otherwise cpp will fail
   159 	# Using absolute paths so must include drive letter otherwise cpp will fail
   155 	# Also adding the directory containing the HRH file to main includes paths in
   160 	# Also adding the directory containing the HRH file to main includes paths in
   156 	# case it includes files
   161 	# case it includes files
   157 	my $variantFilePath = Path_Split('Path',$variantMacroHRHFile);
   162 	my $variantFilePath = Path_Split('Path',$variantMacroHRHFile);
   174 \tTYPE: $opts{'type'}
   179 \tTYPE: $opts{'type'}
   175 \tVARIANT: $opts{'variant'}
   180 \tVARIANT: $opts{'variant'}
   176 \tINSTRUCTION SET: $opts{'inst'}
   181 \tINSTRUCTION SET: $opts{'inst'}
   177 \tBUILD: $opts{'build'}
   182 \tBUILD: $opts{'build'}
   178 \tMODULES: $opts{'modules'}
   183 \tMODULES: $opts{'modules'}
   179 \tepocroot: $opts{'epocroot'}
       
   180 EOF
   184 EOF
   181 }
   185 }
   182 
   186 
   183 #Pick out the type file
   187 #Pick out the type file
   184 my $skel;
   188 my $skel;
   260 $defines .= "-D E32PATH=$e32path ";
   264 $defines .= "-D E32PATH=$e32path ";
   261 $defines .= "-D BASEPATH=$BasePath ";
   265 $defines .= "-D BASEPATH=$BasePath ";
   262 $defines .= "-D EPOCROOT=$EpocRoot ";
   266 $defines .= "-D EPOCROOT=$EpocRoot ";
   263 $defines .= "-D SMAIN=$smain " if $smain;
   267 $defines .= "-D SMAIN=$smain " if $smain;
   264 
   268 
   265 
       
   266 foreach (@{$opts{'define'}}) {
   269 foreach (@{$opts{'define'}}) {
   267 	my @array=split(/,/,$_);
   270 	my @array=split(/,/,$_);
   268 	foreach (@array) {
   271 	foreach (@array) {
   269 		$defines.="-D ".uc $_." ";
   272 		$defines.="-D ".uc $_." ";
   270 		$pagedCode = 1 if $_ eq 'PAGED_CODE';
   273 		$pagedCode = 1 if $_ eq 'PAGED_CODE';
   283 	next if ($_ eq 'modules');
   286 	next if ($_ eq 'modules');
   284 	next if ($_ eq 'zip');
   287 	next if ($_ eq 'zip');
   285 	next if ($_ eq 'symbol');
   288 	next if ($_ eq 'symbol');
   286 	next if ($_ eq 'kerneltrace');
   289 	next if ($_ eq 'kerneltrace');
   287 	next if ($_ eq 'define');
   290 	next if ($_ eq 'define');
   288 	next if ($_ eq 'epocroot');
       
   289 	$defines.="-D ".uc $_."=".$opts{$_}." ";
   291 	$defines.="-D ".uc $_."=".$opts{$_}." ";
   290 	$defines.="-D ".uc $_."_".$opts{$_}." ";
   292 	$defines.="-D ".uc $_."_".$opts{$_}." ";
   291 }
   293 }
   292 
   294 
   293 $defines.="-D SINGLE " if ($single);
   295 $defines.="-D SINGLE " if ($single);
   306 
   308 
   307 my $ret=1;
   309 my $ret=1;
   308 my $cppcmd;
   310 my $cppcmd;
   309 if($opts{'build'}=~/^u/i) {
   311 if($opts{'build'}=~/^u/i) {
   310 	# Unicode build
   312 	# Unicode build
   311 	#$cppcmd = "c:/apps/Raptor/win32/mingw/bin/cpp $cppflags -D UNICODE $defines rom1.tmp rom2.tmp";
       
   312 	#$cppcmd = "F:/S60/devices/S60_5th_Edition_SDK_v1.0_2/epoc32/gcc/bin/cpp $cppflags -D UNICODE $defines rom1.tmp rom2.tmp";
       
   313 	$cppcmd = "$Epoc32Path/gcc/bin/cpp $cppflags -D UNICODE $defines rom1.tmp rom2.tmp";
   313 	$cppcmd = "$Epoc32Path/gcc/bin/cpp $cppflags -D UNICODE $defines rom1.tmp rom2.tmp";
   314 	} else {
   314 } else {
   315 	$cppcmd = "cpp $cppflags $defines rom1.tmp rom2.tmp";
   315 	$cppcmd = "cpp $cppflags $defines rom1.tmp rom2.tmp";
   316 }
   316 }
   317 print "\nExecuting CPP:\n\t$cppcmd\n" if $debug;
   317 print "Executing CPP:\n\t$cppcmd\n" if $debug;
   318 $ret = system($cppcmd);
   318 $ret = system($cppcmd);
   319 die "ERROR EXECUTING CPP\n" if $ret;
   319 die "ERROR EXECUTING CPP\n" if $ret;
   320 
   320 
   321 # Zap any ## marks REMS or blank lines
   321 # Zap any ## marks REMS or blank lines
   322 
   322 
   323 cleanup("rom2.tmp", "rom3.tmp", $k);
   323 cleanup("rom2.tmp", "rom3.tmp", $k);
   324 
       
   325 
   324 
   326 # scan tmp file and generate auxiliary files, if required
   325 # scan tmp file and generate auxiliary files, if required
   327 open TMP, "rom3.tmp" or die("Can't open rom3.tmp\n");
   326 open TMP, "rom3.tmp" or die("Can't open rom3.tmp\n");
   328 my $line;
   327 my $line;
   329 while ($line=<TMP>)
   328 while ($line=<TMP>)
   542 
   541 
   543 The following options are required:
   542 The following options are required:
   544   --variant=<variant>         e.g. --variant=assabet
   543   --variant=<variant>         e.g. --variant=assabet
   545   --inst=<instruction set>    e.g. --inst=arm4
   544   --inst=<instruction set>    e.g. --inst=arm4
   546   --build=<build>             e.g. --build=udeb
   545   --build=<build>             e.g. --build=udeb
   547   --epocroot=<epocroot>       e.g. --epocroot="\\"
       
   548   --type=<type of rom>  
   546   --type=<type of rom>  
   549          tshell for a text shell rom
   547          tshell for a text shell rom
   550          e32tests for a rom with e32tests
   548          e32tests for a rom with e32tests
   551          f32tests for rom with f32tests
   549          f32tests for rom with f32tests
   552          alltests for all the tests
   550          alltests for all the tests
   618 sub checkopts {
   616 sub checkopts {
   619 	unless($opts{variant}) { die "No Variant specified"; }
   617 	unless($opts{variant}) { die "No Variant specified"; }
   620 	$opts{'build'}="UDEB" unless($opts{'build'});
   618 	$opts{'build'}="UDEB" unless($opts{'build'});
   621 	$opts{'type'}="TSHELL" unless($opts{'type'});
   619 	$opts{'type'}="TSHELL" unless($opts{'type'});
   622 	$opts{'inst'}="ARM4" unless($opts{'inst'});
   620 	$opts{'inst'}="ARM4" unless($opts{'inst'});
   623 	$opts{'epocroot'}="\\" unless($opts{'epocroot'});
       
   624 
   621 
   625 	my $additional;
   622 	my $additional;
   626 	if ($opts{'modules'}) {
   623 	if ($opts{'modules'}) {
   627 		$additional="_".$opts{modules};
   624 		$additional="_".$opts{modules};
   628 		$additional=~ s/,/_/ig;
   625 		$additional=~ s/,/_/ig;
   629 	}
   626 	}
   630 	my $build=lc $opts{build};
   627 	my $build=lc $opts{build};
   631 	$EpocRoot=lc $opts{epocroot};
       
   632 	#print "EpocRoot = $EpocRoot\n";
       
   633 	my $inst=uc $opts{'inst'};
   628 	my $inst=uc $opts{'inst'};
   634 	if ($inst eq "MARM") {
   629 	if ($inst eq "MARM") {
   635 		# Hackery to cope with old compiler
   630 		# Hackery to cope with old compiler
   636 		$main="MARM";
   631 		$main="MARM";
   637 		$euserdir="MARM";
   632 		$euserdir="MARM";