sbsv1/abld/e32util/epocrc.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) 2000-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 Resource 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
use warnings;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    19
use Cwd;		# for cwd
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    20
use FindBin;		# for FindBin::Bin
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    21
use File::Copy;		# for copy()
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    22
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    23
my $curdrive="x";	    	# will be initialised when first needed
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
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    26
# establish the path to the Perl binaries
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    27
BEGIN {
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    28
	require 5.005_03;		# check user has a version of perl that will cope
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    29
	$PerlBinPath = $FindBin::Bin;	# X:/epoc32/tools
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    30
	$PerlBinPath =~ s/\//\\/g;	# X:\epoc32\tools
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    31
}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    32
use lib $PerlBinPath;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    33
use lockit_info;
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
  epocrc [options] srcfile [-ooutputfile] [-hheaderfile] [-l "TargetPath:CWDir"]  
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    45
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    46
Compile an EPOC resource file, optionally generating a compiled resource 
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    47
file and an associated header file.
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    48
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    49
The available options are
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    50
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    51
   -Dxxx, -Ixxx      -- C++ preprocessor arguments
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    52
   -preincludeFILE   -- optional FILE to be used as a preinclude file in all preprocessing
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    53
   -u                -- compile for use with Unicode EPOC
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    54
   -ttmpdir          -- specify a directory for temporary files
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    55
   -nocpp            -- do not call C++ preprocessor
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    56
   -l                -- if specified, capture all source to \\epoc32\\localisation\\... 
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    57
   -uid2 N           -- specifies 2nd UID for output file
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    58
   -uid3 N           -- specifies 3rd UID for output file 
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    59
   -m[nnn](,[nnn])*  -- suppress warning nnn in rcomp, can supply multiple 
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    60
                        comma-separated three digit values
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    61
   -v                -- verbose output
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    62
   -vv               -- more verbose, -v passed to rcomp			
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    63
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    64
See the file epocrc.config for futher usage options.
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    65
   
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    66
The resource file is first passed through the C++ preprocessor, using any 
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    67
specified preprocessor arguments, and then compiled with RCOMP.EXE to 
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    68
generate a compiled resource and the associated header file. 
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    69
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    70
All intermediate files are generated into a temporary directory.
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    71
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    72
Specifying either -uid2 or -uid3 overrides all uids specified in the source file.
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    73
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    74
If -preinclude FILE is not specified, the preinclude file listed in
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    75
%EPOCROOT%epoc32\\tools\\variant\\variant.cfg is used in all preprocessing.
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    76
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    77
USAGE_EOF
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    78
	}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    79
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    80
#-------------------------------------------------------
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    81
# Process commandline arguments
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    82
#
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    83
# 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
    84
#
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    85
my $opt_uid2='';
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    86
my $opt_uid3='';
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    87
my $sourcefile="";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    88
my $opt_o="";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    89
my $opt_m="";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    90
my $opt_h="";	
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    91
my $opt_l="";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    92
my $tmpdir="";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    93
my $unicode=0;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    94
my $opt_v=0;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    95
my $opt_vmore=0;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    96
my $opt_cpp = 1;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    97
my $check_rls_items = 0;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    98
my $strict_checking = 0;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    99
my $test_mode = 0;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   100
my $warnings_to_enable = 0;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   101
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   102
my $variantMacroHRHFile = "";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   103
my $exe = &PreprocessorToUseExe();
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   104
my $cpp_spec= "$exe -nostdinc -undef -C ";	    # preserve comments
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   105
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   106
my $errors = 0;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   107
while (@ARGV)
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   108
	{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   109
	my $arg = shift @ARGV;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   110
	if ($arg =~ /^-D(.*)$/)
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   111
		{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   112
		if ($1 eq "")
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   113
		    {
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   114
		    $arg = shift @ARGV;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   115
		    $cpp_spec .= "-D \"$arg\" ";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   116
		    }
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   117
		else
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   118
		    {
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   119
		    $cpp_spec .= "$arg ";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   120
		    }
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   121
		next;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   122
		}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   123
	if ($arg =~ /^-I-$/)
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   124
		{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   125
		$cpp_spec .= "-I- ";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   126
		next;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   127
		}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   128
	if ($arg =~ /^-I(.*)$/)
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   129
		{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   130
		$cpp_spec .= "-I ";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   131
		if ($1 eq "")
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   132
		    {
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   133
		    $arg = shift @ARGV;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   134
		    }
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   135
		else
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   136
		    {
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   137
		    $arg = $1;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   138
		    }
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   139
		$cpp_spec .= quoted_path($arg)." ";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   140
		next;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   141
		}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   142
	if ($arg =~ /^-preinclude(.*)$/)
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   143
		{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   144
		$variantMacroHRHFile = $1;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   145
		next;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   146
		}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   147
	if ($arg =~ /^-v$/)
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   148
		{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   149
		$opt_v =1;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   150
		next;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   151
		}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   152
	if ($arg =~ /^-vv$/)
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   153
		{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   154
		$opt_vmore =1;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   155
		$opt_v =1;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   156
		next;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   157
		}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   158
	if ($arg =~ /^-nocpp$/)
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   159
		{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   160
		$opt_cpp =0;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   161
		next;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   162
		}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   163
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   164
	if ($arg =~ /^-uid2$/)
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   165
		{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   166
		$opt_uid2 = shift @ARGV;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   167
		next;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   168
		}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   169
	
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   170
	if ($arg =~ /^-uid3$/)
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   171
		{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   172
		$opt_uid3 = shift @ARGV;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   173
		next;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   174
		}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   175
	
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   176
	if ($arg =~ /^-u$/)
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   177
		{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   178
		$unicode =1;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   179
		next;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   180
		}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   181
	if ($arg =~ /^-o(.*)$/)
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   182
		{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   183
		$opt_o =$1;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   184
		next;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   185
		}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   186
	if ($arg =~ /^-h(.*)$/)
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   187
		{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   188
		$opt_h =$1;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   189
		next;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   190
		}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   191
	if ($arg =~ /^-t(.*)\\?$/)
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   192
		{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   193
		$tmpdir ="$1\\";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   194
		next;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   195
		}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   196
	if ($arg =~ /^-l(.*)$/)
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   197
		{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   198
		$opt_l =$1;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   199
		next;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   200
		}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   201
	if($arg =~ /^(-m.*)$/)
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   202
		{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   203
		$opt_m =$1;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   204
		next;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   205
		}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   206
	if ($arg =~ /^-epocrc-test$/)
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   207
		{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   208
		$test_mode = 1;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   209
		next;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   210
		}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   211
	if ($arg =~ /^-/)
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   212
		{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   213
		print "Unknown arg: $arg\n";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   214
		$errors++;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   215
		next;
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
	if (($opt_uid3 ne "*") && ($opt_uid2 eq "0"))
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   219
		{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   220
    print "\n Error: uid3 specified without uid2 \n";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   221
	  $errors++;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   222
	  exit;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   223
	  }
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   224
	     
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   225
	$sourcefile=$arg;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   226
	}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   227
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   228
if ($errors || $sourcefile eq "")
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   229
	{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   230
	print_usage();
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   231
	exit 1;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   232
	}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   233
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   234
my @enabled_warnings = ();
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   235
my $file_line;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   236
my @includes_from_config;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   237
my $epocrc_config = $ENV{EPOCROOT}. "epoc32\\tools\\epocrc.config";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   238
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   239
if(-e $epocrc_config)
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   240
	{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   241
	print "Opening configuration file " . $ENV{EPOCROOT} . "epoc32\\tools\\epocrc.config.\n" if ($opt_v);
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   242
	open EPOCRC_CONFIG, $ENV{EPOCROOT}. "epoc32\\tools\\epocrc.config" or die $ENV{EPOCROOT} . "epoc32\\tools\\epocrc.config";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   243
	
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   244
	while ($file_line = <EPOCRC_CONFIG>)
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   245
		{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   246
		if($file_line=~/^\s*check_rls_items\s*=\s*(\d+)\s*;?\s*(\#.*)?$/)
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   247
			{ # matches check_rls_items = <digits> followed by optional semi-colon followed by optional perl comment
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   248
			$check_rls_items = $1;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   249
			}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   250
		elsif($file_line=~/^\s*strict_checking\s*=\s*(\d+)\s*;?\s*(\#.*)?$/)
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   251
			{ # matches strict_checking = <digits> followed by optional semi-colon followed by optional perl comment
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   252
			$strict_checking = $1;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   253
			}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   254
		elsif($file_line=~/^\s*\#.*$/)
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   255
			{ # matches perl comment on a line by itself
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   256
			}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   257
		elsif($file_line=~/^\s*$/)
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   258
			{ # matches empty lines and lines with only whitespace
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   259
			}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   260
		elsif($file_line=~/^\s*Include\:\s*(.*)\s*$/i)
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   261
			{ # matches Include: followed by a file location
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   262
			push @includes_from_config, $1;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   263
			}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   264
		elsif($file_line=~/^\s*warnings_to_enable\s*=\s*(\S+)\s*;?\s*(\#.*)?$/)
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   265
			{ # matches warnings_to_enable = <warnings> where <warnings> is a comma separated list of the warning numbers
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   266
			$warnings_to_enable = $1;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   267
			# Append 0's to the warning numbers to make them 3 digit
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   268
			@enabled_warnings = map (sprintf("%03d",$_), split(/,/, $warnings_to_enable));
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   269
			}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   270
		else
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   271
			{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   272
			print "Error: cannot parse line -- $file_line\n";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   273
			exit(1);
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   274
			}
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
else
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   278
	{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   279
	print "No configuration file found at " . $ENV{EPOCROOT} . "epoc32\\tools\\epocrc.config, using default values.\n" if ($opt_v);
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   280
	}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   281
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   282
unless ($check_rls_items==0 || $check_rls_items==1)
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   283
	{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   284
	print "* Error: \$check_rls_items must take the value 0 or 1\n";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   285
	exit(1);
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   286
	}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   287
unless ($strict_checking==0 || $strict_checking==1)
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   288
	{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   289
	print "* Error: \$strict_checking must take the value 0 or 1\n";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   290
	exit(1);
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   291
	}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   292
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   293
if($check_rls_items==0 && $strict_checking==1)
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   294
	{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   295
	print "* Error: \$check_rls_items must be set to 1 to allow strict checking of rls comments\n";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   296
	exit(1);
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   297
	}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   298
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   299
print "Values: \$check_rls_items=$check_rls_items ,\$strict_checking=$strict_checking and \$warnings_to_enable=$warnings_to_enable\n" if ($opt_v);
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   300
 
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   301
# Remove the warnings to be enabled from the warnings to be supressed list
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   302
if(@enabled_warnings) 
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   303
	{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   304
 	foreach my $warnings(@enabled_warnings)
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   305
 		{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   306
 		$opt_m =~ s/$warnings,*//g;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   307
 		}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   308
 	}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   309
 
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   310
# Remove the last , character from $opt_m, which could have been left by previous processing
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   311
$opt_m =~ s/,{1}$//;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   312
	
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   313
# If all warnings are removed, then $opt_m needs to be blanked
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   314
if ($opt_m =~/^-m$/) 
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   315
	{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   316
	$opt_m = "";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   317
	}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   318
use File::Basename;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   319
my $outputfile=$opt_o;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   320
my $rss_base = basename($sourcefile);
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   321
my ($rssfile) = split(/\./, $rss_base);	    # remove extension
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   322
my $output_base;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   323
my $not_used;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   324
my $lang;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   325
my $rpp_name;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   326
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   327
if (defined $ENV{ABLD_TOOLSMOD_COMPATIBILITY_MODE} &&  ($ENV{ABLD_TOOLSMOD_COMPATIBILITY_MODE} eq 'alpha')) {
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   328
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   329
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   330
$output_base = basename($outputfile);
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   331
($not_used,$lang) = split(/\.r/, $output_base);	    # get current lang from the filename
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   332
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   333
$rpp_name = $tmpdir . $rssfile . $lang . ".rpp";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   334
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   335
}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   336
else {
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   337
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   338
$rpp_name = $tmpdir. $rssfile . ".rpp";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   339
	
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   340
}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   341
my $headerfile=$opt_h;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   342
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   343
if ($opt_v)
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   344
	{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   345
	print "* Source file:   $sourcefile\n";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   346
	print "* Resource file: $outputfile\n" if ($outputfile ne "");
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   347
	print "* Header file:   $headerfile\n" if ($headerfile ne "");
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   348
	}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   349
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   350
$opt_o = "-o\"$outputfile\"" if ($outputfile ne "");
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   351
$opt_h = "-h\"$headerfile\"" if ($headerfile ne "");
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
#-------------------------------------------------------
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   355
# Run the preprocessor
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   356
#
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   357
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   358
if($opt_cpp) 
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   359
	{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   360
	$cpp_spec .= "-D_UNICODE " if ($unicode);
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   361
	
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   362
	$cpp_spec .= quoted_path($sourcefile) ." -o ". quoted_path($rpp_name);
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   363
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   364
  # get the HRH file containing all the Variant specific Macros, if not specified on the command line
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   365
	$variantMacroHRHFile = Variant_GetMacroHRHFile() if (!$variantMacroHRHFile);
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   366
	if($variantMacroHRHFile)
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   367
		{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   368
		my $variantFilePath = Path_Split('Path',$variantMacroHRHFile);
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   369
		chop( $variantFilePath );
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   370
		$cpp_spec .= " -I ".quoted_path($variantFilePath)." -include ".quoted_path($variantMacroHRHFile); 
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   371
		}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   372
	
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   373
	if($check_rls_items)
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   374
		{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   375
		my $includePath;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   376
		foreach my $include (@includes_from_config)
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   377
			{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   378
			my $relInclude = $ENV{EPOCROOT} . $include;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   379
			$relInclude=~s/^(.*)\\$/$1/;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   380
			if(-d $relInclude)
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   381
				{				
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   382
				$cpp_spec .= " -I ".quoted_path($relInclude);
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   383
				}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   384
			elsif(-e $relInclude)
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   385
				{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   386
				$includePath = Path_Split('Path',$include);
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   387
				$includePath=~s/^(.*)\\$/$1/;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   388
				$cpp_spec .= " -I ".quoted_path($ENV{EPOCROOT}.$includePath)." -include ".quoted_path($relInclude);			
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   389
				}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   390
			else
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   391
				{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   392
				print "Warning; cannot recognise $include as a valid file or directory.\n";
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
		}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   396
		
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   397
	print "* $cpp_spec\n" if ($opt_v);
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   398
	system($cpp_spec);
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   399
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   400
	my $cpp_status = $?;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   401
	die "* cpp failed\n" if ($cpp_status != 0);
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   402
	}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   403
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   404
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   405
#-------------------------------------------------------
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   406
# Copy rpp files to epoc32\localisation if not checking
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   407
# rls items for localisation tags
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   408
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   409
if ($opt_l ne "" && $check_rls_items == 0)
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   410
	{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   411
if (defined $ENV{ABLD_TOOLSMOD_COMPATIBILITY_MODE} &&  ($ENV{ABLD_TOOLSMOD_COMPATIBILITY_MODE} eq 'alpha')) {
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   412
	&Lockit_SrcFile($rssfile, $rpp_name, $opt_l, "RSC", "", $outputfile, $lang);
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   413
}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   414
else {
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   415
	&Lockit_SrcFile($rssfile, $rpp_name, $opt_l, "RSC", "", $outputfile);
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   416
}
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
#-------------------------------------------------------
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   420
# Merge rls strings to rpp if not checking rls items
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   421
# for localisation tags
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   422
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   423
if($check_rls_items == 0)
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   424
	{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   425
	&Merge_rls_string($rpp_name);	
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   426
	}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   427
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   428
#-------------------------------------------------------
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   429
# Test stage if -test_mode has been used
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   430
#
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   431
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   432
my $rcomp_spec = "";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   433
my $test_number = "";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   434
my $test_dir = "";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   435
my $output_redir = "";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   436
if($test_mode)
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   437
	{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   438
	my $file_line;	
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   439
	open EPOCRC_TEST, "epocrc.test";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   440
	while ($file_line = <EPOCRC_TEST>)
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   441
		{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   442
		if($file_line =~ /^\s*RCOMP:\s*(\S+)\s*$/)
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   443
			{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   444
			$rcomp_spec = $1;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   445
			}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   446
		elsif($file_line =~ /^\s*TEST-NUMBER:\s*(\d+)\s*$/)
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   447
			{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   448
			$test_number = "$1";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   449
			}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   450
		elsif($file_line =~ /^\s*TEST-DIR:\s*(\S+)\s*$/)
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   451
			{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   452
			$test_dir = $1;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   453
			}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   454
		}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   455
	if($rcomp_spec eq "" || $test_number eq "" || $test_dir eq "")
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   456
		{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   457
		print "$rcomp_spec\n";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   458
		print "$test_number\n";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   459
		print "$test_dir\n";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   460
		print "Error: could not extract required information from epocrc.test file\n";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   461
		exit(1);
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   462
		}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   463
	$output_redir = " 1>" . $test_dir . $rcomp_spec . "\.stdout 2>" . $test_dir . $rcomp_spec . "\.stderr";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   464
	$rcomp_spec .= " ";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   465
	}
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
# Run the resource compiler
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   469
#
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   470
if($rcomp_spec eq "")
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   471
	{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   472
	$rcomp_spec = "rcomp ";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   473
	}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   474
$rcomp_spec .= "-u " if ($unicode);
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   475
$rcomp_spec .= "-v " if ($opt_vmore);
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   476
$rcomp_spec .= "$opt_m " if ($opt_m ne "");
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   477
$rcomp_spec .= "-l " if ($check_rls_items);
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   478
$rcomp_spec .= "-force " if($strict_checking); 
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   479
if ($opt_uid2 ne '' || $opt_uid3 ne '')
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   480
	{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   481
	$opt_uid2 = "0" if ($opt_uid2 eq '');	# defaults to zero
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   482
	$opt_uid3 = "*" if ($opt_uid3 eq '');	# defaults to * = derived from NAME
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   483
	$rcomp_spec .= "-{$opt_uid2,$opt_uid3} ";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   484
	}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   485
$rcomp_spec .= "$opt_o $opt_h -s\"$rpp_name\" -i\"$sourcefile\"";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   486
$rcomp_spec .= "$output_redir";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   487
print "* $rcomp_spec\n" if ($opt_v);
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   488
system($rcomp_spec);
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   489
if ($? != 0)
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   490
	{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   491
	print "* RCOMP failed - deleting output files\n";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   492
	unlink $outputfile if ($outputfile ne "");
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   493
	unlink $headerfile if ($headerfile ne "");
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   494
	exit 1;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   495
	}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   496
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   497
	if (-e $outputfile)
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   498
	{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   499
		use File::stat; 
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   500
		if (stat($outputfile)->size > 65535)
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   501
		{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   502
			# Resource file bigger than 64kB are not supported.
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   503
			print "* Compiled resource file bigger than 64kB\n";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   504
			print "* RCOMP failed - deleting output files\n";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   505
			unlink $outputfile if ($outputfile ne "");
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   506
			unlink $headerfile if ($headerfile ne "");
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   507
			exit 1;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   508
		}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   509
	}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   510
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   511
#-------------------------------------------------------
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   512
# Copy rpp files to epoc32\localisation if checked
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   513
# file for localisation tags
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   514
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   515
if ($opt_l ne "" && $check_rls_items == 1)
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   516
	{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   517
if (defined $ENV{ABLD_TOOLSMOD_COMPATIBILITY_MODE} &&  ($ENV{ABLD_TOOLSMOD_COMPATIBILITY_MODE} eq 'alpha')) {
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   518
	&Lockit_SrcFile($rssfile, $rpp_name, $opt_l, "RSC", "", $outputfile, $lang);
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   519
}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   520
else {
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   521
	&Lockit_SrcFile($rssfile, $rpp_name, $opt_l, "RSC", "", $outputfile);
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   522
}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   523
}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   524
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   525
# exit cleanly
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   526
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   527
if(!$test_mode)
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   528
	{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   529
	print "* deleting $rpp_name\n" if ($opt_v);
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   530
	unlink $rpp_name;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   531
	}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   532
exit 0;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   533
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   534
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   535
#-------------------------------------------------------
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   536
# Subroutine: convert path into something acceptable to CPP.EXE
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   537
#
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   538
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   539
sub quoted_path
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   540
    {
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   541
    my ($arg) = @_;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   542
    return "\"$arg\"" if ($arg !~ /^\\[^\\]/);	# not an absolute path
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   543
    if ($curdrive eq "x")
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   544
		{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   545
		$curdrive="";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   546
		$curdrive=$1 if (cwd =~ /^(.:)/);	
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   547
		}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   548
    return "\"$curdrive$arg\"";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   549
    }
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   550
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   551
#-------------------------------------------------------
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   552
# Subroutine: Merge the rls strings in the rpp file specified
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   553
#
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   554
sub Merge_rls_string
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   555
	{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   556
	my ($rppfile) = @_;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   557
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   558
	my $line;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   559
	my $StringId;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   560
	my $key;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   561
	my $value;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   562
	my $StringToSubstitute;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   563
	my %ResourceString;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   564
	
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   565
	print "* merging text strings to $rppfile\n" if ($opt_v);
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   566
	
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   567
	open NEWRPP, ">$rppfile.new" or die "* Can't write to $rppfile.new";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   568
	open RPP, "$rppfile" or die "* Can't open $rppfile";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   569
	
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   570
	while ($line = <RPP>) 	{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   571
		while (($StringId, $StringToSubstitute)=each %ResourceString)
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   572
		{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   573
			$line=~s/\b$StringId\b/$StringToSubstitute/g if ($line !~ /^rls_string/);
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   574
		}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   575
	
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   576
		# find quoted "" strings
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   577
		if($line =~ /^rls_string\s+(\S+)\s+(.*$)/)
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   578
		{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   579
			my $text = $2;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   580
			$key = $1;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   581
			$line=~s/(.*)/\/\/$1/;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   582
			my $substr_count = 0;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   583
			if(!exists $ResourceString{$key})
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   584
			{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   585
			SUBSTR:	while (1)
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   586
			{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   587
				# find quoted "" strings e.g. "hello"
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   588
				if($text =~ /^(\s*\"(.*?\\.)*.*?\")/)		
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   589
				{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   590
					$value = $1;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   591
					$text = $';
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   592
					++$substr_count;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   593
				}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   594
	
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   595
				# find quoted '' strings. e.g. 'world'
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   596
				elsif($text =~ /^(\s*\'(.*?\\.)*.*?\')/)			
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   597
				{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   598
					$value = $1;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   599
					$text = $';
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   600
					++$substr_count;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   601
				}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   602
	
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   603
				# find hex strings e.g. <0x34><0x45><0x65>
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   604
				elsif($text =~ /^(\s*(<.*?>)+)/)		
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   605
				{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   606
					$value = $1;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   607
					$text = $';
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   608
					++$substr_count;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   609
				}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   610
	
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   611
				# find c comment e.g. /*hello world*/ (may exist between strings)
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   612
				elsif($text =~ /^(\s*\/\*.*?\*\/)/)		
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   613
				{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   614
					$text = $';
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   615
					next SUBSTR; # ignore embedded comment
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   616
				}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   617
	
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   618
				# find c++ comment e.g. //hello world (may exist after strings)
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   619
				elsif($text =~ /^(\s*\/\/.*$)/)		
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   620
				{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   621
					$text = $';
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   622
					next SUBSTR; # ignore trailing comment
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   623
				}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   624
	
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   625
				# exit search
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   626
				else
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   627
				{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   628
					if ($substr_count == 0)
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   629
					{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   630
						warn("WARNING: rls_string $key either has incorrect syntax or no value\n");
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   631
					}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   632
					last SUBSTR;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   633
				}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   634
			$ResourceString{$key} .= $value;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   635
			}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   636
		  	}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   637
		}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   638
		print NEWRPP $line;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   639
	}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   640
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   641
	close RPP;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   642
	close NEWRPP;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   643
	copy ("$rppfile.new", "$rppfile");
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   644
	unlink ("$rppfile.new");
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   645
	}