kernel/eka/rombuild/rom_sbs.pl
author Arnaud Lenoir
Thu, 25 Mar 2010 15:00:34 +0000
branchRCL_3
changeset 86 8e4dfe27c581
parent 84 b379919d420f
child 106 2a153f39070a
permissions -rw-r--r--
Removed debug (print).
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
						 );
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
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
    56
my $main;
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
    57
my $kmain;
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
    58
my $toroot;
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
    59
my $e32path;
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
    60
my $rombuildpath;
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
    61
my $euserdir;
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
    62
my $elocldir;
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
    63
my $kbdir;
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
    64
my $romname;
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
    65
my $single;
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
    66
my $smain;
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
    67
my $pagedCode;
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
    68
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
    69
my $quiet;
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
    70
$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
    71
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
    72
my $drive;
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
    73
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
    74
# 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
    75
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
    76
my $toolpath;
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
    77
my $Epoc32Path;
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
    78
my $EpocRoot;
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
    79
my $drive;
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
    80
my $BasePath;
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
    81
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
    82
BEGIN {
7
0a6fb11f0655 Adjusted EPOCROOT handling so that in the context of Raptor invocation,
Simon Howkins <simonh@symbian.org>
parents: 5
diff changeset
    83
0a6fb11f0655 Adjusted EPOCROOT handling so that in the context of Raptor invocation,
Simon Howkins <simonh@symbian.org>
parents: 5
diff changeset
    84
	$EpocRoot = $ENV{EPOCROOT};
0a6fb11f0655 Adjusted EPOCROOT handling so that in the context of Raptor invocation,
Simon Howkins <simonh@symbian.org>
parents: 5
diff changeset
    85
	die "ERROR: Must set the EPOCROOT environment variable.\n" if (!defined($EpocRoot));
0a6fb11f0655 Adjusted EPOCROOT handling so that in the context of Raptor invocation,
Simon Howkins <simonh@symbian.org>
parents: 5
diff changeset
    86
	print "Environmental epocroot - >$EpocRoot<\n";
0a6fb11f0655 Adjusted EPOCROOT handling so that in the context of Raptor invocation,
Simon Howkins <simonh@symbian.org>
parents: 5
diff changeset
    87
	$EpocRoot =~ s-/-\\-go;	# for those working with UNIX shells
0a6fb11f0655 Adjusted EPOCROOT handling so that in the context of Raptor invocation,
Simon Howkins <simonh@symbian.org>
parents: 5
diff changeset
    88
	if ($EpocRoot =~ /^([a-z]:)(.*)$/i)
5
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
    89
	{
7
0a6fb11f0655 Adjusted EPOCROOT handling so that in the context of Raptor invocation,
Simon Howkins <simonh@symbian.org>
parents: 5
diff changeset
    90
		# Raptor style: Drive letter and trailing \\ removed
0a6fb11f0655 Adjusted EPOCROOT handling so that in the context of Raptor invocation,
Simon Howkins <simonh@symbian.org>
parents: 5
diff changeset
    91
		$drive = $1;
0a6fb11f0655 Adjusted EPOCROOT handling so that in the context of Raptor invocation,
Simon Howkins <simonh@symbian.org>
parents: 5
diff changeset
    92
		$EpocRoot = "$2\\";
0a6fb11f0655 Adjusted EPOCROOT handling so that in the context of Raptor invocation,
Simon Howkins <simonh@symbian.org>
parents: 5
diff changeset
    93
		$ENV{EPOCROOT} = $EpocRoot;
5
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
    94
	}
7
0a6fb11f0655 Adjusted EPOCROOT handling so that in the context of Raptor invocation,
Simon Howkins <simonh@symbian.org>
parents: 5
diff changeset
    95
	die "ERROR: EPOCROOT must be an absolute path, " .
0a6fb11f0655 Adjusted EPOCROOT handling so that in the context of Raptor invocation,
Simon Howkins <simonh@symbian.org>
parents: 5
diff changeset
    96
		"not containing a drive letter.\n" if ($EpocRoot !~ /^\\/);
0a6fb11f0655 Adjusted EPOCROOT handling so that in the context of Raptor invocation,
Simon Howkins <simonh@symbian.org>
parents: 5
diff changeset
    97
	die "ERROR: EPOCROOT must not be a UNC path.\n" if ($EpocRoot =~ /^\\\\/);
0a6fb11f0655 Adjusted EPOCROOT handling so that in the context of Raptor invocation,
Simon Howkins <simonh@symbian.org>
parents: 5
diff changeset
    98
	die "ERROR: EPOCROOT must end with a backslash.\n" if ($EpocRoot !~ /\\$/);
0a6fb11f0655 Adjusted EPOCROOT handling so that in the context of Raptor invocation,
Simon Howkins <simonh@symbian.org>
parents: 5
diff changeset
    99
	die "ERROR: EPOCROOT must specify an existing directory.\n" if (!-d $EpocRoot);
0a6fb11f0655 Adjusted EPOCROOT handling so that in the context of Raptor invocation,
Simon Howkins <simonh@symbian.org>
parents: 5
diff changeset
   100
0a6fb11f0655 Adjusted EPOCROOT handling so that in the context of Raptor invocation,
Simon Howkins <simonh@symbian.org>
parents: 5
diff changeset
   101
	# The cpp needed a drive apparently
0a6fb11f0655 Adjusted EPOCROOT handling so that in the context of Raptor invocation,
Simon Howkins <simonh@symbian.org>
parents: 5
diff changeset
   102
	my $cwd = Cwd::cwd();
0a6fb11f0655 Adjusted EPOCROOT handling so that in the context of Raptor invocation,
Simon Howkins <simonh@symbian.org>
parents: 5
diff changeset
   103
	$cwd =~ /^(.)/;
0a6fb11f0655 Adjusted EPOCROOT handling so that in the context of Raptor invocation,
Simon Howkins <simonh@symbian.org>
parents: 5
diff changeset
   104
	$drive = "$1:" unless $drive;
0a6fb11f0655 Adjusted EPOCROOT handling so that in the context of Raptor invocation,
Simon Howkins <simonh@symbian.org>
parents: 5
diff changeset
   105
	print "epocroot = >$EpocRoot<\n";
0a6fb11f0655 Adjusted EPOCROOT handling so that in the context of Raptor invocation,
Simon Howkins <simonh@symbian.org>
parents: 5
diff changeset
   106
	print "drive = >$drive<\n";
0a6fb11f0655 Adjusted EPOCROOT handling so that in the context of Raptor invocation,
Simon Howkins <simonh@symbian.org>
parents: 5
diff changeset
   107
5
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   108
	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
   109
	$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
   110
	$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
   111
	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
   112
		if ($cwd =~ /\\$/) {
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   113
			$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
   114
		} else {
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   115
			$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
   116
		}
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   117
	}
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   118
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   119
	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
   120
	shift(@path);
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   121
	$toroot = ('..\\') x @path;
84
b379919d420f Modify the script to solve problem with e32path and change all / to \ to allow to build rom image without any errors!!
Arnaud Lenoir
parents: 79
diff changeset
   122
	$toroot =~ s/\\$//;
b379919d420f Modify the script to solve problem with e32path and change all / to \ to allow to build rom image without any errors!!
Arnaud Lenoir
parents: 79
diff changeset
   123
	#e32path supposed to be = to "\sf\os"
5
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   124
	$e32path = $fp0;
84
b379919d420f Modify the script to solve problem with e32path and change all / to \ to allow to build rom image without any errors!!
Arnaud Lenoir
parents: 79
diff changeset
   125
	$e32path =~ s/\\kernelhwsrv\\kernel\\eka\\rombuild\\rom_sbs\.pl$//i;
5
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   126
	$e32path =~ s/^[A-Za-z]://;
84
b379919d420f Modify the script to solve problem with e32path and change all / to \ to allow to build rom image without any errors!!
Arnaud Lenoir
parents: 79
diff changeset
   127
	$rombuildpath = $toroot."\\sf\\os\\kernelhwsrv\\kernel\\eka\\rombuild";
5
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   128
	$Epoc32Path = $toroot;
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   129
	$Epoc32Path =~ s/\\$//;
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   130
	$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
   131
	$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
   132
	push @INC, $toolpath;
84
b379919d420f Modify the script to solve problem with e32path and change all / to \ to allow to build rom image without any errors!!
Arnaud Lenoir
parents: 79
diff changeset
   133
	$BasePath = $toroot . $e32path."\\";
5
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   134
}
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   135
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   136
use E32Plat;
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   137
{
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   138
        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
   139
}
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   140
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   141
if ($debug) {
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   142
	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
   143
	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
   144
	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
   145
	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
   146
	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
   147
	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
   148
	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
   149
	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
   150
}
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   151
8
8d0f562530b6 Adjusted cpp flags so that cpp will be able to find includes such as <rom/syborg/header.iby>
Simon Howkins <simonh@symbian.org>
parents: 7
diff changeset
   152
my $cppflags="-P -undef -traditional -lang-c++ -nostdinc -iwithprefixbefore $rombuildpath -I $rombuildpath -I $drive$Epoc32Path ";
5
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   153
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   154
# 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
   155
# (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
   156
# 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
   157
use E32Variant;
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   158
use Pathutl;
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   159
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
   160
if($variantMacroHRHFile){
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   161
	# 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
   162
	# 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
   163
	# 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
   164
	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
   165
	$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
   166
}
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
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
   169
	usage();
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   170
	exit 0;
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   171
}
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   172
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   173
# 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
   174
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   175
checkopts();
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   176
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   177
if (!$quiet) {
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   178
	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
   179
	print <<EOF;
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   180
OPTIONS:
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   181
\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
   182
\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
   183
\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
   184
\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
   185
\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
   186
EOF
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   187
}
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   188
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   189
#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
   190
my $skel;
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   191
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   192
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
   193
	$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
   194
} 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
   195
	$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
   196
} else {
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   197
	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
   198
}
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   199
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   200
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
   201
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   202
# 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
   203
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   204
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
   205
	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
   206
	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
   207
	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
   208
	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
   209
	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
   210
}
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
# 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
   213
# 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
   214
# 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
   215
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   216
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
   217
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   218
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
   219
	$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
   220
	$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
   221
} else {
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   222
	$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
   223
}
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   224
$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
   225
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   226
if ($single) {
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   227
	# 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
   228
	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
   229
		$smain='SARM';
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   230
	} else {
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   231
		$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
   232
	}
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   233
} else {
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   234
	$smain=$main;
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   235
}
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   236
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   237
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
   238
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
   239
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   240
# 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
   241
print OUT "\nromname=$romname\n";
84
b379919d420f Modify the script to solve problem with e32path and change all / to \ to allow to build rom image without any errors!!
Arnaud Lenoir
parents: 79
diff changeset
   242
# Go through the iby file passed as parameter of this script and replace flags by proper values before copying the line in rom1.tmp.
5
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   243
while(<X>) {
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   244
	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
   245
	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
   246
	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
   247
	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
   248
	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
   249
	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
   250
	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
   251
	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
   252
	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
   253
	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
   254
	print OUT;
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   255
}
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   256
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   257
close X;
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   258
close OUT;
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   259
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   260
# 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
   261
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   262
my $defines = "";
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 MAIN=$main ";
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   264
$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
   265
$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
   266
$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
   267
$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
   268
$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
   269
$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
   270
$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
   271
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   272
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
   273
	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
   274
	foreach (@array) {
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   275
		$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
   276
		$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
   277
		}
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
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
   281
	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
   282
	foreach (@array) {
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   283
		$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
   284
		}
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   285
	}
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   286
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   287
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
   288
	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
   289
	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
   290
	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
   291
	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
   292
	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
   293
	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
   294
	$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
   295
	$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
   296
}
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   297
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   298
$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
   299
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   300
sub IsRVCTBuild($) {
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   301
    my ($build)=@_;
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   302
    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
   303
	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
   304
	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
   305
	return 0;
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
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   308
$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
   309
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   310
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
   311
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   312
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
   313
my $cppcmd;
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   314
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
   315
	# Unicode build
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   316
	$cppcmd = "$Epoc32Path/gcc/bin/cpp $cppflags -D UNICODE $defines rom1.tmp rom2.tmp";
7
0a6fb11f0655 Adjusted EPOCROOT handling so that in the context of Raptor invocation,
Simon Howkins <simonh@symbian.org>
parents: 5
diff changeset
   317
} else {
79
5e2688cee105 Modify the line 315 of rom_sbs.pl to access cpp.exe when not building for Unicode.
Arnaud Lenoir
parents: 8
diff changeset
   318
	$cppcmd = "$Epoc32Path/gcc/bin/cpp $cppflags $defines rom1.tmp rom2.tmp";
5
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   319
}
7
0a6fb11f0655 Adjusted EPOCROOT handling so that in the context of Raptor invocation,
Simon Howkins <simonh@symbian.org>
parents: 5
diff changeset
   320
print "Executing CPP:\n\t$cppcmd\n" if $debug;
5
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   321
$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
   322
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
   323
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   324
# 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
   325
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   326
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
   327
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   328
# 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
   329
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
   330
my $line;
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   331
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
   332
	{
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*gentestpaged/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("paged");	}
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   335
	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
   336
		genfile("nonpaged");	}
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   337
	}
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
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
   340
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   341
# 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
   342
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   343
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
   344
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
   345
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
   346
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
   347
my $corerofsname="";
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   348
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
   349
my $line;
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   350
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
   351
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
   352
	{
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   353
	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
   354
		{
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   355
		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
   356
		$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
   357
		$corerofsname=$line;
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   358
		$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
   359
		$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
   360
		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
   361
		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
   362
		$rofs++;
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   363
		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
   364
		}
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
	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
   367
		{
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   368
		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
   369
		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
   370
			close TMP;
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   371
			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
   372
		}
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   373
		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
   374
		$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
   375
		$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
   376
		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
   377
			close TMP;
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   378
			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
   379
		}
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   380
		$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
   381
		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
   382
		$extension++;
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   383
		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
   384
		}
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
	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
   387
		{
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   388
		$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
   389
		}
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   390
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   391
	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
   392
		close TMP;
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   393
		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
   394
	}
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   395
	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
   396
	$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
   397
	}
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   398
close DUMPFILE;
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   399
close TMP;
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   400
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   401
# 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
   402
# 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
   403
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
   404
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   405
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
   406
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
   407
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   408
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
   409
	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
   410
}
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
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
   413
{
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   414
	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
   415
		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
   416
	}
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   417
	else {
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   418
		$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
   419
		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
   420
	}
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   421
}
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   422
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   423
close IN;
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   424
close ROM;
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   425
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   426
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
   427
	close ROFS;
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
	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
   430
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   431
my $flags;
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   432
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   433
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
   434
	$flags.=" -$_";
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   435
}
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   436
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   437
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
   438
	$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
   439
}
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   440
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   441
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
   442
	$flags.=" -compress";
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   443
}
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   444
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   445
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
   446
$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
   447
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   448
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
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
   451
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   452
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
   453
	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
   454
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   455
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
   456
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
   457
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   458
while(<Y>) {
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   459
	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
   460
	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
   461
	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
   462
	$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
   463
	$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
   464
}
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   465
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   466
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
   467
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
   468
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   469
my$rerrors;
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   470
my $rofsbuilder;
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   471
if ($rofs) {
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   472
	$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
   473
	$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
   474
	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
   475
		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
   476
		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
   477
		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
   478
		if ($? != 0)
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   479
			{
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   480
			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
   481
			$rerrors++;
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
		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
   484
		}
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   485
}
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   486
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   487
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
   488
	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
   489
		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
   490
		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
   491
		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
   492
		if ($? != 0)
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   493
			{
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   494
			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
   495
			$rerrors++;
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
		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
   498
		}
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   499
}
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   500
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   501
if ($nerrors) {
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 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
   503
} elsif ($nwarnings) {
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 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
   505
} elsif ($rerrors) {
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   506
	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
   507
} else {
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   508
	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
   509
}
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   510
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
   511
	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
   512
	$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
   513
	unlink $zipname;
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   514
	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
   515
}
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   516
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
   517
	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
   518
	$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
   519
	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
   520
	$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
   521
	unlink $logname;
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   522
	unlink $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("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
   524
	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
   525
	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
   526
}
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   527
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   528
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
   529
	exit 4;
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   530
}	
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
exit 0;
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   533
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
################################ Subroutines  ##################################
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   536
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   537
sub usage {
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   538
	print <<EOT;
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
rom <options>
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   541
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   542
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
   543
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
   544
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   545
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
   546
  --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
   547
  --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
   548
  --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
   549
  --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
   550
         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
   551
         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
   552
         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
   553
         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
   554
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   555
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
   556
  --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
   557
  --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
   558
  --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
   559
  --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
   560
  --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
   561
  --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
   562
  --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
   563
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   564
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
   565
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
   566
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   567
EOT
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
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   570
sub cleanup($$$) {
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   571
	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
   572
	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
   573
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   574
	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
   575
	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
   576
  
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   577
	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
   578
		$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
   579
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   580
		# 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
   581
		$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
   582
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   583
		# 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
   584
	
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   585
		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
   586
			if($lastblank) {
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   587
				# Do nothing
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   588
			} else {
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   589
				# 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
   590
				$lastblank=1;
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   591
				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
   592
			}
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   593
		} else {
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   594
			# Not blank
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   595
			$lastblank=0;
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   596
			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
   597
				$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
   598
			}
84
b379919d420f Modify the script to solve problem with e32path and change all / to \ to allow to build rom image without any errors!!
Arnaud Lenoir
parents: 79
diff changeset
   599
			
b379919d420f Modify the script to solve problem with e32path and change all / to \ to allow to build rom image without any errors!!
Arnaud Lenoir
parents: 79
diff changeset
   600
			# This next line is about converting all the / to \ to make sure that we are using the right format for the build generation	
b379919d420f Modify the script to solve problem with e32path and change all / to \ to allow to build rom image without any errors!!
Arnaud Lenoir
parents: 79
diff changeset
   601
			$line =~ s/\//\\/g;
b379919d420f Modify the script to solve problem with e32path and change all / to \ to allow to build rom image without any errors!!
Arnaud Lenoir
parents: 79
diff changeset
   602
			
5
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   603
			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
   604
		}
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   605
	}
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   606
	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
   607
	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
   608
}
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   609
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   610
sub IsSmp($) {
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   611
	my %SmpKernelDirs=(
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   612
		'x86smp' => 1,
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   613
		'x86gmp' => 1,
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   614
		'arm4smp' => 1,
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   615
		'armv4smp' => 1,
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   616
		'armv5smp' => 1
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
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   619
	my ($kdir) = @_;
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   620
	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
   621
}
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   622
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   623
sub checkopts {
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   624
	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
   625
	$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
   626
	$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
   627
	$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
   628
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   629
	my $additional;
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   630
	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
   631
		$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
   632
		$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
   633
	}
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   634
	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
   635
	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
   636
	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
   637
		# 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
   638
		$main="MARM";
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   639
		$euserdir="MARM";
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   640
		$elocldir="MARM";
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   641
	}
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   642
	else {
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   643
		$main=$inst;
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   644
		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
   645
			$euserdir="ARMI";
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   646
		} else {
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   647
			$euserdir=$main;
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   648
		}
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   649
		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
   650
			$elocldir="ARM4";
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   651
		} else {
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   652
			$elocldir=$main;
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   653
		}
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   654
	}
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   655
	$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
   656
	$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
   657
	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
   658
		$euserdir = $kmain;
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   659
	}
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   660
	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
   661
		$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
   662
	} else {
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   663
		$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
   664
		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
   665
			$romname.='D';
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
		$romname.='.IMG';
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
}
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
sub lookupFileInfo($$)
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 ($infile, $fullname) = @_;
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
	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
   676
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   677
	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
   678
	while(<TMP>)
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   679
	{
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   680
		$_ = lc;
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   681
		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
   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 ($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
   684
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   685
			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
   686
			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
   687
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   688
			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
   689
			{
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   690
				close TMP;
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   691
				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
   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
	}
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
	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
   697
}
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
sub lookupSymbolInfo($$)
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
	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
   702
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   703
	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
   704
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   705
	# 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
   706
	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
   707
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   708
	while (<TMP>)
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
		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
   711
		{
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   712
			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
   713
			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
   714
			{
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   715
				close TMP;
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   716
				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
   717
			}
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   718
		}
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   719
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   720
		# 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
   721
		# 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
   722
		#
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   723
		# 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
   724
		#
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   725
		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
   726
		{
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   727
			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
   728
			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
   729
			{
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   730
				close TMP;
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   731
				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
   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
	}
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
	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
   737
}
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
sub parsePatchData($$)
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
	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
   742
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   743
	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
   744
	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
   745
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   746
	my $line;
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   747
	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
   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 ($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
   750
		{
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   751
			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
   752
			{
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   753
				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
   754
			}
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   755
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   756
			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
   757
			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
   758
			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
   759
			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
   760
			{
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   761
				($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
   762
				$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
   763
			}
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
			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
   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 ($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
   768
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   769
				my $max;
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   770
				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
   771
				{
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   772
					my $bytes;
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   773
					$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
   774
					$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
   775
					$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
   776
					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
   777
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   778
					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
   779
					{
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   780
						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
   781
					}
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
					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
   784
					{
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   785
						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
   786
					}
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   787
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   788
					$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
   789
					$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
   790
					$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
   791
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   792
					$symbolSize = $bytes;
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   793
				}
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 == 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
   795
				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
   796
				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
   797
				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
   798
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   799
				$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
   800
				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
   801
				{
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   802
					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
   803
					$value &= $max;
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
				$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
   806
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   807
				$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
   808
			}
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   809
			else
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
				$line = "";
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
		}
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
		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
   817
	}
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   818
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   819
	close IN;
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   820
	close OUT;
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   821
}
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   822
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   823
sub genfile {
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   824
	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
   825
	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
   826
		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
   827
		unlink $file;
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   828
		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
   829
		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
   830
			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
   831
			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
   832
			$count++;
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   833
			} 
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   834
			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
   835
			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
   836
			}
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   837
			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
   838
			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
   839
			}
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   840
			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
   841
			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
   842
			}
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   843
			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
   844
			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
   845
			}
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   846
			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
   847
			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
   848
			}
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   849
		}
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   850
	} else {
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   851
		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
   852
		unlink $file;
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   853
		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
   854
		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
   855
			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
   856
			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
   857
			$count++;
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   858
			} 
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   859
			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
   860
			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
   861
			}
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   862
			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
   863
			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
   864
			}
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   865
			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
   866
			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
   867
			}
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   868
			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
   869
			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
   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
}
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
__END__
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   876
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   877
# 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
   878
# Local Variables:
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   879
# mode:perl
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   880
# 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
   881
# End:
4ab060f25417 Create and register FLM for building ROMs with rom_sbs.pl through SBSv2.
Arnaud Lenoir <arnaudl@symbian.org>
parents:
diff changeset
   882