imgtools/buildrom/tools/featureconfigurator.pl
author jascui
Mon, 29 Nov 2010 15:43:27 +0800
changeset 709 1ec2202bb75b
parent 697 818fe0ed324b
permissions -rw-r--r--
Removing "repeated" file existence checking from ROMBUILD
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
697
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
     1
#
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
     2
# Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
     3
# All rights reserved.
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
     4
# This component and the accompanying materials are made available
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
     5
# under the terms of the License "Eclipse Public License v1.0"
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
     6
# which accompanies this distribution, and is available
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
     7
# at the URL "http://www.eclipse.org/legal/epl-v10.html".
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
     8
#
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
     9
# Initial Contributors:
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
    10
# Nokia Corporation - initial contribution.
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
    11
#
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
    12
# Contributors:
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
    13
#
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
    14
# Description: 
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
    15
# This package is to build rom image
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
    16
#
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
    17
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
    18
use FindBin;		# for FindBin::Bin
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
    19
my $PerlLibPath;    # fully qualified pathname of the directory containing our Perl modules
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
    20
my $PerlEPOCPath;
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
    21
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
    22
BEGIN {
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
    23
# check user has a version of perl that will cope
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
    24
	require 5.005_03;
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
    25
# establish the path to the Perl libraries
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
    26
    $PerlLibPath = $FindBin::Bin;	
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
    27
#    $PerlLibPath =~ s/\//\\/g;
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
    28
    $PerlLibPath .= "\\";
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
    29
    $PerlLibPath =~ s/\\/\//g;
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
    30
    
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
    31
    $PerlEPOCPath = $ENV{EPOCROOT};
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
    32
    $PerlEPOCPath =~ s/\\/\//g;
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
    33
    $PerlEPOCPath .= "\/" unless $PerlEPOCPath =~ /\/$/;
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
    34
    $PerlEPOCPath .= "epoc32\/tools\/";
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
    35
}
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
    36
use lib $PerlEPOCPath."build/lib/";
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
    37
use lib $PerlEPOCPath;
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
    38
use lib $PerlLibPath;
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
    39
use strict;
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
    40
use romutl;
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
    41
use romosvariant;
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
    42
# Work out the relative path to the epoc32 directory 
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
    43
use Cwd; 
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
    44
use File::Basename;
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
    45
# global variables specific to data drive image generation. 
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
    46
use File::Path ;					# Module to provide functions to remove or create directories in a convenient way.
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
    47
use File::Find; 
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
    48
use features;
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
    49
use flexmodload;	     # To load modules dynamically
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
    50
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
    51
my $enforceFeatureManager = 0; # Flag to make Feature Manager mandatory if SYMBIAN_FEATURE_MANAGER macro is defined. 
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
    52
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
    53
my $BuildromMajorVersion = 0 ;
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
    54
my $BuildromMinorVersion = 2;
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
    55
my $BuildromPatchVersion = 0;
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
    56
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
    57
my $outputoby = "output.oby" ;
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
    58
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
    59
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
    60
sub print_usage {
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
    61
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
    62
	# Option "-fm" will be supported instead of option "-f|fr" if SYMBIAN_FEATURE_MANAGER macro is defined.
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
    63
	my $featuresOptionUsage = "-f<featureuids> or\n".
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
    64
	"   -fr=<featureuids>            -- feature registry database XML file name\n";
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
    65
	if ($enforceFeatureManager) {
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
    66
		$featuresOptionUsage = "-fm=<featuredbfile>          -- feature manager/feature registry database XML file name.\n".
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
    67
							   "                                   Multiple XML files can be passed seperated by commas.\n".
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
    68
							   "   -nofm=<featuresdatafile>     -- don't generate features data file.\n".
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
    69
							   "                                   Instead use pre-built features data file.\n";
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
    70
	}
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
    71
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
    72
#........1.........2.........3.........4.........5.........6.........7.....
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
    73
	print <<USAGE_EOF;
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
    74
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
    75
FEATURECONFIGURATOR - feature configuration tool V$BuildromMajorVersion.$BuildromMinorVersion.$BuildromPatchVersion
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
    76
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
    77
Usage:
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
    78
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
    79
  featureconfigurator [options] obyfile [obyfile2 ...]   
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
    80
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
    81
Configurate features from *.iby/*.oby files and output a 
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
    82
consolidated obyfile for buildrom's use. 
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
    83
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
    84
This is a front end of buildrom, which partly implements 
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
    85
functionalities of buildrom.
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
    86
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
    87
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
    88
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
    89
The available options are
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
    90
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
    91
   -h                           -- Print this message
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
    92
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
    93
   $featuresOptionUsage
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
    94
   -oby-charset=<charset>       -- Used character set in which OBY was written
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
    95
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
    96
   -k or -keepgoing             -- Enable keepgoing,continue to config features
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
    97
                                   and create oby file.
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
    98
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
    99
   -argfile=xxx                 -- Specify argument-file name containing list of 
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   100
                                   command-line arguments to featureconfigurator
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   101
   -workdir=xxx                 -- Specify a directory for generated files. 
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   102
                                   The working directory will not be changed even this option is used.
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   103
   
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   104
   -I<directory>                -- Use <directory> for the referenced IBY/OBY files
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   105
   -D<xxx>                      -- Define xxx for C++ preprocessor
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   106
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   107
   -stdcpp                      -- Ignore symbian customized cpp and try to find 
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   108
                                   another cpp in the PATH.(for Windows only)
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   109
   -cpp=<xxx>                   -- Use xxx as path of CPP preprocessor.
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   110
 
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   111
   -o<xxx.oby>                  -- Output oby file name is set to xxx.oby
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   112
                                   If this argument is not given, then output oby file is
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   113
                                   "output.oby". output files are placed under workdir.
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   114
								   
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   115
	-s                          -- strict option, any missing files will stop buildrom
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   116
	-v                          -- verbose
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   117
	-noiby[=<n>]                -- if n = 0, then create iby files, otherwise don't create iby files, "-noiby=0" is default
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   118
	-w                          -- suppress cpp warnings.
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   119
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   120
USAGE_EOF
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   121
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   122
}
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   123
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   124
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   125
my $PerlEPOCPath = &get_epocroot()."epoc32\/tools\/";   # fully qualified pathname of the directory containing EPOC Perl modules
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   126
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   127
 
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   128
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   129
my $xmlrequired = 0; # assume xml required is false. Used to determine if xml
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   130
                     # modules should be loaded.
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   131
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   132
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   133
my @tempfiles;  	
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   134
my $preserve = 0; 	#flag to indicate if temporary files should be preserved
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   135
my $uppath="x";	    	# will be initialised when first needed
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   136
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   137
my $epocroot = &get_epocroot;
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   138
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   139
my @obyfiles;
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   140
my $cppargs = "-nostdinc -undef";
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   141
my $opt_k = 0;
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   142
my $opt_v = 0; 
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   143
my $opt_w = 0 ;
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   144
my $strict = 0;
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   145
my $line;
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   146
my $errors = 0;
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   147
my $thisdir=cwd;
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   148
$thisdir=~s-\\-\/-go;		    # separator from Perl 5.005_02+ is forward slash
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   149
$thisdir.= "\/" unless $thisdir =~ /\/$/;
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   150
$thisdir =~ s-\/-\\-g if (&is_windows); 
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   151
my $workdir = $thisdir ;
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   152
my $rominclude = $epocroot."epoc32\/rom\/include\/";
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   153
$rominclude = &get_epocdrive().$rominclude unless $rominclude =~ /^.:/;
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   154
$rominclude =~s-\\-\/-g;
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   155
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   156
my @xmlDBFile = ();
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   157
my $noiby = 0;
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   158
my @obydata;
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   159
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   160
my @featurefilearray; #2d array storing names and locations of feature files in each rom image
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   161
my @featureslist; #array of hashes, stores all the features which are to go into the feature files
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   162
my $featurefilecount=0; #counts number of feature files in each rom image
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   163
my $featurescount=0; #counts number of features
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   164
my $dir; # Stores the ROM image location of features.dat/featreg.cfg files
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   165
my $featurefilename; # Stores the name of feature file to be generated(i.e. "features.dat" or "featreg.cfg")
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   166
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   167
my $featuremanager = 0; #Flag to enable support for feature manager database XML file and to generate  
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   168
			# features data file.
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   169
my $noFeatureManager = 0; # Flag to stop the generation of features.dat file and use pre-built features.dat if provided.
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   170
my $preBuiltFeaturesDataFile  = ''; # To store the name of pre-built features.dat file provided with "-nofm" option.
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   171
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   172
#Image Content XML file that supports specific feature to be added
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   173
my $image_content = undef;
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   174
#Feature list XML file that acts as database containing all features details
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   175
my $featureXml = undef; 
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   176
my $customizedPlat = undef; 
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   177
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   178
#Summary of files(both executables and data files) currently includes 
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   179
#	host and ROM file names, 
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   180
#	size of the file in ROM
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   181
#	whether the file is hidden
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   182
# This option is added so that the above additional information is emitted by rombuild/rofsbuild tools
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   183
# only when supplied with this option so that the existing tools don't get affected.
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   184
my $logLevel="";
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   185
 
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   186
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   187
# Feature Variation modules and data
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   188
my %featureVariant;
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   189
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   190
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   191
my $opt_workdir = 0; 
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   192
my $stdcpp = 0;
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   193
my $obycharset;
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   194
my $cppoption = 0;
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   195
my $preprocessor = "cpp"; 
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   196
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   197
sub is_fullpath {
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   198
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   199
my $path = shift ;
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   200
	if (&is_windows) {
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   201
		if( $path =~ /^[a-z]:/i) {
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   202
			return 1 ;
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   203
		}
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   204
		elsif($path =~ /^\\/) {
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   205
			return 1 ;
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   206
		}
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   207
		else {
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   208
			return 0 ;
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   209
		}			
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   210
	}
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   211
	else {
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   212
		return 1 if($path =~ /^\//) ;
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   213
		return 0;
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   214
	}
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   215
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   216
}
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   217
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   218
sub match_obyfile
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   219
{
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   220
	my ($obyfile) = @_;
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   221
	if (-f $obyfile)
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   222
	{
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   223
		push @obyfiles, $obyfile;
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   224
		return 1;
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   225
	}
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   226
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   227
	# search for the oby file in the list of include directories
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   228
	my @otherDirs = ($rominclude);
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   229
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   230
	if ($featureVariant{'VALID'})
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   231
	{
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   232
		my $dirRef = $featureVariant{'ROM_INCLUDES'};
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   233
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   234
		@otherDirs = @$dirRef if ($dirRef);
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   235
	}
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   236
	foreach my $dir (@otherDirs)
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   237
	{
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   238
		print "$dir/$obyfile\n" if ($opt_v);
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   239
		if (-f "$dir/$obyfile")
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   240
		{
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   241
		    push @obyfiles, "$dir/$obyfile";
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   242
		    return 1;
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   243
		}
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   244
	}
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   245
	return 0;
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   246
}
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   247
 
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   248
# Subroutine to process parameter-file
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   249
sub parameterFileProcessor
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   250
{
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   251
	my $paramFile = shift(@_);	
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   252
	my @paramFileParamaters = ();	
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   253
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   254
	my $fileOpenFlag = 1;
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   255
	open FILE,"<", $paramFile or $fileOpenFlag = 0;
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   256
	
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   257
	if(!$fileOpenFlag)
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   258
	{
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   259
		print "Error: Could not open parameter-file \"$paramFile\" for reading.\n";
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   260
		return;
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   261
	}
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   262
	
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   263
	# Parse parameter-file and collect all the parameters in an array
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   264
	while(my $line = <FILE>)
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   265
	{
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   266
		# Read the line till character ';'(used for providing comments in the file) or EOL
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   267
		$line = $1 if ($line =~ /(.*);/); 
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   268
		
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   269
		# Split the parameters specified in a line based on white-spaces		
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   270
		my @paramaters = split(/(\s)/,$line);	
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   271
		
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   272
		my $flag = 0;
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   273
		my $argWithQuotes='';
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   274
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   275
		foreach my $value (@paramaters) 
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   276
		{	
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   277
			# If the parameter doesn't conatian double quotes then push it 
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   278
			# to the list of parameters.
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   279
			if(($value !~ /\"/) && (!$argWithQuotes)) 
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   280
			{
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   281
				if ($value !~ /^\s*$/) 
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   282
				{
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   283
					push @paramFileParamaters,$value;
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   284
				}		
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   285
			}
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   286
			# If the parameter is in the form  -fm="faturedb.xml" then remove
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   287
			# double quotes and push it to the list of parameters.
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   288
			elsif(($value =~ /\".*\"/))
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   289
			{
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   290
				$value =~ s/\"//g;
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   291
				push @paramFileParamaters,$value;
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   292
			}
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   293
			# If the parameter is in the form  -fm="fature  db.xml" then read
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   294
			# the parameter starting from opening quote till the closing quote.
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   295
			elsif( ($value =~ /\"/) && $argWithQuotes) 
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   296
			{
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   297
				$argWithQuotes .= $value;
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   298
				$argWithQuotes =~ s/\"//g;
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   299
				push @paramFileParamaters,$argWithQuotes;
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   300
				$argWithQuotes='';		
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   301
			}
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   302
			else
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   303
			{
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   304
				$argWithQuotes .= $value;
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   305
			}
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   306
		}		
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   307
	}
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   308
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   309
	close FILE;	
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   310
	if (!@paramFileParamaters)
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   311
	{
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   312
		print "Warning: No parameters specified in paramer-file \"$paramFile\".\n";		
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   313
		return;
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   314
	}
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   315
	
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   316
	my $paramFileFlag = 1;
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   317
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   318
	# Invoke subroutine "process_cmdline_arguments" to process the parameters read from
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   319
	# the parameter file.
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   320
	&process_cmdline_arguments($paramFileFlag, @paramFileParamaters);
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   321
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   322
}
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   323
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   324
# Processes the command line arguments passed to buildrom tool
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   325
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   326
sub process_cmdline_arguments
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   327
{
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   328
 
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   329
	my ($paramFileFlag, @argList); 
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   330
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   331
	if (defined @_) {
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   332
		($paramFileFlag, @argList) = @_;
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   333
	}
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   334
	else {
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   335
		if(scalar(@ARGV) == 0){
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   336
			my @hrhMacros = &get_variantmacrolist;	
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   337
			$enforceFeatureManager = 1 if (grep /^SYMBIAN_FEATURE_MANAGER\s*$/, @hrhMacros);
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   338
			print_usage();
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   339
			exit 1;				
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   340
		}
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   341
		
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   342
		@argList = @ARGV;
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   343
	}
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   344
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   345
	if (!defined $paramFileFlag)  {
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   346
	
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   347
		# Enforce Feature Manager if macro SYMBIAN_FEATURE_MANAGER is defined in the HRH file.
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   348
		my @hrhMacros = &get_variantmacrolist;	
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   349
		$enforceFeatureManager = 1 if (grep /^SYMBIAN_FEATURE_MANAGER\s*$/, @hrhMacros);
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   350
		# Process the parameters of parameter-file if passed.
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   351
		foreach my $arg (@argList) {
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   352
			if ($arg =~ /^-h/i) {
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   353
				print_usage();
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   354
				exit 1;				
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   355
			}
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   356
		}
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   357
		# Process the parameters of parameter-file if passed.
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   358
		foreach my $arg (@argList) {
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   359
			&parameterFileProcessor($1) if ($arg =~ /^-argfile=(.*)/) ;
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   360
		}
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   361
	}
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   362
	# first searching argList for keepgoing option
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   363
	my @newArgList = () ;
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   364
	foreach my $arg (@argList) {
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   365
		if ( $arg =~ /^-k$/i || $arg =~ /^-keepgoing$/i ) {
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   366
			$opt_k = 1;	 
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   367
		}
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   368
		elsif ($arg =~ /^-s$/) {
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   369
			$strict = 1; 
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   370
	    }
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   371
		elsif ($arg =~ /^-v$/) {
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   372
			$opt_v =1; 
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   373
	    }
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   374
		elsif( $arg =~ /^-w$/) {
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   375
			$opt_w = 1 ;
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   376
		}
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   377
		elsif ($arg =~ /^-workdir=(.*)/) {			
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   378
			$workdir = $1;
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   379
			$workdir = $thisdir.$workdir unless(&is_fullpath($workdir)) ;
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   380
			$workdir.= "\/" unless $workdir =~ /\/$/;
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   381
			mkdir($workdir) unless (-d $workdir); 
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   382
		}else {
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   383
			push @newArgList, $arg ;
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   384
		}
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   385
	}
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   386
	foreach my $arg (@newArgList)
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   387
	{
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   388
	    if ($arg =~ /^-argfile=(.*)/)  {
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   389
			&parameterFileProcessor($1) if (defined $paramFileFlag); 
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   390
		}
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   391
		elsif ($arg =~ /^-DFEATUREVARIANT=(.*)/) {
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   392
			my $varname = $1;			
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   393
			if ($varname =~ /^\.(.*)$/) {
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   394
				# for testing, locate the VAR file in the current directory
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   395
				%featureVariant = get_variant($1, ".");
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   396
			}
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   397
			else {
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   398
				%featureVariant = get_variant($varname);
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   399
			}
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   400
			if (!$featureVariant{'VALID'}) {
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   401
			    print "FEATUREVARIANT $varname is not VALID\n";
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   402
				$errors++;
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   403
			}
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   404
			if ($featureVariant{'VIRTUAL'}) {
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   405
			    print "FEATUREVARIANT $varname is VIRTUAL\n";
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   406
				$errors++;
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   407
			}
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   408
			addDrivesToFeatureVariantPaths(); 
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   409
		}
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   410
		elsif ($arg =~ /^-[DI]/) {
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   411
			$cppargs .= " $arg";  
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   412
	    } 
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   413
	    elsif ($arg =~/^-oby-charset=(.*)$/i) {
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   414
		$obycharset = $1; 
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   415
	    }
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   416
		elsif($arg =~ /^-o(.*)/i)   {
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   417
			$outputoby = $1;  
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   418
		} 
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   419
		elsif ($arg =~ /^-noiby(=(\d))$/i ) {
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   420
			if(!$1) {
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   421
				$noiby = 1;
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   422
			}
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   423
			else {
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   424
				if(!$2) {
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   425
					print "Warning: No value for \"-noiby=\" option, use default.\n";
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   426
				}
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   427
				else {
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   428
					$noiby = $2 ;
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   429
				}
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   430
			}
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   431
		}
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   432
		#Process feature manager database xml file 
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   433
	    elsif($arg =~ /^-fm=(.*)/) {
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   434
			if (!$enforceFeatureManager) {
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   435
				print "Unknown arg: $arg\n";
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   436
				$errors++;
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   437
				next;
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   438
			}
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   439
			$featureXml = $1;			
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   440
			$xmlrequired = 1;
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   441
			$featuremanager = 1;
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   442
			if ($featureXml =~ /^$/)  {
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   443
				print "Error: No filename specified with \"-fm=\" option.\n";
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   444
			} 
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   445
			else {			
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   446
				@xmlDBFile = split /,/,$featureXml if($noiby == 0);
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   447
			} 
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   448
	    }
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   449
		elsif ($arg =~ /^-nofm(=(.*))?$/) {
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   450
			if (!$enforceFeatureManager)  {
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   451
				print "Unknown arg: $arg\n";
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   452
				$errors++;
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   453
				next;
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   454
			}
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   455
   			$noFeatureManager = 1; 
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   456
            if(!$2) {
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   457
                print "Warning: No filename specified with \"-nofm=\" option, feature data file might not be included.\n";
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   458
            }
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   459
            else {
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   460
                $preBuiltFeaturesDataFile = $2;						
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   461
            } 	
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   462
		}
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   463
		#Process feature registry database xml file 
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   464
	    elsif($arg =~ /^-fr=(.*)/ || $arg =~ /^-f(.*)/) {
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   465
			if ($enforceFeatureManager)
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   466
			{
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   467
				print "Error: Option \"-f|-fr\" is no longer supported.\n";
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   468
				$errors++;
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   469
				next;
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   470
			}			
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   471
			$featureXml = $1;
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   472
			$xmlrequired = 1;			
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   473
			print "Error: No filename specified with \"-f|-fr\" option.\n" if ($featureXml =~ /^$/) ;
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   474
	    } 
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   475
		elsif ($arg =~ /^-stdcpp$/i) {
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   476
			if (&is_linux) {
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   477
				print "Warning: option -stdcpp only apply for Windows\n"; 
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   478
			}
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   479
			if ($cppoption) {
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   480
				print "Error: -stdcpp option and -cpp=xxx option cannot be used at the same time.\n";
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   481
				exit (1);
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   482
			}
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   483
			$stdcpp = 1; 
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   484
		}
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   485
		elsif ($arg =~ /^-cpp=(.*)/) {
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   486
			if ($stdcpp) {
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   487
				print "Error: -stdcpp option and -cpp=xxx option cannot be used at the same time.\n";
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   488
				exit (1);
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   489
			}
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   490
			print "Warning: -cpp option has been set before. The previous configuration will be overwritten!\n" if ($cppoption);
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   491
			$cppoption = 1;
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   492
			$preprocessor = $1;
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   493
			$preprocessor =~ s-\\-\/-g;
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   494
			$preprocessor =~ s-EPOCROOT##\/?-$epocroot-g;
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   495
			if (-d $preprocessor) {
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   496
				$preprocessor .= "\/" unless $preprocessor =~ /\/$/;
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   497
				$preprocessor .= "cpp";
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   498
			} 
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   499
		} 
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   500
	    elsif ($arg =~ /^-/)  {
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   501
			print "Unknown arg: $arg\n";
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   502
			$errors++;
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   503
			next;
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   504
	    }
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   505
		else {
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   506
			# It's an OBY file
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   507
			next if (match_obyfile($arg));
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   508
			next if (match_obyfile("$arg.oby"));
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   509
			print "Cannot find oby file: $arg\n";
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   510
			$errors++ if(!$opt_k);
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   511
		}	    
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   512
	}
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   513
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   514
	return if (defined $paramFileFlag) ;
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   515
	if (@obyfiles<1 ) {
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   516
	    print "Missing obyfile argument\n";
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   517
	    $errors++ if(!$opt_k);
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   518
	}
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   519
	if(defined($obycharset)) {
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   520
		print "Warning: Ignoring not supportted charset $obycharset, local charset will be used as default!\n" unless($obycharset =~ /utf-?8/i);
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   521
	}
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   522
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   523
	if ($errors) {
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   524
	    print_usage();
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   525
	    exit 1;
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   526
	}
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   527
	
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   528
	if ($noFeatureManager && $featuremanager)  {
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   529
		print "Warning: Ignoring \"-nofm\" option, as both \"-nofm\" and \"-fm\" options are provided.\n";			
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   530
		$noFeatureManager = 0;
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   531
	}
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   532
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   533
	# Adding variant specific macros by including a HRH file
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   534
	# (only required if no Feature Variant is used)
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   535
	if (!$featureVariant{'VALID'}) {
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   536
	    my $variantMacroHRHFile = get_variantmacroHRHfile();
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   537
	    if($variantMacroHRHFile){
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   538
	        my $variantFilePath = split_path('Path',$variantMacroHRHFile);
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   539
	        $cppargs .= " -I " . &append_driveandquote($variantFilePath) . " -include " . &append_driveandquote($variantMacroHRHFile); 
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   540
	        print "in cmd process $cppargs\n" if ($opt_v);
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   541
	    }
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   542
	}
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   543
	# load the required modules if xml is required
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   544
	if ($xmlrequired == 1) {
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   545
	    load_featuresutil() if (defined ($featureXml));	    
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   546
	}
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   547
}
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   548
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   549
#----------------------------------------------------------------------------------
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   550
# Preprocessing phase	
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   551
#
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   552
# Concatentate the specified .oby files and pass them through cpp
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   553
# to get the raw ROM specification in tmp1.oby
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   554
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   555
sub preprocessing_phase
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   556
{
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   557
	 
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   558
	
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   559
	my $temp1OBYFile = $workdir."tmp1.oby";
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   560
	unlink "$temp1OBYFile";
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   561
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   562
#	Macro "ROM_FEATURE_MANAGEMENT" is defined when "-f|fr" or "-fm" is used
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   563
	$cppargs .= " -w" if($opt_w) ;
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   564
	$cppargs .= " -DROM_FEATURE_MANAGEMENT " if (defined ($featureXml));
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   565
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   566
	# add pre-include file and include directories for feature variants
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   567
	if ($featureVariant{'VALID'})
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   568
	{
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   569
		$cppargs .= " -I.";
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   570
		my $incRef = $featureVariant{'ROM_INCLUDES'};
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   571
		if ($incRef) {
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   572
			foreach (@$incRef) {
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   573
				$cppargs .= " -I \"$_\"";
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   574
			}
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   575
		}
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   576
		my $HRH = $featureVariant{'VARIANT_HRH'};
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   577
		$cppargs .= " -include \"$HRH\"" if ($HRH);
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   578
	}
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   579
	else {
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   580
		# no feature variant so use the standard includes
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   581
		$cppargs .= " -I. -I \"$rominclude\"";
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   582
	}
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   583
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   584
	$preprocessor = find_stdcpp() if ($stdcpp);
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   585
	print "* $preprocessor -Wno-endif-labels -o $temp1OBYFile $cppargs\n" if ($opt_v);
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   586
	
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   587
	is_existinpath("$preprocessor", romutl::DIE_NOT_FOUND);
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   588
	$errors = 0; 
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   589
	open CPP, "| $preprocessor -Wno-endif-labels -o $temp1OBYFile $cppargs" or die "* Can't execute cpp";
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   590
	foreach my $arg (@obyfiles) {
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   591
		print CPP "\n#line 1 \"$arg\"\n";
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   592
	
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   593
		if(open(OBY, $arg)) {
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   594
			print "* reading $arg\n" if ($opt_v);
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   595
			while ($line=<OBY>) {
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   596
				print CPP $line;
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   597
			}
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   598
			close OBY;
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   599
		}
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   600
		else {
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   601
			print STDERR "* Can't open $arg\n";
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   602
			if(!$opt_k){			
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   603
				close CPP;
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   604
				exit(1);
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   605
			}
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   606
		}
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   607
	}
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   608
	close CPP;
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   609
	my $cpp_status = $?;
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   610
	die "* cpp failed\n" if ($cpp_status != 0 || !-f "$temp1OBYFile");
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   611
	
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   612
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   613
	if( defined ($image_content)) {
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   614
		#Read the OBY file that was generated by the pre-processor
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   615
		&ReadPreprocessedFile($temp1OBYFile);
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   616
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   617
#		Check if the static dependencies of the OBY binaries are resolved.
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   618
		&ImageContentHandler::UpdateObyBinaryStaticDep();
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   619
		
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   620
		#Now append the files collected from cdfs.
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   621
		&ImageContentHandler::GenObyFile($temp1OBYFile);
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   622
	}
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   623
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   624
 
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   625
	if($obycharset =~ /utf-?8/i) {
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   626
		my $utf8file = $workdir."tmp1utf8.oby";
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   627
		open INFILE, "<$temp1OBYFile" or die "* Can't open file $temp1OBYFile";
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   628
		open CHARSETTRAN, "| charsettran -to=hostcharset > $utf8file" or die "* Can't execute charsetran";
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   629
		while(<INFILE>) {
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   630
			print CHARSETTRAN $_;
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   631
		}
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   632
		close CHARSETTRAN;
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   633
		close INFILE;	
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   634
		unlink $temp1OBYFile  or die "* Can't remove file $temp1OBYFile";
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   635
		rename 	$utf8file, $temp1OBYFile or die "* Can't rename file $utf8file to file $temp1OBYFile";
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   636
	}
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   637
	
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   638
	open TMPOBY, "<$temp1OBYFile" or die "*cpp output can not be read.\n"; 
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   639
	@obydata = <TMPOBY> ;
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   640
	close TMPOBY;
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   641
 
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   642
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   643
	
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   644
}
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   645
 
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   646
sub load_featuresutil
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   647
{
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   648
	&FlexLoad_ModuleL("featuresutil");
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   649
			
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   650
	# Parse the feature database XML file
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   651
	if(!&featuresutil::parseXMLDatabase($featureXml, $featuremanager, $strict))
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   652
	{
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   653
		$featureXml = undef;
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   654
		exit(1) if($strict);
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   655
	}
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   656
}
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   657
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   658
#----------------------------------------------------------------------------------
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   659
# Feature registry configuration file/Features data file generation phase
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   660
#
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   661
# If feature registry configuration files/features data files are required then creates these files for
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   662
# each ROM/ROFS image
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   663
#
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   664
sub featurefile_creation_phase
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   665
{
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   666
		# Set the name and Rom Image location of feature file.
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   667
	if ($enforceFeatureManager)  {
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   668
		# features data file location
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   669
		$dir = "private\/10205054\/";
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   670
		$featurefilename = "features.dat";
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   671
	}
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   672
	else {
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   673
		# feature registry configuration file location
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   674
		$dir = "private\/102744CA\/"; 
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   675
		$featurefilename = "featreg.cfg";
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   676
	}
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   677
	my $onlysmrimage  = 1 ;
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   678
	
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   679
	foreach $line(@obydata) {		
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   680
		if(($line =~ /^\s*romsize\s*=/i) || ( $line=~ /^\s*rom_image/i) || ($line =~ /^\s*data_image/i)) {
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   681
			$onlysmrimage = 0;
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   682
			last;
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   683
		}
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   684
	}	
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   685
	if ($enforceFeatureManager && (!$featuremanager) && (!$noFeatureManager) ) {
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   686
		my $defaultFeatureDbFlag = 0;
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   687
		foreach $line(@obydata) { 
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   688
			if ($line=~/^\s*defaultfeaturedb\s*=?\s*(\S+)/i) {	
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   689
				# Get the default value for featuredatabasefile
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   690
				
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   691
				$featureXml = "$epocroot$1";
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   692
				$featureXml =~ s-\\-\/-g;
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   693
				$featuremanager = 1;				
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   694
				$defaultFeatureDbFlag = 1;
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   695
				load_featuresutil();				
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   696
				last;
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   697
			}
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   698
		}
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   699
		if(!$defaultFeatureDbFlag && !$onlysmrimage)
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   700
		{
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   701
			print "Error: Neither option \"-fm|-nofm\" nor default value for featuredatabase file is provided.\n";
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   702
			exit(1);			
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   703
		}
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   704
	}
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   705
	my @newobydata = ();
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   706
	if (defined ($featureXml))  {
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   707
		my $featurefilecount=0;
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   708
		my $romimage=0;
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   709
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   710
		foreach $line (@obydata) {
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   711
			# specify which romimage following lines are part of
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   712
			if ($line=~/^\s*ROM_IMAGE\[(\d)\]/) {
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   713
				$romimage=$1;
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   714
				$featurefilecount=0;
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   715
			}
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   716
			elsif ($line =~ /^\s*REM/i || $line =~ /^\s*\r?\n$/ ){
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   717
				next ;
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   718
				# ignore empty
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   719
			}
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   720
			elsif($line =~ /^\s*(FEATURE)\s*(\S*)\s*(.*)/i || $line =~ /^\s*(EXCLUDE_FEATURE)\s*(\S*)\s*(.*)/i) {
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   721
				
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   722
				# FEATURE  <feature_name>  [ SF  <status falgs> ] [ UD  <user data> ]
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   723
				my $feature = $1;
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   724
				my $featurevalue = $2;
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   725
				my $featureargs = $3;
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   726
				my $reservedbit = 0;
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   727
				my %featureflags=();			 
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   728
				# Options 'SF' and 'UD' will be supported only for "-fm" option
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   729
				if ($featuremanager)  {
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   730
					# [ SF  <status falgs> ] [ UD  <user data> ]
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   731
					$featureargs =~	/(\S*)\s*(\S*)\s*(\S*)\s*(\S*)\s*/ ;
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   732
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   733
					# Store the values of 'SF' and 'UD', or any invalid option, if provided					
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   734
					$featureflags{uc($1)} = $2 if ($1);  
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   735
					$featureflags{uc($3)} = $4 if ($3); 
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   736
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   737
					# Generate a warning if the option provided with Feature/Exclude_Feature keyword is  
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   738
					# not 'SF' or 'UD'.
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   739
					foreach my $Key (keys %featureflags) {						
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   740
						if ($Key !~ /^(SF|UD)$/) {
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   741
							print "Warning: Invalid argument \"$Key\" specified for feature $featurevalue\n";
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   742
							delete $featureflags{$Key};
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   743
							next;
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   744
						}						
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   745
					}							
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   746
				}				
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   747
				# In verbose mode, generate warning if "SF|UD" arguments or invalid arguments are specified
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   748
				# for "-f|fr" option.
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   749
				elsif ($featureargs && $opt_v) {
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   750
					print "Invalid argument(s) \"$featureargs\" provided for feature \"$featurevalue\"\n";
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   751
					foreach my $Key (keys %featureflags) {
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   752
						delete $featureflags{$Key};
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   753
					}
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   754
				}				
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   755
				
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   756
				# The feature file name is of the format featreg.cfg[x-y] or features.dat[x-y] 
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   757
				# where x is the romimage id, y is always 0, reserved for future use.
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   758
				my $targetfeaturefile;
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   759
				if (($romimage == 0) && ($reservedbit == 0)) {
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   760
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   761
					# Core image will not have the mangled name
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   762
				 	$targetfeaturefile = $featurefilename;
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   763
				}
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   764
				else {
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   765
				 	$targetfeaturefile = $featurefilename . "\[". $romimage . "\-$reservedbit\]";
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   766
				}
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   767
				my $flag=1;
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   768
				my $featureflag;
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   769
				if ($feature =~ /^FEATURE$/i) {
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   770
					$featureflag = 1;
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   771
				}
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   772
				else {
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   773
					$featureflag = 0;
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   774
				}
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   775
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   776
				my $i;
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   777
 				# loop to see if name of feature file already added to this romimage in array
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   778
				for($i=0;$i<$featurefilecount && $flag;$i++) {
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   779
					$flag=0 if($featurefilearray[$romimage][$i]{cfgfile} eq $targetfeaturefile);
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   780
				}
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   781
			
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   782
				if($flag) { # adds feature file if not yet listed for this romimage in array
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   783
					$featurefilearray[$romimage][$featurefilecount++]={cfgfile=>$targetfeaturefile, cfgdir=>$dir};
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   784
					$i=$featurefilecount;
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   785
				}
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   786
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   787
				$featureslist[$featurescount]= {feature=>$featurevalue, include=>$featureflag, rom=>$romimage, cfgfile=>$i-1};
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   788
				
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   789
				# Store the value of 'SF' in 'featureslist' array
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   790
				$featureslist[$featurescount]->{SF} = $featureflags{SF} if (defined $featureflags{SF}) ;
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   791
				# Store the value of 'UD' in 'featureslist' array
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   792
				$featureslist[$featurescount]->{UD} = $featureflags{UD} if (defined $featureflags{UD}) ;
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   793
				$featurescount++;
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   794
			}
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   795
		}
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   796
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   797
		# Create Feature File
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   798
		for(my $i=0;$i<scalar @featurefilearray;$i++) {
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   799
			my $j=0;
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   800
			while(defined $featurefilearray[$i][$j])
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   801
			{
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   802
				my $targetfeaturefile = $workdir.$featurefilearray[$i][$j]{cfgfile}; 
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   803
				if (!(&featuresutil::createFeatureFile($i,$j,$targetfeaturefile,\@featureslist,$featuremanager)))  {
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   804
					$featurefilearray[$i][$j]{cfgfile}= undef;
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   805
					exit(1) if($strict);					
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   806
				}
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   807
				$j++;
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   808
			}
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   809
		} 
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   810
		my $flag=1;
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   811
        	my $imageIdx=0;
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   812
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   813
		# Add feature files to ROM image, adds lines to obey file to specify existing locations
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   814
		# of feature files and target locations. 
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   815
		
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   816
		# features.dat will be written to the end of rom/rofs
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   817
		my @lastFLs = ();
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   818
		my $lastRomIndex = 0 ;
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   819
		
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   820
		foreach $line (@obydata) {
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   821
			if($line =~/^\s*ROM_IMAGE\[(\d)\]/i) {
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   822
				my $index=$1;
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   823
						
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   824
				if($lastRomIndex != $index) {
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   825
					foreach my $fl(@lastFLs) {
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   826
						push @newobydata,$fl ;
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   827
					}
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   828
					@lastFLs = ();
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   829
					$lastRomIndex = $index ;
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   830
				}
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   831
				push @newobydata, "\n" . $line . "\n";	
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   832
				my $j=0;
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   833
				while(defined $featurefilearray[$index][$j]) {
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   834
					$flag = 0 if($index == 0);
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   835
					# Put in feature files for current ROM_IMAGE
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   836
					my $targetfeaturefile = $featurefilearray[$index][$j]{cfgfile};
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   837
					# Rom images will not have mangled name for feature files
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   838
				 					
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   839
					# Rofsbuild will set attribute 'exattrib=U' in the entry record when this field is used.
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   840
					# File Server when asked for a directory listing would notice the attribute and will return the 
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   841
					# list with mangled names. Hence, mangled name for feature files should not be put in ROM_IMAGE.
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   842
					my $exattribute = "" ;					
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   843
					if (defined $targetfeaturefile ) {
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   844
						$exattribute = "exattrib=U" if($index > 0);
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   845
						push @lastFLs, "ROM_IMAGE[$index] data=" . $workdir . $targetfeaturefile . " \"". $featurefilearray[$index][$j]{cfgdir} .$featurefilename .  "\"\t\t" . $exattribute . "\n";
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   846
						$featurefilearray[$index][$j]{cfgfile} = undef ;
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   847
					}
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   848
					$j++;
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   849
				}
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   850
			}
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   851
			elsif($line !~ /^\s*(FEATURE)\s*/i && $line !~ /^\s*(EXCLUDE_FEATURE)\s*/i && $line !~/^\s*defaultfeaturedb\s*=?\s*(\S+)/i) {
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   852
				# Put in all other lines except the FEATURE and EXCLUDE_FEATURE keywords
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   853
				push @newobydata, $line;
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   854
			}
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   855
			else {
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   856
				push @newobydata, " "; 
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   857
			}
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   858
			 
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   859
		}
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   860
		foreach my $fl(@lastFLs) {
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   861
			push @newobydata,$fl ;
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   862
		}
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   863
		if($flag) { 
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   864
			# Put in feature files for ROM_IMAGE[0] if it is the only ROM_IMAGE
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   865
			my $k=0;
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   866
			while(defined $featurefilearray[0][$k])
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   867
			{ 
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   868
				my $targetfeaturefile = $featurefilearray[0][$k]{cfgfile};
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   869
				if (defined $targetfeaturefile)
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   870
				{
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   871
					push @newobydata, "data=" . $workdir . $targetfeaturefile . " \"" . $featurefilearray[0][$k]{cfgdir} . $targetfeaturefile . "\"\n";
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   872
					$featurefilearray[0][$k]{cfgfile} = undef ;
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   873
				}
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   874
				$k++;
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   875
			}
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   876
		}
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   877
	}
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   878
	elsif ($enforceFeatureManager && $noFeatureManager && $preBuiltFeaturesDataFile) {
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   879
        print "Valid: $preBuiltFeaturesDataFile\n";
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   880
		if (-e $preBuiltFeaturesDataFile)  { 
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   881
			my $flag = 1;
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   882
			foreach my $line (@obydata)
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   883
			{
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   884
				# Put in the pre-built features data file in ROM_IMAGE[0] 
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   885
				if($line =~/^\s*ROM_IMAGE\[1\]/i)
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   886
				{
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   887
					push @newobydata, "data=$preBuiltFeaturesDataFile" . " \"" . $dir . $featurefilename . "\"\n";
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   888
					$flag =0;
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   889
				}
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   890
				push @newobydata, $line;
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   891
			}
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   892
			if($flag)
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   893
			{ 
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   894
				# Put in the pre-built features data file in ROM_IMAGE[0] if it is the only ROM_IMAGE
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   895
				push @newobydata, "data=$preBuiltFeaturesDataFile" . " \"" . $dir . $featurefilename . "\"\n";
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   896
			}
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   897
		}
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   898
		else
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   899
		{
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   900
			print "Error: File \"$preBuiltFeaturesDataFile\" doesn't exist.\n";
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   901
			exit(1);
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   902
		}
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   903
	}
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   904
	elsif ($enforceFeatureManager) {
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   905
	    print "Error: no feature data file or pre-built feature data file is provided!";
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   906
	    exit(1);
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   907
	}
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   908
	
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   909
		my $output ;
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   910
	if(&is_windows) {
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   911
		if($outputoby =~ /^[\\\/]/ || $outputoby =~ /^[a-zA-Z]:/)  {
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   912
			$output = $outputoby ;
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   913
		}
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   914
		else {
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   915
			$output = $workdir.$outputoby;
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   916
		}
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   917
	}
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   918
	else {
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   919
		if($outputoby =~ /^[\/]/ )  {
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   920
			$output = $outputoby ;
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   921
		}
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   922
		else {
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   923
			$output = $workdir.$outputoby;
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   924
		}
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   925
	} 
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   926
	unlink $output if(-e $output);
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   927
	print "* Writing $output...\n" if($opt_v);
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   928
	unless(open FOUT, ">$output"){
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   929
		print "Error: Can not write to $output.\n";
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   930
		exit(1);
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   931
	}
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   932
	foreach(@newobydata){
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   933
		chomp ;
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   934
		print FOUT "$_\n";
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   935
	} 
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   936
	close FOUT ; 
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   937
	print "* Done.\n" if($opt_v);
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   938
}
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   939
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   940
# make sure that all the absolute feature variant paths include a
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   941
# drive letter. This is required because cpp will not work with
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   942
# absolute paths starting with slashes.
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   943
sub addDrivesToFeatureVariantPaths
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   944
{
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   945
	return unless $featureVariant{'VALID'};
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   946
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   947
	my $current = &get_epocdrive;
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   948
	my $drive = $1 if ($current =~ /^(.:)/);
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   949
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   950
	# pre-include file
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   951
	my $HRH = $featureVariant{'VARIANT_HRH'};
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   952
	$featureVariant{'VARIANT_HRH'} = $drive . $HRH if ($HRH =~ /^[\\\/]/);
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   953
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   954
	# ROM include path
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   955
	my $dirRef = $featureVariant{'ROM_INCLUDES'};
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   956
	return unless $dirRef;
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   957
	my $i = 0;
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   958
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   959
	foreach my $dir (@$dirRef)
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   960
	{
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   961
		$$dirRef[$i] = $drive . $dir if ($dir =~ /^[\\\/]/);
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   962
		$i++;
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   963
	}
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   964
}
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   965
#
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   966
# Process the given absolute path
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   967
# Add backslash at the end if required
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   968
# @param - path to be processed
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   969
#
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   970
sub processPath
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   971
{
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   972
	my ($path) = shift;
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   973
	
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   974
	return if( $$path =~ /(\\$)/ );
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   975
	return if( $$path =~ /(\/$)/ );
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   976
	$$path .= "/";
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   977
}
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   978
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   979
# Main block for buildrom module invocation
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   980
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   981
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   982
# Processes the buildrom command line parameters.
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   983
&process_cmdline_arguments; 
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   984
if(scalar(@xmlDBFile) > 0) { 
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   985
	&processPath(\$epocroot);
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   986
	&processPath(\$thisdir);
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   987
	&features::set_DefaultPath($epocroot, \$thisdir, \$thisdir, \$thisdir, \$thisdir);
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   988
	if(&features::open_Database(@xmlDBFile)) {  
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   989
		&features::generate_Obeyfile($workdir);	 
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   990
	}
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   991
}
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   992
#Preprocessing phase
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   993
&preprocessing_phase; 
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   994
# Creates feature registry configuration file/features data file.
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   995
&featurefile_creation_phase;
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   996
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   997
818fe0ed324b Moving feature configuration out of the buildrom scope.
Ross Qin <ross.qin@nokia.com>
parents:
diff changeset
   998
1;