BaseTools: Workspace - use built in OrderedDict instead of custom version.

We dont use any feature added by custom dictionary class.

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:
Carsey, Jaben
2018-04-04 05:03:09 +08:00
committed by Yonghong Zhu
parent 1f1c671284
commit a0767bae29
3 changed files with 36 additions and 43 deletions

View File

@ -635,7 +635,7 @@ class DscBuildData(PlatformBuildClassObject):
## Retrieve [SkuIds] section information ## Retrieve [SkuIds] section information
def _GetSkuIds(self): def _GetSkuIds(self):
if self._SkuIds is None: if self._SkuIds is None:
self._SkuIds = sdict() self._SkuIds = OrderedDict()
RecordList = self._RawData[MODEL_EFI_SKU_ID, self._Arch] RecordList = self._RawData[MODEL_EFI_SKU_ID, self._Arch]
for Record in RecordList: for Record in RecordList:
if Record[0] in [None, '']: if Record[0] in [None, '']:
@ -662,7 +662,7 @@ class DscBuildData(PlatformBuildClassObject):
return int(intstr,16) if intstr.upper().startswith("0X") else int(intstr) return int(intstr,16) if intstr.upper().startswith("0X") else int(intstr)
def _GetDefaultStores(self): def _GetDefaultStores(self):
if self.DefaultStores is None: if self.DefaultStores is None:
self.DefaultStores = sdict() self.DefaultStores = OrderedDict()
RecordList = self._RawData[MODEL_EFI_DEFAULT_STORES, self._Arch] RecordList = self._RawData[MODEL_EFI_DEFAULT_STORES, self._Arch]
for Record in RecordList: for Record in RecordList:
if Record[0] in [None, '']: if Record[0] in [None, '']:
@ -692,7 +692,7 @@ class DscBuildData(PlatformBuildClassObject):
if self._Modules is not None: if self._Modules is not None:
return self._Modules return self._Modules
self._Modules = sdict() self._Modules = OrderedDict()
RecordList = self._RawData[MODEL_META_DATA_COMPONENT, self._Arch] RecordList = self._RawData[MODEL_META_DATA_COMPONENT, self._Arch]
Macros = self._Macros Macros = self._Macros
Macros["EDK_SOURCE"] = GlobalData.gEcpSource Macros["EDK_SOURCE"] = GlobalData.gEcpSource
@ -1122,7 +1122,7 @@ class DscBuildData(PlatformBuildClassObject):
## Retrieve all PCD settings in platform ## Retrieve all PCD settings in platform
def _GetPcds(self): def _GetPcds(self):
if self._Pcds is None: if self._Pcds is None:
self._Pcds = sdict() self._Pcds = OrderedDict()
self.__ParsePcdFromCommandLine() self.__ParsePcdFromCommandLine()
self._Pcds.update(self._GetPcd(MODEL_PCD_FIXED_AT_BUILD)) self._Pcds.update(self._GetPcd(MODEL_PCD_FIXED_AT_BUILD))
self._Pcds.update(self._GetPcd(MODEL_PCD_PATCHABLE_IN_MODULE)) self._Pcds.update(self._GetPcd(MODEL_PCD_PATCHABLE_IN_MODULE))
@ -1157,7 +1157,7 @@ class DscBuildData(PlatformBuildClassObject):
## Retrieve [BuildOptions] ## Retrieve [BuildOptions]
def _GetBuildOptions(self): def _GetBuildOptions(self):
if self._BuildOptions is None: if self._BuildOptions is None:
self._BuildOptions = sdict() self._BuildOptions = OrderedDict()
# #
# Retrieve build option for EDKII and EDK style module # Retrieve build option for EDKII and EDK style module
# #
@ -1179,9 +1179,9 @@ class DscBuildData(PlatformBuildClassObject):
def GetBuildOptionsByModuleType(self, Edk, ModuleType): def GetBuildOptionsByModuleType(self, Edk, ModuleType):
if self._ModuleTypeOptions is None: if self._ModuleTypeOptions is None:
self._ModuleTypeOptions = sdict() self._ModuleTypeOptions = OrderedDict()
if (Edk, ModuleType) not in self._ModuleTypeOptions: if (Edk, ModuleType) not in self._ModuleTypeOptions:
options = sdict() options = OrderedDict()
self._ModuleTypeOptions[Edk, ModuleType] = options self._ModuleTypeOptions[Edk, ModuleType] = options
DriverType = '%s.%s' % (Edk, ModuleType) DriverType = '%s.%s' % (Edk, ModuleType)
CommonDriverType = '%s.%s' % ('COMMON', ModuleType) CommonDriverType = '%s.%s' % ('COMMON', ModuleType)
@ -1446,7 +1446,7 @@ class DscBuildData(PlatformBuildClassObject):
# @retval a dict object contains settings of given PCD type # @retval a dict object contains settings of given PCD type
# #
def _GetPcd(self, Type): def _GetPcd(self, Type):
Pcds = sdict() Pcds = OrderedDict()
# #
# tdict is a special dict kind of type, used for selecting correct # tdict is a special dict kind of type, used for selecting correct
# PCD settings for certain ARCH # PCD settings for certain ARCH
@ -1457,7 +1457,7 @@ class DscBuildData(PlatformBuildClassObject):
PcdSet = set() PcdSet = set()
# Find out all possible PCD candidates for self._Arch # Find out all possible PCD candidates for self._Arch
RecordList = self._RawData[Type, self._Arch] RecordList = self._RawData[Type, self._Arch]
PcdValueDict = sdict() PcdValueDict = OrderedDict()
for TokenSpaceGuid, PcdCName, Setting, Arch, SkuName, Dummy3, Dummy4,Dummy5 in RecordList: for TokenSpaceGuid, PcdCName, Setting, Arch, SkuName, Dummy3, Dummy4,Dummy5 in RecordList:
SkuName = SkuName.upper() SkuName = SkuName.upper()
SkuName = 'DEFAULT' if SkuName == 'COMMON' else SkuName SkuName = 'DEFAULT' if SkuName == 'COMMON' else SkuName
@ -2230,7 +2230,7 @@ class DscBuildData(PlatformBuildClassObject):
def _GetDynamicPcd(self, Type): def _GetDynamicPcd(self, Type):
Pcds = sdict() Pcds = OrderedDict()
# #
# tdict is a special dict kind of type, used for selecting correct # tdict is a special dict kind of type, used for selecting correct
# PCD settings for certain ARCH and SKU # PCD settings for certain ARCH and SKU
@ -2395,7 +2395,7 @@ class DscBuildData(PlatformBuildClassObject):
VariableAttrs = {} VariableAttrs = {}
Pcds = sdict() Pcds = OrderedDict()
# #
# tdict is a special dict kind of type, used for selecting correct # tdict is a special dict kind of type, used for selecting correct
# PCD settings for certain ARCH and SKU # PCD settings for certain ARCH and SKU
@ -2557,7 +2557,7 @@ class DscBuildData(PlatformBuildClassObject):
def _GetDynamicVpdPcd(self, Type): def _GetDynamicVpdPcd(self, Type):
Pcds = sdict() Pcds = OrderedDict()
# #
# tdict is a special dict kind of type, used for selecting correct # tdict is a special dict kind of type, used for selecting correct
# PCD settings for certain ARCH and SKU # PCD settings for certain ARCH and SKU

View File

@ -1,7 +1,7 @@
## @file ## @file
# This file is used to create a database used by build tool # This file is used to create a database used by build tool
# #
# Copyright (c) 2008 - 2017, Intel Corporation. All rights reserved.<BR> # Copyright (c) 2008 - 2018, Intel Corporation. All rights reserved.<BR>
# (C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR> # (C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>
# This program and the accompanying materials # This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License # are licensed and made available under the terms and conditions of the BSD License
@ -17,6 +17,7 @@ from Common.DataType import *
from Common.Misc import * from Common.Misc import *
from types import * from types import *
from MetaFileParser import * from MetaFileParser import *
from collections import OrderedDict
from Workspace.BuildClassObject import ModuleBuildClassObject, LibraryClassObject, PcdClassObject from Workspace.BuildClassObject import ModuleBuildClassObject, LibraryClassObject, PcdClassObject
## Module build information from INF file ## Module build information from INF file
@ -156,7 +157,7 @@ class InfBuildData(ModuleBuildClassObject):
self._ModuleUnloadImageList = None self._ModuleUnloadImageList = None
self._ConstructorList = None self._ConstructorList = None
self._DestructorList = None self._DestructorList = None
self._Defs = None self._Defs = OrderedDict()
self._Binaries = None self._Binaries = None
self._Sources = None self._Sources = None
self._LibraryClasses = None self._LibraryClasses = None
@ -166,7 +167,7 @@ class InfBuildData(ModuleBuildClassObject):
self._Ppis = None self._Ppis = None
self._PpiComments = None self._PpiComments = None
self._Guids = None self._Guids = None
self._GuidsUsedByPcd = sdict() self._GuidsUsedByPcd = OrderedDict()
self._GuidComments = None self._GuidComments = None
self._Includes = None self._Includes = None
self._Packages = None self._Packages = None
@ -246,8 +247,6 @@ class InfBuildData(ModuleBuildClassObject):
# items defined _PROPERTY_ don't need additional processing # items defined _PROPERTY_ don't need additional processing
if Name in self: if Name in self:
self[Name] = Value self[Name] = Value
if self._Defs is None:
self._Defs = sdict()
self._Defs[Name] = Value self._Defs[Name] = Value
self._Macros[Name] = Value self._Macros[Name] = Value
# some special items in [Defines] section need special treatment # some special items in [Defines] section need special treatment
@ -255,7 +254,7 @@ class InfBuildData(ModuleBuildClassObject):
if Name in ('EFI_SPECIFICATION_VERSION', 'UEFI_SPECIFICATION_VERSION'): if Name in ('EFI_SPECIFICATION_VERSION', 'UEFI_SPECIFICATION_VERSION'):
Name = 'UEFI_SPECIFICATION_VERSION' Name = 'UEFI_SPECIFICATION_VERSION'
if self._Specification is None: if self._Specification is None:
self._Specification = sdict() self._Specification = OrderedDict()
self._Specification[Name] = GetHexVerValue(Value) self._Specification[Name] = GetHexVerValue(Value)
if self._Specification[Name] is None: if self._Specification[Name] is None:
EdkLogger.error("build", FORMAT_NOT_SUPPORTED, EdkLogger.error("build", FORMAT_NOT_SUPPORTED,
@ -307,8 +306,6 @@ class InfBuildData(ModuleBuildClassObject):
File=self.MetaFile, Line=Record[-1]) File=self.MetaFile, Line=Record[-1])
self._CustomMakefile[TokenList[0]] = TokenList[1] self._CustomMakefile[TokenList[0]] = TokenList[1]
else: else:
if self._Defs is None:
self._Defs = sdict()
self._Defs[Name] = Value self._Defs[Name] = Value
self._Macros[Name] = Value self._Macros[Name] = Value
@ -337,14 +334,14 @@ class InfBuildData(ModuleBuildClassObject):
EdkLogger.error("build", FORMAT_NOT_SUPPORTED, "MM_CORE_STANDALONE module type can't be used in the module with PI_SPECIFICATION_VERSION less than 0x00010032", File=self.MetaFile) EdkLogger.error("build", FORMAT_NOT_SUPPORTED, "MM_CORE_STANDALONE module type can't be used in the module with PI_SPECIFICATION_VERSION less than 0x00010032", File=self.MetaFile)
if self._ModuleType == SUP_MODULE_MM_STANDALONE: if self._ModuleType == SUP_MODULE_MM_STANDALONE:
EdkLogger.error("build", FORMAT_NOT_SUPPORTED, "MM_STANDALONE module type can't be used in the module with PI_SPECIFICATION_VERSION less than 0x00010032", File=self.MetaFile) EdkLogger.error("build", FORMAT_NOT_SUPPORTED, "MM_STANDALONE module type can't be used in the module with PI_SPECIFICATION_VERSION less than 0x00010032", File=self.MetaFile)
if self._Defs and 'PCI_DEVICE_ID' in self._Defs and 'PCI_VENDOR_ID' in self._Defs \ if 'PCI_DEVICE_ID' in self._Defs and 'PCI_VENDOR_ID' in self._Defs \
and 'PCI_CLASS_CODE' in self._Defs and 'PCI_REVISION' in self._Defs: and 'PCI_CLASS_CODE' in self._Defs and 'PCI_REVISION' in self._Defs:
self._BuildType = 'UEFI_OPTIONROM' self._BuildType = 'UEFI_OPTIONROM'
if 'PCI_COMPRESS' in self._Defs: if 'PCI_COMPRESS' in self._Defs:
if self._Defs['PCI_COMPRESS'] not in ('TRUE', 'FALSE'): if self._Defs['PCI_COMPRESS'] not in ('TRUE', 'FALSE'):
EdkLogger.error("build", FORMAT_INVALID, "Expected TRUE/FALSE for PCI_COMPRESS: %s" % self.MetaFile) EdkLogger.error("build", FORMAT_INVALID, "Expected TRUE/FALSE for PCI_COMPRESS: %s" % self.MetaFile)
elif self._Defs and 'UEFI_HII_RESOURCE_SECTION' in self._Defs \ elif 'UEFI_HII_RESOURCE_SECTION' in self._Defs \
and self._Defs['UEFI_HII_RESOURCE_SECTION'] == 'TRUE': and self._Defs['UEFI_HII_RESOURCE_SECTION'] == 'TRUE':
self._BuildType = 'UEFI_HII' self._BuildType = 'UEFI_HII'
else: else:
@ -398,7 +395,7 @@ class InfBuildData(ModuleBuildClassObject):
# File=self.MetaFile, Line=LineNo) # File=self.MetaFile, Line=LineNo)
else: else:
if self._BuildOptions is None: if self._BuildOptions is None:
self._BuildOptions = sdict() self._BuildOptions = OrderedDict()
if ToolList[0] in self._TOOL_CODE_: if ToolList[0] in self._TOOL_CODE_:
Tool = self._TOOL_CODE_[ToolList[0]] Tool = self._TOOL_CODE_[ToolList[0]]
@ -590,11 +587,8 @@ class InfBuildData(ModuleBuildClassObject):
## Retrieve definies other than above ones ## Retrieve definies other than above ones
def _GetDefines(self): def _GetDefines(self):
if self._Defs is None: if len(self._Defs) == 0 and self._Header_ is None:
if self._Header_ is None: self._GetHeaderInfo()
self._GetHeaderInfo()
if self._Defs is None:
self._Defs = sdict()
return self._Defs return self._Defs
## Retrieve binary files ## Retrieve binary files
@ -688,7 +682,7 @@ class InfBuildData(ModuleBuildClassObject):
## Retrieve library classes employed by this module ## Retrieve library classes employed by this module
def _GetLibraryClassUses(self): def _GetLibraryClassUses(self):
if self._LibraryClasses is None: if self._LibraryClasses is None:
self._LibraryClasses = sdict() self._LibraryClasses = OrderedDict()
RecordList = self._RawData[MODEL_EFI_LIBRARY_CLASS, self._Arch, self._Platform] RecordList = self._RawData[MODEL_EFI_LIBRARY_CLASS, self._Arch, self._Platform]
for Record in RecordList: for Record in RecordList:
Lib = Record[0] Lib = Record[0]
@ -717,8 +711,8 @@ class InfBuildData(ModuleBuildClassObject):
## Retrieve protocols consumed/produced by this module ## Retrieve protocols consumed/produced by this module
def _GetProtocols(self): def _GetProtocols(self):
if self._Protocols is None: if self._Protocols is None:
self._Protocols = sdict() self._Protocols = OrderedDict()
self._ProtocolComments = sdict() self._ProtocolComments = OrderedDict()
RecordList = self._RawData[MODEL_EFI_PROTOCOL, self._Arch, self._Platform] RecordList = self._RawData[MODEL_EFI_PROTOCOL, self._Arch, self._Platform]
for Record in RecordList: for Record in RecordList:
CName = Record[0] CName = Record[0]
@ -742,8 +736,8 @@ class InfBuildData(ModuleBuildClassObject):
## Retrieve PPIs consumed/produced by this module ## Retrieve PPIs consumed/produced by this module
def _GetPpis(self): def _GetPpis(self):
if self._Ppis is None: if self._Ppis is None:
self._Ppis = sdict() self._Ppis = OrderedDict()
self._PpiComments = sdict() self._PpiComments = OrderedDict()
RecordList = self._RawData[MODEL_EFI_PPI, self._Arch, self._Platform] RecordList = self._RawData[MODEL_EFI_PPI, self._Arch, self._Platform]
for Record in RecordList: for Record in RecordList:
CName = Record[0] CName = Record[0]
@ -767,8 +761,8 @@ class InfBuildData(ModuleBuildClassObject):
## Retrieve GUIDs consumed/produced by this module ## Retrieve GUIDs consumed/produced by this module
def _GetGuids(self): def _GetGuids(self):
if self._Guids is None: if self._Guids is None:
self._Guids = sdict() self._Guids = OrderedDict()
self._GuidComments = sdict() self._GuidComments = OrderedDict()
RecordList = self._RawData[MODEL_EFI_GUID, self._Arch, self._Platform] RecordList = self._RawData[MODEL_EFI_GUID, self._Arch, self._Platform]
for Record in RecordList: for Record in RecordList:
CName = Record[0] CName = Record[0]
@ -869,8 +863,8 @@ class InfBuildData(ModuleBuildClassObject):
## Retrieve PCDs used in this module ## Retrieve PCDs used in this module
def _GetPcds(self): def _GetPcds(self):
if self._Pcds is None: if self._Pcds is None:
self._Pcds = sdict() self._Pcds = OrderedDict()
self._PcdComments = sdict() self._PcdComments = OrderedDict()
self._Pcds.update(self._GetPcd(MODEL_PCD_FIXED_AT_BUILD)) self._Pcds.update(self._GetPcd(MODEL_PCD_FIXED_AT_BUILD))
self._Pcds.update(self._GetPcd(MODEL_PCD_PATCHABLE_IN_MODULE)) self._Pcds.update(self._GetPcd(MODEL_PCD_PATCHABLE_IN_MODULE))
self._Pcds.update(self._GetPcd(MODEL_PCD_FEATURE_FLAG)) self._Pcds.update(self._GetPcd(MODEL_PCD_FEATURE_FLAG))
@ -881,7 +875,7 @@ class InfBuildData(ModuleBuildClassObject):
## Retrieve build options specific to this module ## Retrieve build options specific to this module
def _GetBuildOptions(self): def _GetBuildOptions(self):
if self._BuildOptions is None: if self._BuildOptions is None:
self._BuildOptions = sdict() self._BuildOptions = OrderedDict()
RecordList = self._RawData[MODEL_META_DATA_BUILD_OPTION, self._Arch, self._Platform] RecordList = self._RawData[MODEL_META_DATA_BUILD_OPTION, self._Arch, self._Platform]
for Record in RecordList: for Record in RecordList:
ToolChainFamily = Record[0] ToolChainFamily = Record[0]
@ -920,7 +914,7 @@ class InfBuildData(ModuleBuildClassObject):
"'%s' module must specify the type of [Depex] section" % self.ModuleType, "'%s' module must specify the type of [Depex] section" % self.ModuleType,
File=self.MetaFile) File=self.MetaFile)
Depex = sdict() Depex = OrderedDict()
for Record in RecordList: for Record in RecordList:
DepexStr = ReplaceMacro(Record[0], self._Macros, False) DepexStr = ReplaceMacro(Record[0], self._Macros, False)
Arch = Record[3] Arch = Record[3]
@ -961,7 +955,7 @@ class InfBuildData(ModuleBuildClassObject):
if self._DepexExpression is None: if self._DepexExpression is None:
self._DepexExpression = tdict(False, 2) self._DepexExpression = tdict(False, 2)
RecordList = self._RawData[MODEL_EFI_DEPEX, self._Arch] RecordList = self._RawData[MODEL_EFI_DEPEX, self._Arch]
DepexExpression = sdict() DepexExpression = OrderedDict()
for Record in RecordList: for Record in RecordList:
DepexStr = ReplaceMacro(Record[0], self._Macros, False) DepexStr = ReplaceMacro(Record[0], self._Macros, False)
Arch = Record[3] Arch = Record[3]
@ -979,7 +973,7 @@ class InfBuildData(ModuleBuildClassObject):
return self._GuidsUsedByPcd return self._GuidsUsedByPcd
## Retrieve PCD for given type ## Retrieve PCD for given type
def _GetPcd(self, Type): def _GetPcd(self, Type):
Pcds = sdict() Pcds = OrderedDict()
PcdDict = tdict(True, 4) PcdDict = tdict(True, 4)
PcdList = [] PcdList = []
RecordList = self._RawData[Type, self._Arch, self._Platform] RecordList = self._RawData[Type, self._Arch, self._Platform]

View File

@ -11,7 +11,6 @@
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
# #
from Common.Misc import sdict
from collections import OrderedDict, defaultdict from collections import OrderedDict, defaultdict
from Common.DataType import SUP_MODULE_USER_DEFINED from Common.DataType import SUP_MODULE_USER_DEFINED
from BuildClassObject import LibraryClassObject from BuildClassObject import LibraryClassObject
@ -113,7 +112,7 @@ def _GetModuleLibraryInstances(Module, Platform, BuildDatabase, Arch, Target, To
LibraryConsumerList = [Module] LibraryConsumerList = [Module]
Constructor = [] Constructor = []
ConsumedByList = OrderedListDict() ConsumedByList = OrderedListDict()
LibraryInstance = sdict() LibraryInstance = OrderedDict()
while len(LibraryConsumerList) > 0: while len(LibraryConsumerList) > 0:
M = LibraryConsumerList.pop() M = LibraryConsumerList.pop()