toolsandutils/e32tools/rombuild/romnibus.pl
author Mike Kinghan <mikek@symbian.org>
Wed, 24 Nov 2010 09:17:29 +0000
branchGCC_SURGE
changeset 80 d82e43335b24
permissions -rw-r--r--
Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
80
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
     1
#!/usr/bin/perl
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
     2
#
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
     3
# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
     4
# All rights reserved.
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
     5
# This component and the accompanying materials are made available
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
     6
# under the terms of the License "Eclipse Public License v1.0"
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
     7
# which accompanies this distribution, and is available
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
     8
# at the URL "http://www.eclipse.org/legal/epl-v10.html".
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
     9
#
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    10
# Initial Contributors:
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    11
# Nokia Corporation - initial contribution.
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    12
#
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    13
# Contributors:
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    14
# Mike Kinghan, mikek@symbian.org, for Symbian Foundation
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    15
#
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    16
# Description:
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    17
#
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    18
# romnibus.pl - Yet another rombuild wrapper. This one's claim to fame is that
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    19
# it works in Linux and in Windows, works when invoked from sbsv2 and when
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    20
# not invoked from sbsv2.
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    21
#
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    22
# Pre-processes the .oby/iby files then invokes rombuild.exe
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    23
# (or other specified builder)
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    24
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    25
# First, read our config file
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    26
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    27
use strict;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    28
use Getopt::Long;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    29
use Cwd;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    30
use Cwd 'abs_path';
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    31
use File::Spec;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    32
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    33
my $on_windows;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    34
my $epocroot_vol;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    35
my $epocroot_dir;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    36
my $epocroot_file;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    37
my %dir_listings = ();	
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    38
my %opts=();
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    39
my $param_count = scalar(@ARGV);
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    40
my (@assps, @builds, %variants, @templates, %flags, %insts, %zip, %builder);
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    41
my $main;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    42
my $kmain;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    43
my $toroot;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    44
my $e32path;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    45
my $rombuildpath;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    46
my $euserdir;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    47
my $elocldir;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    48
my $kbdir;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    49
my $romname;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    50
my $single;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    51
my $smain;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    52
my $pagedCode;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    53
my $debug;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    54
my $quiet;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    55
my $toolpath;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    56
my $epoc32path;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    57
my $epocroot;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    58
my $lc_epocroot;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    59
my $drive = "";
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    60
my $base_path;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    61
my $line;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    62
sub Variant_GetMacroHRHFile;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    63
sub is_RVCT_build($);
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    64
sub parse_cfg;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    65
sub ASSPS;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    66
sub BUILDS;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    67
sub TEMPLATES;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    68
sub usage;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    69
sub rectify($$$);
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    70
sub match_abbrev($$);
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    71
sub check_opts;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    72
sub lookup_file_info($$);
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    73
sub lookupSymbolInfo($$);
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    74
sub parse_patch_data($$);
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    75
sub gen_file;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    76
sub nix_fixes {
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    77
#	Fix case-sensitivity offenders for unix/linux environment.
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    78
	my $e32plat_pm = File::Spec->catfile($toolpath,"e32plat.pm");
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    79
	my $armutl_pm = File::Spec->catfile($toolpath,"armutl.pm");
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    80
	my $bpabiutl_pm = File::Spec->catfile($toolpath,"bpabiutl.pm");
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    81
	my $e32variant_pm = File::Spec->catfile($toolpath,"e32variant.pm");
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    82
	my $E32Plat_pm = File::Spec->catfile($toolpath,"E32Plat.pm");
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    83
	my $Armutl_pm = File::Spec->catfile($toolpath,"Armutl.pm");
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    84
	my $BPABIutl_pm = File::Spec->catfile($toolpath,"BPABIutl.pm");
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    85
	my $E32Variant_pm = File::Spec->catfile($toolpath,"E32Variant.pm");
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    86
	# Create symlinks for case-sensitively misnamed modules we need.
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    87
	unless ( -f $E32Plat_pm or -l $E32Plat_pm) {
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    88
		symlink($e32plat_pm,$E32Plat_pm);
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    89
	}
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    90
	unless ( -f $Armutl_pm or -l $Armutl_pm) {
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    91
		symlink($armutl_pm,$Armutl_pm);
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    92
	}
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    93
	unless ( -f $BPABIutl_pm or -l $BPABIutl_pm) {
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    94
		symlink($bpabiutl_pm,$BPABIutl_pm);
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    95
	}
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    96
	unless ( -f $E32Variant_pm or -l $E32Variant_pm) {
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    97
		symlink($e32variant_pm,$E32Variant_pm);
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    98
	}
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    99
	# Make uppercase symlinks to all .bsf files in /epoc32/tools
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   100
	my @bsf_files = glob(File::Spec->catfile($toolpath,"*.bsf"));
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   101
	foreach my $bsf_file (@bsf_files) {
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   102
		my ($vol,$dirs,$file) = File::Spec->splitpath($bsf_file);
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   103
		$file =~ /^(\S+)\.bsf/;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   104
		my $uc_stem = uc($1);
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   105
		my $uc_bsf_file = File::Spec->catpath($vol,$dirs,($uc_stem .".bsf"));
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   106
		unless ( -f $uc_bsf_file or -l $uc_bsf_file ) {
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   107
			symlink($bsf_file,$uc_bsf_file) or die "Can't symlink $bsf_file -> $uc_bsf_file. $!";
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   108
		}
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   109
	}
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   110
}
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   111
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   112
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   113
BEGIN {
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   114
	$on_windows = $^O =~ /^MSWin/ ? 1 : 0;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   115
	$epocroot = $ENV{EPOCROOT};
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   116
	die "ERROR: Must set the EPOCROOT environment variable.\n" if (!defined($epocroot));
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   117
	print "Environmental epocroot - >$epocroot<\n";
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   118
	$epocroot =~ s/:$/:\//, if $on_windows;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   119
	$epocroot = abs_path($epocroot);
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   120
	die "ERROR: EPOCROOT must specify an existing directory.\n" if (!-d $epocroot);
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   121
	($epocroot_vol,$epocroot_dir,$epocroot_file) = File::Spec->splitpath($epocroot);
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   122
	$epocroot = File::Spec->catfile(($epocroot_vol,$epocroot_dir,$epocroot_file),undef);
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   123
	print "EPOCROOT=$ENV{EPOCROOT} resolved as \"$epocroot\"\n";
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   124
	$lc_epocroot = lc($epocroot);
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   125
	$epoc32path = File::Spec->catfile($epocroot,"epoc32");
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   126
	$toolpath = File::Spec->catfile($epoc32path,"tools");
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   127
	push @INC, $toolpath;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   128
	nix_fixes(), unless ($on_windows);
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   129
}
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   130
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   131
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   132
my $result = GetOptions (\%opts, "assp=s",
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   133
						 "inst=s",
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   134
						 "type=s",
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   135
						 "variant=s",
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   136
						 "build=s", 
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   137
						 "conf=s",
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   138
						 "name=s",
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   139
						 "modules=s",
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   140
						 "xabi=s",
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   141
						 "clean",
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   142
						 "quiet",
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   143
						 "help",
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   144
						 "debug",
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   145
						 "zip",
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   146
						 "symbol",
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   147
						 "noheader",
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   148
						 "kerneltrace=s",
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   149
						 "rombuilder=s",
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   150
						 "define=s@",
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   151
						 "rofsbuilder=s",
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   152
						 "compress",
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   153
						 );
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   154
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   155
$debug = $opts{debug};
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   156
$quiet = $opts{quiet} unless $debug;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   157
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   158
my $cwd = Cwd::cwd();
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   159
my ($vol,$dirs,$file) = File::Spec->splitpath($cwd);
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   160
$drive = $vol, if ($on_windows);
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   161
my @path_parts = File::Spec->splitdir($dirs);
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   162
while(@path_parts[-1] ne "sf") {
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   163
	pop(@path_parts);
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   164
}
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   165
$base_path = File::Spec->catdir((@path_parts,"os"));
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   166
$base_path = "$drive$base_path", if ($on_windows);
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   167
$rombuildpath = File::Spec->catfile($base_path,"kernelhwsrv","kernel","eka","rombuild");
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   168
$base_path .= ($on_windows ? '\\' : '/');  
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   169
$e32path = ($on_windows ? "\\sf\\os" : "/sf/os"); 
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   170
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   171
use E32Plat;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   172
{
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   173
        Plat_Init($toolpath . ($on_windows ? '\\' : '/'));
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   174
}
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   175
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   176
if ($debug) {
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   177
	print "epocroot = $epocroot\n";
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   178
	print "epoc32path = $epoc32path\n";
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   179
	print "drive = $drive\n";
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   180
	print "toolpath = $toolpath\n";
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   181
	print "toroot = $toroot\n";
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   182
	print "e32path = $e32path\n";
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   183
	print "rombuildpath = $rombuildpath\n";
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   184
	print "base_path = $base_path\n";
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   185
}
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   186
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   187
#my $cppflags="-P -undef -Wno-endif-labels -traditional -lang-c++ -nostdinc -iwithprefixbefore $rombuildpath -I $rombuildpath -I $drive$epoc32path ";
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   188
my $cppflags="-P -undef -Wno-endif-labels -traditional -lang-c++ -nostdinc -I $rombuildpath -I $epoc32path ";
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   189
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   190
# Include variant hrh file defines when processing oby and ibys with cpp
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   191
# (Code copied from \\EPOC\master\cedar\generic\tools\romkit\tools\buildrom.pm -
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   192
# it used relative path to the working dir but we are using absolute path seems neater)
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   193
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   194
my $variantMacroHRHFile = Variant_GetMacroHRHFile();
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   195
if($variantMacroHRHFile){
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   196
	my ($ignore1,$dir,$file) = File::Spec->splitpath($variantMacroHRHFile);
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   197
	$cppflags .= " -I " . File::Spec->catpath($epocroot_vol,$dir,undef) . " -include " . File::Spec->catpath($epocroot_vol,$dir,$file); 
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   198
}
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   199
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   200
if($param_count == 0 || $opts{'help'} || !$result) {
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   201
	usage();
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   202
	exit 0;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   203
}
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   204
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   205
# Now check that the options we have make sense
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   206
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   207
checkopts();
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   208
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   209
if (!$quiet) {
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   210
	print "Starting directory: ", Cwd::cwd(), "\n";
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   211
	print <<EOF;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   212
OPTIONS:
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   213
\tTYPE: $opts{'type'}
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   214
\tVARIANT: $opts{'variant'}
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   215
\tINSTRUCTION SET: $opts{'inst'}
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   216
\tBUILD: $opts{'build'}
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   217
\tMODULES: $opts{'modules'}
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   218
EOF
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   219
}
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   220
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   221
#Pick out the type file
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   222
my $skel = "$opts{'type'}.oby";
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   223
unless (-e $skel) {
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   224
	$skel= File::Spec->catfile($rombuildpath,"$opts{'type'}.oby");
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   225
}
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   226
unless (-e $skel) {
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   227
	die "Can't find type file for type $opts{'type'}, $!";
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   228
}
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   229
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   230
print "Using type file $skel\n" if !$quiet;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   231
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   232
# If clean is specified, zap all the image and .oby files
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   233
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   234
if($opts{'clean'}) {
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   235
	unlink glob("*.img");
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   236
	unlink "rom.oby";
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   237
	unlink "rombuild.log";
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   238
	unlink glob("*.rofs");
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   239
	unlink "rofsbuild.log";
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   240
}
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   241
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   242
# Now pre-pre-process this file to point to the right places for .ibys
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   243
# Unfortunately cpp won't do macro replacement in #include strings, so
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   244
# we have to do it by hand
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   245
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   246
my $k = $opts{kerneltrace};
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   247
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   248
if ($opts{assp}=~/^m(\S+)/i) {
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   249
	$kbdir="kb$1";
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   250
	$kbdir="kbarm" if (lc $1 eq 'eig');
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   251
} else {
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   252
	$kbdir="kb$opts{assp}";
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   253
}
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   254
$single=1 if ($opts{assp}=~/^s(\S+)/i);
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   255
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   256
if ($single) {
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   257
	# Hackery to cope with old compiler
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   258
	if ($main eq 'MARM') {
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   259
		$smain='SARM';
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   260
	} else {
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   261
		$smain="S$main";
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   262
	}
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   263
} else {
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   264
	$smain=$main;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   265
}
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   266
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   267
unless ($on_windows) {
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   268
	$main = lc($main);
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   269
	$kmain = lc($kmain);
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   270
}
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   271
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   272
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   273
open(X, "$skel") || die "Can't open type file $skel, $!";
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   274
open(OUT, "> rom1.tmp") || die "Can't open output file, $!";
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   275
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   276
# First output the ROM name
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   277
print OUT "\nromname=$romname\n";
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   278
while(<X>) {
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   279
	s/\#\#ASSP\#\#/$opts{'assp'}/;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   280
	s/\#\#VARIANT\#\#/$opts{'variant'}/;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   281
	s/\#\#BUILD\#\#/$opts{'build'}/;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   282
	s/\#\#MAIN\#\#/$main/;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   283
	s/\#\#KMAIN\#\#/$kmain/;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   284
	s/\#\#E32PATH\#\#/$e32path/;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   285
	s/\#\#BASEPATH\#\#/$base_path/;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   286
	s/\#\#EUSERDIR\#\#/$euserdir/;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   287
	s/\#\#ELOCLDIR\#\#/$elocldir/;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   288
	s/\#\#KBDIR\#\#/$kbdir/;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   289
	unless ($on_windows) {
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   290
		if (m/#include/) {
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   291
			s|\\|\/|g;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   292
			lc;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   293
		}
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   294
	}
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   295
	print OUT;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   296
}
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   297
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   298
close X;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   299
close OUT;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   300
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   301
# Use cpp to pull in include chains and replace defines
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   302
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   303
my $defines = "";
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   304
$defines .= "-D MAIN=$main ";
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   305
$defines .= "-D KMAIN=$kmain ";
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   306
$defines .= "-D EUSERDIR=$euserdir ";
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   307
$defines .= "-D ELOCLDIR=$elocldir ";
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   308
$defines .= "-D E32PATH=$e32path ";
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   309
$defines .= "-D BASEPATH=$base_path ";
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   310
$defines .= "-D EPOCROOT=$epocroot ";
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   311
$defines .= "-D SMAIN=$smain " if $smain;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   312
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   313
foreach (@{$opts{'define'}}) {
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   314
	my @array=split(/,/,$_);
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   315
	foreach (@array) {
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   316
		$defines.="-D ".uc $_." ";
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   317
		$pagedCode = 1 if $_ eq 'PAGED_CODE';
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   318
		}
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   319
	}
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   320
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   321
if ($opts{'modules'}) {
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   322
	my @array=split(/,/,$opts{'modules'});
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   323
	foreach (@array) {
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   324
		$defines.="-D ".uc $_." ";
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   325
		}
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   326
	}
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   327
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   328
foreach (keys %opts) {
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   329
	next if ($_ eq 'name');
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   330
	next if ($_ eq 'modules');
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   331
	next if ($_ eq 'zip');
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   332
	next if ($_ eq 'symbol');
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   333
	next if ($_ eq 'kerneltrace');
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   334
	next if ($_ eq 'define');
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   335
	$defines.="-D ".uc $_."=".$opts{$_}." ";
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   336
	$defines.="-D ".uc $_."_".$opts{$_}." ";
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   337
}
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   338
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   339
$defines.="-D SINGLE " if ($single);
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   340
$defines.="-D RVCT " if (IsRVCTBuild($main));
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   341
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   342
print "Using defines $defines\n" if !$quiet;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   343
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   344
my $ret=1;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   345
my $cppcmd;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   346
if($opts{'build'}=~/^u/i and $on_windows) {
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   347
	# Unicode build
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   348
	$cppcmd = File::Spec->catfile($epoc32path,"gcc","bin","cpp") . " $cppflags -D UNICODE $defines rom1.tmp rom2.tmp";
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   349
} else {
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   350
	$cppcmd = "cpp $cppflags $defines rom1.tmp rom2.tmp";
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   351
}
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   352
print "Executing CPP:\n\t$cppcmd\n" if $debug;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   353
$ret = system($cppcmd);
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   354
die "ERROR EXECUTING CPP\n" if $ret;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   355
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   356
# Purge remarks and blank lines. Complete source filenames and adapt them to host filesystem.
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   357
rectify("rom2.tmp", "rom3.tmp", $k);
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   358
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   359
# scan tmp file and generate auxiliary files, if required
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   360
open TMP, "rom3.tmp" or die("Can't open rom3.tmp\n");
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   361
while ($line=<TMP>)
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   362
	{
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   363
	if ($line=~/\s*gentestpaged/i) {
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   364
		genfile("paged");	}
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   365
	if ($line=~/\s*gentestnonpaged/i) {
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   366
		genfile("nonpaged");	}
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   367
	}
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   368
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   369
parsePatchData("rom3.tmp", "rom4.tmp");
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   370
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   371
# break down the oby file into rom, rofs and extensions oby files
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   372
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   373
my $oby_index =0;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   374
my $dumpfile="rom.oby";
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   375
my $rofs=0;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   376
my $extension=0;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   377
my $corerofsname="";
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   378
open DUMPFILE, ">$dumpfile" or die("Can't create $dumpfile\n");
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   379
open TMP, "rom4.tmp" or die("Can't open rom4.tmp\n");
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   380
while ($line=<TMP>)
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   381
	{
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   382
	if ($line=~/^\s*rofsname/i)
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   383
		{
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   384
		close DUMPFILE;							# close rom.oby or previous rofs#/extension#.oby
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   385
		$oby_index=1;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   386
		$corerofsname=$line;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   387
		$corerofsname =~ s/rofsname\s*=\s*//i;		# save core rofs name
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   388
		chomp($corerofsname);
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   389
		unlink $corerofsname || print "unable to delete $corerofsname";
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   390
		my $dumpfile="rofs".$rofs.".oby";
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   391
		$rofs++;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   392
		open DUMPFILE, ">$dumpfile" or (close TMP and die("Can't create $dumpfile\n"));
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   393
		}
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   394
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   395
	if ($line=~/^\s*coreimage/i)
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   396
		{
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   397
		close DUMPFILE;							# close rofs.oby
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   398
		if ($oby_index ne 1) {
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   399
			close TMP;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   400
			die "Must specify ROFS image before ROFS extension\n";
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   401
		}
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   402
		my $name=$line;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   403
		$name =~ s/coreimage\s*=\s*//i;		# read core rofs name
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   404
		chomp($name); 			# remove trailing \n
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   405
		if ($name ne $corerofsname) {
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   406
			close TMP;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   407
			die "This extension does not relate to previous ROFS\n";
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   408
		}
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   409
		$oby_index=33;						# open window
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   410
		my $dumpfile="extension".$extension.".oby";
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   411
		$extension++;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   412
		open DUMPFILE, ">$dumpfile" or (close TMP and die("Can't create $dumpfile\n"));
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   413
		}
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   414
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   415
	if ($line=~/^\s*extensionrofs/i)
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   416
		{
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   417
		$oby_index=3 if ($oby_index eq 2);
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   418
		}
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   419
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   420
	if (($oby_index eq 2) && !($line=~/^\s*$/)) {
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   421
		close TMP;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   422
		die "Bad ROFS extension specification\n";
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   423
	}
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   424
	print DUMPFILE $line;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   425
	$oby_index=2 if ($oby_index eq 33);		# close window
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   426
	}
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   427
close DUMPFILE;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   428
close TMP;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   429
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   430
# 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
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   431
# is automatically put into rofs
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   432
rename('rom.oby', 'rom4.tmp') || die;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   433
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   434
open(IN, 'rom4.tmp') || die "Can't read rom4.tmp";
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   435
open(ROM, '>rom.oby') || die "Can't write to rom.oby";
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   436
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   437
if ($oby_index >= 1 && $pagedCode)	{
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   438
	open(ROFS, '>>rofs0.oby') || die "Can't append to rofs0.oby";
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   439
}
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   440
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   441
while ($line=<IN>)
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   442
{
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   443
	if(($oby_index >= 1) && ($pagedCode) && ($line=~/^\s*data\s*=/) && !($line=~/\.*paging_unmovable\s*/)) {
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   444
		print ROFS $line;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   445
	}
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   446
	else {
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   447
		$line=~s/paging_unmovable//;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   448
		print ROM $line;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   449
	}
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   450
}
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   451
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   452
close IN;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   453
close ROM;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   454
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   455
if ($oby_index >= 1 && $pagedCode)	{
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   456
	close ROFS;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   457
}
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   458
	unlink 'rom4.tmp';
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   459
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   460
my $flags;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   461
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   462
foreach (@{$flags{$opts{'assp'}}}) {
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   463
	$flags.=" -$_";
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   464
}
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   465
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   466
if($opts{'noheader'}) {
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   467
	$flags.=" -no-header";
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   468
}
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   469
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   470
if($opts{'compress'}) {
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   471
	$flags.=" -compress";
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   472
}
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   473
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   474
my $builder = $opts{'rombuilder'};
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   475
if ($on_windows) {
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   476
	$builder = File::Spec->catfile($toolpath,"rombuild.exe") unless ($builder);
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   477
}
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   478
else {
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   479
	$builder = File::Spec->catfile($toolpath,"rombuild") unless ($builder);
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   480
	unless ( -x $builder ) {
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   481
		chmod 0755,$builder;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   482
	}
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   483
}
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   484
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   485
print "$builder $flags -type-safe-link -S rom.oby 2>&1\n\n";
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   486
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   487
open(Y, "$builder $flags -type-safe-link -S rom.oby 2>&1 | ") || 
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   488
	die "Can't start $builder command, $!";
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   489
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   490
my $nerrors=0;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   491
my $nwarnings=0;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   492
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   493
while(<Y>) {
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   494
	my $error=(/^error:/i);
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   495
	my $warning=(/^warning:/i);
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   496
	print if ($error or $warning or !$quiet);
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   497
	$nerrors++ if ($error);
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   498
	$nwarnings++ if ($warning);
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   499
}
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   500
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   501
print "\nGenerated .oby file is rom.oby\n" if !$quiet;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   502
print "\nGenerated image file is $romname\n" if (!$nerrors);
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   503
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   504
my$rerrors;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   505
my $rofsbuilder;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   506
if ($rofs) {
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   507
	$rofsbuilder = $opts{'rofsbuilder'};
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   508
	$rofsbuilder = "rofsbuild" unless ($rofsbuilder);
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   509
	for(my $i=0;$i<$rofs;++$i) {
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   510
		print "Executing $rofsbuilder on main rofs\n" if !$quiet;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   511
		my $image="rofs".$i.".oby";
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   512
		system("$rofsbuilder $image");
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   513
		if ($? != 0)
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   514
			{
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   515
			print "$rofsbuilder $image returned $?\n";
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   516
			$rerrors++;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   517
			}
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   518
		rename "rofsbuild.log", "rofs$i.log"
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   519
		}
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   520
}
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   521
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   522
if ($rofs and $extension) {
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   523
	for(my $i=0;$i<$extension;++$i) {
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   524
		print "Executing $rofsbuilder on extension rofs\n" if !$quiet;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   525
		my $image="extension".$i.".oby";
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   526
		system("$rofsbuilder $image");
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   527
		if ($? != 0)
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   528
			{
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   529
			print "$rofsbuilder $image returned $?\n";
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   530
			$rerrors++;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   531
			}
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   532
		rename "rofsbuild.log", "extension$i.log"
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   533
		}
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   534
}
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   535
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   536
if ($nerrors) {
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   537
	print "\n\n Errors found during $builder!!\n\nLeaving tmp files\n";
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   538
} elsif ($nwarnings) {
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   539
	print "\n\n Warnings during $builder!!\n\nLeaving tmp files\n";
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   540
} elsif ($rerrors) {
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   541
	print "\n\n Errors during $rofsbuilder!!\n\nLeaving tmp files\n";
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   542
} else {
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   543
	unlink glob("*.tmp") if !$debug;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   544
}
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   545
if ($opts{zip} or $zip{$opts{assp}}) {
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   546
	my $zipname=$romname;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   547
	$zipname =~ s/\.(\w+)$/\.zip/i;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   548
	unlink $zipname;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   549
	system("zip $zipname $romname");
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   550
}
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   551
if ($opts{symbol}) {
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   552
	my $logname=$romname;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   553
	$logname =~ s/\.(\w+)$/\.log/i;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   554
	my $obyname=$romname;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   555
	$obyname =~ s/\.(\w+)$/\.oby/i;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   556
	unlink $logname;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   557
	unlink $obyname;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   558
	system("rename rombuild.log $logname");
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   559
	system("rename rom.oby $obyname");
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   560
	system("maksym $logname");
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   561
}
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   562
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   563
#IMK if ($nerrors || $nwarnings || $rerrors) {
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   564
#IMK	exit 4;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   565
#IMK}	
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   566
if ($nerrors || $rerrors) {
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   567
	exit 4;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   568
}	
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   569
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   570
	
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   571
exit 0;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   572
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   573
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   574
################################ Subroutines  ##################################
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   575
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   576
sub usage {
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   577
	print <<EOT;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   578
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   579
rom <options>
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   580
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   581
Generate a rom image for the specified target, along with a rom.oby file
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   582
that can be fed to (a) rombuild to regenerate the image.
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   583
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   584
The following options are required:
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   585
  --variant=<variant>         e.g. --variant=assabet
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   586
  --inst=<instruction set>    e.g. --inst=arm4
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   587
  --build=<build>             e.g. --build=udeb
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   588
  --type=<type of rom>  
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   589
         tshell for a text shell rom
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   590
         e32tests for a rom with e32tests
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   591
         f32tests for rom with f32tests
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   592
         alltests for all the tests
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   593
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   594
The following are optional:
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   595
  --name=<image name>               Give image file specified name
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   596
  --noheader                        Pass -no-header option on to rombuild
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   597
  --help                            This help message.
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   598
  --clean                           Remove existing generated files first
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   599
  --quiet                           Be less verbose
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   600
  --modules=<comma separated list>  List of additional modules for this ROM
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   601
  --define=<comma separated list>   List of CPP macros to define
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   602
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   603
Options may be specified as a short abbreviation 
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   604
e.g. -b udeb instead of --build udeb
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   605
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   606
EOT
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   607
}
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   608
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   609
sub rectify($$$) {
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   610
	my ($in, $out, $k) = @_;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   611
	my $lastblank;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   612
	my $lineno = 0;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   613
	my $epocroot_pattern = $on_windows ? $epocroot . '\\\\' : $epocroot;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   614
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   615
	open(OUTPUT_FILE, "> $out") or die "Cannot open $out for output";
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   616
	open(INPUT_FILE, "< $in") or die "Cannot open for $in input";
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   617
  
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   618
	while ($line=<INPUT_FILE>) {
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   619
		++$lineno;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   620
		if ($line =~ /^\/\// ) {} # Ignore c++ commented lines.
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   621
		elsif ($line =~ /^\s*REM\s+/i) {} # Ignore REM commented lines.
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   622
		elsif ($line =~ /^\s*$/) { # Compress blank lines down to one
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   623
			if($lastblank) {
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   624
				# Do nothing
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   625
			}
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   626
			else {
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   627
				# This is the first blank line
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   628
				$lastblank=1;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   629
				print OUTPUT_FILE $line;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   630
			}
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   631
		}
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   632
		else {
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   633
			# Not blank
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   634
			my $epoc32_line = 0;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   635
			$lastblank = 0;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   636
			$line =~ s|\#\#||g; # Delete "token-pasting" ops
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   637
			$line =~ s|//.*$||g; # Delete trailing c++ comments
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   638
			# prefix the epocroot dir to occurrences of 'epoc32' in all "KEYWORD=..." lines.
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   639
			$line =~ s/(=\s*)[\\\/]epoc32/\1$epoc32path/i;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   640
			$epoc32_line = defined($1);
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   641
			if (!$epoc32_line) {
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   642
				$line =~ /(=.*$epocroot_pattern)/i;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   643
				$epoc32_line = defined($1);
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   644
			}
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   645
			if (!$epoc32_line) {
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   646
				if ($k and $line=~/^\s*kerneltrace/i) {
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   647
					$line = "kerneltrace $k\n";
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   648
				}
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   649
			}
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   650
			elsif ($on_windows) {
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   651
				$line =~ s|\/|\\|g;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   652
			}
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   653
			elsif ($line =~ /(^bootbinary\s*=\s*${epocroot}epoc32)(\S+)$/) {
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   654
				# unixify the bootbinary line
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   655
				my $tail = $2;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   656
				$line =~ s|\\|\/|g;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   657
				$tail =~ s|\\|\/|g;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   658
				my $lc_tail = lc($tail);
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   659
				$line =~ s|$tail|$lc_tail|;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   660
			}
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   661
			elsif ($line =~ /^(\s*\S+\s*=\s*)(\S+)(\s*\S*)/) {
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   662
				#unixify the lefthand sides of rom-mapping lines.
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   663
				my $keyword_part = $1;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   664
				my $src = $2;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   665
				my $dest = $3;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   666
				$dest =~ s/^\s+//;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   667
				$dest =~ s/\s+$//;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   668
				$src =~ s|\\|\/|g;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   669
				if ($dest) {
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   670
					my ($vol,$dir,$leaf) = File::Spec->splitpath($src);
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   671
					my $lc_leaf = lc($leaf);
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   672
					my $lc_dir = lc($dir);
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   673
					$lc_dir =~ s/\/$//;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   674
					$lc_dir =~ s|^$lc_epocroot|$epocroot|;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   675
					my $fulldir = $lc_dir;	
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   676
					$fulldir =~ s|//|/|g;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   677
					$dest =~ s|\/|\\|g;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   678
					$dest = '\\' . $dest, unless ($dest =~ /^\\/);
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   679
					unless ( -d $fulldir ) {
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   680
						chomp $line;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   681
						# Lower-cased source directory doesn't exist. Give up.
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   682
						die "Guessed source directory \"$fulldir\" does not exist for line $lineno: \"$line\"\n";
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   683
					}
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   684
					if (($leaf eq $lc_leaf) or (-f "$fulldir\/$leaf")) { 
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   685
						# Using source directory lowercase and source filename as input.
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   686
						$line = "${keyword_part}${lc_dir}\/${leaf}\t${dest}\n";
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   687
					}
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   688
					elsif ( -f "$fulldir\/$lc_leaf") {
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   689
						# Using source directory source filename both lowercase.
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   690
						$line = "${keyword_part}${lc_dir}\/${lc_leaf}\t${dest}\n";
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   691
					}
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   692
					else { # Harder.
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   693
						my @dirlist;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   694
						my $found = 0;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   695
						if (!defined($dir_listings{$fulldir})) {
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   696
							# Haven't got a cached dir listing for the source directory.
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   697
							# Make one now.
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   698
							@dirlist = glob("$fulldir.*");
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   699
							$dir_listings{$fulldir} = \@dirlist;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   700
						}	
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   701
						@dirlist = @{dir_listings{$fulldir}}; # Get listing of source directory from cache.
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   702
						foreach my $file (@dirlist) {
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   703
							# See if any file in the source directory case-insensitively matches the input source file.
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   704
							if ( (-f "$fulldir\/$file") and (lc($file) eq $lc_leaf)) {
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   705
								$line = "${keyword_part}${lc_dir}\/${file}\t${dest}\n";
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   706
								$found = 1;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   707
								last;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   708
							}
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   709
						}
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   710
						unless ($found) {
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   711
							die "Cannot find any file case-insensitively matching \"$fulldir\/$leaf\" at line $lineno: \"$line\"\n";
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   712
						}
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   713
					}
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   714
				}
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   715
				else {
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   716
					$line =~ s|\\|\/|g;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   717
				}								
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   718
			}
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   719
			print OUTPUT_FILE $line;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   720
		}
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   721
	}
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   722
	close(INPUT_FILE);
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   723
	close(OUTPUT_FILE);
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   724
}
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   725
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   726
sub IsRVCTBuild($) {
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   727
    my ($build)=@_;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   728
    return 1 if ($build =~ /^ARMV/i);
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   729
	my @customizations = Plat_Customizations('ARMV5');
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   730
	return 1 if (grep /$build/, @customizations);
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   731
	return 0;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   732
}
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   733
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   734
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   735
sub IsSmp($) {
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   736
	my %SmpKernelDirs=(
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   737
		'x86smp' => 1,
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   738
		'x86gmp' => 1,
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   739
		'arm4smp' => 1,
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   740
		'armv4smp' => 1,
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   741
		'armv5smp' => 1
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   742
	);
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   743
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   744
	my ($kdir) = @_;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   745
	return $SmpKernelDirs{lc $kdir};
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   746
}
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   747
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   748
sub checkopts {
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   749
	unless($opts{variant}) { die "No Variant specified"; }
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   750
	$opts{'build'}="UDEB" unless($opts{'build'});
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   751
	$opts{'type'}="TSHELL" unless($opts{'type'});
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   752
	$opts{'inst'}="ARM4" unless($opts{'inst'});
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   753
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   754
	my $additional;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   755
	if ($opts{'modules'}) {
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   756
		$additional="_".$opts{modules};
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   757
		$additional=~ s/,/_/ig;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   758
	}
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   759
	my $build=lc $opts{build};
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   760
	my $inst=uc $opts{'inst'};
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   761
	if ($inst eq "MARM") {
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   762
		# Hackery to cope with old compiler
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   763
		$main="MARM";
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   764
		$euserdir="MARM";
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   765
		$elocldir="MARM";
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   766
	}
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   767
	else {
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   768
		$main=$inst;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   769
		if ($main eq "THUMB") {
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   770
			$euserdir="ARMI";
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   771
		} else {
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   772
			$euserdir=$main;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   773
		}
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   774
		if ($main eq "ARMI" or $main eq "THUMB") {
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   775
			$elocldir="ARM4";
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   776
		} else {
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   777
			$elocldir=$main;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   778
		}
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   779
	}
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   780
	$kmain = $opts{'xabi'};
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   781
	$kmain = $main unless ($kmain);
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   782
	if (IsSmp($kmain)) {
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   783
		$euserdir = $kmain;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   784
	}
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   785
	if ($opts{name}) {
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   786
		$romname=$opts{name};
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   787
	} else {
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   788
		$romname=uc($opts{variant}.$additional.$main);
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   789
		if ($build=~/^\w*DEB$/i) {
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   790
			$romname.='D';
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   791
		}
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   792
		$romname.='.IMG';
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   793
	}
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   794
}
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   795
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   796
sub lookupFileInfo($$)
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   797
{
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   798
	my ($infile, $fullname) = @_;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   799
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   800
	my ($name, $ext) = $fullname =~ /^(.+)\.(\w+)$/ ? ($1, $2) : ($fullname, undef);
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   801
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   802
	open TMP, $infile or die("Can't open $infile\n");
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   803
	while(<TMP>)
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   804
	{
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   805
		$_ = lc;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   806
		if(/^\s*(\S+)\s*=\s*(\S+)\s+(\S+)/i)
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   807
		{
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   808
			my ($src, $dest) = ($2, $3);
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   809
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   810
			my $destFullname = $dest =~ /^.*\\(.+)$/ ? $1 : $dest;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   811
			my ($destName, $destExt) = $destFullname =~ /^(.+?)\.(\w+)$/ ? ($1, $2) : ($destFullname, undef);
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   812
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   813
			if ($destName eq $name && (!$ext || $ext eq $destExt))
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   814
			{
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   815
				close TMP;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   816
				return ($src, $dest);
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   817
			}
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   818
		}
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   819
	}
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   820
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   821
	die "patchdata: Can't find file $fullname\n";
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   822
}
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   823
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   824
sub lookupSymbolInfo($$)
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   825
{
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   826
	my ($file, $name) = @_;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   827
	open TMP, $file or die "Can't read $file\n";
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   828
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   829
	# ignore local symbols.
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   830
	while (<TMP>)
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   831
	{
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   832
		last if /Global Symbols|Linker script and memory map/;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   833
	}
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   834
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   835
  my @return_values = ();
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   836
  my $line;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   837
	while ($line = <TMP>)
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   838
	{
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   839
		next if (index($line, $name) < 0);		
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   840
		
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   841
		# RVCT 2.2
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   842
		# 
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   843
		#     KHeapMinCellSize  0x0004e38c  Data 4  mem.o(.constdata)
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   844
		#
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   845
		if ($line =~ /^\s*(\S+)\s+(\S+)\s+data\s+(\S+)/i)
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   846
		{
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   847
			my ($symbol, $addr, $size) = ($1, $2, $3);
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   848
			if ($symbol eq $name)
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   849
			{
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   850
				@return_values = ($addr, $size);
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   851
				last;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   852
			}
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   853
		}
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   854
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   855
		# This is a quick fix for RVCT 3.1, which uses the text "(EXPORTED)"
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   856
		# in the map file. Here is an example:
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   857
		#
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   858
		# KHeapMinCellSize (EXPORTED) 0x0003d81c Data 4 mem.o(.constdata)
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   859
		#
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   860
		elsif ($line =~ /^\s*(\S+)\s+\(exported\)\s+(\S+)\s+data\s+(\S+)/i)
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   861
		{
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   862
			my ($symbol, $addr, $size) = ($1, $2, $3);
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   863
			if ($symbol eq $name)
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   864
			{
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   865
				@return_values = ($addr, $size);
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   866
				last;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   867
			}
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   868
		}
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   869
		
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   870
		# GCC 4.x map files
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   871
		#                 0x00114c68                KHeapMinCellSize
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   872
		#                 0x00114c6c                KHeapShrinkHysRatio
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   873
		#  .rodata        0x00115130      0x968 M:/epoc32/build/kernel/c_99481fddbd6c6f58/_omap3530_ekern_exe/armv5/udeb/heap_hybrid.o
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   874
		#
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   875
		elsif ($line =~ /^.+\s+(0x\S+)\s+(\S+)/i)
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   876
		{
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   877
			my ($addr, $symbol) = ($1, $2);
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   878
			if ($symbol eq $name)
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   879
			{
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   880
				my $next_line = <TMP>;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   881
				if ($next_line =~ /^.+\s+(0x\S+)\s+(\S+)/i)
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   882
				{
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   883
					my $addr2 = $1;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   884
					
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   885
					@return_values = ($addr, hex($addr2) - hex($addr));
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   886
					last;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   887
				}
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   888
			}
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   889
		}
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   890
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   891
	}
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   892
	close TMP;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   893
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   894
	die "patchdata: Can't find symbol $name\n" if (scalar @return_values == 0);
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   895
	return @return_values;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   896
}
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   897
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   898
sub parsePatchData($$)
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   899
{
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   900
	my ($infile, $outfile) = @_;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   901
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   902
	open IN, $infile or die("Can't read $infile\n");
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   903
	open OUT, ">$outfile" or die("Can't write $outfile\n");
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   904
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   905
	my $line;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   906
	while($line = <IN>)
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   907
	{
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   908
		if ($line =~ /^\s*patchdata\s+(.+?)\s*$/i)
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   909
		{
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   910
			if ($1 !~ /(\S+)\s*@\s*(\S+)\s+(\S+)\s*$/)
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   911
			{
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   912
				die "Bad patchdata command: $line\n";
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   913
			}
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   914
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   915
			my ($file, $symbol, $value) = (lc $1, $2, $3);
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   916
			my ($srcFile, $destFile) = lookupFileInfo($infile, $file);
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   917
			my ($index, $elementSize) = (undef, undef);
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   918
			if ($symbol =~ s/:(\d+)\[(\d+)\]$//)
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   919
			{
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   920
				($index, $elementSize) = ($2, $1);
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   921
				$index = hex($index) if $index =~ /^0x/i;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   922
			}
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   923
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   924
			if ($srcFile =~ /\\armv5(smp)?\\/i)
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   925
			{
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   926
				my ($symbolAddr, $symbolSize) = lookupSymbolInfo("$srcFile.map", $symbol);
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   927
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   928
				my $max;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   929
				if (defined($index))
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   930
				{
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   931
					my $bytes;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   932
					$bytes = 1, $max = 0xff       if $elementSize ==  8;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   933
					$bytes = 2, $max = 0xffff     if $elementSize == 16;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   934
					$bytes = 4, $max = 0xffffffff if $elementSize == 32;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   935
					die("patchdata: invalid element size $elementSize: $line\n") unless defined($bytes);
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   936
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   937
					if ($bytes > 1 && (($symbolSize & ($bytes-1)) != 0))
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   938
					{
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   939
						die("patchdata: unexpected symbol size $symbolSize for array $symbol ($elementSize-bit elements)\n");
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   940
					}
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   941
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   942
					if ($index >= int($symbolSize / $bytes))
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   943
					{
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   944
						die("patchdata: index $index out of bounds for $symbol of $symbolSize bytes ($elementSize-bit elements)\n");
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   945
					}
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   946
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   947
					$symbolAddr = hex($symbolAddr) if $symbolAddr =~ /^0x/i;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   948
					$symbolAddr += $index * $bytes;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   949
					$symbolAddr = sprintf("0x%x", $symbolAddr);
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   950
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   951
					$symbolSize = $bytes;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   952
				}
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   953
				elsif ($symbolSize == 1) { $max = 0xff; }
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   954
				elsif ($symbolSize == 2) { $max = 0xffff; }
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   955
				elsif ($symbolSize == 4) { $max = 0xffffffff; }
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   956
				else { die "patchdata: Unexpected symbol size $symbolSize for $symbol\n"; }
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   957
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   958
				$value = hex($value) if $value =~ /^0x/i;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   959
				if ($value > $max)
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   960
				{
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   961
					print("Warning:  Value overflow of $symbol\n");
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   962
					$value &= $max;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   963
				}					
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   964
				$value = sprintf("0x%08x", $value);
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   965
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   966
				$line = "patchdata $destFile addr $symbolAddr $symbolSize $value\n";
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   967
			}
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   968
			else
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   969
			{
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   970
				$line = "";
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   971
			}
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   972
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   973
		}
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   974
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   975
		print OUT $line;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   976
	}
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   977
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   978
	close IN;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   979
	close OUT;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   980
}
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   981
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   982
sub genfile {
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   983
	my $count=0;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   984
	if($_[0] eq 'paged') {
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   985
		my $file='gentestpaged.txt';
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   986
		unlink $file;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   987
		open(OUTFILE, ">$file") or die "Can't open output file, $!";
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   988
		for(my $i=0;$i<50000;++$i) {
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   989
			if(($i >5) && ($i % 40 ==0)) {
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   990
			print OUTFILE "\n";
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   991
			$count++;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   992
			} 
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   993
			if(($i+$count) % 5 ==0) {
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   994
			print OUTFILE "SATOR ";
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   995
			}
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   996
			if(($i+$count) % 5 ==1) {
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   997
			print OUTFILE "AREPO ";
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   998
			}
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   999
			if(($i+$count) % 5 ==2) {
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
  1000
			print OUTFILE "TENET ";
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
  1001
			}
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
  1002
			if(($i+$count) % 5 ==3) {
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
  1003
			print OUTFILE "OPERA ";
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
  1004
			}
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
  1005
			if(($i+$count) % 5 ==4) {
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
  1006
			print OUTFILE "ROTAS ";
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
  1007
			}
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
  1008
		}
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
  1009
	} else {
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
  1010
		my $file='gentestnonpaged.txt';
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
  1011
		unlink $file;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
  1012
		open(OUTFILE, ">$file") or die "Can't open output file, $!";
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
  1013
		for(my $i=0;$i<20000;++$i) {
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
  1014
			if(($i >5) && ($i % 40 ==0)) {
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
  1015
			print OUTFILE "\n";
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
  1016
			$count++;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
  1017
			} 
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
  1018
			if(($i+$count) % 4 ==0) {
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
  1019
			print OUTFILE "STEP ";
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
  1020
			}
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
  1021
			if(($i+$count) % 4 ==1) {
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
  1022
			print OUTFILE "TIME ";
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
  1023
			}
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
  1024
			if(($i+$count) % 4 ==2) {
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
  1025
			print OUTFILE "EMIT ";
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
  1026
			}
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
  1027
			if(($i+$count) % 4 ==3) {
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
  1028
			print OUTFILE "PETS ";
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
  1029
			}
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
  1030
		}
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
  1031
	}
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
  1032
}
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
  1033
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
  1034
sub Variant_GetMacroHRHFile {
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
  1035
	my $cfgFile =  File::Spec->catfile($toolpath,"variant","variant.cfg"); # default location
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
  1036
	# save the volume, if any.
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
  1037
	my ($cfg_vol,$ignore1,$ignore2) = File::Spec->splitpath($cfgFile);    
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
  1038
    my $file;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
  1039
    if(-e $cfgFile){
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
  1040
		open(FILE, $cfgFile) || die "\nCould not open for reading: " . $cfgFile ."\n";
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
  1041
		while (<FILE>) {
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
  1042
			# strip comments
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
  1043
			s/^([^#]*)#.*$/$1/o;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
  1044
			# skip blank lines
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
  1045
			if (/^\s*$/o) {
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
  1046
				next;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
  1047
			}
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
  1048
			# get the hrh file
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
  1049
			if($_ =~ /\.hrh/xi){
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
  1050
				$file = $_; 
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
  1051
				last;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
  1052
			}
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
  1053
		}
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
  1054
		close FILE;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
  1055
		die "\nERROR: No variant file specified in $cfgFile!\n" unless $file;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
  1056
		$file =~ s/\s+//g;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
  1057
		$file =~ s|\\|\/|g, unless($on_windows);
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
  1058
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
  1059
		if ($on_windows) {
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
  1060
			if (File::Spec->file_name_is_absolute($file)) {
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
  1061
				my ($vol,$dir,$leaf) = File::Spec->splitpath($file);
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
  1062
				unless ( $vol) {
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
  1063
					$vol = substr $epocroot,0,2;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
  1064
					$file = substr $file,1;                 
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
  1065
					$file = File::Spec->catfile($epocroot,$dir,$leaf);
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
  1066
				}
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
  1067
				die "\nERROR: Variant file specified in $cfgFile is not on the same volume as EPOCROOT\n", if (lc($vol) ne lc($cfg_vol));
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
  1068
			}
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
  1069
			else {
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
  1070
				$file = File::Spec->catfile($epoc32path,$file);
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
  1071
			}
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
  1072
		}
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
  1073
		elsif (File::Spec->file_name_is_absolute($file) && ! -e $file) {
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
  1074
			$file = File::Spec->catfile($epocroot,$file);
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
  1075
		} 
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
  1076
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
  1077
		unless(-e $file) {
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
  1078
			die "\nERROR: $cfgFile specifies $file which doesn't exist!\n";
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
  1079
		}
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
  1080
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
  1081
		$file =~ s/\//\\/g, if ($on_windows);
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
  1082
    }
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
  1083
    return $file;
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
  1084
}
d82e43335b24 Add the portable rombuild wrapper romnibus.pl to make it available for Windows as well as Linux
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
  1085