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