kernel/eka/rombuild/rom_sbs.pl
author William Roberts <williamr@symbian.org>
Tue, 20 Jul 2010 09:59:06 +0100
changeset 214 aa7a21cbc82b
child 217 96e53742b989
permissions -rw-r--r--
Really supply rom.flm and friends (missed from previous commit)
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",
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    52
						 "compress",
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;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   123
	$e32path =~ s/\\kernelhwsrv\\kernel\\eka\\rombuild\\rom\.pl$//i;
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;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   131
	$BasePath = $toroot . $e32path;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   132
}
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
use E32Plat;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   135
{
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   136
        Plat_Init($toolpath);
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   137
}
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
if ($debug) {
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   140
	print "EpocRoot = $EpocRoot\n";
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   141
	print "Epoc32Path = $Epoc32Path\n";
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   142
	print "drive = $drive\n";
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   143
	print "toolpath = $toolpath\n";
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   144
	print "toroot = $toroot\n";
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   145
	print "e32path = $e32path\n";
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   146
	print "rombuildpath = $rombuildpath\n";
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   147
	print "BasePath = $BasePath\n";
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   148
}
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
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
   151
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   152
# 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
   153
# (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
   154
# 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
   155
use E32Variant;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   156
use Pathutl;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   157
my $variantMacroHRHFile = Variant_GetMacroHRHFile();
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   158
if($variantMacroHRHFile){
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   159
	# 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
   160
	# 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
   161
	# case it includes files
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   162
	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
   163
	$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
   164
}
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
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
   167
	usage();
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   168
	exit 0;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   169
}
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
# 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
   172
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   173
checkopts();
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   174
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   175
if (!$quiet) {
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   176
	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
   177
	print <<EOF;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   178
OPTIONS:
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   179
\tTYPE: $opts{'type'}
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   180
\tVARIANT: $opts{'variant'}
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   181
\tINSTRUCTION SET: $opts{'inst'}
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   182
\tBUILD: $opts{'build'}
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   183
\tMODULES: $opts{'modules'}
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   184
EOF
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   185
}
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
#Pick out the type file
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   188
my $skel;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   189
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   190
if (-e "$opts{'type'}.oby") {
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   191
	$skel="$opts{'type'}.oby";
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   192
} 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
   193
	$skel="$rombuildpath\\$opts{'type'}.oby";
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   194
} else {
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   195
	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
   196
}
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
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
   199
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   200
# 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
   201
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   202
if($opts{'clean'}) {
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   203
	unlink glob("*.img");
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   204
	unlink "rom.oby";
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   205
	unlink "rombuild.log";
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   206
	unlink glob("*.rofs");
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   207
	unlink "rofsbuild.log";
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   208
}
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
# 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
   211
# 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
   212
# 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
   213
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   214
my $k = $opts{kerneltrace};
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   215
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   216
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
   217
	$kbdir="kb$1";
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   218
	$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
   219
} else {
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   220
	$kbdir="kb$opts{assp}";
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   221
}
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   222
$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
   223
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   224
if ($single) {
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   225
	# 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
   226
	if ($main eq 'MARM') {
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   227
		$smain='SARM';
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   228
	} else {
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   229
		$smain="S$main";
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   230
	}
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   231
} else {
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   232
	$smain=$main;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   233
}
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
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
   236
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
   237
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   238
# First output the ROM name
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   239
print OUT "\nromname=$romname\n";
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   240
while(<X>) {
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   241
	s/\#\#ASSP\#\#/$opts{'assp'}/;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   242
	s/\#\#VARIANT\#\#/$opts{'variant'}/;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   243
	s/\#\#BUILD\#\#/$opts{'build'}/;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   244
	s/\#\#MAIN\#\#/$main/;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   245
	s/\#\#KMAIN\#\#/$kmain/;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   246
	s/\#\#E32PATH\#\#/$e32path/;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   247
	s/\#\#BASEPATH\#\#/$BasePath/;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   248
	s/\#\#EUSERDIR\#\#/$euserdir/;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   249
	s/\#\#ELOCLDIR\#\#/$elocldir/;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   250
	s/\#\#KBDIR\#\#/$kbdir/;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   251
	print OUT;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   252
}
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
close X;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   255
close OUT;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   256
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   257
# 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
   258
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   259
my $defines = "";
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   260
$defines .= "-D MAIN=$main ";
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   261
$defines .= "-D KMAIN=$kmain ";
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   262
$defines .= "-D EUSERDIR=$euserdir ";
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   263
$defines .= "-D ELOCLDIR=$elocldir ";
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   264
$defines .= "-D E32PATH=$e32path ";
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   265
$defines .= "-D BASEPATH=$BasePath ";
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   266
$defines .= "-D EPOCROOT=$EpocRoot ";
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   267
$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
   268
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   269
foreach (@{$opts{'define'}}) {
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   270
	my @array=split(/,/,$_);
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   271
	foreach (@array) {
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   272
		$defines.="-D ".uc $_." ";
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   273
		$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
   274
		}
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
if ($opts{'modules'}) {
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   278
	my @array=split(/,/,$opts{'modules'});
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   279
	foreach (@array) {
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   280
		$defines.="-D ".uc $_." ";
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   281
		}
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
foreach (keys %opts) {
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   285
	next if ($_ eq 'name');
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   286
	next if ($_ eq 'modules');
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   287
	next if ($_ eq 'zip');
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   288
	next if ($_ eq 'symbol');
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   289
	next if ($_ eq 'kerneltrace');
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   290
	next if ($_ eq 'define');
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   291
	$defines.="-D ".uc $_."=".$opts{$_}." ";
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
}
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
$defines.="-D SINGLE " if ($single);
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   296
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   297
sub IsRVCTBuild($) {
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   298
    my ($build)=@_;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   299
    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
   300
	my @customizations = Plat_Customizations('ARMV5');
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   301
	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
   302
	return 0;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   303
}
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
$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
   306
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   307
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
   308
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   309
my $ret=1;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   310
my $cppcmd;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   311
if($opts{'build'}=~/^u/i) {
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   312
	# Unicode build
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   313
	$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
   314
} else {
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   315
	$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
   316
}
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   317
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
   318
$ret = system($cppcmd);
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   319
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
   320
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   321
# 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
   322
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   323
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
   324
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   325
# 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
   326
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
   327
my $line;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   328
while ($line=<TMP>)
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   329
	{
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   330
	if ($line=~/\s*gentestpaged/i) {
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   331
		genfile("paged");	}
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   332
	if ($line=~/\s*gentestnonpaged/i) {
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   333
		genfile("nonpaged");	}
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   334
	}
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   335
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   336
parsePatchData("rom3.tmp", "rom4.tmp");
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   337
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   338
# 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
   339
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   340
my $oby_index =0;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   341
my $dumpfile="rom.oby";
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   342
my $rofs=0;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   343
my $extension=0;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   344
my $corerofsname="";
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   345
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
   346
my $line;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   347
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
   348
while ($line=<TMP>)
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   349
	{
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   350
	if ($line=~/^\s*rofsname/i)
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   351
		{
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   352
		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
   353
		$oby_index=1;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   354
		$corerofsname=$line;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   355
		$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
   356
		$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
   357
		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
   358
		my $dumpfile="rofs".$rofs.".oby";
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   359
		$rofs++;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   360
		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
   361
		}
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   362
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   363
	if ($line=~/^\s*coreimage/i)
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   364
		{
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   365
		close DUMPFILE;							# close rofs.oby
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   366
		if ($oby_index ne 1) {
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   367
			close TMP;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   368
			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
   369
		}
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   370
		my $name=$line;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   371
		$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
   372
		$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
   373
		if ($name ne $corerofsname) {
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   374
			close TMP;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   375
			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
   376
		}
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   377
		$oby_index=33;						# open window
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   378
		my $dumpfile="extension".$extension.".oby";
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   379
		$extension++;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   380
		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
   381
		}
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   382
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   383
	if ($line=~/^\s*extensionrofs/i)
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   384
		{
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   385
		$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
   386
		}
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   387
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   388
	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
   389
		close TMP;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   390
		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
   391
	}
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   392
	print DUMPFILE $line;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   393
	$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
   394
	}
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   395
close DUMPFILE;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   396
close TMP;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   397
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   398
# 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
   399
# is automatically put into rofs
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   400
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
   401
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   402
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
   403
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
   404
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   405
if ($oby_index >= 1 && $pagedCode)	{
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   406
	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
   407
}
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
while ($line=<IN>)
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   410
{
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   411
	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
   412
		print ROFS $line;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   413
	}
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   414
	else {
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   415
		$line=~s/paging_unmovable//;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   416
		print ROM $line;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   417
	}
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
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   420
close IN;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   421
close ROM;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   422
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   423
if ($oby_index >= 1 && $pagedCode)	{
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   424
	close ROFS;
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
	unlink 'rom4.tmp';
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
my $flags;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   429
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   430
foreach (@{$flags{$opts{'assp'}}}) {
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   431
	$flags.=" -$_";
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   432
}
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   433
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   434
if($opts{'noheader'}) {
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   435
	$flags.=" -no-header";
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
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   438
if($opts{'compress'}) {
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   439
	$flags.=" -compress";
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   440
}
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   441
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   442
my $builder = $opts{'rombuilder'};
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   443
$builder = "rombuild" unless ($builder);
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
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
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
   448
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   449
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
   450
	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
   451
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   452
my $nerrors=0;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   453
my $nwarnings=0;
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
while(<Y>) {
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   456
	my $error=(/^error:/i);
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   457
	my $warning=(/^warning:/i);
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   458
	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
   459
	$nerrors++ if ($error);
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   460
	$nwarnings++ if ($warning);
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
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
   464
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
   465
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   466
my$rerrors;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   467
my $rofsbuilder;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   468
if ($rofs) {
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   469
	$rofsbuilder = $opts{'rofsbuilder'};
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   470
	$rofsbuilder = "rofsbuild" unless ($rofsbuilder);
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   471
	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
   472
		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
   473
		my $image="rofs".$i.".oby";
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   474
		system("$rofsbuilder $image");
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   475
		if ($? != 0)
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   476
			{
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   477
			print "$rofsbuilder $image returned $?\n";
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   478
			$rerrors++;
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
		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
   481
		}
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
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   484
if ($rofs and $extension) {
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   485
	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
   486
		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
   487
		my $image="extension".$i.".oby";
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   488
		system("$rofsbuilder $image");
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   489
		if ($? != 0)
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   490
			{
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   491
			print "$rofsbuilder $image returned $?\n";
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   492
			$rerrors++;
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
		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
   495
		}
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
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   498
if ($nerrors) {
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   499
	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
   500
} elsif ($nwarnings) {
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   501
	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
   502
} elsif ($rerrors) {
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   503
	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
   504
} else {
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   505
	unlink glob("*.tmp") if !$debug;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   506
}
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   507
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
   508
	my $zipname=$romname;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   509
	$zipname =~ s/\.(\w+)$/\.zip/i;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   510
	unlink $zipname;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   511
	system("zip $zipname $romname");
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
if ($opts{symbol}) {
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   514
	my $logname=$romname;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   515
	$logname =~ s/\.(\w+)$/\.log/i;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   516
	my $obyname=$romname;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   517
	$obyname =~ s/\.(\w+)$/\.oby/i;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   518
	unlink $logname;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   519
	unlink $obyname;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   520
	system("rename rombuild.log $logname");
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   521
	system("rename rom.oby $obyname");
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   522
	system("maksym $logname");
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   523
}
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   524
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   525
if ($nerrors || $nwarnings || $rerrors) {
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   526
	exit 4;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   527
}	
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   528
	
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   529
exit 0;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   530
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   531
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   532
################################ Subroutines  ##################################
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   533
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   534
sub usage {
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   535
	print <<EOT;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   536
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   537
rom <options>
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   538
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   539
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
   540
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
   541
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   542
The following options are required:
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   543
  --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
   544
  --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
   545
  --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
   546
  --type=<type of rom>  
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   547
         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
   548
         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
   549
         f32tests for rom with f32tests
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   550
         alltests for all the tests
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   551
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   552
The following are optional:
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   553
  --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
   554
  --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
   555
  --help                            This help message.
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   556
  --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
   557
  --quiet                           Be less verbose
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   558
  --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
   559
  --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
   560
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   561
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
   562
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
   563
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   564
EOT
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   565
}
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 cleanup($$$) {
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   568
	my ($in, $out, $k) = @_;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   569
	my ($line, $lastblank);
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   570
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   571
	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
   572
	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
   573
  
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   574
	while ($line=<INPUT_FILE>) {
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   575
		$line=~s/##//g;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   576
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   577
		# file=\epoc32\...  ==> file=%EPOCROOT%\epoc32\...
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   578
		$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
   579
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   580
		# 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
   581
	
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   582
		if($line=~/^\s*$/) {
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   583
			if($lastblank) {
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   584
				# Do nothing
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   585
			} else {
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   586
				# 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
   587
				$lastblank=1;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   588
				print OUTPUT_FILE $line;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   589
			}
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   590
		} else {
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   591
			# Not blank
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   592
			$lastblank=0;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   593
			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
   594
				$line = "kerneltrace $k\n";
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   595
			}
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   596
			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
   597
		}
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
	close(INPUT_FILE);
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   600
	close(OUTPUT_FILE);
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   601
}
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   602
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   603
sub IsSmp($) {
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   604
	my %SmpKernelDirs=(
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   605
		'x86smp' => 1,
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   606
		'x86gmp' => 1,
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   607
		'arm4smp' => 1,
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   608
		'armv4smp' => 1,
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   609
		'armv5smp' => 1
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   610
	);
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   611
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   612
	my ($kdir) = @_;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   613
	return $SmpKernelDirs{lc $kdir};
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
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   616
sub checkopts {
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   617
	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
   618
	$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
   619
	$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
   620
	$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
   621
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   622
	my $additional;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   623
	if ($opts{'modules'}) {
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   624
		$additional="_".$opts{modules};
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   625
		$additional=~ s/,/_/ig;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   626
	}
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   627
	my $build=lc $opts{build};
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   628
	my $inst=uc $opts{'inst'};
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   629
	if ($inst eq "MARM") {
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   630
		# 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
   631
		$main="MARM";
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   632
		$euserdir="MARM";
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   633
		$elocldir="MARM";
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
	else {
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   636
		$main=$inst;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   637
		if ($main eq "THUMB") {
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   638
			$euserdir="ARMI";
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   639
		} else {
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   640
			$euserdir=$main;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   641
		}
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   642
		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
   643
			$elocldir="ARM4";
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   644
		} else {
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   645
			$elocldir=$main;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   646
		}
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
	$kmain = $opts{'xabi'};
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   649
	$kmain = $main unless ($kmain);
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   650
	if (IsSmp($kmain)) {
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   651
		$euserdir = $kmain;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   652
	}
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   653
	if ($opts{name}) {
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   654
		$romname=$opts{name};
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   655
	} else {
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   656
		$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
   657
		if ($build=~/^\w*DEB$/i) {
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   658
			$romname.='D';
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
		$romname.='.IMG';
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   661
	}
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   662
}
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   663
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   664
sub lookupFileInfo($$)
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   665
{
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   666
	my ($infile, $fullname) = @_;
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
	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
   669
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   670
	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
   671
	while(<TMP>)
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   672
	{
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   673
		$_ = lc;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   674
		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
   675
		{
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   676
			my ($src, $dest) = ($2, $3);
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   677
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   678
			my $destFullname = $dest =~ /^.*\\(.+)$/ ? $1 : $dest;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   679
			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
   680
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   681
			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
   682
			{
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   683
				close TMP;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   684
				return ($src, $dest);
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
		}
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   687
	}
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   688
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   689
	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
   690
}
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   691
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   692
sub lookupSymbolInfo($$)
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   693
{
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   694
	my ($file, $name) = @_;
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
	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
   697
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   698
	# ignore local symbols.
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   699
	while (<TMP>)
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
		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
   702
	}
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   703
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   704
  my @return_values = ();
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   705
  my $line;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   706
	while ($line = <TMP>)
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   707
	{
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   708
		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
   709
		
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   710
		# RVCT 2.2
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   711
		# 
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   712
		#     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
   713
		#
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   714
		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
   715
		{
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   716
			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
   717
			if ($symbol eq $name)
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
				@return_values = ($addr, $size);
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   720
				last;
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
		}
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
		# 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
   725
		# 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
   726
		#
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   727
		# 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
   728
		#
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   729
		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
   730
		{
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   731
			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
   732
			if ($symbol eq $name)
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
				@return_values = ($addr, $size);
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   735
				last;
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
		}
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   738
		
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   739
		# GCC 4.x map files
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   740
		#                 0x00114c68                KHeapMinCellSize
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   741
		#                 0x00114c6c                KHeapShrinkHysRatio
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   742
		#  .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
   743
		#
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   744
		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
   745
		{
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   746
			my ($addr, $symbol) = ($1, $2);
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   747
			if ($symbol eq $name)
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 $next_line = <TMP>;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   750
				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
   751
				{
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   752
					my $addr2 = $1;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   753
					
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   754
					@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
   755
					last;
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
			}
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   758
		}
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
	}
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   761
	close TMP;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   762
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   763
	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
   764
	return @return_values;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   765
}
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
sub parsePatchData($$)
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   768
{
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   769
	my ($infile, $outfile) = @_;
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
	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
   772
	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
   773
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   774
	my $line;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   775
	while($line = <IN>)
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
		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
   778
		{
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   779
			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
   780
			{
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   781
				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
   782
			}
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   783
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   784
			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
   785
			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
   786
			my ($index, $elementSize) = (undef, undef);
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   787
			if ($symbol =~ s/:(\d+)\[(\d+)\]$//)
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   788
			{
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   789
				($index, $elementSize) = ($2, $1);
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   790
				$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
   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
			if ($srcFile =~ /\\armv5(smp)?\\/i)
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   794
			{
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   795
				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
   796
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   797
				my $max;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   798
				if (defined($index))
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
					my $bytes;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   801
					$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
   802
					$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
   803
					$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
   804
					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
   805
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   806
					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
   807
					{
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   808
						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
   809
					}
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   810
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   811
					if ($index >= int($symbolSize / $bytes))
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   812
					{
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   813
						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
   814
					}
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
					$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
   817
					$symbolAddr += $index * $bytes;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   818
					$symbolAddr = sprintf("0x%x", $symbolAddr);
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   819
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   820
					$symbolSize = $bytes;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   821
				}
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   822
				elsif ($symbolSize == 1) { $max = 0xff; }
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   823
				elsif ($symbolSize == 2) { $max = 0xffff; }
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   824
				elsif ($symbolSize == 4) { $max = 0xffffffff; }
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   825
				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
   826
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   827
				$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
   828
				if ($value > $max)
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   829
				{
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   830
					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
   831
					$value &= $max;
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
				$value = sprintf("0x%08x", $value);
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   834
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   835
				$line = "patchdata $destFile addr $symbolAddr $symbolSize $value\n";
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   836
			}
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   837
			else
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   838
			{
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   839
				$line = "";
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   840
			}
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
		}
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
		print OUT $line;
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
	close IN;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   848
	close OUT;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   849
}
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
sub genfile {
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   852
	my $count=0;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   853
	if($_[0] eq 'paged') {
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   854
		my $file='gentestpaged.txt';
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   855
		unlink $file;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   856
		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
   857
		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
   858
			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
   859
			print OUTFILE "\n";
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   860
			$count++;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   861
			} 
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   862
			if(($i+$count) % 5 ==0) {
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   863
			print OUTFILE "SATOR ";
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   864
			}
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   865
			if(($i+$count) % 5 ==1) {
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   866
			print OUTFILE "AREPO ";
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   867
			}
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   868
			if(($i+$count) % 5 ==2) {
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   869
			print OUTFILE "TENET ";
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
			if(($i+$count) % 5 ==3) {
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   872
			print OUTFILE "OPERA ";
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
			if(($i+$count) % 5 ==4) {
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   875
			print OUTFILE "ROTAS ";
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   876
			}
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
	} else {
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   879
		my $file='gentestnonpaged.txt';
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   880
		unlink $file;
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   881
		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
   882
		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
   883
			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
   884
			print OUTFILE "\n";
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   885
			$count++;
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
			if(($i+$count) % 4 ==0) {
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   888
			print OUTFILE "STEP ";
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   889
			}
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   890
			if(($i+$count) % 4 ==1) {
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   891
			print OUTFILE "TIME ";
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   892
			}
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   893
			if(($i+$count) % 4 ==2) {
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   894
			print OUTFILE "EMIT ";
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   895
			}
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   896
			if(($i+$count) % 4 ==3) {
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   897
			print OUTFILE "PETS ";
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
		}
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   900
	}
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
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   903
__END__
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
# 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
   906
# Local Variables:
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   907
# mode:perl
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   908
# tab-width:4
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   909
# End:
aa7a21cbc82b Really supply rom.flm and friends (missed from previous commit)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   910