sbsv1/abld/e32util/epocaif.pl
author lorewang
Wed, 01 Dec 2010 16:05:36 +0800
changeset 715 e0739b8406dd
parent 599 fa7a3cc6effd
permissions -rw-r--r--
Specify extenal tool with path
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
599
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
     1
# Copyright (c) 2001-2009 Nokia Corporation and/or its subsidiary(-ies).
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
     2
# All rights reserved.
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
     3
# This component and the accompanying materials are made available
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
     4
# under the terms of "Eclipse Public License v1.0"
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
     5
# which accompanies this distribution, and is available
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
     6
# at the URL "http://www.eclipse.org/legal/epl-v10.html".
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
     7
#
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
     8
# Initial Contributors:
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
     9
# Nokia Corporation - initial contribution.
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    10
#
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    11
# Contributors:
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    12
#
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    13
# Description:
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    14
# Wrapper to support the EPOC AIF Compiler
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    15
# 
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    16
#
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    17
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    18
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    19
use FindBin;		# for FindBin::Bin
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    20
use File::Copy;		# for copy()
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    21
use Cwd;		# for cwd
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    22
use File::Basename;	# for basename()
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    23
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    24
my $PerlBinPath;	# fully qualified pathname of the directory containing this script
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    25
my $curdrive="x";	    	# will be initialised when first needed
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    26
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    27
# establish the path to the Perl binaries
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    28
BEGIN {
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    29
	require 5.005_03;		# check user has a version of perl that will cope
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    30
	$PerlBinPath = $FindBin::Bin;	# X:/epoc32/tools
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    31
	$PerlBinPath =~ s/\//\\/g;	# X:\epoc32\tools
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    32
}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    33
use lib $PerlBinPath;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    34
use E32Variant;         # for variant specific macros
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    35
use Pathutl;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    36
use Preprocessor;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    37
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    38
sub print_usage
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    39
	{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    40
#........1.........2.........3.........4.........5.........6.........7.....
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    41
	print <<USAGE_EOF;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    42
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    43
Usage:
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    44
  epocaif [options] srcfile [-o outputfile] [-t tmpdir] [-b "bmps" | -m mbm] [-l "TargetPath:CWD"]
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    45
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    46
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    47
The available options are
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    48
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    49
   -Ixxx  -- C++ preprocessor arguments
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    50
   -o	  -- output AIF file name including path
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    51
   -t	  -- tempory directory for intermediate files
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    52
   -b	  -- list of bitmaps Eg., "-b/c8\\location\\bmp1 /c8\\location\\bmp2.."
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    53
   -m	  -- compiled MBM file (alternative to -b)
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    54
   -l	  -- if specified, captures all source to \\epoc32\\localisation\\...
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    55
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    56
The aif resource file is then passed through the C++ preprocessor, using any 
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    57
specified preprocessor arguments, and then compiled with RCOMP.EXE to 
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    58
generate a compiled resource.
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    59
The -m or -b option is used to generate a suitable MBM file, if required.
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    60
The MBM and the compiled resource are then combined to produce an AIF file.
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    61
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    62
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    63
USAGE_EOF
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    64
	}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    65
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    66
#-------------------------------------------------------
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    67
# Process commandline arguments
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    68
#
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    69
# Can't use the Getopt package because it doesn't like the -D and -I style options
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    70
#
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    71
my $sourcefile="";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    72
my $opt_o="";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    73
my $opt_h="";	
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    74
my $tmpdir="";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    75
my $opt_v=1;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    76
my $opt_b="";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    77
my $opt_l="";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    78
my $opt_m="";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    79
my $TrgPath;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    80
my $xipaif=1;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    81
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    82
my $exe = &PreprocessorToUseExe();
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    83
my $cpp_spec= "$exe -undef -C ";	    # preserve comments
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    84
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    85
my $errors = 0;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    86
while (@ARGV)
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    87
	{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    88
	my $arg = shift @ARGV;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    89
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    90
	if ($arg =~ /^-I-$/)
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    91
		{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    92
		$cpp_spec .= "-I- ";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    93
		next;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    94
		}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    95
	if ($arg =~ /^-I(.*)$/)
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    96
		{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    97
		$cpp_spec .= "-I ";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    98
		if ($1 eq "")
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    99
		    {
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   100
		    $arg = shift @ARGV;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   101
		    }
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   102
		else
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   103
		    {
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   104
		    $arg = $1;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   105
		    }
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   106
		$cpp_spec .= quoted_path($arg)." ";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   107
		next;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   108
		}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   109
	if ($arg =~ /^-v$/)
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   110
		{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   111
		$opt_v =1;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   112
		next;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   113
		}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   114
	if ($arg =~ /^-o(.*)$/)
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   115
		{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   116
		$opt_o =$1;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   117
		$TrgPath = $opt_o;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   118
		next;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   119
		}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   120
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   121
	if ($arg =~ /^-t(.*)\\?$/)
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   122
		{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   123
		$tmpdir =$1;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   124
		next;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   125
		}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   126
	if ($arg =~ /^-b(.*)$/)
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   127
		{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   128
		$opt_b =$1;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   129
		next;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   130
		}	
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   131
	if ($arg =~ /^-m(.*)$/)
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   132
		{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   133
		$opt_m =$1;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   134
		next;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   135
		}	
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   136
	if ($arg =~ /^-l(.*)$/)
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   137
		{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   138
		$opt_l =$1;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   139
		next;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   140
		}	
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   141
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   142
	if ($arg =~ /^-/)
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   143
		{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   144
		print "Unknown arg: $arg\n";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   145
		$errors++;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   146
		next;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   147
		}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   148
	$sourcefile=$arg;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   149
	}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   150
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   151
if ($opt_m ne "" && $opt_b ne "")
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   152
	{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   153
	print "Can't specify both -m and -b\n";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   154
	$errors++;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   155
	}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   156
if ($errors || $sourcefile eq "")
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   157
	{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   158
	print_usage();
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   159
	exit 1;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   160
	}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   161
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   162
my $rss_base = basename($sourcefile);
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   163
my ($rssfile) = split(/\./, $rss_base);	    # remove extension
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   164
my $rpp_name = "$tmpdir\\$rssfile.rpp";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   165
my $outputfile="$tmpdir\\AIF.RSC";	
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   166
my $headerfile=$opt_h;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   167
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   168
if ($opt_v)
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   169
	{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   170
	print "* Source file:   $sourcefile\n";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   171
	print "* Resource file: $outputfile\n" if ($outputfile ne "");
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   172
	}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   173
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   174
$opt_o = "-o\"$outputfile\"" if ($outputfile ne "");
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   175
$opt_h = "-h\"$headerfile\"" if ($headerfile ne "");
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   176
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   177
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   178
#-------------------------------------------------------
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   179
# Run the preprocessor
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   180
#
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   181
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   182
my $variantMacroHRHFile = Variant_GetMacroHRHFile();
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   183
if($variantMacroHRHFile){
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   184
    my $variantFilePath = Path_Split('Path',$variantMacroHRHFile);
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   185
    chop ( $variantFilePath );
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   186
    $cpp_spec .= " -I \"" . &Path_RltToWork($variantFilePath) . "\" -include " . &Path_RltToWork($variantMacroHRHFile) . " "; 
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   187
}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   188
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   189
$cpp_spec .= "-I $PerlBinPath\\..\\include ";	# extra path to support shared tools
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   190
$cpp_spec .= "-D_UNICODE ";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   191
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   192
$cpp_spec .= quoted_path($sourcefile) ." -o ". quoted_path($rpp_name);
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   193
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   194
print "* $cpp_spec\n" if ($opt_v);
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   195
system($cpp_spec);
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   196
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   197
my $cpp_status = $?;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   198
die "* cpp failed\n" if ($cpp_status != 0);
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   199
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   200
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   201
#-------------------------------------------------------
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   202
# Copy source to epoc32\localisation
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   203
#
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   204
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   205
if ($opt_l ne "")
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   206
{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   207
use lockit_info;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   208
	my ($rssfile, $FileType) = split(/\./, basename($TrgPath));
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   209
	&Lockit_SrcFile($rssfile, $rpp_name, $opt_l, $FileType, $opt_b);
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   210
}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   211
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   212
#-------------------------------------------------------
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   213
# Merge rls strings to rpp
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   214
#
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   215
&Merge_rls_string($rpp_name);
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   216
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   217
#-------------------------------------------------------
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   218
# Run the resource compiler
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   219
#
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   220
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   221
my $rcomp_spec = "rcomp -u ";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   222
$rcomp_spec .= "-:$tmpdir\\_dump_of_resource_ "; # causes Rcomp to dump each resource (uncompressed and unpadded) in $tmpdir\\_dump_of_resource_1, $tmpdir\\_dump_of_resource_2, etc
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   223
$rcomp_spec .= "$opt_o $opt_h -s\"$rpp_name\" -i\"$sourcefile\"";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   224
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   225
print "* $rcomp_spec\n" if ($opt_v);
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   226
system($rcomp_spec);
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   227
if ($? != 0)
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   228
	{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   229
	print "* RCOMP failed - deleting output files\n";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   230
	unlink $outputfile if ($outputfile ne "");
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   231
	unlink $headerfile if ($headerfile ne "");
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   232
	exit 1;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   233
	}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   234
print "* deleting $rpp_name\n" if ($opt_v);
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   235
unlink $rpp_name;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   236
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   237
#-------------------------------------------------------
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   238
# Run bmconv, if needed
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   239
#
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   240
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   241
if ($opt_b ne "")
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   242
	{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   243
	print "* bmconv /q $tmpdir\\AIF.MBM $opt_b\n" if ($opt_v);
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   244
	system("bmconv /q $tmpdir\\AIF.MBM $opt_b");
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   245
	if ($? != 0)
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   246
		{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   247
		print "* BMCONV failed\n";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   248
		exit 1;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   249
		}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   250
	print "* bmconv /q /s $tmpdir\\AIF_XIP.MBM $opt_b\n" if ($opt_v);
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   251
	system("bmconv /q /s $tmpdir\\AIF_xip.MBM $opt_b");
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   252
	
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   253
	if ($? != 0)
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   254
		{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   255
		print "* BMCONV failed\n";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   256
		exit 1;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   257
		}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   258
	}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   259
elsif ($opt_m ne "")
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   260
	{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   261
	print "* copy $opt_m $tmpdir\\AIF.MBM\n" if ($opt_v); 
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   262
	copy($opt_m, "$tmpdir\\AIF.MBM");
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   263
	# no xip file genarated 
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   264
	$xipaif=0;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   265
	}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   266
else
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   267
	{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   268
	# no bitmap specified - this is legitimate
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   269
	unlink("$tmpdir\\AIF.MBM");
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   270
	unlink("$tmpdir\\AIF_xip.MBM");
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   271
	}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   272
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   273
#-------------------------------------------------------
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   274
# Get the from UID from the first four bytes of "$tmpdir\\_dump_of_resource_1"
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   275
#
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   276
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   277
open(DUMP_OF_RESOURCE_1, "< $tmpdir\\_dump_of_resource_1") or die("* Can't open dump file\n");
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   278
binmode(DUMP_OF_RESOURCE_1);
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   279
my $data;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   280
my $numberOfBytesRead=read(DUMP_OF_RESOURCE_1, $data, 4);
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   281
defined($numberOfBytesRead) or die("* Can't read from dump file\n");
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   282
($numberOfBytesRead>=4) or die("* Dump file too short\n");
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   283
my $uid=(unpack('V', $data))[0];
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   284
undef($data);
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   285
undef($numberOfBytesRead);
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   286
close(DUMP_OF_RESOURCE_1) or die("* Can't close dump file\n");
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   287
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   288
#-------------------------------------------------------
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   289
# Produce the AIF file from the RSC and MBM files
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   290
#
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   291
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   292
my $uidcrc = "uidcrc.exe 0x101fb032 0 ".sprintf('0x%08x', $uid)." $tmpdir\\out.aif";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   293
my $uidcrc_xip = "uidcrc.exe 0x101fb032 0 ".sprintf('0x%08x', $uid)." $tmpdir\\out_xip.aif";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   294
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   295
print "* $uidcrc\n" if ($opt_v);
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   296
system($uidcrc);
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   297
if ($? != 0)
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   298
	{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   299
	print "* UIDCRC failed\n";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   300
	exit 1;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   301
	}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   302
if ($xipaif ne 0)
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   303
	{	
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   304
	print "* $uidcrc\n" if ($opt_v);
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   305
	system($uidcrc_xip);
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   306
	if ($? != 0)
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   307
		{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   308
		print "* UIDCRC failed\n";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   309
		exit 1;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   310
		}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   311
	}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   312
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   313
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   314
open(OUT_AIF, ">> $tmpdir\\out.aif") or die("* Can't open temporary file\n");
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   315
binmode(OUT_AIF);
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   316
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   317
if ($xipaif ne 0)
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   318
	{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   319
	open(OUTXIP_AIF, ">> $tmpdir\\out_xip.aif") or die("* Can't open temporary file\n");
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   320
	binmode(OUTXIP_AIF);
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   321
	}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   322
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   323
print "* Writing length of the RSC-block\n" if ($opt_v);
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   324
my $lengthOfRscBlock=-s("$tmpdir\\aif.rsc");
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   325
my $numberOfPaddingBytes=(4-($lengthOfRscBlock%4))%4;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   326
print(OUT_AIF pack('V', $lengthOfRscBlock));
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   327
if ($xipaif ne 0)
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   328
	{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   329
	print(OUTXIP_AIF pack('V', $lengthOfRscBlock));
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   330
	}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   331
print "* Appending the RSC-block\n" if ($opt_v);
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   332
&appendFile(\*OUT_AIF, "$tmpdir\\aif.rsc");
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   333
if ($xipaif ne 0)
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   334
	{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   335
	&appendFile(\*OUTXIP_AIF, "$tmpdir\\aif.rsc");
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   336
	}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   337
# append any necessary padding bytes so that the file-offset of the start of the MBM-block is a multiple of 4-bytes
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   338
print(OUT_AIF ('_' x $numberOfPaddingBytes));
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   339
if ($xipaif ne 0)
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   340
	{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   341
	print(OUTXIP_AIF ('_' x $numberOfPaddingBytes));
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   342
	}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   343
if (-e("$tmpdir\\aif.mbm"))
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   344
	{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   345
	print "* Appending the MBM-block\n" if ($opt_v);
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   346
	&appendFile(\*OUT_AIF, "$tmpdir\\aif.mbm");
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   347
	}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   348
if (-e("$tmpdir\\aif_xip.mbm"))
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   349
	{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   350
	print "* Appending the XIPMBM-block\n" if ($opt_v);
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   351
	&appendFile(\*OUTXIP_AIF, "$tmpdir\\aif_xip.mbm");
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   352
	}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   353
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   354
close(OUT_AIF) or die("* Can't close temporary file\n");
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   355
if ($xipaif ne 0)
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   356
	{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   357
	close(OUTXIP_AIF) or die("* Can't close temporary file\n");
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   358
	}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   359
print "* copy $tmpdir\\out.aif $TrgPath\n" if ($opt_v);
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   360
copy("$tmpdir\\out.aif", "$TrgPath");
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   361
if ($xipaif ne 0)
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   362
	{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   363
	my $basepath = &Path_Split('Path', $TrgPath);
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   364
	my $ext=&Path_Split('Ext',  $TrgPath);
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   365
	my $basename = basename($TrgPath, $ext);
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   366
	my $xip="_xip";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   367
	print "* copy $tmpdir\\out_xip.aif $basepath$basename$xip$ext\n" if ($opt_v);
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   368
	copy("$tmpdir\\out_xip.aif", "$basepath$basename$xip$ext");
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   369
	}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   370
unlink("$tmpdir\\_dump_of_resource_*");
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   371
unlink("$tmpdir\\aif.rsc");
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   372
unlink("$tmpdir\\aif.mbm");
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   373
unlink("$tmpdir\\out.aif");
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   374
unlink("$tmpdir\\aif_xip.mbm");
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   375
unlink("$tmpdir\\out_xip.aif");
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   376
exit 0;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   377
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   378
#-------------------------------------------------------
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   379
# Subroutine: convert path into something acceptable to CPP.EXE
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   380
#
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   381
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   382
sub quoted_path
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   383
    {
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   384
    my ($arg) = @_;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   385
    return "\"$arg\"" if ($arg !~ /^\\[^\\]/);	# not an absolute path
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   386
    if ($curdrive eq "x")
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   387
		{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   388
		$curdrive="";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   389
		$curdrive=$1 if (cwd =~ /^(.:)/);	
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   390
		}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   391
    return "\"$curdrive$arg\"";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   392
    }
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   393
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   394
#-------------------------------------------------------
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   395
# Subroutine: Merge the rls strings in the rpp file specified
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   396
#
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   397
sub Merge_rls_string
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   398
	{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   399
	my ($rppfile) = @_;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   400
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   401
	my $line;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   402
	my $StringId;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   403
	my $key;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   404
	my $value;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   405
	my $StringToSubstitute;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   406
	my %ResourceString;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   407
	
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   408
	print "* merging text strings to $rppfile\n" if ($opt_v);
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   409
	
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   410
	open NEWRPP, ">$rppfile.new" or die "* Can't write to $rppfile.new";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   411
	open RPP, "$rppfile" or die "* Can't open $rppfile";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   412
	
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   413
	while ($line = <RPP>) 	{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   414
		while (($StringId, $StringToSubstitute)=each %ResourceString)
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   415
		{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   416
			$line=~s/\b$StringId\b/$StringToSubstitute/g if ($line !~ /^rls_string/);
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   417
		}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   418
	
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   419
		# find quoted "" strings
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   420
		if($line =~ /^rls_string\s+(\S+)\s+(.*$)/)
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   421
		{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   422
			my $text = $2;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   423
			$key = $1;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   424
			$line=~s/(.*)/\/\/$1/;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   425
			my $substr_count = 0;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   426
			if(!exists $ResourceString{$key})
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   427
			{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   428
			SUBSTR:	while (1)
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   429
			{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   430
				# find quoted "" strings e.g. "hello"
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   431
				if($text =~ /^(\s*\"(.*?\\.)*.*?\")/)		
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   432
				{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   433
					$value = $1;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   434
					$text = $';
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   435
					++$substr_count;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   436
				}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   437
	
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   438
				# find quoted '' strings. e.g. 'world'
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   439
				elsif($text =~ /^(\s*\'(.*?\\.)*.*?\')/)			
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   440
				{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   441
					$value = $1;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   442
					$text = $';
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   443
					++$substr_count;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   444
				}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   445
	
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   446
				# find hex strings e.g. <0x34><0x45><0x65>
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   447
				elsif($text =~ /^(\s*(<.*?>)+)/)		
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   448
				{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   449
					$value = $1;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   450
					$text = $';
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   451
					++$substr_count;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   452
				}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   453
	
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   454
				# find c comment e.g. /*hello world*/ (may exist between strings)
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   455
				elsif($text =~ /^(\s*\/\*.*?\*\/)/)		
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   456
				{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   457
					$text = $';
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   458
					next SUBSTR; # ignore embedded comment
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   459
				}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   460
	
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   461
				# find c++ comment e.g. //hello world (may exist after strings)
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   462
				elsif($text =~ /^(\s*\/\/.*$)/)		
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   463
				{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   464
					$text = $';
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   465
					next SUBSTR; # ignore trailing comment
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   466
				}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   467
	
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   468
				# exit search
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   469
				else
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   470
				{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   471
					if ($substr_count == 0)
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   472
					{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   473
						warn("WARNING: rls_string $key either has incorrect syntax or no value\n");
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   474
					}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   475
					last SUBSTR;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   476
				}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   477
			$ResourceString{$key} .= $value;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   478
			}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   479
		  	}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   480
		}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   481
		print NEWRPP $line;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   482
	}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   483
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   484
	close RPP;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   485
	close NEWRPP;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   486
	copy ("$rppfile.new", "$rppfile");
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   487
	unlink ("$rppfile.new");
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   488
	}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   489
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   490
#-------------------------------------------------------
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   491
# Subroutine: Append a file into the open (binary) file already opened
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   492
#
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   493
sub appendFile
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   494
	{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   495
	my $fileHandleOfTarget=shift;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   496
	my $fileNameOfSource=shift;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   497
	open(SOURCE, "< $fileNameOfSource") or die("* Can't open $fileNameOfSource\n");
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   498
	binmode(SOURCE);
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   499
	for (;;)
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   500
		{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   501
		my $data;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   502
		my $numberOfBytesRead=read(SOURCE, $data, 1024);
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   503
		defined($numberOfBytesRead) or die("* Can't read from $fileNameOfSource\n");
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   504
		if ($numberOfBytesRead==0)
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   505
			{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   506
			last;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   507
			}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   508
		print($fileHandleOfTarget $data);
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   509
		}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   510
	close(SOURCE) or die("* Can't close $fileNameOfSource\n");
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   511
	}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   512