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