mirror of https://github.com/acidanthera/audk.git
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>
This commit is contained in:
parent
6e6d767edf
commit
1f1c671284
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue