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