imgtools/buildrom/tools/featurecfg.pm
changeset 0 044383f39525
equal deleted inserted replaced
-1:000000000000 0:044383f39525
       
     1 #
       
     2 # Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 # All rights reserved.
       
     4 # This component and the accompanying materials are made available
       
     5 # under the terms of the License "Eclipse Public License v1.0"
       
     6 # which accompanies this distribution, and is available
       
     7 # at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 #
       
     9 # Initial Contributors:
       
    10 # Nokia Corporation - initial contribution.
       
    11 #
       
    12 # Contributors:
       
    13 #
       
    14 # Description: 
       
    15 # featureregistry.pm
       
    16 #
       
    17 
       
    18 # This package contains routines to create the feature registry file.
       
    19 use featurefile;
       
    20 package featurecfg;
       
    21 
       
    22 BEGIN
       
    23 {
       
    24 	@ISA = qw (featurefile);	# Declare this a child of featurefile class
       
    25 }       
       
    26 
       
    27 use featureparser;
       
    28 use strict;
       
    29 
       
    30 # Class constructor
       
    31 sub new
       
    32 {
       
    33 	my ($class,$xmlDBHandle) = @_;
       
    34 	my $object = $class->SUPER::new($xmlDBHandle); # Invoke base class new function
       
    35 		
       
    36 	$object->{_FEATURELIST} = undef;
       
    37 	$object->{_FEATUREHASHMAP} = undef;	
       
    38 	$object->{_FILEVERSION} = 0;
       
    39 
       
    40 	return $object;
       
    41 }
       
    42 
       
    43 # Subroutine to create feature map
       
    44 # @param $object					- Object reference which is passed implicitly
       
    45 sub createFeatureMap
       
    46 {
       
    47 	my $object = shift;		
       
    48 	
       
    49 	foreach my $fidMain (@{$object->{_FEATURELIST}}) 
       
    50 	{
       
    51 		my $fid = $fidMain->{uid};
       
    52 		
       
    53 #		Check whether the feature is present in feature list XMl file or not.
       
    54 #		If not, then generate an error message and discard this feature.
       
    55 		if (!$object->isPresentInFeatureListXML($fidMain)) 
       
    56 		{
       
    57 			next;
       
    58 		}	
       
    59 
       
    60 #		Initialise the status bit
       
    61 		$fidMain->{status} = 0;
       
    62 
       
    63 #		If a feature is to be included in Rom, then set the 0th bit.
       
    64 #		If a feature is explicitly to be excluded from ROM, then nothing is to be done, 
       
    65 #		since the 0th bit is already set to zero.
       
    66 		if ($fidMain->{include} == 1)
       
    67 		{
       
    68 			$fidMain->{status} |= 1;
       
    69 		}
       
    70 
       
    71 		my $featInfoRef = ($object->{_XMLDBHANDLE})->getFeatureInfo($fid);
       
    72 
       
    73 #		Check if the individual feature is installable, If so, set the 1st bit.
       
    74 		if($featInfoRef->{installable} eq "true")
       
    75 		{
       
    76 			$fidMain->{status} |= 2;
       
    77 		}
       
    78 		
       
    79 		$object->{_FEATUREHASHMAP}->{$fid} = $fidMain->{status};
       
    80 	}	
       
    81 }
       
    82 
       
    83 # Subroutine to write the feature entries in the feature registry configuration file.
       
    84 # @param $object					- Object reference which is passed implicitly
       
    85 sub writeFeatures
       
    86 {
       
    87 	my $object = shift;
       
    88 
       
    89 	foreach my $featureId (sort {$a <=> $b} (keys %{$object->{_FEATUREHASHMAP}}))
       
    90 	{
       
    91 		$object->write2File($featureId);
       
    92 		$object->write2File($object->{_FEATUREHASHMAP}->{$featureId});
       
    93 	}
       
    94 }
       
    95 
       
    96 1;