diff options
author | Carsey, Jaben <jaben.carsey@intel.com> | 2018-09-11 06:18:06 +0800 |
---|---|---|
committer | Yonghong Zhu <yonghong.zhu@intel.com> | 2018-09-20 22:18:07 +0800 |
commit | b0a2645162a43973befe05743a3c90d0a906b339 (patch) | |
tree | cb383c68abdd2a1d77bb021f057799f289b98fa0 /BaseTools | |
parent | 71cac3f791c2469468838ded6519b624d32345bb (diff) | |
download | edk2-b0a2645162a43973befe05743a3c90d0a906b339.zip edk2-b0a2645162a43973befe05743a3c90d0a906b339.tar.gz edk2-b0a2645162a43973befe05743a3c90d0a906b339.tar.bz2 |
BaseTools: refactor Build Database objects
1) use namedtuple instead of custom class when apropriate
2) rename collections.OrderedDict to OrderedDict since we import it already
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/BuildClassObject.py | 32 |
1 files changed, 9 insertions, 23 deletions
diff --git a/BaseTools/Source/Python/Workspace/BuildClassObject.py b/BaseTools/Source/Python/Workspace/BuildClassObject.py index 12227b8..ece1176 100644 --- a/BaseTools/Source/Python/Workspace/BuildClassObject.py +++ b/BaseTools/Source/Python/Workspace/BuildClassObject.py @@ -11,8 +11,8 @@ # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
+from collections import OrderedDict, namedtuple
from Common.DataType import *
-import collections
## PcdClassObject
#
@@ -166,17 +166,17 @@ class StructurePcd(PcdClassObject): self.StructuredPcdIncludeFile = [] if StructuredPcdIncludeFile is None else StructuredPcdIncludeFile
self.PackageDecs = Packages
self.DefaultStoreName = [default_store]
- self.DefaultValues = collections.OrderedDict()
+ self.DefaultValues = OrderedDict()
self.PcdMode = None
- self.SkuOverrideValues = collections.OrderedDict()
+ self.SkuOverrideValues = OrderedDict()
self.FlexibleFieldName = None
self.StructName = None
self.PcdDefineLineNo = 0
self.PkgPath = ""
self.DefaultValueFromDec = ""
self.ValueChain = set()
- self.PcdFieldValueFromComm = collections.OrderedDict()
- self.PcdFieldValueFromFdf = collections.OrderedDict()
+ self.PcdFieldValueFromComm = OrderedDict()
+ self.PcdFieldValueFromFdf = OrderedDict()
def __repr__(self):
return self.TypeName
@@ -190,9 +190,9 @@ class StructurePcd(PcdClassObject): self.DefaultValueFromDec = DefaultValue
def AddOverrideValue (self, FieldName, Value, SkuName, DefaultStoreName, FileName="", LineNo=0):
if SkuName not in self.SkuOverrideValues:
- self.SkuOverrideValues[SkuName] = collections.OrderedDict()
+ self.SkuOverrideValues[SkuName] = OrderedDict()
if DefaultStoreName not in self.SkuOverrideValues[SkuName]:
- self.SkuOverrideValues[SkuName][DefaultStoreName] = collections.OrderedDict()
+ self.SkuOverrideValues[SkuName][DefaultStoreName] = OrderedDict()
if FieldName in self.SkuOverrideValues[SkuName][DefaultStoreName]:
del self.SkuOverrideValues[SkuName][DefaultStoreName][FieldName]
self.SkuOverrideValues[SkuName][DefaultStoreName][FieldName] = [Value.strip(), FileName, LineNo]
@@ -243,21 +243,7 @@ class StructurePcd(PcdClassObject): self.PcdFieldValueFromComm = PcdObject.PcdFieldValueFromComm if PcdObject.PcdFieldValueFromComm else self.PcdFieldValueFromComm
self.PcdFieldValueFromFdf = PcdObject.PcdFieldValueFromFdf if PcdObject.PcdFieldValueFromFdf else self.PcdFieldValueFromFdf
-## LibraryClassObject
-#
-# This Class defines LibraryClassObject used in BuildDatabase
-#
-# @param object: Inherited from object class
-# @param Name: Input value for LibraryClassName, default is None
-# @param SupModList: Input value for SupModList, default is []
-#
-# @var LibraryClass: To store value for LibraryClass
-# @var SupModList: To store value for SupModList
-#
-class LibraryClassObject(object):
- def __init__(self, Name = None, SupModList = []):
- self.LibraryClass = Name
- self.SupModList = SupModList
+LibraryClassObject = namedtuple('LibraryClassObject', ['LibraryClass','SupModList'], verbose=False)
## ModuleBuildClassObject
#
@@ -325,7 +311,7 @@ class ModuleBuildClassObject(object): self.Binaries = []
self.Sources = []
- self.LibraryClasses = collections.OrderedDict()
+ self.LibraryClasses = OrderedDict()
self.Libraries = []
self.Protocols = []
self.Ppis = []
|