kernel/eka/rombuild/rom_sbs.pl
author William Roberts <williamr@symbian.org>
Mon, 26 Jul 2010 11:21:15 +0100
branchGCC_SURGE
changeset 230 ec72eca27576
parent 223 9b475c7a1224
parent 227 e4a1175ecbc0
permissions -rw-r--r--
Merge in latest fix for rom_sbs.pl
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
214
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
     1
#!perl
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
     2
#
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
     3
# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
     4
# All rights reserved.
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
     5
# This component and the accompanying materials are made available
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
     6
# under the terms of the License "Eclipse Public License v1.0"
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
     7
# which accompanies this distribution, and is available
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
     8
# at the URL "http://www.eclipse.org/legal/epl-v10.html".
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
     9
#
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    10
# Initial Contributors:
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    11
# Nokia Corporation - initial contribution.
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    12
#
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    13
# Contributors:
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    14
#
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    15
# Description:
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    16
#
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    17
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    18
# rom.pl - Build a rom
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    19
#
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    20
# Pre-processes the .oby/iby files then invokes rombuild.exe
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    21
# (or other specified builder)
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    22
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    23
# First, read our config file
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    24
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    25
use strict;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    26
use Getopt::Long;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    27
use Cwd;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    28
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    29
#Getopt::Long::Configure("ignore_case");
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    30
my %opts=();
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    31
my $param_count = scalar(@ARGV);
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    32
my $result = GetOptions (\%opts, "assp=s",
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    33
						 "inst=s",
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    34
						 "type=s",
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    35
						 "variant=s",
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    36
						 "build=s", 
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    37
						 "conf=s",
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    38
						 "name=s",
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    39
						 "modules=s",
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    40
						 "xabi=s",
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    41
						 "clean",
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    42
						 "quiet",
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    43
						 "help",
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    44
						 "_debug",
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    45
						 "zip",
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    46
						 "symbol",
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    47
						 "noheader",
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    48
						 "kerneltrace=s",
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    49
						 "rombuilder=s",
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    50
						 "define=s@",
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    51
						 "rofsbuilder=s",
224
da1922ac85fb Pull rom.pl updates into rom_sbs.pl. to complete the fix for bug 3358
William Roberts <williamr@symbian.org>
parents: 217
diff changeset
    52
						 "compress"
214
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    53
						 );
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    54
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    55
my (@assps, @builds, %variants, @templates, %flags, %insts, %zip, %builder);
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    56
my $main;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    57
my $kmain;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    58
my $toroot;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    59
my $e32path;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    60
my $rombuildpath;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    61
my $euserdir;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    62
my $elocldir;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    63
my $kbdir;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    64
my $romname;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    65
my $single;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    66
my $smain;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    67
my $pagedCode;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    68
my $debug = $opts{_debug};
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    69
my $quiet;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    70
$quiet = $opts{quiet} unless $debug;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    71
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    72
my $drive;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    73
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    74
# discover where this script is running from to set the $toroot and $e32path variables
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    75
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    76
my $toolpath;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    77
my $Epoc32Path;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    78
my $EpocRoot;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    79
my $drive;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    80
my $BasePath;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    81
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    82
BEGIN {
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    83
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    84
	$EpocRoot = $ENV{EPOCROOT};
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    85
	die "ERROR: Must set the EPOCROOT environment variable.\n" if (!defined($EpocRoot));
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    86
	print "Environmental epocroot - >$EpocRoot<\n";
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    87
	$EpocRoot =~ s-/-\\-go;	# for those working with UNIX shells
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    88
	if ($EpocRoot =~ /^([a-z]:)(.*)$/i)
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    89
	{
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    90
		# Raptor style: Drive letter and trailing \\ removed
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    91
		$drive = $1;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    92
		$EpocRoot = "$2\\";
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    93
		$ENV{EPOCROOT} = $EpocRoot;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    94
	}
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    95
	die "ERROR: EPOCROOT must be an absolute path, " .
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    96
		"not containing a drive letter.\n" if ($EpocRoot !~ /^\\/);
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    97
	die "ERROR: EPOCROOT must not be a UNC path.\n" if ($EpocRoot =~ /^\\\\/);
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    98
	die "ERROR: EPOCROOT must end with a backslash.\n" if ($EpocRoot !~ /\\$/);
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    99
	die "ERROR: EPOCROOT must specify an existing directory.\n" if (!-d $EpocRoot);
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   100
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   101
	# The cpp needed a drive apparently
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   102
	my $cwd = Cwd::cwd();
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   103
	$cwd =~ /^(.)/;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   104
	$drive = "$1:" unless $drive;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   105
	print "epocroot = >$EpocRoot<\n";
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   106
	print "drive = >$drive<\n";
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   107
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   108
	my $fp0 = $0;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   109
	$cwd =~ s/\//\\/g;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   110
	$fp0 =~ s/\//\\/g;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   111
	unless ($fp0 =~ /^([A-Za-z]:)?\\/) {
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   112
		if ($cwd =~ /\\$/) {
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   113
			$fp0 = "$cwd$fp0";
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   114
		} else {
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   115
			$fp0 = "$cwd\\$fp0";
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   116
		}
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   117
	}
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   118
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   119
	my @path = split(/\\/, $cwd);
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   120
	shift(@path);
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   121
	$toroot = ('..\\') x @path;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   122
	$e32path = $fp0;
217
96e53742b989 Fix calculation of e32path in rom_sbs.pl - Bug 3358
William Roberts <williamr@symbian.org>
parents: 214
diff changeset
   123
	$e32path =~ s/\\kernelhwsrv\\kernel\\eka\\rombuild\\.*$//i;
214
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   124
	$e32path =~ s/^[A-Za-z]://;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   125
	$rombuildpath = $toroot."sf\\os\\kernelhwsrv\\kernel\\eka\\rombuild";
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   126
	$Epoc32Path = $toroot;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   127
	$Epoc32Path =~ s/\\$//;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   128
	$Epoc32Path .= $EpocRoot . "epoc32";
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   129
	$toolpath = "$Epoc32Path\\tools\\";
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   130
	push @INC, $toolpath;
227
e4a1175ecbc0 Final fix to rom_sbs.pl for Bug 3358
William Roberts <williamr@symbian.org>
parents: 224
diff changeset
   131
	$BasePath = "$toroot$e32path\\";    # Note: toroot may be empty!
e4a1175ecbc0 Final fix to rom_sbs.pl for Bug 3358
William Roberts <williamr@symbian.org>
parents: 224
diff changeset
   132
	$BasePath =~ s/\\\\/\\/g;	# clean up path seaprators
214
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   133
}
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   134
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   135
use E32Plat;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   136
{
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   137
        Plat_Init($toolpath);
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   138
}
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   139
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   140
if ($debug) {
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   141
	print "EpocRoot = $EpocRoot\n";
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   142
	print "Epoc32Path = $Epoc32Path\n";
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   143
	print "drive = $drive\n";
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   144
	print "toolpath = $toolpath\n";
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   145
	print "toroot = $toroot\n";
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   146
	print "e32path = $e32path\n";
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   147
	print "rombuildpath = $rombuildpath\n";
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   148
	print "BasePath = $BasePath\n";
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   149
}
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   150
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   151
my $cppflags="-P -undef -traditional -lang-c++ -nostdinc -iwithprefixbefore $rombuildpath -I $rombuildpath -I $drive$Epoc32Path ";
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   152
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   153
# Include variant hrh file defines when processing oby and ibys with cpp
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   154
# (Code copied from \\EPOC\master\cedar\generic\tools\romkit\tools\buildrom.pm -
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   155
# it used relative path to the working dir but we are using absolute path seems neater)
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   156
use E32Variant;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   157
use Pathutl;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   158
my $variantMacroHRHFile = Variant_GetMacroHRHFile();
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   159
if($variantMacroHRHFile){
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   160
	# Using absolute paths so must include drive letter otherwise cpp will fail
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   161
	# Also adding the directory containing the HRH file to main includes paths in
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   162
	# case it includes files
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   163
	my $variantFilePath = Path_Split('Path',$variantMacroHRHFile);
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   164
	$cppflags .= " -I $drive$variantFilePath -include $drive$variantMacroHRHFile";
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   165
}
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   166
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   167
if($param_count == 0 || $opts{'help'} || !$result) {
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   168
	usage();
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   169
	exit 0;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   170
}
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   171
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   172
# Now check that the options we have make sense
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   173
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   174
checkopts();
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   175
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   176
if (!$quiet) {
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   177
	print "Starting directory: ", Cwd::cwd(), "\n";
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   178
	print <<EOF;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   179
OPTIONS:
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   180
\tTYPE: $opts{'type'}
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   181
\tVARIANT: $opts{'variant'}
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   182
\tINSTRUCTION SET: $opts{'inst'}
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   183
\tBUILD: $opts{'build'}
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   184
\tMODULES: $opts{'modules'}
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   185
EOF
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   186
}
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   187
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   188
#Pick out the type file
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   189
my $skel;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   190
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   191
if (-e "$opts{'type'}.oby") {
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   192
	$skel="$opts{'type'}.oby";
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   193
} elsif (-e "$rombuildpath\\$opts{'type'}.oby") {
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   194
	$skel="$rombuildpath\\$opts{'type'}.oby";
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   195
} else {
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   196
	die "Can't find type file for type $opts{'type'}, $!";
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   197
}
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   198
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   199
print "Using type file $skel\n" if !$quiet;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   200
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   201
# If clean is specified, zap all the image and .oby files
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   202
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   203
if($opts{'clean'}) {
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   204
	unlink glob("*.img");
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   205
	unlink "rom.oby";
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   206
	unlink "rombuild.log";
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   207
	unlink glob("*.rofs");
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   208
	unlink "rofsbuild.log";
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   209
}
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   210
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   211
# Now pre-pre-process this file to point to the right places for .ibys
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   212
# Unfortunately cpp won't do macro replacement in #include strings, so
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   213
# we have to do it by hand
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   214
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   215
my $k = $opts{kerneltrace};
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   216
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   217
if ($opts{assp}=~/^m(\S+)/i) {
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   218
	$kbdir="kb$1";
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   219
	$kbdir="kbarm" if (lc $1 eq 'eig');
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   220
} else {
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   221
	$kbdir="kb$opts{assp}";
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   222
}
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   223
$single=1 if ($opts{assp}=~/^s(\S+)/i);
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   224
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   225
if ($single) {
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   226
	# Hackery to cope with old compiler
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   227
	if ($main eq 'MARM') {
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   228
		$smain='SARM';
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   229
	} else {
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   230
		$smain="S$main";
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   231
	}
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   232
} else {
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   233
	$smain=$main;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   234
}
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   235
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   236
open(X, "$skel") || die "Can't open type file $skel, $!";
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   237
open(OUT, "> rom1.tmp") || die "Can't open output file, $!";
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   238
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   239
# First output the ROM name
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   240
print OUT "\nromname=$romname\n";
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   241
while(<X>) {
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   242
	s/\#\#ASSP\#\#/$opts{'assp'}/;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   243
	s/\#\#VARIANT\#\#/$opts{'variant'}/;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   244
	s/\#\#BUILD\#\#/$opts{'build'}/;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   245
	s/\#\#MAIN\#\#/$main/;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   246
	s/\#\#KMAIN\#\#/$kmain/;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   247
	s/\#\#E32PATH\#\#/$e32path/;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   248
	s/\#\#BASEPATH\#\#/$BasePath/;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   249
	s/\#\#EUSERDIR\#\#/$euserdir/;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   250
	s/\#\#ELOCLDIR\#\#/$elocldir/;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   251
	s/\#\#KBDIR\#\#/$kbdir/;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   252
	print OUT;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   253
}
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   254
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   255
close X;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   256
close OUT;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   257
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   258
# Use cpp to pull in include chains and replace defines
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   259
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   260
my $defines = "";
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   261
$defines .= "-D MAIN=$main ";
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   262
$defines .= "-D KMAIN=$kmain ";
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   263
$defines .= "-D EUSERDIR=$euserdir ";
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   264
$defines .= "-D ELOCLDIR=$elocldir ";
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   265
$defines .= "-D E32PATH=$e32path ";
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   266
$defines .= "-D BASEPATH=$BasePath ";
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   267
$defines .= "-D EPOCROOT=$EpocRoot ";
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   268
$defines .= "-D SMAIN=$smain " if $smain;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   269
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   270
foreach (@{$opts{'define'}}) {
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   271
	my @array=split(/,/,$_);
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   272
	foreach (@array) {
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   273
		$defines.="-D ".uc $_." ";
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   274
		$pagedCode = 1 if $_ eq 'PAGED_CODE';
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   275
		}
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   276
	}
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   277
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   278
if ($opts{'modules'}) {
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   279
	my @array=split(/,/,$opts{'modules'});
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   280
	foreach (@array) {
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   281
		$defines.="-D ".uc $_." ";
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   282
		}
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   283
	}
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   284
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   285
foreach (keys %opts) {
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   286
	next if ($_ eq 'name');
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   287
	next if ($_ eq 'modules');
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   288
	next if ($_ eq 'zip');
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   289
	next if ($_ eq 'symbol');
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   290
	next if ($_ eq 'kerneltrace');
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   291
	next if ($_ eq 'define');
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   292
	$defines.="-D ".uc $_."=".$opts{$_}." ";
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   293
	$defines.="-D ".uc $_."_".$opts{$_}." ";
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   294
}
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   295
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   296
$defines.="-D SINGLE " if ($single);
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   297
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   298
sub IsRVCTBuild($) {
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   299
    my ($build)=@_;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   300
    return 1 if ($build =~ /^ARMV/i);
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   301
	my @customizations = Plat_Customizations('ARMV5');
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   302
	return 1 if (grep /$build/, @customizations);
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   303
	return 0;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   304
}
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   305
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   306
$defines.="-D RVCT " if (IsRVCTBuild($main));
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   307
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   308
print "Using defines $defines\n" if !$quiet;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   309
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   310
my $ret=1;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   311
my $cppcmd;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   312
if($opts{'build'}=~/^u/i) {
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   313
	# Unicode build
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   314
	$cppcmd = "$Epoc32Path/gcc/bin/cpp $cppflags -D UNICODE $defines rom1.tmp rom2.tmp";
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   315
} else {
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   316
	$cppcmd = "cpp $cppflags $defines rom1.tmp rom2.tmp";
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   317
}
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   318
print "Executing CPP:\n\t$cppcmd\n" if $debug;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   319
$ret = system($cppcmd);
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   320
die "ERROR EXECUTING CPP\n" if $ret;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   321
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   322
# Zap any ## marks REMS or blank lines
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   323
224
da1922ac85fb Pull rom.pl updates into rom_sbs.pl. to complete the fix for bug 3358
William Roberts <williamr@symbian.org>
parents: 217
diff changeset
   324
print "Cleaning up rom2.tmp to make rom3.tmp\n" if $debug;
214
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   325
cleanup("rom2.tmp", "rom3.tmp", $k);
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   326
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   327
# scan tmp file and generate auxiliary files, if required
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   328
open TMP, "rom3.tmp" or die("Can't open rom3.tmp\n");
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   329
my $line;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   330
while ($line=<TMP>)
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   331
	{
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   332
	if ($line=~/\s*gentestpaged/i) {
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   333
		genfile("paged");	}
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   334
	if ($line=~/\s*gentestnonpaged/i) {
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   335
		genfile("nonpaged");	}
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   336
	}
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   337
224
da1922ac85fb Pull rom.pl updates into rom_sbs.pl. to complete the fix for bug 3358
William Roberts <williamr@symbian.org>
parents: 217
diff changeset
   338
print "Parsing PatchData to make rom4.tmp\n" if $debug;
214
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   339
parsePatchData("rom3.tmp", "rom4.tmp");
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   340
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   341
# break down the oby file into rom, rofs and extensions oby files
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   342
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   343
my $oby_index =0;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   344
my $dumpfile="rom.oby";
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   345
my $rofs=0;
224
da1922ac85fb Pull rom.pl updates into rom_sbs.pl. to complete the fix for bug 3358
William Roberts <williamr@symbian.org>
parents: 217
diff changeset
   346
my $smr=0;
214
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   347
my $extension=0;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   348
my $corerofsname="";
224
da1922ac85fb Pull rom.pl updates into rom_sbs.pl. to complete the fix for bug 3358
William Roberts <williamr@symbian.org>
parents: 217
diff changeset
   349
my $smrname="";
214
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   350
open DUMPFILE, ">$dumpfile" or die("Can't create $dumpfile\n");
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   351
my $line;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   352
open TMP, "rom4.tmp" or die("Can't open rom4.tmp\n");
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   353
while ($line=<TMP>)
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   354
	{
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   355
	if ($line=~/^\s*rofsname/i)
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   356
		{
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   357
		close DUMPFILE;							# close rom.oby or previous rofs#/extension#.oby
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   358
		$oby_index=1;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   359
		$corerofsname=$line;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   360
		$corerofsname =~ s/rofsname\s*=\s*//i;		# save core rofs name
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   361
		$corerofsname =~ s/\s*$//g; 			# remove trailing \n
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   362
		unlink $corerofsname || print "unable to delete $corerofsname";
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   363
		my $dumpfile="rofs".$rofs.".oby";
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   364
		$rofs++;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   365
		open DUMPFILE, ">$dumpfile" or (close TMP and die("Can't create $dumpfile\n"));
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   366
		}
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   367
224
da1922ac85fb Pull rom.pl updates into rom_sbs.pl. to complete the fix for bug 3358
William Roberts <williamr@symbian.org>
parents: 217
diff changeset
   368
	if ($line=~/^\s*imagename/i)
da1922ac85fb Pull rom.pl updates into rom_sbs.pl. to complete the fix for bug 3358
William Roberts <williamr@symbian.org>
parents: 217
diff changeset
   369
		{
da1922ac85fb Pull rom.pl updates into rom_sbs.pl. to complete the fix for bug 3358
William Roberts <williamr@symbian.org>
parents: 217
diff changeset
   370
		close DUMPFILE;							# close rom.oby or previous rofs#/extension#.oby
da1922ac85fb Pull rom.pl updates into rom_sbs.pl. to complete the fix for bug 3358
William Roberts <williamr@symbian.org>
parents: 217
diff changeset
   371
		$smrname=$line;
da1922ac85fb Pull rom.pl updates into rom_sbs.pl. to complete the fix for bug 3358
William Roberts <williamr@symbian.org>
parents: 217
diff changeset
   372
		$smrname =~ s/imagename\s*=\s*//i;		# save smr name
da1922ac85fb Pull rom.pl updates into rom_sbs.pl. to complete the fix for bug 3358
William Roberts <williamr@symbian.org>
parents: 217
diff changeset
   373
		$smrname =~ s/\s*$//g; 			# remove trailing \n
da1922ac85fb Pull rom.pl updates into rom_sbs.pl. to complete the fix for bug 3358
William Roberts <williamr@symbian.org>
parents: 217
diff changeset
   374
		unlink $smrname || print "unable to delete $smrname";
da1922ac85fb Pull rom.pl updates into rom_sbs.pl. to complete the fix for bug 3358
William Roberts <williamr@symbian.org>
parents: 217
diff changeset
   375
		my $dumpfile="smr".$smr.".oby";
da1922ac85fb Pull rom.pl updates into rom_sbs.pl. to complete the fix for bug 3358
William Roberts <williamr@symbian.org>
parents: 217
diff changeset
   376
		$smr++;
da1922ac85fb Pull rom.pl updates into rom_sbs.pl. to complete the fix for bug 3358
William Roberts <williamr@symbian.org>
parents: 217
diff changeset
   377
		open DUMPFILE, ">$dumpfile" or (close TMP and die("Can't create $dumpfile\n"));
da1922ac85fb Pull rom.pl updates into rom_sbs.pl. to complete the fix for bug 3358
William Roberts <williamr@symbian.org>
parents: 217
diff changeset
   378
		}
da1922ac85fb Pull rom.pl updates into rom_sbs.pl. to complete the fix for bug 3358
William Roberts <williamr@symbian.org>
parents: 217
diff changeset
   379
214
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   380
	if ($line=~/^\s*coreimage/i)
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   381
		{
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   382
		close DUMPFILE;							# close rofs.oby
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   383
		if ($oby_index ne 1) {
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   384
			close TMP;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   385
			die "Must specify ROFS image before ROFS extension\n";
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   386
		}
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   387
		my $name=$line;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   388
		$name =~ s/coreimage\s*=\s*//i;		# read core rofs name
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   389
		$name =~ s/\s*$//g; 			# remove trailing \n
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   390
		if ($name ne $corerofsname) {
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   391
			close TMP;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   392
			die "This extension does not relate to previous ROFS\n";
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   393
		}
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   394
		$oby_index=33;						# open window
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   395
		my $dumpfile="extension".$extension.".oby";
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   396
		$extension++;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   397
		open DUMPFILE, ">$dumpfile" or (close TMP and die("Can't create $dumpfile\n"));
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   398
		}
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   399
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   400
	if ($line=~/^\s*extensionrofs/i)
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   401
		{
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   402
		$oby_index=3 if ($oby_index eq 2);
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   403
		}
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   404
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   405
	if (($oby_index eq 2) && !($line=~/^\s*$/)) {
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   406
		close TMP;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   407
		die "Bad ROFS extension specification\n";
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   408
	}
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   409
	print DUMPFILE $line;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   410
	$oby_index=2 if ($oby_index eq 33);		# close window
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   411
	}
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   412
close DUMPFILE;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   413
close TMP;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   414
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   415
# For paged roms that use rofs, move all data= lines in rom which are not 'paging_unmovable' to rofs, so that paged ram-loaded code
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   416
# is automatically put into rofs
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   417
rename('rom.oby', 'rom4.tmp') || die;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   418
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   419
open(IN, 'rom4.tmp') || die "Can't read rom4.tmp";
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   420
open(ROM, '>rom.oby') || die "Can't write to rom.oby";
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   421
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   422
if ($oby_index >= 1 && $pagedCode)	{
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   423
	open(ROFS, '>>rofs0.oby') || die "Can't append to rofs0.oby";
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   424
}
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   425
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   426
while ($line=<IN>)
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   427
{
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   428
	if(($oby_index >= 1) && ($pagedCode) && ($line=~/^\s*data\s*=/) && !($line=~/\.*paging_unmovable\s*/)) {
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   429
		print ROFS $line;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   430
	}
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   431
	else {
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   432
		$line=~s/paging_unmovable//;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   433
		print ROM $line;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   434
	}
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   435
}
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   436
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   437
close IN;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   438
close ROM;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   439
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   440
if ($oby_index >= 1 && $pagedCode)	{
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   441
	close ROFS;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   442
}
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   443
	unlink 'rom4.tmp';
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   444
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   445
my $flags;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   446
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   447
foreach (@{$flags{$opts{'assp'}}}) {
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   448
	$flags.=" -$_";
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   449
}
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   450
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   451
if($opts{'noheader'}) {
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   452
	$flags.=" -no-header";
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   453
}
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   454
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   455
if($opts{'compress'}) {
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   456
	$flags.=" -compress";
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   457
}
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   458
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   459
my $builder = $opts{'rombuilder'};
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   460
$builder = "rombuild" unless ($builder);
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   461
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   462
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   463
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   464
print "$builder $flags -type-safe-link -S rom.oby 2>&1\n\n";
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   465
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   466
open(Y, "$builder $flags -type-safe-link -S rom.oby 2>&1 |") || 
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   467
	die "Can't start $builder command, $!";
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   468
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   469
my $nerrors=0;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   470
my $nwarnings=0;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   471
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   472
while(<Y>) {
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   473
	my $error=(/^error:/i);
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   474
	my $warning=(/^warning:/i);
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   475
	print if ($error or $warning or !$quiet);
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   476
	$nerrors++ if ($error);
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   477
	$nwarnings++ if ($warning);
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   478
}
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   479
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   480
print "\nGenerated .oby file is rom.oby\n" if !$quiet;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   481
print "\nGenerated image file is $romname\n" if (!$nerrors);
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   482
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   483
my$rerrors;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   484
my $rofsbuilder;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   485
if ($rofs) {
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   486
	$rofsbuilder = $opts{'rofsbuilder'};
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   487
	$rofsbuilder = "rofsbuild" unless ($rofsbuilder);
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   488
	for(my $i=0;$i<$rofs;++$i) {
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   489
		print "Executing $rofsbuilder on main rofs\n" if !$quiet;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   490
		my $image="rofs".$i.".oby";
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   491
		system("$rofsbuilder $image");
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   492
		if ($? != 0)
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   493
			{
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   494
			print "$rofsbuilder $image returned $?\n";
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   495
			$rerrors++;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   496
			}
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   497
		rename "rofsbuild.log", "rofs$i.log"
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   498
		}
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   499
}
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   500
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   501
if ($rofs and $extension) {
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   502
	for(my $i=0;$i<$extension;++$i) {
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   503
		print "Executing $rofsbuilder on extension rofs\n" if !$quiet;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   504
		my $image="extension".$i.".oby";
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   505
		system("$rofsbuilder $image");
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   506
		if ($? != 0)
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   507
			{
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   508
			print "$rofsbuilder $image returned $?\n";
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   509
			$rerrors++;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   510
			}
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   511
		rename "rofsbuild.log", "extension$i.log"
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   512
		}
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   513
}
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   514
224
da1922ac85fb Pull rom.pl updates into rom_sbs.pl. to complete the fix for bug 3358
William Roberts <williamr@symbian.org>
parents: 217
diff changeset
   515
if ($smr) {
da1922ac85fb Pull rom.pl updates into rom_sbs.pl. to complete the fix for bug 3358
William Roberts <williamr@symbian.org>
parents: 217
diff changeset
   516
	$rofsbuilder = $opts{'rofsbuilder'};
da1922ac85fb Pull rom.pl updates into rom_sbs.pl. to complete the fix for bug 3358
William Roberts <williamr@symbian.org>
parents: 217
diff changeset
   517
	$rofsbuilder = "rofsbuild" unless ($rofsbuilder);
da1922ac85fb Pull rom.pl updates into rom_sbs.pl. to complete the fix for bug 3358
William Roberts <williamr@symbian.org>
parents: 217
diff changeset
   518
	for(my $i=0;$i<$smr;++$i) {
da1922ac85fb Pull rom.pl updates into rom_sbs.pl. to complete the fix for bug 3358
William Roberts <williamr@symbian.org>
parents: 217
diff changeset
   519
		print "Executing $rofsbuilder on smr partition\n" if !$quiet;
da1922ac85fb Pull rom.pl updates into rom_sbs.pl. to complete the fix for bug 3358
William Roberts <williamr@symbian.org>
parents: 217
diff changeset
   520
		my $image="smr".$i.".oby";
da1922ac85fb Pull rom.pl updates into rom_sbs.pl. to complete the fix for bug 3358
William Roberts <williamr@symbian.org>
parents: 217
diff changeset
   521
		system("$rofsbuilder -smr=$image");
da1922ac85fb Pull rom.pl updates into rom_sbs.pl. to complete the fix for bug 3358
William Roberts <williamr@symbian.org>
parents: 217
diff changeset
   522
		if ($? != 0)
da1922ac85fb Pull rom.pl updates into rom_sbs.pl. to complete the fix for bug 3358
William Roberts <williamr@symbian.org>
parents: 217
diff changeset
   523
			{
da1922ac85fb Pull rom.pl updates into rom_sbs.pl. to complete the fix for bug 3358
William Roberts <williamr@symbian.org>
parents: 217
diff changeset
   524
			print "$rofsbuilder -smr=$image returned $?\n";
da1922ac85fb Pull rom.pl updates into rom_sbs.pl. to complete the fix for bug 3358
William Roberts <williamr@symbian.org>
parents: 217
diff changeset
   525
			$rerrors++;
da1922ac85fb Pull rom.pl updates into rom_sbs.pl. to complete the fix for bug 3358
William Roberts <williamr@symbian.org>
parents: 217
diff changeset
   526
			}
da1922ac85fb Pull rom.pl updates into rom_sbs.pl. to complete the fix for bug 3358
William Roberts <williamr@symbian.org>
parents: 217
diff changeset
   527
		rename "rofsbuild.log", "smr$i.log"
da1922ac85fb Pull rom.pl updates into rom_sbs.pl. to complete the fix for bug 3358
William Roberts <williamr@symbian.org>
parents: 217
diff changeset
   528
		}
da1922ac85fb Pull rom.pl updates into rom_sbs.pl. to complete the fix for bug 3358
William Roberts <williamr@symbian.org>
parents: 217
diff changeset
   529
}
da1922ac85fb Pull rom.pl updates into rom_sbs.pl. to complete the fix for bug 3358
William Roberts <williamr@symbian.org>
parents: 217
diff changeset
   530
214
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   531
if ($nerrors) {
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   532
	print "\n\n Errors found during $builder!!\n\nLeaving tmp files\n";
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   533
} elsif ($nwarnings) {
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   534
	print "\n\n Warnings during $builder!!\n\nLeaving tmp files\n";
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   535
} elsif ($rerrors) {
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   536
	print "\n\n Errors during $rofsbuilder!!\n\nLeaving tmp files\n";
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   537
} else {
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   538
	unlink glob("*.tmp") if !$debug;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   539
}
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   540
if ($opts{zip} or $zip{$opts{assp}}) {
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   541
	my $zipname=$romname;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   542
	$zipname =~ s/\.(\w+)$/\.zip/i;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   543
	unlink $zipname;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   544
	system("zip $zipname $romname");
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   545
}
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   546
if ($opts{symbol}) {
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   547
	my $logname=$romname;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   548
	$logname =~ s/\.(\w+)$/\.log/i;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   549
	my $obyname=$romname;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   550
	$obyname =~ s/\.(\w+)$/\.oby/i;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   551
	unlink $logname;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   552
	unlink $obyname;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   553
	system("rename rombuild.log $logname");
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   554
	system("rename rom.oby $obyname");
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   555
	system("maksym $logname");
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   556
}
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   557
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   558
if ($nerrors || $nwarnings || $rerrors) {
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   559
	exit 4;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   560
}	
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   561
	
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   562
exit 0;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   563
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   564
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   565
################################ Subroutines  ##################################
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   566
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   567
sub usage {
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   568
	print <<EOT;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   569
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   570
rom <options>
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   571
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   572
Generate a rom image for the specified target, along with a rom.oby file
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   573
that can be fed to (a) rombuild to regenerate the image.
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   574
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   575
The following options are required:
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   576
  --variant=<variant>         e.g. --variant=assabet
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   577
  --inst=<instruction set>    e.g. --inst=arm4
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   578
  --build=<build>             e.g. --build=udeb
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   579
  --type=<type of rom>  
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   580
         tshell for a text shell rom
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   581
         e32tests for a rom with e32tests
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   582
         f32tests for rom with f32tests
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   583
         alltests for all the tests
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   584
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   585
The following are optional:
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   586
  --name=<image name>               Give image file specified name
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   587
  --noheader                        Pass -no-header option on to rombuild
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   588
  --help                            This help message.
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   589
  --clean                           Remove existing generated files first
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   590
  --quiet                           Be less verbose
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   591
  --modules=<comma separated list>  List of additional modules for this ROM
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   592
  --define=<comma separated list>   List of CPP macros to define
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   593
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   594
Options may be specified as a short abbreviation 
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   595
e.g. -b udeb instead of --build udeb
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   596
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   597
EOT
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   598
}
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   599
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   600
sub cleanup($$$) {
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   601
	my ($in, $out, $k) = @_;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   602
	my ($line, $lastblank);
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   603
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   604
	open(OUTPUT_FILE, "> $out") or die "Cannot open $out for output";
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   605
	open(INPUT_FILE, "< $in") or die "Cannot open for $in input";
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   606
  
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   607
	while ($line=<INPUT_FILE>) {
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   608
		$line=~s/##//g;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   609
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   610
		# file=\epoc32\...  ==> file=%EPOCROOT%\epoc32\...
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   611
		$line =~ s/(=\s*)\\epoc32/\1${EpocRoot}Epoc32/i;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   612
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   613
		# Now compress blank lines down to one
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   614
	
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   615
		if($line=~/^\s*$/) {
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   616
			if($lastblank) {
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   617
				# Do nothing
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   618
			} else {
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   619
				# This is the first blank line
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   620
				$lastblank=1;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   621
				print OUTPUT_FILE $line;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   622
			}
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   623
		} else {
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   624
			# Not blank
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   625
			$lastblank=0;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   626
			if ($k and $line=~/^\s*kerneltrace/i) {
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   627
				$line = "kerneltrace $k\n";
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   628
			}
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   629
			print OUTPUT_FILE $line if !($line=~/^\s*REM\s+/i);
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   630
		}
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   631
	}
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   632
	close(INPUT_FILE);
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   633
	close(OUTPUT_FILE);
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   634
}
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   635
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   636
sub IsSmp($) {
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   637
	my %SmpKernelDirs=(
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   638
		'x86smp' => 1,
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   639
		'x86gmp' => 1,
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   640
		'arm4smp' => 1,
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   641
		'armv4smp' => 1,
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   642
		'armv5smp' => 1
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   643
	);
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   644
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   645
	my ($kdir) = @_;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   646
	return $SmpKernelDirs{lc $kdir};
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   647
}
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   648
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   649
sub checkopts {
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   650
	unless($opts{variant}) { die "No Variant specified"; }
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   651
	$opts{'build'}="UDEB" unless($opts{'build'});
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   652
	$opts{'type'}="TSHELL" unless($opts{'type'});
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   653
	$opts{'inst'}="ARM4" unless($opts{'inst'});
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   654
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   655
	my $additional;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   656
	if ($opts{'modules'}) {
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   657
		$additional="_".$opts{modules};
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   658
		$additional=~ s/,/_/ig;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   659
	}
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   660
	my $build=lc $opts{build};
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   661
	my $inst=uc $opts{'inst'};
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   662
	if ($inst eq "MARM") {
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   663
		# Hackery to cope with old compiler
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   664
		$main="MARM";
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   665
		$euserdir="MARM";
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   666
		$elocldir="MARM";
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   667
	}
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   668
	else {
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   669
		$main=$inst;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   670
		if ($main eq "THUMB") {
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   671
			$euserdir="ARMI";
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   672
		} else {
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   673
			$euserdir=$main;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   674
		}
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   675
		if ($main eq "ARMI" or $main eq "THUMB") {
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   676
			$elocldir="ARM4";
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   677
		} else {
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   678
			$elocldir=$main;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   679
		}
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   680
	}
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   681
	$kmain = $opts{'xabi'};
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   682
	$kmain = $main unless ($kmain);
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   683
	if (IsSmp($kmain)) {
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   684
		$euserdir = $kmain;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   685
	}
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   686
	if ($opts{name}) {
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   687
		$romname=$opts{name};
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   688
	} else {
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   689
		$romname=uc($opts{variant}.$additional.$main);
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   690
		if ($build=~/^\w*DEB$/i) {
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   691
			$romname.='D';
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   692
		}
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   693
		$romname.='.IMG';
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   694
	}
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   695
}
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   696
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   697
sub lookupFileInfo($$)
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   698
{
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   699
	my ($infile, $fullname) = @_;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   700
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   701
	my ($name, $ext) = $fullname =~ /^(.+)\.(\w+)$/ ? ($1, $2) : ($fullname, undef);
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   702
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   703
	open TMP, $infile or die("Can't open $infile\n");
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   704
	while(<TMP>)
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   705
	{
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   706
		$_ = lc;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   707
		if(/^\s*(\S+)\s*=\s*(\S+)\s+(\S+)/i)
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   708
		{
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   709
			my ($src, $dest) = ($2, $3);
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   710
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   711
			my $destFullname = $dest =~ /^.*\\(.+)$/ ? $1 : $dest;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   712
			my ($destName, $destExt) = $destFullname =~ /^(.+?)\.(\w+)$/ ? ($1, $2) : ($destFullname, undef);
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   713
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   714
			if ($destName eq $name && (!$ext || $ext eq $destExt))
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   715
			{
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   716
				close TMP;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   717
				return ($src, $dest);
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   718
			}
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   719
		}
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   720
	}
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   721
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   722
	die "patchdata: Can't find file $fullname\n";
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   723
}
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   724
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   725
sub lookupSymbolInfo($$)
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   726
{
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   727
	my ($file, $name) = @_;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   728
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   729
	open TMP, $file or die "Can't read $file\n";
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   730
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   731
	# ignore local symbols.
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   732
	while (<TMP>)
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   733
	{
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   734
		last if /Global Symbols|Linker script and memory map/;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   735
	}
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   736
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   737
  my @return_values = ();
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   738
  my $line;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   739
	while ($line = <TMP>)
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   740
	{
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   741
		next if (index($line, $name) < 0);		
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   742
		
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   743
		# RVCT 2.2
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   744
		# 
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   745
		#     KHeapMinCellSize  0x0004e38c  Data 4  mem.o(.constdata)
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   746
		#
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   747
		if ($line =~ /^\s*(\S+)\s+(\S+)\s+data\s+(\S+)/i)
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   748
		{
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   749
			my ($symbol, $addr, $size) = ($1, $2, $3);
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   750
			if ($symbol eq $name)
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   751
			{
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   752
				@return_values = ($addr, $size);
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   753
				last;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   754
			}
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   755
		}
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   756
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   757
		# This is a quick fix for RVCT 3.1, which uses the text "(EXPORTED)"
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   758
		# in the map file. Here is an example:
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   759
		#
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   760
		# KHeapMinCellSize (EXPORTED) 0x0003d81c Data 4 mem.o(.constdata)
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   761
		#
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   762
		elsif ($line =~ /^\s*(\S+)\s+\(exported\)\s+(\S+)\s+data\s+(\S+)/i)
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   763
		{
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   764
			my ($symbol, $addr, $size) = ($1, $2, $3);
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   765
			if ($symbol eq $name)
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   766
			{
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   767
				@return_values = ($addr, $size);
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   768
				last;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   769
			}
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   770
		}
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   771
		
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   772
		# GCC 4.x map files
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   773
		#                 0x00114c68                KHeapMinCellSize
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   774
		#                 0x00114c6c                KHeapShrinkHysRatio
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   775
		#  .rodata        0x00115130      0x968 M:/epoc32/build/kernel/c_99481fddbd6c6f58/_omap3530_ekern_exe/armv5/udeb/heap_hybrid.o
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   776
		#
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   777
		elsif ($line =~ /^.+\s+(0x\S+)\s+(\S+)/i)
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   778
		{
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   779
			my ($addr, $symbol) = ($1, $2);
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   780
			if ($symbol eq $name)
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   781
			{
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   782
				my $next_line = <TMP>;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   783
				if ($next_line =~ /^.+\s+(0x\S+)\s+(\S+)/i)
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   784
				{
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   785
					my $addr2 = $1;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   786
					
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   787
					@return_values = ($addr, hex($addr2) - hex($addr));
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   788
					last;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   789
				}
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   790
			}
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   791
		}
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   792
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   793
	}
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   794
	close TMP;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   795
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   796
	die "patchdata: Can't find symbol $name\n" if (scalar @return_values == 0);
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   797
	return @return_values;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   798
}
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   799
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   800
sub parsePatchData($$)
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   801
{
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   802
	my ($infile, $outfile) = @_;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   803
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   804
	open IN, $infile or die("Can't read $infile\n");
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   805
	open OUT, ">$outfile" or die("Can't write $outfile\n");
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   806
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   807
	my $line;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   808
	while($line = <IN>)
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   809
	{
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   810
		if ($line =~ /^\s*patchdata\s+(.+?)\s*$/i)
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   811
		{
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   812
			if ($1 !~ /(\S+)\s*@\s*(\S+)\s+(\S+)\s*$/)
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   813
			{
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   814
				die "Bad patchdata command: $line\n";
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   815
			}
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   816
224
da1922ac85fb Pull rom.pl updates into rom_sbs.pl. to complete the fix for bug 3358
William Roberts <williamr@symbian.org>
parents: 217
diff changeset
   817
			print "Handling $line\n" if $debug;
da1922ac85fb Pull rom.pl updates into rom_sbs.pl. to complete the fix for bug 3358
William Roberts <williamr@symbian.org>
parents: 217
diff changeset
   818
214
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   819
			my ($file, $symbol, $value) = (lc $1, $2, $3);
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   820
			my ($srcFile, $destFile) = lookupFileInfo($infile, $file);
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   821
			my ($index, $elementSize) = (undef, undef);
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   822
			if ($symbol =~ s/:(\d+)\[(\d+)\]$//)
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   823
			{
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   824
				($index, $elementSize) = ($2, $1);
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   825
				$index = hex($index) if $index =~ /^0x/i;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   826
			}
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   827
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   828
			if ($srcFile =~ /\\armv5(smp)?\\/i)
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   829
			{
224
da1922ac85fb Pull rom.pl updates into rom_sbs.pl. to complete the fix for bug 3358
William Roberts <williamr@symbian.org>
parents: 217
diff changeset
   830
				print "..looking up $symbol in $srcFile.map\n" if $debug;
214
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   831
				my ($symbolAddr, $symbolSize) = lookupSymbolInfo("$srcFile.map", $symbol);
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   832
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   833
				my $max;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   834
				if (defined($index))
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   835
				{
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   836
					my $bytes;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   837
					$bytes = 1, $max = 0xff       if $elementSize ==  8;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   838
					$bytes = 2, $max = 0xffff     if $elementSize == 16;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   839
					$bytes = 4, $max = 0xffffffff if $elementSize == 32;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   840
					die("patchdata: invalid element size $elementSize: $line\n") unless defined($bytes);
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   841
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   842
					if ($bytes > 1 && (($symbolSize & ($bytes-1)) != 0))
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   843
					{
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   844
						die("patchdata: unexpected symbol size $symbolSize for array $symbol ($elementSize-bit elements)\n");
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   845
					}
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   846
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   847
					if ($index >= int($symbolSize / $bytes))
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   848
					{
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   849
						die("patchdata: index $index out of bounds for $symbol of $symbolSize bytes ($elementSize-bit elements)\n");
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   850
					}
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   851
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   852
					$symbolAddr = hex($symbolAddr) if $symbolAddr =~ /^0x/i;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   853
					$symbolAddr += $index * $bytes;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   854
					$symbolAddr = sprintf("0x%x", $symbolAddr);
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   855
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   856
					$symbolSize = $bytes;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   857
				}
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   858
				elsif ($symbolSize == 1) { $max = 0xff; }
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   859
				elsif ($symbolSize == 2) { $max = 0xffff; }
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   860
				elsif ($symbolSize == 4) { $max = 0xffffffff; }
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   861
				else { die "patchdata: Unexpected symbol size $symbolSize for $symbol\n"; }
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   862
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   863
				$value = hex($value) if $value =~ /^0x/i;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   864
				if ($value > $max)
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   865
				{
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   866
					print("Warning:  Value overflow of $symbol\n");
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   867
					$value &= $max;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   868
				}					
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   869
				$value = sprintf("0x%08x", $value);
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   870
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   871
				$line = "patchdata $destFile addr $symbolAddr $symbolSize $value\n";
224
da1922ac85fb Pull rom.pl updates into rom_sbs.pl. to complete the fix for bug 3358
William Roberts <williamr@symbian.org>
parents: 217
diff changeset
   872
				print ".. new line is $line\n" if $debug;
214
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   873
			}
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   874
			else
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   875
			{
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   876
				$line = "";
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   877
			}
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   878
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   879
		}
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   880
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   881
		print OUT $line;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   882
	}
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   883
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   884
	close IN;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   885
	close OUT;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   886
}
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   887
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   888
sub genfile {
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   889
	my $count=0;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   890
	if($_[0] eq 'paged') {
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   891
		my $file='gentestpaged.txt';
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   892
		unlink $file;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   893
		open(OUTFILE, ">$file") or die "Can't open output file, $!";
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   894
		for(my $i=0;$i<50000;++$i) {
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   895
			if(($i >5) && ($i % 40 ==0)) {
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   896
			print OUTFILE "\n";
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   897
			$count++;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   898
			} 
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   899
			if(($i+$count) % 5 ==0) {
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   900
			print OUTFILE "SATOR ";
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   901
			}
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   902
			if(($i+$count) % 5 ==1) {
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   903
			print OUTFILE "AREPO ";
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   904
			}
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   905
			if(($i+$count) % 5 ==2) {
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   906
			print OUTFILE "TENET ";
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   907
			}
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   908
			if(($i+$count) % 5 ==3) {
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   909
			print OUTFILE "OPERA ";
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   910
			}
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   911
			if(($i+$count) % 5 ==4) {
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   912
			print OUTFILE "ROTAS ";
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   913
			}
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   914
		}
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   915
	} else {
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   916
		my $file='gentestnonpaged.txt';
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   917
		unlink $file;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   918
		open(OUTFILE, ">$file") or die "Can't open output file, $!";
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   919
		for(my $i=0;$i<20000;++$i) {
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   920
			if(($i >5) && ($i % 40 ==0)) {
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   921
			print OUTFILE "\n";
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   922
			$count++;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   923
			} 
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   924
			if(($i+$count) % 4 ==0) {
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   925
			print OUTFILE "STEP ";
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   926
			}
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   927
			if(($i+$count) % 4 ==1) {
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   928
			print OUTFILE "TIME ";
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   929
			}
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   930
			if(($i+$count) % 4 ==2) {
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   931
			print OUTFILE "EMIT ";
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   932
			}
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   933
			if(($i+$count) % 4 ==3) {
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   934
			print OUTFILE "PETS ";
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   935
			}
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   936
		}
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   937
	}
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   938
}
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   939
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   940
__END__
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   941
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   942
# Tell emacs that this is a perl script even 'though it has a .bat extension
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   943
# Local Variables:
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   944
# mode:perl
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   945
# tab-width:4
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   946
# End:
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   947