jamesa/_common.py
changeset 5 842a773e65f2
equal deleted inserted replaced
4:60053dab7e2a 5:842a773e65f2
       
     1 # Copyright (c) 2009 Symbian Foundation Ltd
       
     2 # This component and the accompanying materials are made available
       
     3 # under the terms of the License "Eclipse Public License v1.0"
       
     4 # which accompanies this distribution, and is available
       
     5 # at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     6 #
       
     7 # Initial Contributors:
       
     8 # Symbian Foundation Ltd - initial contribution.
       
     9 # 
       
    10 # Contributors:
       
    11 #
       
    12 # Description:
       
    13 # Data structure code used by dependency analysis scripts.
       
    14 
       
    15 """Common data structure code for build_graph.py and tools.
       
    16 """
       
    17 
       
    18 __author__ = 'James Aley'
       
    19 __email__ = 'jamesa@symbian.org'
       
    20 __version__ = '1.0'
       
    21 
       
    22 class Node:
       
    23     """Node objects are similar to the Symbian notion of a Component, but
       
    24     they are defined in a practical way for ROM building with less intuitive meaning.
       
    25 
       
    26     A Node object is identified by:
       
    27       - the path to bld.inf
       
    28       where by:
       
    29         - the bld.inf file contains a PRJ_MMPFILES section with a least one MMP file.
       
    30     """
       
    31  
       
    32     def __str__(self):
       
    33         """Represent node as string, using node_path
       
    34         """
       
    35         return self.node_path
       
    36 
       
    37     def __init__(self, path):
       
    38         """Initialize new Node with given path to bld.inf
       
    39         """
       
    40         # path to the bld.inf file associating these mmp components
       
    41         self.node_path = ''
       
    42 
       
    43         # list of node_path values for Node objects owning referenced from
       
    44         # the MMP files
       
    45         self.dependencies = []
       
    46 
       
    47         # contents of this Node, likely not used algorithmically but might
       
    48         # be useful later for reporting.
       
    49         self.mmp_components = []
       
    50 
       
    51         # the following are nodes that also satisfy the dependencies (in part), and may
       
    52         # be of interest when building a ROM.
       
    53         self.interesting = []
       
    54 
       
    55         # dependencies that were not linked to another component in the source tree
       
    56         self.unresolved = []
       
    57 
       
    58         self.node_path = path
       
    59 
       
    60     def add_deps(self, deps):
       
    61         """Add dependencies to the list, filtering duplicates
       
    62         """
       
    63         self.dependencies.extend(filter(lambda x: x not in self.dependencies, deps))
       
    64