summaryrefslogtreecommitdiffstats
path: root/BaseTools
diff options
context:
space:
mode:
authorCarsey, Jaben </o=Intel/ou=Americas01/cn=Workers/cn=Carsey, Jaben>2018-04-04 05:03:08 +0800
committerYonghong Zhu <yonghong.zhu@intel.com>2018-04-08 14:50:17 +0800
commit1f1c67128430bfd8a57213f7147d56f194880a51 (patch)
tree522e57ea815cc690489443316cc7dce97e7d0c49 /BaseTools
parent6e6d767edf855320e49892e5f8773e0b3394b975 (diff)
downloadedk2-1f1c67128430bfd8a57213f7147d56f194880a51.tar.gz
edk2-1f1c67128430bfd8a57213f7147d56f194880a51.tar.bz2
edk2-1f1c67128430bfd8a57213f7147d56f194880a51.zip
BaseTools: use combined version of OrderedDict
since we need order and a default entry, use collections dicts to auto generate. Cc: Liming Gao <liming.gao@intel.com> Cc: Yonghong Zhu <yonghong.zhu@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Jaben Carsey <jaben.carsey@intel.com> Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
Diffstat (limited to 'BaseTools')
-rw-r--r--BaseTools/Source/Python/Workspace/WorkspaceCommon.py18
1 files changed, 11 insertions, 7 deletions
diff --git a/BaseTools/Source/Python/Workspace/WorkspaceCommon.py b/BaseTools/Source/Python/Workspace/WorkspaceCommon.py
index abe34cf9a0..8c27b4ad5b 100644
--- a/BaseTools/Source/Python/Workspace/WorkspaceCommon.py
+++ b/BaseTools/Source/Python/Workspace/WorkspaceCommon.py
@@ -12,11 +12,17 @@
#
from Common.Misc import sdict
+from collections import OrderedDict, defaultdict
from Common.DataType import SUP_MODULE_USER_DEFINED
from BuildClassObject import LibraryClassObject
import Common.GlobalData as GlobalData
from Workspace.BuildClassObject import StructurePcd
+class OrderedListDict(OrderedDict, defaultdict):
+ def __init__(self, *args, **kwargs):
+ super(OrderedListDict, self).__init__(*args, **kwargs)
+ self.default_factory = list
+
## Get all packages from platform for specified arch, target and toolchain
#
# @param Platform: DscBuildData instance
@@ -106,7 +112,7 @@ def _GetModuleLibraryInstances(Module, Platform, BuildDatabase, Arch, Target, To
# EdkII module
LibraryConsumerList = [Module]
Constructor = []
- ConsumedByList = sdict()
+ ConsumedByList = OrderedListDict()
LibraryInstance = sdict()
while len(LibraryConsumerList) > 0:
@@ -145,8 +151,6 @@ def _GetModuleLibraryInstances(Module, Platform, BuildDatabase, Arch, Target, To
if LibraryModule.ConstructorList != [] and LibraryModule not in Constructor:
Constructor.append(LibraryModule)
- if LibraryModule not in ConsumedByList:
- ConsumedByList[LibraryModule] = []
# don't add current module itself to consumer list
if M != Module:
if M in ConsumedByList[LibraryModule]:
@@ -164,7 +168,7 @@ def _GetModuleLibraryInstances(Module, Platform, BuildDatabase, Arch, Target, To
for LibraryClassName in LibraryInstance:
M = LibraryInstance[LibraryClassName]
LibraryList.append(M)
- if ConsumedByList[M] == []:
+ if len(ConsumedByList[M]) == 0:
Q.append(M)
#
@@ -185,7 +189,7 @@ def _GetModuleLibraryInstances(Module, Platform, BuildDatabase, Arch, Target, To
# remove edge e from the graph if Node has no constructor
ConsumedByList[Item].remove(Node)
EdgeRemoved = True
- if ConsumedByList[Item] == []:
+ if len(ConsumedByList[Item]) == 0:
# insert Item into Q
Q.insert(0, Item)
break
@@ -207,7 +211,7 @@ def _GetModuleLibraryInstances(Module, Platform, BuildDatabase, Arch, Target, To
# remove edge e from the graph
ConsumedByList[Item].remove(Node)
- if ConsumedByList[Item] != []:
+ if len(ConsumedByList[Item]) != 0:
continue
# insert Item into Q, if Item has no other incoming edges
Q.insert(0, Item)
@@ -216,7 +220,7 @@ def _GetModuleLibraryInstances(Module, Platform, BuildDatabase, Arch, Target, To
# if any remaining node Item in the graph has a constructor and an incoming edge, then the graph has a cycle
#
for Item in LibraryList:
- if ConsumedByList[Item] != [] and Item in Constructor and len(Constructor) > 1:
+ if len(ConsumedByList[Item]) != 0 and Item in Constructor and len(Constructor) > 1:
return []
if Item not in SortedLibraryList:
SortedLibraryList.append(Item)