* [PATCH v1 0/3] BaseTools: refactor to remove redundant
@ 2018-04-10 14:20 Jaben Carsey
2018-04-10 14:20 ` [PATCH v1 1/3] BaseTools: refactor and remove more keys() usage Jaben Carsey
` (2 more replies)
0 siblings, 3 replies; 8+ messages in thread
From: Jaben Carsey @ 2018-04-10 14:20 UTC (permalink / raw)
To: edk2-devel
Replace raw strings used in lots of places with predefined constants.
remove more out of date keys() usage.
Jaben Carsey (3):
BaseTools: refactor and remove more keys() usage
BaseTools: use predefined constants instead of local strings
BaseTools: use existing contrants to replace raw strings in python
code.
BaseTools/Source/Python/AutoGen/AutoGen.py | 24 +--
BaseTools/Source/Python/AutoGen/BuildEngine.py | 23 +--
BaseTools/Source/Python/AutoGen/GenC.py | 13 +-
BaseTools/Source/Python/AutoGen/GenDepex.py | 3 +-
BaseTools/Source/Python/AutoGen/GenPcdDb.py | 15 +-
BaseTools/Source/Python/AutoGen/GenVar.py | 15 +-
BaseTools/Source/Python/Common/DataType.py | 2 +
BaseTools/Source/Python/GenFds/AprioriSection.py | 3 +-
BaseTools/Source/Python/GenFds/FdfParser.py | 29 ++--
BaseTools/Source/Python/GenFds/Ffs.py | 3 +-
BaseTools/Source/Python/GenFds/FfsInfStatement.py | 5 +-
BaseTools/Source/Python/GenFds/GenFds.py | 13 +-
BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py | 9 +-
BaseTools/Source/Python/GenFds/Section.py | 3 +-
BaseTools/Source/Python/Workspace/DecBuildData.py | 5 +-
BaseTools/Source/Python/Workspace/DscBuildData.py | 173 ++++++++++----------
BaseTools/Source/Python/Workspace/InfBuildData.py | 9 +-
BaseTools/Source/Python/Workspace/MetaFileParser.py | 34 ++--
BaseTools/Source/Python/Workspace/MetaFileTable.py | 22 +--
BaseTools/Source/Python/Workspace/WorkspaceDatabase.py | 6 +-
BaseTools/Source/Python/build/BuildReport.py | 5 +-
21 files changed, 218 insertions(+), 196 deletions(-)
--
2.16.2.windows.1
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v1 1/3] BaseTools: refactor and remove more keys() usage
2018-04-10 14:20 [PATCH v1 0/3] BaseTools: refactor to remove redundant Jaben Carsey
@ 2018-04-10 14:20 ` Jaben Carsey
2018-04-18 8:48 ` Zhu, Yonghong
2018-04-10 14:20 ` [PATCH v1 2/3] BaseTools: use predefined constants instead of local strings Jaben Carsey
2018-04-10 14:20 ` [PATCH v1 3/3] BaseTools: use existing contrants to replace raw strings in python code Jaben Carsey
2 siblings, 1 reply; 8+ messages in thread
From: Jaben Carsey @ 2018-04-10 14:20 UTC (permalink / raw)
To: edk2-devel; +Cc: Liming Gao, Yonghong Zhu
this is no longer required to make dictionary objects iterable.
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>
---
BaseTools/Source/Python/Workspace/DscBuildData.py | 59 +++++++++-----------
1 file changed, 27 insertions(+), 32 deletions(-)
diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py b/BaseTools/Source/Python/Workspace/DscBuildData.py
index cf9608651269..35ef15262a09 100644
--- a/BaseTools/Source/Python/Workspace/DscBuildData.py
+++ b/BaseTools/Source/Python/Workspace/DscBuildData.py
@@ -593,7 +593,7 @@ class DscBuildData(PlatformBuildClassObject):
#
# If command line defined, should override the value in DSC file.
#
- if 'FIX_LOAD_TOP_MEMORY_ADDRESS' in GlobalData.gCommandLineDefines.keys():
+ if 'FIX_LOAD_TOP_MEMORY_ADDRESS' in GlobalData.gCommandLineDefines:
try:
self._LoadFixAddress = int(GlobalData.gCommandLineDefines['FIX_LOAD_TOP_MEMORY_ADDRESS'], 0)
except:
@@ -682,9 +682,7 @@ class DscBuildData(PlatformBuildClassObject):
self.DefaultStores[Record[1].upper()] = (self.ToInt(Record[0]),Record[1].upper())
if TAB_DEFAULT_STORES_DEFAULT not in self.DefaultStores:
self.DefaultStores[TAB_DEFAULT_STORES_DEFAULT] = (0,TAB_DEFAULT_STORES_DEFAULT)
- GlobalData.gDefaultStores = self.DefaultStores.keys()
- if GlobalData.gDefaultStores:
- GlobalData.gDefaultStores.sort()
+ GlobalData.gDefaultStores = sorted(self.DefaultStores.keys())
return self.DefaultStores
## Retrieve [Components] section information
@@ -1430,11 +1428,11 @@ class DscBuildData(PlatformBuildClassObject):
for pcdkey in Pcds:
pcd = Pcds[pcdkey]
- if 'DEFAULT' not in pcd.SkuInfoList.keys() and 'COMMON' in pcd.SkuInfoList.keys():
+ if 'DEFAULT' not in pcd.SkuInfoList and 'COMMON' in pcd.SkuInfoList:
pcd.SkuInfoList['DEFAULT'] = pcd.SkuInfoList['COMMON']
- del(pcd.SkuInfoList['COMMON'])
- elif 'DEFAULT' in pcd.SkuInfoList.keys() and 'COMMON' in pcd.SkuInfoList.keys():
- del(pcd.SkuInfoList['COMMON'])
+ del pcd.SkuInfoList['COMMON']
+ elif 'DEFAULT' in pcd.SkuInfoList and 'COMMON' in pcd.SkuInfoList:
+ del pcd.SkuInfoList['COMMON']
map(self.FilterSkuSettings,[Pcds[pcdkey] for pcdkey in Pcds if Pcds[pcdkey].Type in DynamicPcdType])
return Pcds
@@ -1479,10 +1477,7 @@ class DscBuildData(PlatformBuildClassObject):
else:
PcdValueDict[PcdCName, TokenSpaceGuid] = {SkuName:(PcdValue, DatumType, MaxDatumSize)}
- PcdsKeys = PcdValueDict.keys()
- for PcdCName, TokenSpaceGuid in PcdsKeys:
-
- PcdSetting = PcdValueDict[PcdCName, TokenSpaceGuid]
+ for ((PcdName,TokenSpaceGuid),PcdSetting) in PcdValueDict.iteritems():
PcdValue = None
DatumType = None
MaxDatumSize = None
@@ -1883,7 +1878,7 @@ class DscBuildData(PlatformBuildClassObject):
OverrideValues = {DefaultStore:""}
if Pcd.SkuOverrideValues:
OverrideValues = Pcd.SkuOverrideValues[SkuName]
- for DefaultStoreName in OverrideValues.keys():
+ for DefaultStoreName in OverrideValues:
CApp = CApp + 'void\n'
CApp = CApp + 'Initialize_%s_%s_%s_%s(\n' % (SkuName, DefaultStoreName, Pcd.TokenSpaceGuidCName, Pcd.TokenCName)
CApp = CApp + ' void\n'
@@ -2261,7 +2256,7 @@ class DscBuildData(PlatformBuildClassObject):
PcdValue, DatumType, MaxDatumSize = self._ValidatePcd(PcdCName, TokenSpaceGuid, Setting, Type, Dummy4)
SkuInfo = SkuInfoClass(SkuName, self.SkuIds[SkuName][0], '', '', '', '', '', PcdValue)
- if (PcdCName, TokenSpaceGuid) in Pcds.keys():
+ if (PcdCName, TokenSpaceGuid) in Pcds:
pcdObject = Pcds[PcdCName, TokenSpaceGuid]
pcdObject.SkuInfoList[SkuName] = SkuInfo
if MaxDatumSize.strip():
@@ -2294,15 +2289,15 @@ class DscBuildData(PlatformBuildClassObject):
for sku in pcd.SkuInfoList.values():
if (sku.DefaultValue == "" or sku.DefaultValue==None):
sku.DefaultValue = pcdDecObject.DefaultValue
- if 'DEFAULT' not in pcd.SkuInfoList.keys() and 'COMMON' not in pcd.SkuInfoList.keys():
+ if 'DEFAULT' not in pcd.SkuInfoList and 'COMMON' not in pcd.SkuInfoList:
valuefromDec = pcdDecObject.DefaultValue
SkuInfo = SkuInfoClass('DEFAULT', '0', '', '', '', '', '', valuefromDec)
pcd.SkuInfoList['DEFAULT'] = SkuInfo
- elif 'DEFAULT' not in pcd.SkuInfoList.keys() and 'COMMON' in pcd.SkuInfoList.keys():
+ elif 'DEFAULT' not in pcd.SkuInfoList and 'COMMON' in pcd.SkuInfoList:
pcd.SkuInfoList['DEFAULT'] = pcd.SkuInfoList['COMMON']
- del(pcd.SkuInfoList['COMMON'])
- elif 'DEFAULT' in pcd.SkuInfoList.keys() and 'COMMON' in pcd.SkuInfoList.keys():
- del(pcd.SkuInfoList['COMMON'])
+ del pcd.SkuInfoList['COMMON']
+ elif 'DEFAULT' in pcd.SkuInfoList and 'COMMON' in pcd.SkuInfoList:
+ del pcd.SkuInfoList['COMMON']
map(self.FilterSkuSettings,Pcds.values())
@@ -2311,7 +2306,7 @@ class DscBuildData(PlatformBuildClassObject):
def FilterSkuSettings(self, PcdObj):
if self.SkuIdMgr.SkuUsageType == self.SkuIdMgr.SINGLE:
- if 'DEFAULT' in PcdObj.SkuInfoList.keys() and self.SkuIdMgr.SystemSkuId not in PcdObj.SkuInfoList.keys():
+ if 'DEFAULT' in PcdObj.SkuInfoList and self.SkuIdMgr.SystemSkuId not in PcdObj.SkuInfoList:
PcdObj.SkuInfoList[self.SkuIdMgr.SystemSkuId] = PcdObj.SkuInfoList['DEFAULT']
PcdObj.SkuInfoList = {'DEFAULT':PcdObj.SkuInfoList[self.SkuIdMgr.SystemSkuId]}
PcdObj.SkuInfoList['DEFAULT'].SkuIdName = 'DEFAULT'
@@ -2465,7 +2460,7 @@ class DscBuildData(PlatformBuildClassObject):
EdkLogger.error('Build', PCD_VARIABLE_ATTRIBUTES_CONFLICT_ERROR, "The variable %s.%s for DynamicHii PCDs has conflicting attributes [%s] and [%s] " % (VariableGuid, VariableName, VarAttribute, VariableAttrs[(VariableName, VariableGuid)]))
pcdDecObject = self._DecPcds[PcdCName, TokenSpaceGuid]
- if (PcdCName, TokenSpaceGuid) in Pcds.keys():
+ if (PcdCName, TokenSpaceGuid) in Pcds:
pcdObject = Pcds[PcdCName, TokenSpaceGuid]
if SkuName in pcdObject.SkuInfoList:
Skuitem = pcdObject.SkuInfoList[SkuName]
@@ -2503,15 +2498,15 @@ class DscBuildData(PlatformBuildClassObject):
for default_store in sku.DefaultStoreDict:
sku.DefaultStoreDict[default_store]=pcdDecObject.DefaultValue
pcd.DefaultValue = pcdDecObject.DefaultValue
- if 'DEFAULT' not in pcd.SkuInfoList.keys() and 'COMMON' not in pcd.SkuInfoList.keys():
+ if 'DEFAULT' not in pcd.SkuInfoList and 'COMMON' not in pcd.SkuInfoList:
valuefromDec = pcdDecObject.DefaultValue
SkuInfo = SkuInfoClass('DEFAULT', '0', SkuInfoObj.VariableName, SkuInfoObj.VariableGuid, SkuInfoObj.VariableOffset, valuefromDec,VariableAttribute=SkuInfoObj.VariableAttribute,DefaultStore={DefaultStore:valuefromDec})
pcd.SkuInfoList['DEFAULT'] = SkuInfo
- elif 'DEFAULT' not in pcd.SkuInfoList.keys() and 'COMMON' in pcd.SkuInfoList.keys():
+ elif 'DEFAULT' not in pcd.SkuInfoList and 'COMMON' in pcd.SkuInfoList:
pcd.SkuInfoList['DEFAULT'] = pcd.SkuInfoList['COMMON']
- del(pcd.SkuInfoList['COMMON'])
- elif 'DEFAULT' in pcd.SkuInfoList.keys() and 'COMMON' in pcd.SkuInfoList.keys():
- del(pcd.SkuInfoList['COMMON'])
+ del pcd.SkuInfoList['COMMON']
+ elif 'DEFAULT' in pcd.SkuInfoList and 'COMMON' in pcd.SkuInfoList:
+ del pcd.SkuInfoList['COMMON']
if pcd.MaxDatumSize.strip():
MaxSize = int(pcd.MaxDatumSize, 0)
@@ -2592,7 +2587,7 @@ class DscBuildData(PlatformBuildClassObject):
#
VpdOffset, MaxDatumSize, InitialValue = self._ValidatePcd(PcdCName, TokenSpaceGuid, Setting, Type, Dummy4)
SkuInfo = SkuInfoClass(SkuName, self.SkuIds[SkuName][0], '', '', '', '', VpdOffset, InitialValue)
- if (PcdCName, TokenSpaceGuid) in Pcds.keys():
+ if (PcdCName, TokenSpaceGuid) in Pcds:
pcdObject = Pcds[PcdCName, TokenSpaceGuid]
pcdObject.SkuInfoList[SkuName] = SkuInfo
if MaxDatumSize.strip():
@@ -2626,15 +2621,15 @@ class DscBuildData(PlatformBuildClassObject):
for sku in pcd.SkuInfoList.values():
if (sku.DefaultValue == "" or sku.DefaultValue==None):
sku.DefaultValue = pcdDecObject.DefaultValue
- if 'DEFAULT' not in pcd.SkuInfoList.keys() and 'COMMON' not in pcd.SkuInfoList.keys():
+ if 'DEFAULT' not in pcd.SkuInfoList and 'COMMON' not in pcd.SkuInfoList:
valuefromDec = pcdDecObject.DefaultValue
SkuInfo = SkuInfoClass('DEFAULT', '0', '', '', '', '', SkuInfoObj.VpdOffset, valuefromDec)
pcd.SkuInfoList['DEFAULT'] = SkuInfo
- elif 'DEFAULT' not in pcd.SkuInfoList.keys() and 'COMMON' in pcd.SkuInfoList.keys():
+ elif 'DEFAULT' not in pcd.SkuInfoList and 'COMMON' in pcd.SkuInfoList:
pcd.SkuInfoList['DEFAULT'] = pcd.SkuInfoList['COMMON']
- del(pcd.SkuInfoList['COMMON'])
- elif 'DEFAULT' in pcd.SkuInfoList.keys() and 'COMMON' in pcd.SkuInfoList.keys():
- del(pcd.SkuInfoList['COMMON'])
+ del pcd.SkuInfoList['COMMON']
+ elif 'DEFAULT' in pcd.SkuInfoList and 'COMMON' in pcd.SkuInfoList:
+ del pcd.SkuInfoList['COMMON']
map(self.FilterSkuSettings,Pcds.values())
--
2.16.2.windows.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH v1 2/3] BaseTools: use predefined constants instead of local strings
2018-04-10 14:20 [PATCH v1 0/3] BaseTools: refactor to remove redundant Jaben Carsey
2018-04-10 14:20 ` [PATCH v1 1/3] BaseTools: refactor and remove more keys() usage Jaben Carsey
@ 2018-04-10 14:20 ` Jaben Carsey
2018-04-16 1:43 ` Zhu, Yonghong
2018-04-10 14:20 ` [PATCH v1 3/3] BaseTools: use existing contrants to replace raw strings in python code Jaben Carsey
2 siblings, 1 reply; 8+ messages in thread
From: Jaben Carsey @ 2018-04-10 14:20 UTC (permalink / raw)
To: edk2-devel; +Cc: Liming Gao, Yonghong Zhu
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>
---
BaseTools/Source/Python/AutoGen/AutoGen.py | 24 +--
BaseTools/Source/Python/AutoGen/BuildEngine.py | 23 +--
BaseTools/Source/Python/AutoGen/GenPcdDb.py | 15 +-
BaseTools/Source/Python/AutoGen/GenVar.py | 15 +-
BaseTools/Source/Python/Common/DataType.py | 2 +
BaseTools/Source/Python/GenFds/AprioriSection.py | 3 +-
BaseTools/Source/Python/GenFds/FdfParser.py | 29 ++--
BaseTools/Source/Python/GenFds/FfsInfStatement.py | 5 +-
BaseTools/Source/Python/GenFds/GenFds.py | 13 +-
BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py | 9 +-
BaseTools/Source/Python/GenFds/Section.py | 3 +-
BaseTools/Source/Python/Workspace/DecBuildData.py | 5 +-
BaseTools/Source/Python/Workspace/DscBuildData.py | 154 ++++++++++----------
BaseTools/Source/Python/Workspace/InfBuildData.py | 7 +-
BaseTools/Source/Python/Workspace/MetaFileParser.py | 34 ++---
BaseTools/Source/Python/Workspace/MetaFileTable.py | 22 +--
BaseTools/Source/Python/Workspace/WorkspaceDatabase.py | 6 +-
17 files changed, 196 insertions(+), 173 deletions(-)
diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py b/BaseTools/Source/Python/AutoGen/AutoGen.py
index 3384fdb70b7e..abdddec5ed6a 100644
--- a/BaseTools/Source/Python/AutoGen/AutoGen.py
+++ b/BaseTools/Source/Python/AutoGen/AutoGen.py
@@ -45,6 +45,8 @@ import InfSectionParser
import datetime
import hashlib
from GenVar import VariableMgr,var_info
+from Common.DataType import TAB_DEFAULT
+from Common.DataType import TAB_COMMON
## Regular expression for splitting Dependency Expression string into tokens
gDepexTokenPattern = re.compile("(\(|\)|\w+| \S+\.inf)")
@@ -253,7 +255,7 @@ class WorkspaceAutoGen(AutoGen):
self.BuildDatabase = MetaFileDb
self.MetaFile = ActivePlatform
self.WorkspaceDir = WorkspaceDir
- self.Platform = self.BuildDatabase[self.MetaFile, 'COMMON', Target, Toolchain]
+ self.Platform = self.BuildDatabase[self.MetaFile, TAB_COMMON, Target, Toolchain]
GlobalData.gActivePlatform = self.Platform
self.BuildTarget = Target
self.ToolChain = Toolchain
@@ -803,7 +805,7 @@ class WorkspaceAutoGen(AutoGen):
# Here we just need to get FILE_GUID from INF file, use 'COMMON' as ARCH attribute. and use
# BuildObject from one of AutoGenObjectList is enough.
#
- InfObj = self.AutoGenObjectList[0].BuildDatabase.WorkspaceDb.BuildObject[PathClassObj, 'COMMON', self.BuildTarget, self.ToolChain]
+ InfObj = self.AutoGenObjectList[0].BuildDatabase.WorkspaceDb.BuildObject[PathClassObj, TAB_COMMON, self.BuildTarget, self.ToolChain]
if not InfObj.Guid.upper() in _GuidDict.keys():
_GuidDict[InfObj.Guid.upper()] = FfsFile
else:
@@ -1355,7 +1357,7 @@ class PlatformAutoGen(AutoGen):
EdkLogger.error("build", FILE_READ_FAILURE, "Can not find VPD map file %s to fix up VPD offset." % VpdMapFilePath)
NvStoreOffset = int(NvStoreOffset,16) if NvStoreOffset.upper().startswith("0X") else int(NvStoreOffset)
- default_skuobj = PcdNvStoreDfBuffer[0].SkuInfoList.get("DEFAULT")
+ default_skuobj = PcdNvStoreDfBuffer[0].SkuInfoList.get(TAB_DEFAULT)
maxsize = self.VariableInfo.VpdRegionSize - NvStoreOffset if self.VariableInfo.VpdRegionSize else len(default_skuobj.DefaultValue.split(","))
var_data = self.VariableInfo.PatchNVStoreDefaultMaxSize(maxsize)
@@ -1363,7 +1365,7 @@ class PlatformAutoGen(AutoGen):
default_skuobj.DefaultValue = var_data
PcdNvStoreDfBuffer[0].DefaultValue = var_data
PcdNvStoreDfBuffer[0].SkuInfoList.clear()
- PcdNvStoreDfBuffer[0].SkuInfoList['DEFAULT'] = default_skuobj
+ PcdNvStoreDfBuffer[0].SkuInfoList[TAB_DEFAULT] = default_skuobj
PcdNvStoreDfBuffer[0].MaxDatumSize = str(len(default_skuobj.DefaultValue.split(",")))
return OrgVpdFile
@@ -1603,12 +1605,12 @@ class PlatformAutoGen(AutoGen):
PcdKey in VpdPcdDict:
Pcd = VpdPcdDict[PcdKey]
SkuValueMap = {}
- DefaultSku = Pcd.SkuInfoList.get('DEFAULT')
+ DefaultSku = Pcd.SkuInfoList.get(TAB_DEFAULT)
if DefaultSku:
PcdValue = DefaultSku.DefaultValue
if PcdValue not in SkuValueMap:
SkuValueMap[PcdValue] = []
- VpdFile.Add(Pcd, 'DEFAULT',DefaultSku.VpdOffset)
+ VpdFile.Add(Pcd, TAB_DEFAULT,DefaultSku.VpdOffset)
SkuValueMap[PcdValue].append(DefaultSku)
for (SkuName,Sku) in Pcd.SkuInfoList.items():
@@ -1667,9 +1669,9 @@ class PlatformAutoGen(AutoGen):
# just pick the a value to determine whether is unicode string type
SkuValueMap = {}
SkuObjList = DscPcdEntry.SkuInfoList.items()
- DefaultSku = DscPcdEntry.SkuInfoList.get('DEFAULT')
+ DefaultSku = DscPcdEntry.SkuInfoList.get(TAB_DEFAULT)
if DefaultSku:
- defaultindex = SkuObjList.index(('DEFAULT',DefaultSku))
+ defaultindex = SkuObjList.index((TAB_DEFAULT,DefaultSku))
SkuObjList[0],SkuObjList[defaultindex] = SkuObjList[defaultindex],SkuObjList[0]
for (SkuName,Sku) in SkuObjList:
Sku.VpdOffset = Sku.VpdOffset.strip()
@@ -1793,7 +1795,7 @@ class PlatformAutoGen(AutoGen):
for (SkuName,SkuId) in allskuset:
if type(SkuId) in (str,unicode) and eval(SkuId) == 0 or SkuId == 0:
continue
- pcd.SkuInfoList[SkuName] = copy.deepcopy(pcd.SkuInfoList['DEFAULT'])
+ pcd.SkuInfoList[SkuName] = copy.deepcopy(pcd.SkuInfoList[TAB_DEFAULT])
pcd.SkuInfoList[SkuName].SkuId = SkuId
self.AllPcdList = self._NonDynamicPcdList + self._DynamicPcdList
@@ -2420,7 +2422,7 @@ class PlatformAutoGen(AutoGen):
if self.Platform.SkuName in self.Platform.SkuIds:
SkuName = self.Platform.SkuName
else:
- SkuName = 'DEFAULT'
+ SkuName = TAB_DEFAULT
ToPcd.SkuInfoList = {
SkuName : SkuInfoClass(SkuName, self.Platform.SkuIds[SkuName][0], '', '', '', '', '', ToPcd.DefaultValue)
}
@@ -3458,7 +3460,7 @@ class ModuleAutoGen(AutoGen):
if self._BinaryFileList is None:
self._BinaryFileList = []
for F in self.Module.Binaries:
- if F.Target not in ['COMMON', '*'] and F.Target != self.BuildTarget:
+ if F.Target not in [TAB_COMMON, '*'] and F.Target != self.BuildTarget:
continue
self._BinaryFileList.append(F)
self._ApplyBuildRule(F, F.Type)
diff --git a/BaseTools/Source/Python/AutoGen/BuildEngine.py b/BaseTools/Source/Python/AutoGen/BuildEngine.py
index 0daed7da610d..8e32312a8018 100644
--- a/BaseTools/Source/Python/AutoGen/BuildEngine.py
+++ b/BaseTools/Source/Python/AutoGen/BuildEngine.py
@@ -27,6 +27,7 @@ from Common.String import NormPath
from Common.DataType import *
import Common.EdkLogger as EdkLogger
+from Common.DataType import TAB_COMMON
## Convert file type to file list macro name
#
@@ -375,7 +376,7 @@ class BuildRule:
self.Parse()
# some intrinsic rules
- self.RuleDatabase[TAB_DEFAULT_BINARY_FILE, "COMMON", "COMMON", "COMMON"] = self._BinaryFileRule
+ self.RuleDatabase[TAB_DEFAULT_BINARY_FILE, TAB_COMMON, TAB_COMMON, TAB_COMMON] = self._BinaryFileRule
self.FileTypeList.add(TAB_DEFAULT_BINARY_FILE)
## Parse the build rule strings
@@ -434,9 +435,9 @@ class BuildRule:
## Merge section information just got into rule database
def EndOfSection(self):
Database = self.RuleDatabase
- # if there's specific toochain family, 'COMMON' doesn't make sense any more
- if len(self._TotalToolChainFamilySet) > 1 and 'COMMON' in self._TotalToolChainFamilySet:
- self._TotalToolChainFamilySet.remove('COMMON')
+ # if there's specific toochain family, TAB_COMMON doesn't make sense any more
+ if len(self._TotalToolChainFamilySet) > 1 and TAB_COMMON in self._TotalToolChainFamilySet:
+ self._TotalToolChainFamilySet.remove(TAB_COMMON)
for Family in self._TotalToolChainFamilySet:
Input = self._RuleInfo[Family, self._InputFile]
Output = self._RuleInfo[Family, self._OutputFile]
@@ -463,8 +464,8 @@ class BuildRule:
FileType = ''
RuleNameList = self.RuleContent[LineIndex][1:-1].split(',')
for RuleName in RuleNameList:
- Arch = 'COMMON'
- BuildType = 'COMMON'
+ Arch = TAB_COMMON
+ BuildType = TAB_COMMON
TokenList = [Token.strip().upper() for Token in RuleName.split('.')]
# old format: Build.File-Type
if TokenList[0] == "BUILD":
@@ -499,12 +500,12 @@ class BuildRule:
if Arch not in self._ArchList:
self._ArchList.append(Arch)
- if 'COMMON' in self._BuildTypeList and len(self._BuildTypeList) > 1:
+ if TAB_COMMON in self._BuildTypeList and len(self._BuildTypeList) > 1:
EdkLogger.error("build", FORMAT_INVALID,
"Specific build types must not be mixed with common one",
File=self.RuleFile, Line=LineIndex + 1,
ExtraData=self.RuleContent[LineIndex])
- if 'COMMON' in self._ArchList and len(self._ArchList) > 1:
+ if TAB_COMMON in self._ArchList and len(self._ArchList) > 1:
EdkLogger.error("build", FORMAT_INVALID,
"Specific ARCH must not be mixed with common one",
File=self.RuleFile, Line=LineIndex + 1,
@@ -537,7 +538,7 @@ class BuildRule:
if len(TokenList) > 1:
Family = TokenList[1].strip().upper()
else:
- Family = "COMMON"
+ Family = TAB_COMMON
if Family not in FamilyList:
FamilyList.append(Family)
@@ -545,7 +546,7 @@ class BuildRule:
self._FamilyList = FamilyList
self._TotalToolChainFamilySet.update(FamilyList)
self._State = SectionType.upper()
- if 'COMMON' in FamilyList and len(FamilyList) > 1:
+ if TAB_COMMON in FamilyList and len(FamilyList) > 1:
EdkLogger.error("build", FORMAT_INVALID,
"Specific tool chain family should not be mixed with general one",
File=self.RuleFile, Line=LineIndex + 1,
@@ -637,7 +638,7 @@ if __name__ == '__main__':
print
print str(Br[".ac", "ACPI_TABLE", "IA32", "MSFT"][1])
print
- print str(Br[".s", "SEC", "IPF", "COMMON"][1])
+ print str(Br[".s", "SEC", "IPF", TAB_COMMON][1])
print
print str(Br[".s", "SEC"][1])
diff --git a/BaseTools/Source/Python/AutoGen/GenPcdDb.py b/BaseTools/Source/Python/AutoGen/GenPcdDb.py
index a2c4fb39ec85..88f646b2522c 100644
--- a/BaseTools/Source/Python/AutoGen/GenPcdDb.py
+++ b/BaseTools/Source/Python/AutoGen/GenPcdDb.py
@@ -20,6 +20,7 @@ from ValidCheckingInfoObject import VAR_VALID_OBJECT_FACTORY
from Common.VariableAttributes import VariableAttributes
import copy
from struct import unpack
+from Common.DataType import TAB_DEFAULT
DATABASE_VERSION = 7
@@ -981,14 +982,14 @@ def CreatePcdDataBase(PcdDBData):
delta = {}
basedata = {}
for skuname,skuid in PcdDBData:
- if len(PcdDBData[(skuname,skuid)][1]) != len(PcdDBData[("DEFAULT","0")][1]):
+ if len(PcdDBData[(skuname,skuid)][1]) != len(PcdDBData[(TAB_DEFAULT,"0")][1]):
EdkLogger.ERROR("The size of each sku in one pcd are not same")
for skuname,skuid in PcdDBData:
- if skuname == "DEFAULT":
+ if skuname == TAB_DEFAULT:
continue
- delta[(skuname,skuid)] = [(index,data,hex(data)) for index,data in enumerate(PcdDBData[(skuname,skuid)][1]) if PcdDBData[(skuname,skuid)][1][index] != PcdDBData[("DEFAULT","0")][1][index]]
- basedata[(skuname,skuid)] = [(index,PcdDBData[("DEFAULT","0")][1][index],hex(PcdDBData[("DEFAULT","0")][1][index])) for index,data in enumerate(PcdDBData[(skuname,skuid)][1]) if PcdDBData[(skuname,skuid)][1][index] != PcdDBData[("DEFAULT","0")][1][index]]
- databasebuff = PcdDBData[("DEFAULT","0")][0]
+ delta[(skuname,skuid)] = [(index,data,hex(data)) for index,data in enumerate(PcdDBData[(skuname,skuid)][1]) if PcdDBData[(skuname,skuid)][1][index] != PcdDBData[(TAB_DEFAULT,"0")][1][index]]
+ basedata[(skuname,skuid)] = [(index,PcdDBData[(TAB_DEFAULT,"0")][1][index],hex(PcdDBData[(TAB_DEFAULT,"0")][1][index])) for index,data in enumerate(PcdDBData[(skuname,skuid)][1]) if PcdDBData[(skuname,skuid)][1][index] != PcdDBData[(TAB_DEFAULT,"0")][1][index]]
+ databasebuff = PcdDBData[(TAB_DEFAULT,"0")][0]
for skuname,skuid in delta:
# 8 byte align
@@ -1011,7 +1012,7 @@ def CreatePcdDataBase(PcdDBData):
return newbuffer
def CreateVarCheckBin(VarCheckTab):
- return VarCheckTab[('DEFAULT',"0")]
+ return VarCheckTab[(TAB_DEFAULT,"0")]
def CreateAutoGen(PcdDriverAutoGenData):
autogenC = TemplateString()
for skuname,skuid in PcdDriverAutoGenData:
@@ -1062,7 +1063,7 @@ def NewCreatePcdDatabasePhaseSpecificAutoGen(Platform,Phase):
final_data = ()
for item in PcdDbBuffer:
final_data += unpack("B",item)
- PcdDBData[("DEFAULT","0")] = (PcdDbBuffer, final_data)
+ PcdDBData[(TAB_DEFAULT,"0")] = (PcdDbBuffer, final_data)
return AdditionalAutoGenH, AdditionalAutoGenC, CreatePcdDataBase(PcdDBData)
## Create PCD database in DXE or PEI phase
diff --git a/BaseTools/Source/Python/AutoGen/GenVar.py b/BaseTools/Source/Python/AutoGen/GenVar.py
index d222e6ed5e7e..686258c77c90 100644
--- a/BaseTools/Source/Python/AutoGen/GenVar.py
+++ b/BaseTools/Source/Python/AutoGen/GenVar.py
@@ -20,6 +20,7 @@ import copy
from Common.VariableAttributes import VariableAttributes
from Common.Misc import *
import collections
+from Common.DataType import TAB_DEFAULT
var_info = collections.namedtuple("uefi_var", "pcdindex,pcdname,defaultstoragename,skuname,var_name, var_guid, var_offset,var_attribute,pcd_default_value, default_value, data_type")
NvStorageHeaderSize = 28
@@ -141,7 +142,7 @@ class VariableMgr(object):
default_data_buffer = ""
others_data_buffer = ""
tail = None
- default_sku_default = indexedvarinfo.get(index).get(("DEFAULT","STANDARD"))
+ default_sku_default = indexedvarinfo.get(index).get((TAB_DEFAULT,"STANDARD"))
if default_sku_default.data_type not in ["UINT8","UINT16","UINT32","UINT64","BOOLEAN"]:
var_max_len = max([len(var_item.default_value.split(",")) for var_item in sku_var_info.values()])
@@ -154,13 +155,13 @@ class VariableMgr(object):
for item in default_data_buffer:
default_data_array += unpack("B",item)
- if ("DEFAULT","STANDARD") not in var_data:
- var_data[("DEFAULT","STANDARD")] = collections.OrderedDict()
- var_data[("DEFAULT","STANDARD")][index] = (default_data_buffer,sku_var_info[("DEFAULT","STANDARD")])
+ if (TAB_DEFAULT,"STANDARD") not in var_data:
+ var_data[(TAB_DEFAULT,"STANDARD")] = collections.OrderedDict()
+ var_data[(TAB_DEFAULT,"STANDARD")][index] = (default_data_buffer,sku_var_info[(TAB_DEFAULT,"STANDARD")])
for (skuid,defaultstoragename) in indexedvarinfo.get(index):
tail = None
- if (skuid,defaultstoragename) == ("DEFAULT","STANDARD"):
+ if (skuid,defaultstoragename) == (TAB_DEFAULT,"STANDARD"):
continue
other_sku_other = indexedvarinfo.get(index).get((skuid,defaultstoragename))
@@ -189,7 +190,7 @@ class VariableMgr(object):
if not var_data:
return []
- pcds_default_data = var_data.get(("DEFAULT","STANDARD"),{})
+ pcds_default_data = var_data.get((TAB_DEFAULT,"STANDARD"),{})
NvStoreDataBuffer = ""
var_data_offset = collections.OrderedDict()
offset = NvStorageHeaderSize
@@ -219,7 +220,7 @@ class VariableMgr(object):
data_delta_structure_buffer = ""
for skuname,defaultstore in var_data:
- if (skuname,defaultstore) == ("DEFAULT","STANDARD"):
+ if (skuname,defaultstore) == (TAB_DEFAULT,"STANDARD"):
continue
pcds_sku_data = var_data.get((skuname,defaultstore))
delta_data_set = []
diff --git a/BaseTools/Source/Python/Common/DataType.py b/BaseTools/Source/Python/Common/DataType.py
index 0bc2306ea61a..89d95c8a0bde 100644
--- a/BaseTools/Source/Python/Common/DataType.py
+++ b/BaseTools/Source/Python/Common/DataType.py
@@ -312,6 +312,8 @@ TAB_DEFINE = 'DEFINE'
TAB_NMAKE = 'Nmake'
TAB_USER_EXTENSIONS = 'UserExtensions'
TAB_INCLUDE = '!include'
+TAB_DEFAULT = 'DEFAULT'
+TAB_COMMON = 'COMMON'
#
# Common Define
diff --git a/BaseTools/Source/Python/GenFds/AprioriSection.py b/BaseTools/Source/Python/GenFds/AprioriSection.py
index 92a74670ed25..e6b8aa151b31 100644
--- a/BaseTools/Source/Python/GenFds/AprioriSection.py
+++ b/BaseTools/Source/Python/GenFds/AprioriSection.py
@@ -25,6 +25,7 @@ from Common.String import *
from Common.Misc import SaveFileOnChange,PathClass
from Common import EdkLogger
from Common.BuildToolError import *
+from Common.DataType import TAB_COMMON
## process APRIORI file data and generate PEI/DXE APRIORI file
#
@@ -84,7 +85,7 @@ class AprioriSection (AprioriSectionClassObject):
Guid = Inf.Guid
else:
- Inf = GenFdsGlobalVariable.WorkSpace.BuildObject[PathClass(InfFileName, GenFdsGlobalVariable.WorkSpaceDir), 'COMMON', GenFdsGlobalVariable.TargetName, GenFdsGlobalVariable.ToolChainTag]
+ Inf = GenFdsGlobalVariable.WorkSpace.BuildObject[PathClass(InfFileName, GenFdsGlobalVariable.WorkSpaceDir), TAB_COMMON, GenFdsGlobalVariable.TargetName, GenFdsGlobalVariable.ToolChainTag]
Guid = Inf.Guid
self.BinFileList = Inf.Module.Binaries
diff --git a/BaseTools/Source/Python/GenFds/FdfParser.py b/BaseTools/Source/Python/GenFds/FdfParser.py
index 9b7e898570a3..992dfea926d4 100644
--- a/BaseTools/Source/Python/GenFds/FdfParser.py
+++ b/BaseTools/Source/Python/GenFds/FdfParser.py
@@ -52,6 +52,12 @@ from Common.String import NormPath
import Common.GlobalData as GlobalData
from Common.Expression import *
from Common import GlobalData
+from Common.DataType import TAB_COMMON_DEFINES,SUP_MODULE_BASE, SUP_MODULE_SEC,\
+SUP_MODULE_PEI_CORE, SUP_MODULE_PEIM, SUP_MODULE_DXE_CORE,\
+SUP_MODULE_DXE_DRIVER,SUP_MODULE_DXE_RUNTIME_DRIVER, SUP_MODULE_DXE_SAL_DRIVER,\
+SUP_MODULE_DXE_SMM_DRIVER, SUP_MODULE_UEFI_DRIVER,SUP_MODULE_UEFI_APPLICATION,\
+SUP_MODULE_USER_DEFINED, SUP_MODULE_SMM_CORE, SUP_MODULE_MM_STANDALONE,\
+SUP_MODULE_MM_CORE_STANDALONE,TAB_DEFAULT,TAB_COMMON,ARCH_LIST_FULL
from Common.String import ReplaceMacro
import uuid
from Common.Misc import tdict
@@ -509,8 +515,8 @@ class FdfParser:
if Item == '' or Item == 'RULE':
return
- if Item == 'DEFINES':
- self.__CurSection = ['COMMON', 'COMMON', 'COMMON']
+ if Item == TAB_COMMON_DEFINES.upper():
+ self.__CurSection = [TAB_COMMON, TAB_COMMON, TAB_COMMON]
elif Item == 'VTF' and len(ItemList) == 3:
UiName = ItemList[2]
Pos = UiName.find(',')
@@ -518,9 +524,9 @@ class FdfParser:
UiName = UiName[:Pos]
self.__CurSection = ['VTF', UiName, ItemList[1]]
elif len(ItemList) > 1:
- self.__CurSection = [ItemList[0], ItemList[1], 'COMMON']
+ self.__CurSection = [ItemList[0], ItemList[1], TAB_COMMON]
elif len(ItemList) > 0:
- self.__CurSection = [ItemList[0], 'DUMMY', 'COMMON']
+ self.__CurSection = [ItemList[0], 'DUMMY', TAB_COMMON]
## PreprocessFile() method
#
@@ -884,7 +890,7 @@ class FdfParser:
if self.__CurSection:
# Defines macro
- ScopeMacro = self.__MacroDict['COMMON', 'COMMON', 'COMMON']
+ ScopeMacro = self.__MacroDict[TAB_COMMON, TAB_COMMON, TAB_COMMON]
if ScopeMacro:
MacroDict.update(ScopeMacro)
@@ -3586,7 +3592,7 @@ class FdfParser:
raise Warning("expected '.'", self.FileName, self.CurrentLineNumber)
Arch = self.__SkippedChars.rstrip(".")
- if Arch.upper() not in ("IA32", "X64", "IPF", "EBC", "ARM", "AARCH64", "COMMON"):
+ if Arch.upper() not in ARCH_LIST_FULL:
raise Warning("Unknown Arch '%s'" % Arch, self.FileName, self.CurrentLineNumber)
ModuleType = self.__GetModuleType()
@@ -3632,12 +3638,13 @@ class FdfParser:
if not self.__GetNextWord():
raise Warning("expected Module type", self.FileName, self.CurrentLineNumber)
- if self.__Token.upper() not in ("SEC", "PEI_CORE", "PEIM", "DXE_CORE", \
- "DXE_DRIVER", "DXE_SAL_DRIVER", \
- "DXE_SMM_DRIVER", "DXE_RUNTIME_DRIVER", \
- "UEFI_DRIVER", "UEFI_APPLICATION", "USER_DEFINED", "DEFAULT", "BASE", \
+ if self.__Token.upper() not in (SUP_MODULE_SEC, SUP_MODULE_PEI_CORE, SUP_MODULE_PEIM, SUP_MODULE_DXE_CORE, \
+ SUP_MODULE_DXE_DRIVER, SUP_MODULE_DXE_SAL_DRIVER, \
+ SUP_MODULE_DXE_SMM_DRIVER, SUP_MODULE_DXE_RUNTIME_DRIVER, \
+ SUP_MODULE_UEFI_DRIVER, SUP_MODULE_UEFI_APPLICATION, SUP_MODULE_USER_DEFINED, TAB_DEFAULT, SUP_MODULE_BASE, \
"SECURITY_CORE", "COMBINED_PEIM_DRIVER", "PIC_PEIM", "RELOCATABLE_PEIM", \
- "PE32_PEIM", "BS_DRIVER", "RT_DRIVER", "SAL_RT_DRIVER", "APPLICATION", "ACPITABLE", "SMM_CORE", "MM_STANDALONE", "MM_CORE_STANDALONE"):
+ "PE32_PEIM", "BS_DRIVER", "RT_DRIVER", "SAL_RT_DRIVER", "APPLICATION", "ACPITABLE", \
+ SUP_MODULE_SMM_CORE, SUP_MODULE_MM_STANDALONE, SUP_MODULE_MM_CORE_STANDALONE):
raise Warning("Unknown Module type '%s'" % self.__Token, self.FileName, self.CurrentLineNumber)
return self.__Token
diff --git a/BaseTools/Source/Python/GenFds/FfsInfStatement.py b/BaseTools/Source/Python/GenFds/FfsInfStatement.py
index 0dbffffc9a15..0994b7f8aa6c 100644
--- a/BaseTools/Source/Python/GenFds/FfsInfStatement.py
+++ b/BaseTools/Source/Python/GenFds/FfsInfStatement.py
@@ -47,6 +47,7 @@ import Common.GlobalData as GlobalData
from DepexSection import DepexSection
from Common.Misc import SaveFileOnChange
from Common.Expression import *
+from Common.DataType import TAB_COMMON
## generate FFS from INF
#
@@ -205,7 +206,7 @@ class FfsInfStatement(FfsInfStatementClassObject):
self.ShadowFromInfFile = Inf.Shadow
else:
- Inf = GenFdsGlobalVariable.WorkSpace.BuildObject[PathClassObj, 'COMMON', GenFdsGlobalVariable.TargetName, GenFdsGlobalVariable.ToolChainTag]
+ Inf = GenFdsGlobalVariable.WorkSpace.BuildObject[PathClassObj, TAB_COMMON, GenFdsGlobalVariable.TargetName, GenFdsGlobalVariable.ToolChainTag]
self.BaseName = Inf.BaseName
self.ModuleGuid = Inf.Guid
self.ModuleType = Inf.ModuleType
@@ -568,7 +569,7 @@ class FfsInfStatement(FfsInfStatementClassObject):
RuleName = 'RULE' + \
'.' + \
- 'COMMON' + \
+ TAB_COMMON + \
'.' + \
self.ModuleType.upper()
diff --git a/BaseTools/Source/Python/GenFds/GenFds.py b/BaseTools/Source/Python/GenFds/GenFds.py
index 49e26424bbfc..de6905de8e1f 100644
--- a/BaseTools/Source/Python/GenFds/GenFds.py
+++ b/BaseTools/Source/Python/GenFds/GenFds.py
@@ -43,6 +43,7 @@ from Common.MultipleWorkspace import MultipleWorkspace as mws
import FfsFileStatement
import glob
from struct import unpack
+from Common.DataType import TAB_COMMON
## Version and Copyright
versionNumber = "1.0" + ' ' + gBUILD_VERSION
@@ -239,11 +240,11 @@ def main():
ArchList = Options.archList.split(',')
else:
# EdkLogger.error("GenFds", OPTION_MISSING, "Missing build ARCH")
- ArchList = BuildWorkSpace.BuildObject[GenFdsGlobalVariable.ActivePlatform, 'COMMON', Options.BuildTarget, Options.ToolChain].SupArchList
+ ArchList = BuildWorkSpace.BuildObject[GenFdsGlobalVariable.ActivePlatform, TAB_COMMON, Options.BuildTarget, Options.ToolChain].SupArchList
- TargetArchList = set(BuildWorkSpace.BuildObject[GenFdsGlobalVariable.ActivePlatform, 'COMMON', Options.BuildTarget, Options.ToolChain].SupArchList) & set(ArchList)
+ TargetArchList = set(BuildWorkSpace.BuildObject[GenFdsGlobalVariable.ActivePlatform, TAB_COMMON, Options.BuildTarget, Options.ToolChain].SupArchList) & set(ArchList)
if len(TargetArchList) == 0:
- EdkLogger.error("GenFds", GENFDS_ERROR, "Target ARCH %s not in platform supported ARCH %s" % (str(ArchList), str(BuildWorkSpace.BuildObject[GenFdsGlobalVariable.ActivePlatform, 'COMMON'].SupArchList)))
+ EdkLogger.error("GenFds", GENFDS_ERROR, "Target ARCH %s not in platform supported ARCH %s" % (str(ArchList), str(BuildWorkSpace.BuildObject[GenFdsGlobalVariable.ActivePlatform, TAB_COMMON].SupArchList)))
for Arch in ArchList:
GenFdsGlobalVariable.OutputDirFromDscDict[Arch] = NormPath(BuildWorkSpace.BuildObject[GenFdsGlobalVariable.ActivePlatform, Arch, Options.BuildTarget, Options.ToolChain].OutputDirectory)
@@ -675,7 +676,7 @@ class GenFds :
# @retval None
#
def PreprocessImage(BuildDb, DscFile):
- PcdDict = BuildDb.BuildObject[DscFile, 'COMMON', GenFdsGlobalVariable.TargetName, GenFdsGlobalVariable.ToolChainTag].Pcds
+ PcdDict = BuildDb.BuildObject[DscFile, TAB_COMMON, GenFdsGlobalVariable.TargetName, GenFdsGlobalVariable.ToolChainTag].Pcds
PcdValue = ''
for Key in PcdDict:
PcdObj = PcdDict[Key]
@@ -694,9 +695,9 @@ class GenFds :
if Int64PcdValue > 0:
TopAddress = Int64PcdValue
- ModuleDict = BuildDb.BuildObject[DscFile, 'COMMON', GenFdsGlobalVariable.TargetName, GenFdsGlobalVariable.ToolChainTag].Modules
+ ModuleDict = BuildDb.BuildObject[DscFile, TAB_COMMON, GenFdsGlobalVariable.TargetName, GenFdsGlobalVariable.ToolChainTag].Modules
for Key in ModuleDict:
- ModuleObj = BuildDb.BuildObject[Key, 'COMMON', GenFdsGlobalVariable.TargetName, GenFdsGlobalVariable.ToolChainTag]
+ ModuleObj = BuildDb.BuildObject[Key, TAB_COMMON, GenFdsGlobalVariable.TargetName, GenFdsGlobalVariable.ToolChainTag]
print ModuleObj.BaseName + ' ' + ModuleObj.ModuleType
def GenerateGuidXRefFile(BuildDb, ArchList, FdfParserObj):
diff --git a/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py b/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py
index fcb191981c95..68a0a09c7bbc 100644
--- a/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py
+++ b/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py
@@ -32,6 +32,7 @@ import Common.DataType as DataType
from Common.Misc import PathClass
from Common.LongFilePathSupport import OpenLongFilePath as open
from Common.MultipleWorkspace import MultipleWorkspace as mws
+from Common.DataType import TAB_COMMON
## Global variables
#
@@ -130,7 +131,7 @@ class GenFdsGlobalVariable:
@staticmethod
def GetBuildRules(Inf, Arch):
if not Arch:
- Arch = 'COMMON'
+ Arch = TAB_COMMON
if not Arch in GenFdsGlobalVariable.OutputDirDict:
return {}
@@ -217,7 +218,7 @@ class GenFdsGlobalVariable:
FileList.append((File, DataType.TAB_UNKNOWN_FILE))
for File in Inf.Binaries:
- if File.Target in ['COMMON', '*', GenFdsGlobalVariable.TargetName]:
+ if File.Target in [TAB_COMMON, '*', GenFdsGlobalVariable.TargetName]:
FileList.append((File, File.Type))
for File, FileType in FileList:
@@ -757,7 +758,7 @@ class GenFdsGlobalVariable:
# @param Str String that may contain macro
# @param MacroDict Dictionary that contains macro value pair
#
- def MacroExtend (Str, MacroDict={}, Arch='COMMON'):
+ def MacroExtend (Str, MacroDict={}, Arch=TAB_COMMON):
if Str is None :
return None
@@ -769,7 +770,7 @@ class GenFdsGlobalVariable:
'$(SPACE)' : ' '
}
OutputDir = GenFdsGlobalVariable.OutputDirFromDscDict[GenFdsGlobalVariable.ArchList[0]]
- if Arch != 'COMMON' and Arch in GenFdsGlobalVariable.ArchList:
+ if Arch != TAB_COMMON and Arch in GenFdsGlobalVariable.ArchList:
OutputDir = GenFdsGlobalVariable.OutputDirFromDscDict[Arch]
Dict['$(OUTPUT_DIRECTORY)'] = OutputDir
diff --git a/BaseTools/Source/Python/GenFds/Section.py b/BaseTools/Source/Python/GenFds/Section.py
index 5e0b4bee7d1c..a2b85f651cd5 100644
--- a/BaseTools/Source/Python/GenFds/Section.py
+++ b/BaseTools/Source/Python/GenFds/Section.py
@@ -20,6 +20,7 @@ from GenFdsGlobalVariable import GenFdsGlobalVariable
import Common.LongFilePathOs as os, glob
from Common import EdkLogger
from Common.BuildToolError import *
+from Common.DataType import TAB_COMMON
## section base class
#
@@ -128,7 +129,7 @@ class Section (SectionClassObject):
FileList = []
if FileType is not None:
for File in FfsInf.BinFileList:
- if File.Arch == "COMMON" or FfsInf.CurrentArch == File.Arch:
+ if File.Arch == TAB_COMMON or FfsInf.CurrentArch == File.Arch:
if File.Type == FileType or (int(FfsInf.PiSpecVersion, 16) >= 0x0001000A \
and FileType == 'DXE_DPEX'and File.Type == 'SMM_DEPEX') \
or (FileType == 'TE'and File.Type == 'PE32'):
diff --git a/BaseTools/Source/Python/Workspace/DecBuildData.py b/BaseTools/Source/Python/Workspace/DecBuildData.py
index 49ef1df4aa76..db3ac83ae057 100644
--- a/BaseTools/Source/Python/Workspace/DecBuildData.py
+++ b/BaseTools/Source/Python/Workspace/DecBuildData.py
@@ -16,6 +16,7 @@ from Common.DataType import *
from Common.Misc import *
from types import *
from collections import OrderedDict
+from Common.DataType import TAB_ARCH_COMMON,TAB_COMMON
from Workspace.BuildClassObject import PackageBuildClassObject, StructurePcd, PcdClassObject
@@ -63,7 +64,7 @@ class DecBuildData(PackageBuildClassObject):
# @param Platform (not used for DecBuildData)
# @param Macros Macros used for replacement in DSC file
#
- def __init__(self, File, RawData, BuildDataBase, Arch='COMMON', Target=None, Toolchain=None):
+ def __init__(self, File, RawData, BuildDataBase, Arch=TAB_ARCH_COMMON, Target=None, Toolchain=None):
self.MetaFile = File
self._PackageDir = File.Dir
self._RawData = RawData
@@ -327,7 +328,7 @@ class DecBuildData(PackageBuildClassObject):
PublicInclues.append(File)
if File in self._PrivateIncludes:
EdkLogger.error('build', OPTION_CONFLICT, "Can't determine %s's attribute, it is both defined as Private and non-Private attribute in DEC file." % File, File=self.MetaFile, Line=LineNo)
- if Record[3] == "COMMON":
+ if Record[3] == TAB_COMMON:
self._CommonIncludes.append(File)
return self._Includes
diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py b/BaseTools/Source/Python/Workspace/DscBuildData.py
index 35ef15262a09..8d460891fbe0 100644
--- a/BaseTools/Source/Python/Workspace/DscBuildData.py
+++ b/BaseTools/Source/Python/Workspace/DscBuildData.py
@@ -36,6 +36,8 @@ import re
from Common.Parsing import IsValidWord
from Common.VariableAttributes import VariableAttributes
import Common.GlobalData as GlobalData
+from Common.DataType import TAB_DEFAULT
+from Common.DataType import TAB_ARCH_COMMON,TAB_COMMON
import subprocess
from Common.Misc import SaveFileOnChange
from Workspace.BuildClassObject import PlatformBuildClassObject, StructurePcd, PcdClassObject, ModuleBuildClassObject
@@ -208,7 +210,7 @@ class DscBuildData(PlatformBuildClassObject):
# @param Platform (not used for DscBuildData)
# @param Macros Macros used for replacement in DSC file
#
- def __init__(self, FilePath, RawData, BuildDataBase, Arch='COMMON', Target=None, Toolchain=None):
+ def __init__(self, FilePath, RawData, BuildDataBase, Arch=TAB_ARCH_COMMON, Target=None, Toolchain=None):
self.MetaFile = FilePath
self._RawData = RawData
self._Bdb = BuildDataBase
@@ -509,7 +511,7 @@ class DscBuildData(PlatformBuildClassObject):
if self._Header is None:
self._GetHeaderInfo()
if self._SkuName is None:
- self._SkuName = 'DEFAULT'
+ self._SkuName = TAB_DEFAULT
return self._SkuName
## Override SKUID_IDENTIFIER
@@ -653,10 +655,10 @@ class DscBuildData(PlatformBuildClassObject):
EdkLogger.error('build', FORMAT_INVALID, "The format of the Sku ID name is invalid. The correct format is '(a-zA-Z0-9_)(a-zA-Z0-9_-.)*'",
File=self.MetaFile, Line=Record[-1])
self._SkuIds[Record[1].upper()] = (str(self.ToInt(Record[0])), Record[1].upper(), Record[2].upper())
- if 'DEFAULT' not in self._SkuIds:
- self._SkuIds['DEFAULT'] = ("0","DEFAULT","DEFAULT")
- if 'COMMON' not in self._SkuIds:
- self._SkuIds['COMMON'] = ("0","DEFAULT","DEFAULT")
+ if TAB_DEFAULT not in self._SkuIds:
+ self._SkuIds[TAB_DEFAULT] = ("0",TAB_DEFAULT,TAB_DEFAULT)
+ if TAB_COMMON not in self._SkuIds:
+ self._SkuIds[TAB_COMMON] = ("0",TAB_DEFAULT,TAB_DEFAULT)
return self._SkuIds
def ToInt(self,intstr):
return int(intstr,16) if intstr.upper().startswith("0X") else int(intstr)
@@ -708,7 +710,7 @@ class DscBuildData(PlatformBuildClassObject):
ExtraData=ErrorInfo)
# Check duplication
# If arch is COMMON, no duplicate module is checked since all modules in all component sections are selected
- if self._Arch != 'COMMON' and ModuleFile in self._Modules:
+ if self._Arch != TAB_ARCH_COMMON and ModuleFile in self._Modules:
DuplicatedFile = True
Module = ModuleBuildClassObject()
@@ -817,7 +819,7 @@ class DscBuildData(PlatformBuildClassObject):
EdkLogger.error('build', ErrorCode, File=self.MetaFile, Line=LineNo,
ExtraData=ErrorInfo)
- if ModuleType != 'COMMON' and ModuleType not in SUP_MODULE_LIST:
+ if ModuleType != TAB_COMMON and ModuleType not in SUP_MODULE_LIST:
EdkLogger.error('build', OPTION_UNKNOWN, "Unknown module type [%s]" % ModuleType,
File=self.MetaFile, ExtraData=LibraryInstance, Line=LineNo)
LibraryClassDict[Arch, ModuleType, LibraryClass] = LibraryInstance
@@ -929,9 +931,9 @@ class DscBuildData(PlatformBuildClassObject):
if sku_usage == SkuClass.SINGLE:
for pcdname in Pcds:
pcd = Pcds[pcdname]
- Pcds[pcdname].SkuInfoList = {"DEFAULT":pcd.SkuInfoList[skuid] for skuid in pcd.SkuInfoList if skuid in available_sku}
+ Pcds[pcdname].SkuInfoList = {TAB_DEFAULT:pcd.SkuInfoList[skuid] for skuid in pcd.SkuInfoList if skuid in available_sku}
if type(pcd) is StructurePcd and pcd.SkuOverrideValues:
- Pcds[pcdname].SkuOverrideValues = {"DEFAULT":pcd.SkuOverrideValues[skuid] for skuid in pcd.SkuOverrideValues if skuid in available_sku}
+ Pcds[pcdname].SkuOverrideValues = {TAB_DEFAULT:pcd.SkuOverrideValues[skuid] for skuid in pcd.SkuOverrideValues if skuid in available_sku}
else:
for pcdname in Pcds:
pcd = Pcds[pcdname]
@@ -957,9 +959,9 @@ class DscBuildData(PlatformBuildClassObject):
self._PCD_TYPE_STRING_[MODEL_PCD_PATCHABLE_IN_MODULE]]:
pcd.PcdValueFromComm = pcd.DefaultValue
elif pcd.Type in [self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_HII], self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_EX_HII]]:
- pcd.PcdValueFromComm = pcd.SkuInfoList.get("DEFAULT").HiiDefaultValue
+ pcd.PcdValueFromComm = pcd.SkuInfoList.get(TAB_DEFAULT).HiiDefaultValue
else:
- pcd.PcdValueFromComm = pcd.SkuInfoList.get("DEFAULT").DefaultValue
+ pcd.PcdValueFromComm = pcd.SkuInfoList.get(TAB_DEFAULT).DefaultValue
for pcd in self._Pcds:
if isinstance(self._Pcds[pcd],StructurePcd) and (self._Pcds[pcd].PcdValueFromComm or self._Pcds[pcd].PcdFieldValueFromComm):
UpdateCommandLineValue(self._Pcds[pcd])
@@ -1162,7 +1164,7 @@ class DscBuildData(PlatformBuildClassObject):
for CodeBase in (EDKII_NAME, EDK_NAME):
RecordList = self._RawData[MODEL_META_DATA_BUILD_OPTION, self._Arch, CodeBase]
for ToolChainFamily, ToolChain, Option, Dummy1, Dummy2, Dummy3, Dummy4,Dummy5 in RecordList:
- if Dummy3.upper() != 'COMMON':
+ if Dummy3.upper() != TAB_COMMON:
continue
CurKey = (ToolChainFamily, ToolChain, CodeBase)
#
@@ -1182,7 +1184,7 @@ class DscBuildData(PlatformBuildClassObject):
options = sdict()
self._ModuleTypeOptions[Edk, ModuleType] = options
DriverType = '%s.%s' % (Edk, ModuleType)
- CommonDriverType = '%s.%s' % ('COMMON', ModuleType)
+ CommonDriverType = '%s.%s' % (TAB_COMMON, ModuleType)
RecordList = self._RawData[MODEL_META_DATA_BUILD_OPTION, self._Arch]
for ToolChainFamily, ToolChain, Option, Dummy1, Dummy2, Dummy3, Dummy4,Dummy5 in RecordList:
Type = Dummy2 + '.' + Dummy3
@@ -1282,7 +1284,7 @@ class DscBuildData(PlatformBuildClassObject):
Pcds = AllPcds
DefaultStoreMgr = DefaultStore(self.DefaultStores)
SkuIds = self.SkuIdMgr.AvailableSkuIdSet
- SkuIds.update({'DEFAULT':0})
+ SkuIds.update({TAB_DEFAULT:0})
DefaultStores = set([storename for pcdobj in AllPcds.values() for skuobj in pcdobj.SkuInfoList.values() for storename in skuobj.DefaultStoreDict.keys()])
S_PcdSet = []
@@ -1295,7 +1297,7 @@ class DscBuildData(PlatformBuildClassObject):
for TokenSpaceGuid, PcdCName, Setting, Arch, SkuName, default_store, Dummy4,Dummy5 in RecordList:
SkuName = SkuName.upper()
default_store = default_store.upper()
- SkuName = 'DEFAULT' if SkuName == 'COMMON' else SkuName
+ SkuName = TAB_DEFAULT if SkuName == TAB_COMMON else SkuName
if SkuName not in SkuIds:
continue
@@ -1323,7 +1325,7 @@ class DscBuildData(PlatformBuildClassObject):
str_pcd_obj_str.DefaultFromDSC = {skuname:{defaultstore: str_pcd_obj.SkuInfoList[skuname].DefaultStoreDict.get(defaultstore, str_pcd_obj.SkuInfoList[skuname].DefaultValue) for defaultstore in DefaultStores} for skuname in str_pcd_obj.SkuInfoList}
for str_pcd_data in StrPcdSet[str_pcd]:
if str_pcd_data[3] in SkuIds:
- str_pcd_obj_str.AddOverrideValue(str_pcd_data[2], str(str_pcd_data[6]), 'DEFAULT' if str_pcd_data[3] == 'COMMON' else str_pcd_data[3],'STANDARD' if str_pcd_data[4] == 'COMMON' else str_pcd_data[4], self.MetaFile.File if self.WorkspaceDir not in self.MetaFile.File else self.MetaFile.File[len(self.WorkspaceDir) if self.WorkspaceDir.endswith(os.path.sep) else len(self.WorkspaceDir)+1:],LineNo=str_pcd_data[5])
+ str_pcd_obj_str.AddOverrideValue(str_pcd_data[2], str(str_pcd_data[6]), TAB_DEFAULT if str_pcd_data[3] == TAB_COMMON else str_pcd_data[3],'STANDARD' if str_pcd_data[4] == TAB_COMMON else str_pcd_data[4], self.MetaFile.File if self.WorkspaceDir not in self.MetaFile.File else self.MetaFile.File[len(self.WorkspaceDir) if self.WorkspaceDir.endswith(os.path.sep) else len(self.WorkspaceDir)+1:],LineNo=str_pcd_data[5])
S_pcd_set[str_pcd[1], str_pcd[0]] = str_pcd_obj_str
else:
EdkLogger.error('build', PARSER_ERROR,
@@ -1353,7 +1355,7 @@ class DscBuildData(PlatformBuildClassObject):
NoDefault = False
if skuid not in stru_pcd.SkuOverrideValues:
while nextskuid not in stru_pcd.SkuOverrideValues:
- if nextskuid == "DEFAULT":
+ if nextskuid == TAB_DEFAULT:
NoDefault = True
break
nextskuid = self.SkuIdMgr.GetNextSkuId(nextskuid)
@@ -1366,7 +1368,7 @@ class DscBuildData(PlatformBuildClassObject):
NoDefault = False
if skuid not in stru_pcd.SkuOverrideValues:
while nextskuid not in stru_pcd.SkuOverrideValues:
- if nextskuid == "DEFAULT":
+ if nextskuid == TAB_DEFAULT:
NoDefault = True
break
nextskuid = self.SkuIdMgr.GetNextSkuId(nextskuid)
@@ -1396,14 +1398,14 @@ class DscBuildData(PlatformBuildClassObject):
str_pcd_obj.SkuInfoList[skuname].DefaultStoreDict.update({StoreName:PcdValue})
elif str_pcd_obj.Type in [self._PCD_TYPE_STRING_[MODEL_PCD_FIXED_AT_BUILD],
self._PCD_TYPE_STRING_[MODEL_PCD_PATCHABLE_IN_MODULE]]:
- if skuname in (self.SkuIdMgr.SystemSkuId, 'DEFAULT', 'COMMON'):
+ if skuname in (self.SkuIdMgr.SystemSkuId, TAB_DEFAULT, TAB_COMMON):
str_pcd_obj.DefaultValue = PcdValue
else:
if skuname not in str_pcd_obj.SkuInfoList:
nextskuid = self.SkuIdMgr.GetNextSkuId(skuname)
NoDefault = False
while nextskuid not in str_pcd_obj.SkuInfoList:
- if nextskuid == "DEFAULT":
+ if nextskuid == TAB_DEFAULT:
NoDefault = True
break
nextskuid = self.SkuIdMgr.GetNextSkuId(nextskuid)
@@ -1428,11 +1430,11 @@ class DscBuildData(PlatformBuildClassObject):
for pcdkey in Pcds:
pcd = Pcds[pcdkey]
- if 'DEFAULT' not in pcd.SkuInfoList and 'COMMON' in pcd.SkuInfoList:
- pcd.SkuInfoList['DEFAULT'] = pcd.SkuInfoList['COMMON']
- del pcd.SkuInfoList['COMMON']
- elif 'DEFAULT' in pcd.SkuInfoList and 'COMMON' in pcd.SkuInfoList:
- del pcd.SkuInfoList['COMMON']
+ if TAB_DEFAULT not in pcd.SkuInfoList and TAB_COMMON in pcd.SkuInfoList:
+ pcd.SkuInfoList[TAB_DEFAULT] = pcd.SkuInfoList[TAB_COMMON]
+ del pcd.SkuInfoList[TAB_COMMON]
+ elif TAB_DEFAULT in pcd.SkuInfoList and TAB_COMMON in pcd.SkuInfoList:
+ del pcd.SkuInfoList[TAB_COMMON]
map(self.FilterSkuSettings,[Pcds[pcdkey] for pcdkey in Pcds if Pcds[pcdkey].Type in DynamicPcdType])
return Pcds
@@ -1458,11 +1460,11 @@ class DscBuildData(PlatformBuildClassObject):
PcdValueDict = sdict()
for TokenSpaceGuid, PcdCName, Setting, Arch, SkuName, Dummy3, Dummy4,Dummy5 in RecordList:
SkuName = SkuName.upper()
- SkuName = 'DEFAULT' if SkuName == 'COMMON' else SkuName
+ SkuName = TAB_DEFAULT if SkuName == TAB_COMMON else SkuName
if SkuName not in AvailableSkuIdSet:
EdkLogger.error('build ', PARAMETER_INVALID, 'Sku %s is not defined in [SkuIds] section' % SkuName,
File=self.MetaFile, Line=Dummy5)
- if SkuName in (self.SkuIdMgr.SystemSkuId, 'DEFAULT', 'COMMON'):
+ if SkuName in (self.SkuIdMgr.SystemSkuId, TAB_DEFAULT, TAB_COMMON):
if "." not in TokenSpaceGuid:
PcdSet.add((PcdCName, TokenSpaceGuid, SkuName, Dummy5))
PcdDict[Arch, PcdCName, TokenSpaceGuid, SkuName] = Setting
@@ -1481,10 +1483,10 @@ class DscBuildData(PlatformBuildClassObject):
PcdValue = None
DatumType = None
MaxDatumSize = None
- if 'COMMON' in PcdSetting:
- PcdValue, DatumType, MaxDatumSize = PcdSetting['COMMON']
- if 'DEFAULT' in PcdSetting:
- PcdValue, DatumType, MaxDatumSize = PcdSetting['DEFAULT']
+ if TAB_COMMON in PcdSetting:
+ PcdValue, DatumType, MaxDatumSize = PcdSetting[TAB_COMMON]
+ if TAB_DEFAULT in PcdSetting:
+ PcdValue, DatumType, MaxDatumSize = PcdSetting[TAB_DEFAULT]
if self.SkuIdMgr.SystemSkuId in PcdSetting:
PcdValue, DatumType, MaxDatumSize = PcdSetting[self.SkuIdMgr.SystemSkuId]
@@ -1615,7 +1617,7 @@ class DscBuildData(PlatformBuildClassObject):
FieldName = FieldName.rsplit('[', 1)[0]
CApp = CApp + ' __FLEXIBLE_SIZE(*Size, %s, %s, %d); // From %s Line %d Value %s\n' % (Pcd.DatumType, FieldName.strip("."), ArrayIndex + 1, FieldList[FieldName_ori][1], FieldList[FieldName_ori][2], FieldList[FieldName_ori][0])
for skuname in Pcd.SkuOverrideValues:
- if skuname == "COMMON":
+ if skuname == TAB_COMMON:
continue
for defaultstorenameitem in Pcd.SkuOverrideValues[skuname]:
CApp = CApp + "// SkuName: %s, DefaultStoreName: %s \n" % (skuname, defaultstorenameitem)
@@ -1739,10 +1741,10 @@ class DscBuildData(PlatformBuildClassObject):
CApp = CApp + ' UINT32 FieldSize;\n'
CApp = CApp + ' CHAR8 *Value;\n'
- CApp = CApp + "// SkuName: %s, DefaultStoreName: %s \n" % ('DEFAULT', 'STANDARD')
+ CApp = CApp + "// SkuName: %s, DefaultStoreName: %s \n" % (TAB_DEFAULT, 'STANDARD')
inherit_OverrideValues = Pcd.SkuOverrideValues[SkuName]
- if (SkuName,DefaultStoreName) == ('DEFAULT','STANDARD'):
- pcddefaultvalue = Pcd.DefaultFromDSC.get('DEFAULT',{}).get('STANDARD', Pcd.DefaultValue) if Pcd.DefaultFromDSC else Pcd.DefaultValue
+ if (SkuName,DefaultStoreName) == (TAB_DEFAULT,'STANDARD'):
+ pcddefaultvalue = Pcd.DefaultFromDSC.get(TAB_DEFAULT,{}).get('STANDARD', Pcd.DefaultValue) if Pcd.DefaultFromDSC else Pcd.DefaultValue
else:
if not Pcd.DscRawValue:
# handle the case that structure pcd is not appear in DSC
@@ -1761,14 +1763,14 @@ class DscBuildData(PlatformBuildClassObject):
(Pcd.TokenSpaceGuidCName, Pcd.TokenCName, FieldList))
Value, ValueSize = ParseFieldValue (FieldList)
- if (SkuName,DefaultStoreName) == ('DEFAULT','STANDARD'):
+ if (SkuName,DefaultStoreName) == (TAB_DEFAULT,'STANDARD'):
if isinstance(Value, str):
- CApp = CApp + ' Pcd = %s; // From DSC Default Value %s\n' % (Value, Pcd.DefaultFromDSC.get('DEFAULT',{}).get('STANDARD', Pcd.DefaultValue) if Pcd.DefaultFromDSC else Pcd.DefaultValue)
+ CApp = CApp + ' Pcd = %s; // From DSC Default Value %s\n' % (Value, Pcd.DefaultFromDSC.get(TAB_DEFAULT,{}).get('STANDARD', Pcd.DefaultValue) if Pcd.DefaultFromDSC else Pcd.DefaultValue)
elif IsArray:
#
# Use memcpy() to copy value into field
#
- CApp = CApp + ' Value = %s; // From DSC Default Value %s\n' % (self.IntToCString(Value, ValueSize), Pcd.DefaultFromDSC.get('DEFAULT',{}).get('STANDARD', Pcd.DefaultValue) if Pcd.DefaultFromDSC else Pcd.DefaultValue)
+ CApp = CApp + ' Value = %s; // From DSC Default Value %s\n' % (self.IntToCString(Value, ValueSize), Pcd.DefaultFromDSC.get(TAB_DEFAULT,{}).get('STANDARD', Pcd.DefaultValue) if Pcd.DefaultFromDSC else Pcd.DefaultValue)
CApp = CApp + ' memcpy (Pcd, Value, %d);\n' % (ValueSize)
else:
if isinstance(Value, str):
@@ -1780,7 +1782,7 @@ class DscBuildData(PlatformBuildClassObject):
CApp = CApp + ' Value = %s; // From DSC Default Value %s\n' % (self.IntToCString(Value, ValueSize), Pcd.DscRawValue.get(SkuName,{}).get(DefaultStoreName))
CApp = CApp + ' memcpy (Pcd, Value, %d);\n' % (ValueSize)
continue
- if (SkuName,DefaultStoreName) == ('DEFAULT','STANDARD') or (( (SkuName,'') not in Pcd.ValueChain) and ( (SkuName,DefaultStoreName) not in Pcd.ValueChain )):
+ if (SkuName,DefaultStoreName) == (TAB_DEFAULT,'STANDARD') or (( (SkuName,'') not in Pcd.ValueChain) and ( (SkuName,DefaultStoreName) not in Pcd.ValueChain )):
for FieldName in FieldList:
IsArray = IsFieldValueAnArray(FieldList[FieldName][0])
if IsArray:
@@ -2239,7 +2241,7 @@ class DscBuildData(PlatformBuildClassObject):
for TokenSpaceGuid, PcdCName, Setting, Arch, SkuName, Dummy3, Dummy4,Dummy5 in RecordList:
SkuName = SkuName.upper()
- SkuName = 'DEFAULT' if SkuName == 'COMMON' else SkuName
+ SkuName = TAB_DEFAULT if SkuName == TAB_COMMON else SkuName
if SkuName not in AvailableSkuIdSet:
EdkLogger.error('build', PARAMETER_INVALID, 'Sku %s is not defined in [SkuIds] section' % SkuName,
File=self.MetaFile, Line=Dummy5)
@@ -2289,15 +2291,15 @@ class DscBuildData(PlatformBuildClassObject):
for sku in pcd.SkuInfoList.values():
if (sku.DefaultValue == "" or sku.DefaultValue==None):
sku.DefaultValue = pcdDecObject.DefaultValue
- if 'DEFAULT' not in pcd.SkuInfoList and 'COMMON' not in pcd.SkuInfoList:
+ if TAB_DEFAULT not in pcd.SkuInfoList and TAB_COMMON not in pcd.SkuInfoList:
valuefromDec = pcdDecObject.DefaultValue
- SkuInfo = SkuInfoClass('DEFAULT', '0', '', '', '', '', '', valuefromDec)
- pcd.SkuInfoList['DEFAULT'] = SkuInfo
- elif 'DEFAULT' not in pcd.SkuInfoList and 'COMMON' in pcd.SkuInfoList:
- pcd.SkuInfoList['DEFAULT'] = pcd.SkuInfoList['COMMON']
- del pcd.SkuInfoList['COMMON']
- elif 'DEFAULT' in pcd.SkuInfoList and 'COMMON' in pcd.SkuInfoList:
- del pcd.SkuInfoList['COMMON']
+ SkuInfo = SkuInfoClass(TAB_DEFAULT, '0', '', '', '', '', '', valuefromDec)
+ pcd.SkuInfoList[TAB_DEFAULT] = SkuInfo
+ elif TAB_DEFAULT not in pcd.SkuInfoList and TAB_COMMON in pcd.SkuInfoList:
+ pcd.SkuInfoList[TAB_DEFAULT] = pcd.SkuInfoList[TAB_COMMON]
+ del pcd.SkuInfoList[TAB_COMMON]
+ elif TAB_DEFAULT in pcd.SkuInfoList and TAB_COMMON in pcd.SkuInfoList:
+ del pcd.SkuInfoList[TAB_COMMON]
map(self.FilterSkuSettings,Pcds.values())
@@ -2306,14 +2308,14 @@ class DscBuildData(PlatformBuildClassObject):
def FilterSkuSettings(self, PcdObj):
if self.SkuIdMgr.SkuUsageType == self.SkuIdMgr.SINGLE:
- if 'DEFAULT' in PcdObj.SkuInfoList and self.SkuIdMgr.SystemSkuId not in PcdObj.SkuInfoList:
- PcdObj.SkuInfoList[self.SkuIdMgr.SystemSkuId] = PcdObj.SkuInfoList['DEFAULT']
- PcdObj.SkuInfoList = {'DEFAULT':PcdObj.SkuInfoList[self.SkuIdMgr.SystemSkuId]}
- PcdObj.SkuInfoList['DEFAULT'].SkuIdName = 'DEFAULT'
- PcdObj.SkuInfoList['DEFAULT'].SkuId = '0'
+ if TAB_DEFAULT in PcdObj.SkuInfoList and self.SkuIdMgr.SystemSkuId not in PcdObj.SkuInfoList:
+ PcdObj.SkuInfoList[self.SkuIdMgr.SystemSkuId] = PcdObj.SkuInfoList[TAB_DEFAULT]
+ PcdObj.SkuInfoList = {TAB_DEFAULT:PcdObj.SkuInfoList[self.SkuIdMgr.SystemSkuId]}
+ PcdObj.SkuInfoList[TAB_DEFAULT].SkuIdName = TAB_DEFAULT
+ PcdObj.SkuInfoList[TAB_DEFAULT].SkuId = '0'
elif self.SkuIdMgr.SkuUsageType == self.SkuIdMgr.DEFAULT:
- PcdObj.SkuInfoList = {'DEFAULT':PcdObj.SkuInfoList['DEFAULT']}
+ PcdObj.SkuInfoList = {TAB_DEFAULT:PcdObj.SkuInfoList[TAB_DEFAULT]}
return PcdObj
@@ -2346,7 +2348,7 @@ class DscBuildData(PlatformBuildClassObject):
def CompletePcdValues(self,PcdSet):
Pcds = {}
DefaultStoreObj = DefaultStore(self._GetDefaultStores())
- SkuIds = {skuname:skuid for skuname,skuid in self.SkuIdMgr.AvailableSkuIdSet.items() if skuname !='COMMON'}
+ SkuIds = {skuname:skuid for skuname,skuid in self.SkuIdMgr.AvailableSkuIdSet.items() if skuname !=TAB_COMMON}
DefaultStores = set([storename for pcdobj in PcdSet.values() for skuobj in pcdobj.SkuInfoList.values() for storename in skuobj.DefaultStoreDict.keys()])
for PcdCName, TokenSpaceGuid in PcdSet:
PcdObj = PcdSet[(PcdCName, TokenSpaceGuid)]
@@ -2377,7 +2379,7 @@ class DscBuildData(PlatformBuildClassObject):
PcdObj.SkuInfoList[skuname].SkuId = skuid
PcdObj.SkuInfoList[skuname].SkuIdName = skuname
if PcdType in [self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_HII], self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_EX_HII]]:
- PcdObj.DefaultValue = PcdObj.SkuInfoList.values()[0].HiiDefaultValue if self.SkuIdMgr.SkuUsageType == self.SkuIdMgr.SINGLE else PcdObj.SkuInfoList["DEFAULT"].HiiDefaultValue
+ PcdObj.DefaultValue = PcdObj.SkuInfoList.values()[0].HiiDefaultValue if self.SkuIdMgr.SkuUsageType == self.SkuIdMgr.SINGLE else PcdObj.SkuInfoList[TAB_DEFAULT].HiiDefaultValue
Pcds[PcdCName, TokenSpaceGuid]= PcdObj
return Pcds
## Retrieve dynamic HII PCD settings
@@ -2404,9 +2406,9 @@ class DscBuildData(PlatformBuildClassObject):
for TokenSpaceGuid, PcdCName, Setting, Arch, SkuName, DefaultStore, Dummy4,Dummy5 in RecordList:
SkuName = SkuName.upper()
- SkuName = 'DEFAULT' if SkuName == 'COMMON' else SkuName
+ SkuName = TAB_DEFAULT if SkuName == TAB_COMMON else SkuName
DefaultStore = DefaultStore.upper()
- if DefaultStore == "COMMON":
+ if DefaultStore == TAB_COMMON:
DefaultStore = "STANDARD"
if SkuName not in AvailableSkuIdSet:
EdkLogger.error('build', PARAMETER_INVALID, 'Sku %s is not defined in [SkuIds] section' % SkuName,
@@ -2498,15 +2500,15 @@ class DscBuildData(PlatformBuildClassObject):
for default_store in sku.DefaultStoreDict:
sku.DefaultStoreDict[default_store]=pcdDecObject.DefaultValue
pcd.DefaultValue = pcdDecObject.DefaultValue
- if 'DEFAULT' not in pcd.SkuInfoList and 'COMMON' not in pcd.SkuInfoList:
+ if TAB_DEFAULT not in pcd.SkuInfoList and TAB_COMMON not in pcd.SkuInfoList:
valuefromDec = pcdDecObject.DefaultValue
- SkuInfo = SkuInfoClass('DEFAULT', '0', SkuInfoObj.VariableName, SkuInfoObj.VariableGuid, SkuInfoObj.VariableOffset, valuefromDec,VariableAttribute=SkuInfoObj.VariableAttribute,DefaultStore={DefaultStore:valuefromDec})
- pcd.SkuInfoList['DEFAULT'] = SkuInfo
- elif 'DEFAULT' not in pcd.SkuInfoList and 'COMMON' in pcd.SkuInfoList:
- pcd.SkuInfoList['DEFAULT'] = pcd.SkuInfoList['COMMON']
- del pcd.SkuInfoList['COMMON']
- elif 'DEFAULT' in pcd.SkuInfoList and 'COMMON' in pcd.SkuInfoList:
- del pcd.SkuInfoList['COMMON']
+ SkuInfo = SkuInfoClass(TAB_DEFAULT, '0', SkuInfoObj.VariableName, SkuInfoObj.VariableGuid, SkuInfoObj.VariableOffset, valuefromDec,VariableAttribute=SkuInfoObj.VariableAttribute,DefaultStore={DefaultStore:valuefromDec})
+ pcd.SkuInfoList[TAB_DEFAULT] = SkuInfo
+ elif TAB_DEFAULT not in pcd.SkuInfoList and TAB_COMMON in pcd.SkuInfoList:
+ pcd.SkuInfoList[TAB_DEFAULT] = pcd.SkuInfoList[TAB_COMMON]
+ del pcd.SkuInfoList[TAB_COMMON]
+ elif TAB_DEFAULT in pcd.SkuInfoList and TAB_COMMON in pcd.SkuInfoList:
+ del pcd.SkuInfoList[TAB_COMMON]
if pcd.MaxDatumSize.strip():
MaxSize = int(pcd.MaxDatumSize, 0)
@@ -2566,7 +2568,7 @@ class DscBuildData(PlatformBuildClassObject):
for TokenSpaceGuid, PcdCName, Setting, Arch, SkuName, Dummy3, Dummy4,Dummy5 in RecordList:
SkuName = SkuName.upper()
- SkuName = 'DEFAULT' if SkuName == 'COMMON' else SkuName
+ SkuName = TAB_DEFAULT if SkuName == TAB_COMMON else SkuName
if SkuName not in AvailableSkuIdSet:
EdkLogger.error('build', PARAMETER_INVALID, 'Sku %s is not defined in [SkuIds] section' % SkuName,
File=self.MetaFile, Line=Dummy5)
@@ -2621,15 +2623,15 @@ class DscBuildData(PlatformBuildClassObject):
for sku in pcd.SkuInfoList.values():
if (sku.DefaultValue == "" or sku.DefaultValue==None):
sku.DefaultValue = pcdDecObject.DefaultValue
- if 'DEFAULT' not in pcd.SkuInfoList and 'COMMON' not in pcd.SkuInfoList:
+ if TAB_DEFAULT not in pcd.SkuInfoList and TAB_COMMON not in pcd.SkuInfoList:
valuefromDec = pcdDecObject.DefaultValue
- SkuInfo = SkuInfoClass('DEFAULT', '0', '', '', '', '', SkuInfoObj.VpdOffset, valuefromDec)
- pcd.SkuInfoList['DEFAULT'] = SkuInfo
- elif 'DEFAULT' not in pcd.SkuInfoList and 'COMMON' in pcd.SkuInfoList:
- pcd.SkuInfoList['DEFAULT'] = pcd.SkuInfoList['COMMON']
- del pcd.SkuInfoList['COMMON']
- elif 'DEFAULT' in pcd.SkuInfoList and 'COMMON' in pcd.SkuInfoList:
- del pcd.SkuInfoList['COMMON']
+ SkuInfo = SkuInfoClass(TAB_DEFAULT, '0', '', '', '', '', SkuInfoObj.VpdOffset, valuefromDec)
+ pcd.SkuInfoList[TAB_DEFAULT] = SkuInfo
+ elif TAB_DEFAULT not in pcd.SkuInfoList and TAB_COMMON in pcd.SkuInfoList:
+ pcd.SkuInfoList[TAB_DEFAULT] = pcd.SkuInfoList[TAB_COMMON]
+ del pcd.SkuInfoList[TAB_COMMON]
+ elif TAB_DEFAULT in pcd.SkuInfoList and TAB_COMMON in pcd.SkuInfoList:
+ del pcd.SkuInfoList[TAB_COMMON]
map(self.FilterSkuSettings,Pcds.values())
diff --git a/BaseTools/Source/Python/Workspace/InfBuildData.py b/BaseTools/Source/Python/Workspace/InfBuildData.py
index ded8f610c9c1..53aa6acf5862 100644
--- a/BaseTools/Source/Python/Workspace/InfBuildData.py
+++ b/BaseTools/Source/Python/Workspace/InfBuildData.py
@@ -17,6 +17,7 @@ from Common.DataType import *
from Common.Misc import *
from types import *
from MetaFileParser import *
+from Common.DataType import TAB_ARCH_COMMON,TAB_ARCH_COMMON
from Workspace.BuildClassObject import ModuleBuildClassObject, LibraryClassObject, PcdClassObject
## Module build information from INF file
@@ -106,7 +107,7 @@ class InfBuildData(ModuleBuildClassObject):
# @param Platform The name of platform employing this module
# @param Macros Macros used for replacement in DSC file
#
- def __init__(self, FilePath, RawData, BuildDatabase, Arch='COMMON', Target=None, Toolchain=None):
+ def __init__(self, FilePath, RawData, BuildDatabase, Arch=TAB_ARCH_COMMON, Target=None, Toolchain=None):
self.MetaFile = FilePath
self._ModuleDir = FilePath.Dir
self._RawData = RawData
@@ -114,7 +115,7 @@ class InfBuildData(ModuleBuildClassObject):
self._Arch = Arch
self._Target = Target
self._Toolchain = Toolchain
- self._Platform = 'COMMON'
+ self._Platform = TAB_COMMON
self._SourceOverridePath = None
if FilePath.Key in GlobalData.gOverrideDir:
self._SourceOverridePath = GlobalData.gOverrideDir[FilePath.Key]
@@ -608,7 +609,7 @@ class InfBuildData(ModuleBuildClassObject):
for Record in RecordList:
FileType = Record[0]
LineNo = Record[-1]
- Target = 'COMMON'
+ Target = TAB_COMMON
FeatureFlag = []
if Record[2]:
TokenList = GetSplitValueList(Record[2], TAB_VALUE_SPLIT)
diff --git a/BaseTools/Source/Python/Workspace/MetaFileParser.py b/BaseTools/Source/Python/Workspace/MetaFileParser.py
index f4c1868483d9..79c10fc9fdc6 100644
--- a/BaseTools/Source/Python/Workspace/MetaFileParser.py
+++ b/BaseTools/Source/Python/Workspace/MetaFileParser.py
@@ -31,7 +31,7 @@ from Common.Misc import GuidStructureStringToGuidString, CheckPcdDatum, PathClas
from Common.Expression import *
from CommonDataClass.Exceptions import *
from Common.LongFilePathSupport import OpenLongFilePath as open
-
+from Common.DataType import TAB_ARCH_COMMON,TAB_ARCH_COMMON
from MetaFileTable import MetaFileStorage
from MetaFileCommentParser import CheckInfComment
@@ -219,7 +219,7 @@ class MetaFileParser(object):
NewRecordList = []
for Record in RecordList:
Arch = Record[3]
- if Arch == 'COMMON' or Arch == FilterArch:
+ if Arch == TAB_ARCH_COMMON or Arch == FilterArch:
NewRecordList.append(Record)
return NewRecordList
@@ -319,7 +319,7 @@ class MetaFileParser(object):
if len(ItemList) > 1:
S1 = ItemList[1].upper()
else:
- S1 = 'COMMON'
+ S1 = TAB_ARCH_COMMON
ArchList.add(S1)
# S2 may be Platform or ModuleType
@@ -329,15 +329,15 @@ class MetaFileParser(object):
else:
S2 = ItemList[2].upper()
else:
- S2 = 'COMMON'
+ S2 = TAB_COMMON
if len(ItemList) > 3:
S3 = ItemList[3]
else:
- S3 = "COMMON"
+ S3 = TAB_COMMON
self._Scope.append([S1, S2, S3])
# 'COMMON' must not be used with specific ARCHs at the same section
- if 'COMMON' in ArchList and len(ArchList) > 1:
+ if TAB_ARCH_COMMON in ArchList and len(ArchList) > 1:
EdkLogger.error('Parser', FORMAT_INVALID, "'common' ARCH must not be used with specific ARCHs",
File=self.MetaFile, Line=self._LineIndex + 1, ExtraData=self._CurrentLine)
# If the section information is needed later, it should be stored in database
@@ -455,12 +455,12 @@ class MetaFileParser(object):
for ActiveScope in self._Scope:
Scope0, Scope1,Scope2 = ActiveScope[0], ActiveScope[1],ActiveScope[2]
- if(Scope0, Scope1,Scope2) not in Scope and (Scope0, "COMMON","COMMON") not in Scope and ("COMMON", Scope1,"COMMON") not in Scope:
+ if(Scope0, Scope1,Scope2) not in Scope and (Scope0, TAB_COMMON,TAB_COMMON) not in Scope and (TAB_COMMON, Scope1,TAB_COMMON) not in Scope:
break
else:
ComSpeMacroDict.update(self._SectionsMacroDict[(SectionType, Scope)])
- if ("COMMON", "COMMON","COMMON") in Scope:
+ if (TAB_COMMON, TAB_COMMON,TAB_COMMON) in Scope:
ComComMacroDict.update(self._SectionsMacroDict[(SectionType, Scope)])
Macros.update(ComComMacroDict)
@@ -568,8 +568,8 @@ class InfParser(MetaFileParser):
if Line[0] == TAB_SECTION_START and Line[-1] == TAB_SECTION_END:
if not GetHeaderComment:
for Cmt, LNo in Comments:
- self._Store(MODEL_META_DATA_HEADER_COMMENT, Cmt, '', '', 'COMMON',
- 'COMMON', self._Owner[-1], LNo, -1, LNo, -1, 0)
+ self._Store(MODEL_META_DATA_HEADER_COMMENT, Cmt, '', '', TAB_COMMON,
+ TAB_COMMON, self._Owner[-1], LNo, -1, LNo, -1, 0)
GetHeaderComment = True
else:
TailComments.extend(SectionComments + Comments)
@@ -658,8 +658,8 @@ class InfParser(MetaFileParser):
# If there are tail comments in INF file, save to database whatever the comments are
for Comment in TailComments:
- self._Store(MODEL_META_DATA_TAIL_COMMENT, Comment[0], '', '', 'COMMON',
- 'COMMON', self._Owner[-1], -1, -1, -1, -1, 0)
+ self._Store(MODEL_META_DATA_TAIL_COMMENT, Comment[0], '', '', TAB_COMMON,
+ TAB_COMMON, self._Owner[-1], -1, -1, -1, -1, 0)
self._Done()
## Data parser for the format in which there's path
@@ -1022,7 +1022,7 @@ class DscParser(MetaFileParser):
ExtraData=self._CurrentLine)
ItemType = self.DataType[DirectiveName]
- Scope = [['COMMON', 'COMMON','COMMON']]
+ Scope = [[TAB_COMMON, TAB_COMMON,TAB_COMMON]]
if ItemType == MODEL_META_DATA_INCLUDE:
Scope = self._Scope
if ItemType == MODEL_META_DATA_CONDITIONAL_STATEMENT_ENDIF:
@@ -1832,7 +1832,7 @@ class DecParser(MetaFileParser):
if len(ItemList) > 1:
S1 = ItemList[1].upper()
else:
- S1 = 'COMMON'
+ S1 = TAB_ARCH_COMMON
ArchList.add(S1)
# S2 may be Platform or ModuleType
if len(ItemList) > 2:
@@ -1843,18 +1843,18 @@ class DecParser(MetaFileParser):
EdkLogger.error("Parser", FORMAT_INVALID, 'Please use keyword "Private" as section tag modifier.',
File=self.MetaFile, Line=self._LineIndex + 1, ExtraData=self._CurrentLine)
else:
- S2 = 'COMMON'
+ S2 = TAB_COMMON
PrivateList.add(S2)
if [S1, S2, self.DataType[self._SectionName]] not in self._Scope:
self._Scope.append([S1, S2, self.DataType[self._SectionName]])
# 'COMMON' must not be used with specific ARCHs at the same section
- if 'COMMON' in ArchList and len(ArchList) > 1:
+ if TAB_ARCH_COMMON in ArchList and len(ArchList) > 1:
EdkLogger.error('Parser', FORMAT_INVALID, "'common' ARCH must not be used with specific ARCHs",
File=self.MetaFile, Line=self._LineIndex + 1, ExtraData=self._CurrentLine)
# It is not permissible to mix section tags without the Private attribute with section tags with the Private attribute
- if 'COMMON' in PrivateList and len(PrivateList) > 1:
+ if TAB_COMMON in PrivateList and len(PrivateList) > 1:
EdkLogger.error('Parser', FORMAT_INVALID, "Can't mix section tags without the Private attribute with section tags with the Private attribute",
File=self.MetaFile, Line=self._LineIndex + 1, ExtraData=self._CurrentLine)
diff --git a/BaseTools/Source/Python/Workspace/MetaFileTable.py b/BaseTools/Source/Python/Workspace/MetaFileTable.py
index be3fb3d68856..33d390253b2a 100644
--- a/BaseTools/Source/Python/Workspace/MetaFileTable.py
+++ b/BaseTools/Source/Python/Workspace/MetaFileTable.py
@@ -1,7 +1,7 @@
## @file
# This file is used to create/update/query/erase a meta file table
#
-# Copyright (c) 2008 - 2016, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2008 - 2018, Intel Corporation. All rights reserved.<BR>
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
@@ -18,7 +18,7 @@ import uuid
import Common.EdkLogger as EdkLogger
from Common.BuildToolError import FORMAT_INVALID
-
+from Common.DataType import TAB_ARCH_COMMON,TAB_ARCH_COMMON
from MetaDataTable import Table, TableFile
from MetaDataTable import ConvertToSqlString
from CommonDataClass.DataClass import MODEL_FILE_DSC, MODEL_FILE_DEC, MODEL_FILE_INF, \
@@ -109,7 +109,7 @@ class ModuleTable(MetaFileTable):
# @param EndColumn: EndColumn of a Inf item
# @param Enabled: If this item enabled
#
- def Insert(self, Model, Value1, Value2, Value3, Scope1='COMMON', Scope2='COMMON',
+ def Insert(self, Model, Value1, Value2, Value3, Scope1=TAB_ARCH_COMMON, Scope2=TAB_COMMON,
BelongsToItem=-1, StartLine=-1, StartColumn=-1, EndLine=-1, EndColumn=-1, Enabled=0):
(Value1, Value2, Value3, Scope1, Scope2) = ConvertToSqlString((Value1, Value2, Value3, Scope1, Scope2))
return Table.Insert(
@@ -140,9 +140,9 @@ class ModuleTable(MetaFileTable):
ConditionString = "Model=%s AND Enabled>=0" % Model
ValueString = "Value1,Value2,Value3,Scope1,Scope2,ID,StartLine"
- if Arch is not None and Arch != 'COMMON':
+ if Arch is not None and Arch != TAB_ARCH_COMMON:
ConditionString += " AND (Scope1='%s' OR Scope1='COMMON')" % Arch
- if Platform is not None and Platform != 'COMMON':
+ if Platform is not None and Platform != TAB_COMMON:
ConditionString += " AND (Scope2='%s' OR Scope2='COMMON' OR Scope2='DEFAULT')" % Platform
if BelongsToItem is not None:
ConditionString += " AND BelongsToItem=%s" % BelongsToItem
@@ -191,7 +191,7 @@ class PackageTable(MetaFileTable):
# @param EndColumn: EndColumn of a Dec item
# @param Enabled: If this item enabled
#
- def Insert(self, Model, Value1, Value2, Value3, Scope1='COMMON', Scope2='COMMON',
+ def Insert(self, Model, Value1, Value2, Value3, Scope1=TAB_ARCH_COMMON, Scope2=TAB_COMMON,
BelongsToItem=-1, StartLine=-1, StartColumn=-1, EndLine=-1, EndColumn=-1, Enabled=0):
(Value1, Value2, Value3, Scope1, Scope2) = ConvertToSqlString((Value1, Value2, Value3, Scope1, Scope2))
return Table.Insert(
@@ -221,7 +221,7 @@ class PackageTable(MetaFileTable):
ConditionString = "Model=%s AND Enabled>=0" % Model
ValueString = "Value1,Value2,Value3,Scope1,Scope2,ID,StartLine"
- if Arch is not None and Arch != 'COMMON':
+ if Arch is not None and Arch != TAB_ARCH_COMMON:
ConditionString += " AND (Scope1='%s' OR Scope1='COMMON')" % Arch
SqlCommand = "SELECT %s FROM %s WHERE %s" % (ValueString, self.Table, ConditionString)
@@ -306,7 +306,7 @@ class PlatformTable(MetaFileTable):
# @param EndColumn: EndColumn of a Dsc item
# @param Enabled: If this item enabled
#
- def Insert(self, Model, Value1, Value2, Value3, Scope1='COMMON', Scope2='COMMON', Scope3=TAB_DEFAULT_STORES_DEFAULT,BelongsToItem=-1,
+ def Insert(self, Model, Value1, Value2, Value3, Scope1=TAB_ARCH_COMMON, Scope2=TAB_COMMON, Scope3=TAB_DEFAULT_STORES_DEFAULT,BelongsToItem=-1,
FromItem=-1, StartLine=-1, StartColumn=-1, EndLine=-1, EndColumn=-1, Enabled=1):
(Value1, Value2, Value3, Scope1, Scope2,Scope3) = ConvertToSqlString((Value1, Value2, Value3, Scope1, Scope2,Scope3))
return Table.Insert(
@@ -341,13 +341,13 @@ class PlatformTable(MetaFileTable):
ConditionString = "Model=%s AND Enabled>0" % Model
ValueString = "Value1,Value2,Value3,Scope1,Scope2,Scope3,ID,StartLine"
- if Scope1 is not None and Scope1 != 'COMMON':
+ if Scope1 is not None and Scope1 != TAB_ARCH_COMMON:
ConditionString += " AND (Scope1='%s' OR Scope1='COMMON')" % Scope1
- if Scope2 is not None and Scope2 != 'COMMON':
+ if Scope2 is not None and Scope2 != TAB_COMMON:
# Cover the case that CodeBase is 'COMMON' for BuildOptions section
if '.' in Scope2:
Index = Scope2.index('.')
- NewScope = 'COMMON'+ Scope2[Index:]
+ NewScope = TAB_COMMON+ Scope2[Index:]
ConditionString += " AND (Scope2='%s' OR Scope2='COMMON' OR Scope2='DEFAULT' OR Scope2='%s')" % (Scope2, NewScope)
else:
ConditionString += " AND (Scope2='%s' OR Scope2='COMMON' OR Scope2='DEFAULT')" % Scope2
diff --git a/BaseTools/Source/Python/Workspace/WorkspaceDatabase.py b/BaseTools/Source/Python/Workspace/WorkspaceDatabase.py
index 2b888c0610c3..6c52817d95b3 100644
--- a/BaseTools/Source/Python/Workspace/WorkspaceDatabase.py
+++ b/BaseTools/Source/Python/Workspace/WorkspaceDatabase.py
@@ -1,7 +1,7 @@
## @file
# 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>
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
@@ -305,7 +305,7 @@ determine whether database file is out of date!\n")
PlatformList = []
for PlatformFile in self.TblFile.GetFileList(MODEL_FILE_DSC):
try:
- Platform = self.BuildObject[PathClass(PlatformFile), 'COMMON']
+ Platform = self.BuildObject[PathClass(PlatformFile), TAB_COMMON]
except:
Platform = None
if Platform is not None:
@@ -313,7 +313,7 @@ determine whether database file is out of date!\n")
return PlatformList
def _MapPlatform(self, Dscfile):
- Platform = self.BuildObject[PathClass(Dscfile), 'COMMON']
+ Platform = self.BuildObject[PathClass(Dscfile), TAB_COMMON]
if Platform is None:
EdkLogger.error('build', PARSER_ERROR, "Failed to parser DSC file: %s" % Dscfile)
return Platform
--
2.16.2.windows.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH v1 3/3] BaseTools: use existing contrants to replace raw strings in python code.
2018-04-10 14:20 [PATCH v1 0/3] BaseTools: refactor to remove redundant Jaben Carsey
2018-04-10 14:20 ` [PATCH v1 1/3] BaseTools: refactor and remove more keys() usage Jaben Carsey
2018-04-10 14:20 ` [PATCH v1 2/3] BaseTools: use predefined constants instead of local strings Jaben Carsey
@ 2018-04-10 14:20 ` Jaben Carsey
2018-04-11 1:07 ` Zhu, Yonghong
2 siblings, 1 reply; 8+ messages in thread
From: Jaben Carsey @ 2018-04-10 14:20 UTC (permalink / raw)
To: edk2-devel; +Cc: Liming Gao, Yonghong Zhu
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>
---
BaseTools/Source/Python/AutoGen/GenC.py | 13 +++++++------
BaseTools/Source/Python/AutoGen/GenDepex.py | 3 ++-
BaseTools/Source/Python/GenFds/Ffs.py | 3 ++-
BaseTools/Source/Python/Workspace/InfBuildData.py | 4 ++--
BaseTools/Source/Python/build/BuildReport.py | 5 +++--
5 files changed, 16 insertions(+), 12 deletions(-)
diff --git a/BaseTools/Source/Python/AutoGen/GenC.py b/BaseTools/Source/Python/AutoGen/GenC.py
index 4d9ea1b2a8b1..4a9657420897 100644
--- a/BaseTools/Source/Python/AutoGen/GenC.py
+++ b/BaseTools/Source/Python/AutoGen/GenC.py
@@ -25,6 +25,7 @@ from Common.String import StringToArray
from StrGather import *
from GenPcdDb import CreatePcdDatabaseCode
from IdfClassObject import *
+from Common.DataType import SUP_MODULE_UEFI_APPLICATION
## PCD type string
gItemTypeStringDatabase = {
@@ -782,7 +783,7 @@ gModuleTypeHeaderFile = {
"DXE_RUNTIME_DRIVER": ["PiDxe.h", "Library/BaseLib.h", "Library/DebugLib.h", "Library/UefiBootServicesTableLib.h", "Library/UefiDriverEntryPoint.h"],
"DXE_SAL_DRIVER" : ["PiDxe.h", "Library/BaseLib.h", "Library/DebugLib.h", "Library/UefiBootServicesTableLib.h", "Library/UefiDriverEntryPoint.h"],
"UEFI_DRIVER" : ["Uefi.h", "Library/BaseLib.h", "Library/DebugLib.h", "Library/UefiBootServicesTableLib.h", "Library/UefiDriverEntryPoint.h"],
- "UEFI_APPLICATION" : ["Uefi.h", "Library/BaseLib.h", "Library/DebugLib.h", "Library/UefiBootServicesTableLib.h", "Library/UefiApplicationEntryPoint.h"],
+ SUP_MODULE_UEFI_APPLICATION : ["Uefi.h", "Library/BaseLib.h", "Library/DebugLib.h", "Library/UefiBootServicesTableLib.h", "Library/UefiApplicationEntryPoint.h"],
"SMM_CORE" : ["PiDxe.h", "Library/BaseLib.h", "Library/DebugLib.h", "Library/UefiDriverEntryPoint.h"],
"MM_STANDALONE" : ["PiSmm.h", "Library/BaseLib.h", "Library/DebugLib.h", "Library/SmmDriverStandaloneEntryPoint.h"],
"MM_CORE_STANDALONE" : ["PiSmm.h", "Library/BaseLib.h", "Library/DebugLib.h", "Library/SmmCoreStandaloneEntryPoint.h"],
@@ -1386,7 +1387,7 @@ def CreateLibraryConstructorCode(Info, AutoGenC, AutoGenH):
ConstructorPrototypeString.Append(gLibraryStructorPrototype['PEI'].Replace(Dict))
ConstructorCallingString.Append(gLibraryStructorCall['PEI'].Replace(Dict))
elif Lib.ModuleType in ['DXE_CORE','DXE_DRIVER','DXE_SMM_DRIVER','DXE_RUNTIME_DRIVER',
- 'DXE_SAL_DRIVER','UEFI_DRIVER','UEFI_APPLICATION','SMM_CORE']:
+ 'DXE_SAL_DRIVER','UEFI_DRIVER',SUP_MODULE_UEFI_APPLICATION,'SMM_CORE']:
ConstructorPrototypeString.Append(gLibraryStructorPrototype['DXE'].Replace(Dict))
ConstructorCallingString.Append(gLibraryStructorCall['DXE'].Replace(Dict))
elif Lib.ModuleType in ['MM_STANDALONE','MM_CORE_STANDALONE']:
@@ -1415,7 +1416,7 @@ def CreateLibraryConstructorCode(Info, AutoGenC, AutoGenH):
elif Info.ModuleType in ['PEI_CORE','PEIM']:
AutoGenC.Append(gLibraryString['PEI'].Replace(Dict))
elif Info.ModuleType in ['DXE_CORE','DXE_DRIVER','DXE_SMM_DRIVER','DXE_RUNTIME_DRIVER',
- 'DXE_SAL_DRIVER','UEFI_DRIVER','UEFI_APPLICATION','SMM_CORE']:
+ 'DXE_SAL_DRIVER','UEFI_DRIVER',SUP_MODULE_UEFI_APPLICATION,'SMM_CORE']:
AutoGenC.Append(gLibraryString['DXE'].Replace(Dict))
elif Info.ModuleType in ['MM_STANDALONE','MM_CORE_STANDALONE']:
AutoGenC.Append(gLibraryString['MM'].Replace(Dict))
@@ -1448,7 +1449,7 @@ def CreateLibraryDestructorCode(Info, AutoGenC, AutoGenH):
DestructorPrototypeString.Append(gLibraryStructorPrototype['PEI'].Replace(Dict))
DestructorCallingString.Append(gLibraryStructorCall['PEI'].Replace(Dict))
elif Lib.ModuleType in ['DXE_CORE','DXE_DRIVER','DXE_SMM_DRIVER','DXE_RUNTIME_DRIVER',
- 'DXE_SAL_DRIVER','UEFI_DRIVER','UEFI_APPLICATION', 'SMM_CORE']:
+ 'DXE_SAL_DRIVER','UEFI_DRIVER',SUP_MODULE_UEFI_APPLICATION, 'SMM_CORE']:
DestructorPrototypeString.Append(gLibraryStructorPrototype['DXE'].Replace(Dict))
DestructorCallingString.Append(gLibraryStructorCall['DXE'].Replace(Dict))
elif Lib.ModuleType in ['MM_STANDALONE','MM_CORE_STANDALONE']:
@@ -1477,7 +1478,7 @@ def CreateLibraryDestructorCode(Info, AutoGenC, AutoGenH):
elif Info.ModuleType in ['PEI_CORE','PEIM']:
AutoGenC.Append(gLibraryString['PEI'].Replace(Dict))
elif Info.ModuleType in ['DXE_CORE','DXE_DRIVER','DXE_SMM_DRIVER','DXE_RUNTIME_DRIVER',
- 'DXE_SAL_DRIVER','UEFI_DRIVER','UEFI_APPLICATION','SMM_CORE']:
+ 'DXE_SAL_DRIVER','UEFI_DRIVER',SUP_MODULE_UEFI_APPLICATION,'SMM_CORE']:
AutoGenC.Append(gLibraryString['DXE'].Replace(Dict))
elif Info.ModuleType in ['MM_STANDALONE','MM_CORE_STANDALONE']:
AutoGenC.Append(gLibraryString['MM'].Replace(Dict))
@@ -1556,7 +1557,7 @@ def CreateModuleEntryPointCode(Info, AutoGenC, AutoGenH):
else:
AutoGenC.Append(gMmStandaloneEntryPointString[2].Replace(Dict))
AutoGenH.Append(gMmStandaloneEntryPointPrototype.Replace(Dict))
- elif Info.ModuleType == 'UEFI_APPLICATION':
+ elif Info.ModuleType == SUP_MODULE_UEFI_APPLICATION:
if NumEntryPoints < 2:
AutoGenC.Append(gUefiApplicationEntryPointString[NumEntryPoints].Replace(Dict))
else:
diff --git a/BaseTools/Source/Python/AutoGen/GenDepex.py b/BaseTools/Source/Python/AutoGen/GenDepex.py
index 9acea8f6bfed..8896ad65bfe6 100644
--- a/BaseTools/Source/Python/AutoGen/GenDepex.py
+++ b/BaseTools/Source/Python/AutoGen/GenDepex.py
@@ -24,6 +24,7 @@ from Common.Misc import SaveFileOnChange
from Common.Misc import GuidStructureStringToGuidString
from Common import EdkLogger as EdkLogger
from Common.BuildVersion import gBUILD_VERSION
+from Common.DataType import SUP_MODULE_UEFI_APPLICATION
## Regular expression for matching "DEPENDENCY_START ... DEPENDENCY_END"
gStartClosePattern = re.compile(".*DEPENDENCY_START(.+)DEPENDENCY_END.*", re.S)
@@ -40,7 +41,7 @@ gType2Phase = {
"DXE_RUNTIME_DRIVER": "DXE",
"DXE_SAL_DRIVER" : "DXE",
"UEFI_DRIVER" : "DXE",
- "UEFI_APPLICATION" : "DXE",
+ SUP_MODULE_UEFI_APPLICATION : "DXE",
"SMM_CORE" : "DXE",
"MM_STANDALONE" : "MM",
"MM_CORE_STANDALONE" : "MM",
diff --git a/BaseTools/Source/Python/GenFds/Ffs.py b/BaseTools/Source/Python/GenFds/Ffs.py
index a4178121118b..e5b180eb9324 100644
--- a/BaseTools/Source/Python/GenFds/Ffs.py
+++ b/BaseTools/Source/Python/GenFds/Ffs.py
@@ -16,6 +16,7 @@
# Import Modules
#
from CommonDataClass.FdfClass import FDClassObject
+from Common.DataType import SUP_MODULE_UEFI_APPLICATION
## generate FFS
#
@@ -33,7 +34,7 @@ class Ffs(FDClassObject):
'DXE_SMM_DRIVER' : 'EFI_FV_FILETYPE_DRIVER',
'DXE_RUNTIME_DRIVER': 'EFI_FV_FILETYPE_DRIVER',
'UEFI_DRIVER' : 'EFI_FV_FILETYPE_DRIVER',
- 'UEFI_APPLICATION' : 'EFI_FV_FILETYPE_APPLICATION',
+ SUP_MODULE_UEFI_APPLICATION : 'EFI_FV_FILETYPE_APPLICATION',
'SMM_CORE' : 'EFI_FV_FILETYPE_SMM_CORE',
'MM_STANDALONE' : 'EFI_FV_FILETYPE_MM_STANDALONE',
'MM_CORE_STANDALONE' : 'EFI_FV_FILETYPE_MM_CORE_STANDALONE'
diff --git a/BaseTools/Source/Python/Workspace/InfBuildData.py b/BaseTools/Source/Python/Workspace/InfBuildData.py
index 53aa6acf5862..c1841487f64f 100644
--- a/BaseTools/Source/Python/Workspace/InfBuildData.py
+++ b/BaseTools/Source/Python/Workspace/InfBuildData.py
@@ -17,7 +17,7 @@ from Common.DataType import *
from Common.Misc import *
from types import *
from MetaFileParser import *
-from Common.DataType import TAB_ARCH_COMMON,TAB_ARCH_COMMON
+from Common.DataType import TAB_ARCH_COMMON,TAB_ARCH_COMMON,SUP_MODULE_UEFI_APPLICATION
from Workspace.BuildClassObject import ModuleBuildClassObject, LibraryClassObject, PcdClassObject
## Module build information from INF file
@@ -82,7 +82,7 @@ class InfBuildData(ModuleBuildClassObject):
# "SMM_DRIVER" : "DXE_SMM_DRIVER",
# "BS_DRIVER" : "DXE_SMM_DRIVER",
# "BS_DRIVER" : "UEFI_DRIVER",
- "APPLICATION" : "UEFI_APPLICATION",
+ "APPLICATION" : SUP_MODULE_UEFI_APPLICATION,
"LOGO" : "BASE",
}
diff --git a/BaseTools/Source/Python/build/BuildReport.py b/BaseTools/Source/Python/build/BuildReport.py
index 966a2aa5abf1..190b58cfa44e 100644
--- a/BaseTools/Source/Python/build/BuildReport.py
+++ b/BaseTools/Source/Python/build/BuildReport.py
@@ -47,6 +47,7 @@ from Common.String import NormPath
from Common.DataType import *
import collections
from Common.Expression import *
+from Common.DataType import SUP_MODULE_UEFI_APPLICATION
## Pattern to extract contents in EDK DXS files
gDxsDependencyPattern = re.compile(r"DEPENDENCY_START(.+)DEPENDENCY_END", re.DOTALL)
@@ -117,7 +118,7 @@ gDriverTypeMap = {
'DXE_SMM_DRIVER' : '0x7 (DRIVER)',
'DXE_RUNTIME_DRIVER': '0x7 (DRIVER)',
'UEFI_DRIVER' : '0x7 (DRIVER)',
- 'UEFI_APPLICATION' : '0x9 (APPLICATION)',
+ SUP_MODULE_UEFI_APPLICATION : '0x9 (APPLICATION)',
'SMM_CORE' : '0xD (SMM_CORE)',
'SMM_DRIVER' : '0xA (SMM)', # Extension of module type to support PI 1.1 SMM drivers
'MM_STANDALONE' : '0xE (MM_STANDALONE)',
@@ -410,7 +411,7 @@ class DepexReport(object):
if not ModuleType:
ModuleType = gComponentType2ModuleType.get(M.ComponentType, "")
- if ModuleType in ["SEC", "PEI_CORE", "DXE_CORE", "SMM_CORE", "MM_CORE_STANDALONE", "UEFI_APPLICATION"]:
+ if ModuleType in ["SEC", "PEI_CORE", "DXE_CORE", "SMM_CORE", "MM_CORE_STANDALONE", SUP_MODULE_UEFI_APPLICATION]:
return
for Source in M.SourceFileList:
--
2.16.2.windows.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH v1 3/3] BaseTools: use existing contrants to replace raw strings in python code.
2018-04-10 14:20 ` [PATCH v1 3/3] BaseTools: use existing contrants to replace raw strings in python code Jaben Carsey
@ 2018-04-11 1:07 ` Zhu, Yonghong
2018-04-11 14:20 ` Carsey, Jaben
0 siblings, 1 reply; 8+ messages in thread
From: Zhu, Yonghong @ 2018-04-11 1:07 UTC (permalink / raw)
To: Carsey, Jaben, edk2-devel@lists.01.org; +Cc: Gao, Liming, Zhu, Yonghong
Hi Jaben,
Seems only replaced 'UEFI_APPLICATION', what about others, eg ' DXE_SMM_DRIVER' ? Do you have plan to update it ?
Best Regards,
Zhu Yonghong
-----Original Message-----
From: Carsey, Jaben
Sent: Tuesday, April 10, 2018 10:20 PM
To: edk2-devel@lists.01.org
Cc: Gao, Liming <liming.gao@intel.com>; Zhu, Yonghong <yonghong.zhu@intel.com>
Subject: [PATCH v1 3/3] BaseTools: use existing contrants to replace raw strings in python code.
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>
---
BaseTools/Source/Python/AutoGen/GenC.py | 13 +++++++------
BaseTools/Source/Python/AutoGen/GenDepex.py | 3 ++-
BaseTools/Source/Python/GenFds/Ffs.py | 3 ++-
BaseTools/Source/Python/Workspace/InfBuildData.py | 4 ++--
BaseTools/Source/Python/build/BuildReport.py | 5 +++--
5 files changed, 16 insertions(+), 12 deletions(-)
diff --git a/BaseTools/Source/Python/AutoGen/GenC.py b/BaseTools/Source/Python/AutoGen/GenC.py
index 4d9ea1b2a8b1..4a9657420897 100644
--- a/BaseTools/Source/Python/AutoGen/GenC.py
+++ b/BaseTools/Source/Python/AutoGen/GenC.py
@@ -25,6 +25,7 @@ from Common.String import StringToArray from StrGather import * from GenPcdDb import CreatePcdDatabaseCode from IdfClassObject import *
+from Common.DataType import SUP_MODULE_UEFI_APPLICATION
## PCD type string
gItemTypeStringDatabase = {
@@ -782,7 +783,7 @@ gModuleTypeHeaderFile = {
"DXE_RUNTIME_DRIVER": ["PiDxe.h", "Library/BaseLib.h", "Library/DebugLib.h", "Library/UefiBootServicesTableLib.h", "Library/UefiDriverEntryPoint.h"],
"DXE_SAL_DRIVER" : ["PiDxe.h", "Library/BaseLib.h", "Library/DebugLib.h", "Library/UefiBootServicesTableLib.h", "Library/UefiDriverEntryPoint.h"],
"UEFI_DRIVER" : ["Uefi.h", "Library/BaseLib.h", "Library/DebugLib.h", "Library/UefiBootServicesTableLib.h", "Library/UefiDriverEntryPoint.h"],
- "UEFI_APPLICATION" : ["Uefi.h", "Library/BaseLib.h", "Library/DebugLib.h", "Library/UefiBootServicesTableLib.h", "Library/UefiApplicationEntryPoint.h"],
+ SUP_MODULE_UEFI_APPLICATION : ["Uefi.h", "Library/BaseLib.h", "Library/DebugLib.h", "Library/UefiBootServicesTableLib.h", "Library/UefiApplicationEntryPoint.h"],
"SMM_CORE" : ["PiDxe.h", "Library/BaseLib.h", "Library/DebugLib.h", "Library/UefiDriverEntryPoint.h"],
"MM_STANDALONE" : ["PiSmm.h", "Library/BaseLib.h", "Library/DebugLib.h", "Library/SmmDriverStandaloneEntryPoint.h"],
"MM_CORE_STANDALONE" : ["PiSmm.h", "Library/BaseLib.h", "Library/DebugLib.h", "Library/SmmCoreStandaloneEntryPoint.h"],
@@ -1386,7 +1387,7 @@ def CreateLibraryConstructorCode(Info, AutoGenC, AutoGenH):
ConstructorPrototypeString.Append(gLibraryStructorPrototype['PEI'].Replace(Dict))
ConstructorCallingString.Append(gLibraryStructorCall['PEI'].Replace(Dict))
elif Lib.ModuleType in ['DXE_CORE','DXE_DRIVER','DXE_SMM_DRIVER','DXE_RUNTIME_DRIVER',
- 'DXE_SAL_DRIVER','UEFI_DRIVER','UEFI_APPLICATION','SMM_CORE']:
+ 'DXE_SAL_DRIVER','UEFI_DRIVER',SUP_MODULE_UEFI_APPLICATION,'SMM_CORE']:
ConstructorPrototypeString.Append(gLibraryStructorPrototype['DXE'].Replace(Dict))
ConstructorCallingString.Append(gLibraryStructorCall['DXE'].Replace(Dict))
elif Lib.ModuleType in ['MM_STANDALONE','MM_CORE_STANDALONE']:
@@ -1415,7 +1416,7 @@ def CreateLibraryConstructorCode(Info, AutoGenC, AutoGenH):
elif Info.ModuleType in ['PEI_CORE','PEIM']:
AutoGenC.Append(gLibraryString['PEI'].Replace(Dict))
elif Info.ModuleType in ['DXE_CORE','DXE_DRIVER','DXE_SMM_DRIVER','DXE_RUNTIME_DRIVER',
- 'DXE_SAL_DRIVER','UEFI_DRIVER','UEFI_APPLICATION','SMM_CORE']:
+ 'DXE_SAL_DRIVER','UEFI_DRIVER',SUP_MODULE_UEFI_APPLICATION,'SMM_CORE']:
AutoGenC.Append(gLibraryString['DXE'].Replace(Dict))
elif Info.ModuleType in ['MM_STANDALONE','MM_CORE_STANDALONE']:
AutoGenC.Append(gLibraryString['MM'].Replace(Dict))
@@ -1448,7 +1449,7 @@ def CreateLibraryDestructorCode(Info, AutoGenC, AutoGenH):
DestructorPrototypeString.Append(gLibraryStructorPrototype['PEI'].Replace(Dict))
DestructorCallingString.Append(gLibraryStructorCall['PEI'].Replace(Dict))
elif Lib.ModuleType in ['DXE_CORE','DXE_DRIVER','DXE_SMM_DRIVER','DXE_RUNTIME_DRIVER',
- 'DXE_SAL_DRIVER','UEFI_DRIVER','UEFI_APPLICATION', 'SMM_CORE']:
+ 'DXE_SAL_DRIVER','UEFI_DRIVER',SUP_MODULE_UEFI_APPLICATION, 'SMM_CORE']:
DestructorPrototypeString.Append(gLibraryStructorPrototype['DXE'].Replace(Dict))
DestructorCallingString.Append(gLibraryStructorCall['DXE'].Replace(Dict))
elif Lib.ModuleType in ['MM_STANDALONE','MM_CORE_STANDALONE']:
@@ -1477,7 +1478,7 @@ def CreateLibraryDestructorCode(Info, AutoGenC, AutoGenH):
elif Info.ModuleType in ['PEI_CORE','PEIM']:
AutoGenC.Append(gLibraryString['PEI'].Replace(Dict))
elif Info.ModuleType in ['DXE_CORE','DXE_DRIVER','DXE_SMM_DRIVER','DXE_RUNTIME_DRIVER',
- 'DXE_SAL_DRIVER','UEFI_DRIVER','UEFI_APPLICATION','SMM_CORE']:
+ 'DXE_SAL_DRIVER','UEFI_DRIVER',SUP_MODULE_UEFI_APPLICATION,'SMM_CORE']:
AutoGenC.Append(gLibraryString['DXE'].Replace(Dict))
elif Info.ModuleType in ['MM_STANDALONE','MM_CORE_STANDALONE']:
AutoGenC.Append(gLibraryString['MM'].Replace(Dict))
@@ -1556,7 +1557,7 @@ def CreateModuleEntryPointCode(Info, AutoGenC, AutoGenH):
else:
AutoGenC.Append(gMmStandaloneEntryPointString[2].Replace(Dict))
AutoGenH.Append(gMmStandaloneEntryPointPrototype.Replace(Dict))
- elif Info.ModuleType == 'UEFI_APPLICATION':
+ elif Info.ModuleType == SUP_MODULE_UEFI_APPLICATION:
if NumEntryPoints < 2:
AutoGenC.Append(gUefiApplicationEntryPointString[NumEntryPoints].Replace(Dict))
else:
diff --git a/BaseTools/Source/Python/AutoGen/GenDepex.py b/BaseTools/Source/Python/AutoGen/GenDepex.py
index 9acea8f6bfed..8896ad65bfe6 100644
--- a/BaseTools/Source/Python/AutoGen/GenDepex.py
+++ b/BaseTools/Source/Python/AutoGen/GenDepex.py
@@ -24,6 +24,7 @@ from Common.Misc import SaveFileOnChange from Common.Misc import GuidStructureStringToGuidString from Common import EdkLogger as EdkLogger from Common.BuildVersion import gBUILD_VERSION
+from Common.DataType import SUP_MODULE_UEFI_APPLICATION
## Regular expression for matching "DEPENDENCY_START ... DEPENDENCY_END"
gStartClosePattern = re.compile(".*DEPENDENCY_START(.+)DEPENDENCY_END.*", re.S) @@ -40,7 +41,7 @@ gType2Phase = {
"DXE_RUNTIME_DRIVER": "DXE",
"DXE_SAL_DRIVER" : "DXE",
"UEFI_DRIVER" : "DXE",
- "UEFI_APPLICATION" : "DXE",
+ SUP_MODULE_UEFI_APPLICATION : "DXE",
"SMM_CORE" : "DXE",
"MM_STANDALONE" : "MM",
"MM_CORE_STANDALONE" : "MM",
diff --git a/BaseTools/Source/Python/GenFds/Ffs.py b/BaseTools/Source/Python/GenFds/Ffs.py
index a4178121118b..e5b180eb9324 100644
--- a/BaseTools/Source/Python/GenFds/Ffs.py
+++ b/BaseTools/Source/Python/GenFds/Ffs.py
@@ -16,6 +16,7 @@
# Import Modules
#
from CommonDataClass.FdfClass import FDClassObject
+from Common.DataType import SUP_MODULE_UEFI_APPLICATION
## generate FFS
#
@@ -33,7 +34,7 @@ class Ffs(FDClassObject):
'DXE_SMM_DRIVER' : 'EFI_FV_FILETYPE_DRIVER',
'DXE_RUNTIME_DRIVER': 'EFI_FV_FILETYPE_DRIVER',
'UEFI_DRIVER' : 'EFI_FV_FILETYPE_DRIVER',
- 'UEFI_APPLICATION' : 'EFI_FV_FILETYPE_APPLICATION',
+ SUP_MODULE_UEFI_APPLICATION : 'EFI_FV_FILETYPE_APPLICATION',
'SMM_CORE' : 'EFI_FV_FILETYPE_SMM_CORE',
'MM_STANDALONE' : 'EFI_FV_FILETYPE_MM_STANDALONE',
'MM_CORE_STANDALONE' : 'EFI_FV_FILETYPE_MM_CORE_STANDALONE'
diff --git a/BaseTools/Source/Python/Workspace/InfBuildData.py b/BaseTools/Source/Python/Workspace/InfBuildData.py
index 53aa6acf5862..c1841487f64f 100644
--- a/BaseTools/Source/Python/Workspace/InfBuildData.py
+++ b/BaseTools/Source/Python/Workspace/InfBuildData.py
@@ -17,7 +17,7 @@ from Common.DataType import * from Common.Misc import * from types import * from MetaFileParser import * -from Common.DataType import TAB_ARCH_COMMON,TAB_ARCH_COMMON
+from Common.DataType import
+TAB_ARCH_COMMON,TAB_ARCH_COMMON,SUP_MODULE_UEFI_APPLICATION
from Workspace.BuildClassObject import ModuleBuildClassObject, LibraryClassObject, PcdClassObject ## Module build information from INF file @@ -82,7 +82,7 @@ class InfBuildData(ModuleBuildClassObject):
# "SMM_DRIVER" : "DXE_SMM_DRIVER",
# "BS_DRIVER" : "DXE_SMM_DRIVER",
# "BS_DRIVER" : "UEFI_DRIVER",
- "APPLICATION" : "UEFI_APPLICATION",
+ "APPLICATION" : SUP_MODULE_UEFI_APPLICATION,
"LOGO" : "BASE",
}
diff --git a/BaseTools/Source/Python/build/BuildReport.py b/BaseTools/Source/Python/build/BuildReport.py
index 966a2aa5abf1..190b58cfa44e 100644
--- a/BaseTools/Source/Python/build/BuildReport.py
+++ b/BaseTools/Source/Python/build/BuildReport.py
@@ -47,6 +47,7 @@ from Common.String import NormPath from Common.DataType import * import collections from Common.Expression import *
+from Common.DataType import SUP_MODULE_UEFI_APPLICATION
## Pattern to extract contents in EDK DXS files gDxsDependencyPattern = re.compile(r"DEPENDENCY_START(.+)DEPENDENCY_END", re.DOTALL) @@ -117,7 +118,7 @@ gDriverTypeMap = {
'DXE_SMM_DRIVER' : '0x7 (DRIVER)',
'DXE_RUNTIME_DRIVER': '0x7 (DRIVER)',
'UEFI_DRIVER' : '0x7 (DRIVER)',
- 'UEFI_APPLICATION' : '0x9 (APPLICATION)',
+ SUP_MODULE_UEFI_APPLICATION : '0x9 (APPLICATION)',
'SMM_CORE' : '0xD (SMM_CORE)',
'SMM_DRIVER' : '0xA (SMM)', # Extension of module type to support PI 1.1 SMM drivers
'MM_STANDALONE' : '0xE (MM_STANDALONE)',
@@ -410,7 +411,7 @@ class DepexReport(object):
if not ModuleType:
ModuleType = gComponentType2ModuleType.get(M.ComponentType, "")
- if ModuleType in ["SEC", "PEI_CORE", "DXE_CORE", "SMM_CORE", "MM_CORE_STANDALONE", "UEFI_APPLICATION"]:
+ if ModuleType in ["SEC", "PEI_CORE", "DXE_CORE", "SMM_CORE", "MM_CORE_STANDALONE", SUP_MODULE_UEFI_APPLICATION]:
return
for Source in M.SourceFileList:
--
2.16.2.windows.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH v1 3/3] BaseTools: use existing contrants to replace raw strings in python code.
2018-04-11 1:07 ` Zhu, Yonghong
@ 2018-04-11 14:20 ` Carsey, Jaben
0 siblings, 0 replies; 8+ messages in thread
From: Carsey, Jaben @ 2018-04-11 14:20 UTC (permalink / raw)
To: Zhu, Yonghong, edk2-devel@lists.01.org; +Cc: Gao, Liming
I would like to replace all use of string constants with the ones in DataType. I just didn't get to the rest.
> -----Original Message-----
> From: Zhu, Yonghong
> Sent: Tuesday, April 10, 2018 6:08 PM
> To: Carsey, Jaben <jaben.carsey@intel.com>; edk2-devel@lists.01.org
> Cc: Gao, Liming <liming.gao@intel.com>; Zhu, Yonghong
> <yonghong.zhu@intel.com>
> Subject: RE: [PATCH v1 3/3] BaseTools: use existing contrants to replace raw
> strings in python code.
> Importance: High
>
> Hi Jaben,
>
> Seems only replaced 'UEFI_APPLICATION', what about others, eg '
> DXE_SMM_DRIVER' ? Do you have plan to update it ?
>
> Best Regards,
> Zhu Yonghong
>
>
> -----Original Message-----
> From: Carsey, Jaben
> Sent: Tuesday, April 10, 2018 10:20 PM
> To: edk2-devel@lists.01.org
> Cc: Gao, Liming <liming.gao@intel.com>; Zhu, Yonghong
> <yonghong.zhu@intel.com>
> Subject: [PATCH v1 3/3] BaseTools: use existing contrants to replace raw
> strings in python code.
>
> 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>
> ---
> BaseTools/Source/Python/AutoGen/GenC.py | 13 +++++++------
> BaseTools/Source/Python/AutoGen/GenDepex.py | 3 ++-
> BaseTools/Source/Python/GenFds/Ffs.py | 3 ++-
> BaseTools/Source/Python/Workspace/InfBuildData.py | 4 ++--
> BaseTools/Source/Python/build/BuildReport.py | 5 +++--
> 5 files changed, 16 insertions(+), 12 deletions(-)
>
> diff --git a/BaseTools/Source/Python/AutoGen/GenC.py
> b/BaseTools/Source/Python/AutoGen/GenC.py
> index 4d9ea1b2a8b1..4a9657420897 100644
> --- a/BaseTools/Source/Python/AutoGen/GenC.py
> +++ b/BaseTools/Source/Python/AutoGen/GenC.py
> @@ -25,6 +25,7 @@ from Common.String import StringToArray from
> StrGather import * from GenPcdDb import CreatePcdDatabaseCode from
> IdfClassObject import *
> +from Common.DataType import SUP_MODULE_UEFI_APPLICATION
>
> ## PCD type string
> gItemTypeStringDatabase = {
> @@ -782,7 +783,7 @@ gModuleTypeHeaderFile = {
> "DXE_RUNTIME_DRIVER": ["PiDxe.h", "Library/BaseLib.h",
> "Library/DebugLib.h", "Library/UefiBootServicesTableLib.h",
> "Library/UefiDriverEntryPoint.h"],
> "DXE_SAL_DRIVER" : ["PiDxe.h", "Library/BaseLib.h",
> "Library/DebugLib.h", "Library/UefiBootServicesTableLib.h",
> "Library/UefiDriverEntryPoint.h"],
> "UEFI_DRIVER" : ["Uefi.h", "Library/BaseLib.h", "Library/DebugLib.h",
> "Library/UefiBootServicesTableLib.h", "Library/UefiDriverEntryPoint.h"],
> - "UEFI_APPLICATION" : ["Uefi.h", "Library/BaseLib.h",
> "Library/DebugLib.h", "Library/UefiBootServicesTableLib.h",
> "Library/UefiApplicationEntryPoint.h"],
> + SUP_MODULE_UEFI_APPLICATION : ["Uefi.h", "Library/BaseLib.h",
> "Library/DebugLib.h", "Library/UefiBootServicesTableLib.h",
> "Library/UefiApplicationEntryPoint.h"],
> "SMM_CORE" : ["PiDxe.h", "Library/BaseLib.h",
> "Library/DebugLib.h", "Library/UefiDriverEntryPoint.h"],
> "MM_STANDALONE" : ["PiSmm.h", "Library/BaseLib.h",
> "Library/DebugLib.h", "Library/SmmDriverStandaloneEntryPoint.h"],
> "MM_CORE_STANDALONE" : ["PiSmm.h", "Library/BaseLib.h",
> "Library/DebugLib.h", "Library/SmmCoreStandaloneEntryPoint.h"],
> @@ -1386,7 +1387,7 @@ def CreateLibraryConstructorCode(Info, AutoGenC,
> AutoGenH):
>
> ConstructorPrototypeString.Append(gLibraryStructorPrototype['PEI'].Replac
> e(Dict))
>
> ConstructorCallingString.Append(gLibraryStructorCall['PEI'].Replace(Dict))
> elif Lib.ModuleType in
> ['DXE_CORE','DXE_DRIVER','DXE_SMM_DRIVER','DXE_RUNTIME_DRIVER',
> -
> 'DXE_SAL_DRIVER','UEFI_DRIVER','UEFI_APPLICATION','SMM_CORE']:
> +
> 'DXE_SAL_DRIVER','UEFI_DRIVER',SUP_MODULE_UEFI_APPLICATION,'SMM
> _CORE']:
>
> ConstructorPrototypeString.Append(gLibraryStructorPrototype['DXE'].Replac
> e(Dict))
>
> ConstructorCallingString.Append(gLibraryStructorCall['DXE'].Replace(Dict))
> elif Lib.ModuleType in
> ['MM_STANDALONE','MM_CORE_STANDALONE']:
> @@ -1415,7 +1416,7 @@ def CreateLibraryConstructorCode(Info, AutoGenC,
> AutoGenH):
> elif Info.ModuleType in ['PEI_CORE','PEIM']:
> AutoGenC.Append(gLibraryString['PEI'].Replace(Dict))
> elif Info.ModuleType in
> ['DXE_CORE','DXE_DRIVER','DXE_SMM_DRIVER','DXE_RUNTIME_DRIVER',
> -
> 'DXE_SAL_DRIVER','UEFI_DRIVER','UEFI_APPLICATION','SMM_CORE']:
> +
> 'DXE_SAL_DRIVER','UEFI_DRIVER',SUP_MODULE_UEFI_APPLICATION,'SMM
> _CORE']:
> AutoGenC.Append(gLibraryString['DXE'].Replace(Dict))
> elif Info.ModuleType in
> ['MM_STANDALONE','MM_CORE_STANDALONE']:
> AutoGenC.Append(gLibraryString['MM'].Replace(Dict))
> @@ -1448,7 +1449,7 @@ def CreateLibraryDestructorCode(Info, AutoGenC,
> AutoGenH):
>
> DestructorPrototypeString.Append(gLibraryStructorPrototype['PEI'].Replace
> (Dict))
>
> DestructorCallingString.Append(gLibraryStructorCall['PEI'].Replace(Dict))
> elif Lib.ModuleType in
> ['DXE_CORE','DXE_DRIVER','DXE_SMM_DRIVER','DXE_RUNTIME_DRIVER',
> - 'DXE_SAL_DRIVER','UEFI_DRIVER','UEFI_APPLICATION',
> 'SMM_CORE']:
> +
> 'DXE_SAL_DRIVER','UEFI_DRIVER',SUP_MODULE_UEFI_APPLICATION,
> 'SMM_CORE']:
>
> DestructorPrototypeString.Append(gLibraryStructorPrototype['DXE'].Replac
> e(Dict))
>
> DestructorCallingString.Append(gLibraryStructorCall['DXE'].Replace(Dict))
> elif Lib.ModuleType in
> ['MM_STANDALONE','MM_CORE_STANDALONE']:
> @@ -1477,7 +1478,7 @@ def CreateLibraryDestructorCode(Info, AutoGenC,
> AutoGenH):
> elif Info.ModuleType in ['PEI_CORE','PEIM']:
> AutoGenC.Append(gLibraryString['PEI'].Replace(Dict))
> elif Info.ModuleType in
> ['DXE_CORE','DXE_DRIVER','DXE_SMM_DRIVER','DXE_RUNTIME_DRIVER',
> -
> 'DXE_SAL_DRIVER','UEFI_DRIVER','UEFI_APPLICATION','SMM_CORE']:
> +
> 'DXE_SAL_DRIVER','UEFI_DRIVER',SUP_MODULE_UEFI_APPLICATION,'SMM
> _CORE']:
> AutoGenC.Append(gLibraryString['DXE'].Replace(Dict))
> elif Info.ModuleType in
> ['MM_STANDALONE','MM_CORE_STANDALONE']:
> AutoGenC.Append(gLibraryString['MM'].Replace(Dict))
> @@ -1556,7 +1557,7 @@ def CreateModuleEntryPointCode(Info, AutoGenC,
> AutoGenH):
> else:
> AutoGenC.Append(gMmStandaloneEntryPointString[2].Replace(Dict))
> AutoGenH.Append(gMmStandaloneEntryPointPrototype.Replace(Dict))
> - elif Info.ModuleType == 'UEFI_APPLICATION':
> + elif Info.ModuleType == SUP_MODULE_UEFI_APPLICATION:
> if NumEntryPoints < 2:
>
> AutoGenC.Append(gUefiApplicationEntryPointString[NumEntryPoints].Repla
> ce(Dict))
> else:
> diff --git a/BaseTools/Source/Python/AutoGen/GenDepex.py
> b/BaseTools/Source/Python/AutoGen/GenDepex.py
> index 9acea8f6bfed..8896ad65bfe6 100644
> --- a/BaseTools/Source/Python/AutoGen/GenDepex.py
> +++ b/BaseTools/Source/Python/AutoGen/GenDepex.py
> @@ -24,6 +24,7 @@ from Common.Misc import SaveFileOnChange from
> Common.Misc import GuidStructureStringToGuidString from Common
> import EdkLogger as EdkLogger from Common.BuildVersion import
> gBUILD_VERSION
> +from Common.DataType import SUP_MODULE_UEFI_APPLICATION
>
> ## Regular expression for matching "DEPENDENCY_START ...
> DEPENDENCY_END"
> gStartClosePattern =
> re.compile(".*DEPENDENCY_START(.+)DEPENDENCY_END.*", re.S) @@ -40,7
> +41,7 @@ gType2Phase = {
> "DXE_RUNTIME_DRIVER": "DXE",
> "DXE_SAL_DRIVER" : "DXE",
> "UEFI_DRIVER" : "DXE",
> - "UEFI_APPLICATION" : "DXE",
> + SUP_MODULE_UEFI_APPLICATION : "DXE",
> "SMM_CORE" : "DXE",
> "MM_STANDALONE" : "MM",
> "MM_CORE_STANDALONE" : "MM",
> diff --git a/BaseTools/Source/Python/GenFds/Ffs.py
> b/BaseTools/Source/Python/GenFds/Ffs.py
> index a4178121118b..e5b180eb9324 100644
> --- a/BaseTools/Source/Python/GenFds/Ffs.py
> +++ b/BaseTools/Source/Python/GenFds/Ffs.py
> @@ -16,6 +16,7 @@
> # Import Modules
> #
> from CommonDataClass.FdfClass import FDClassObject
> +from Common.DataType import SUP_MODULE_UEFI_APPLICATION
>
> ## generate FFS
> #
> @@ -33,7 +34,7 @@ class Ffs(FDClassObject):
> 'DXE_SMM_DRIVER' : 'EFI_FV_FILETYPE_DRIVER',
> 'DXE_RUNTIME_DRIVER': 'EFI_FV_FILETYPE_DRIVER',
> 'UEFI_DRIVER' : 'EFI_FV_FILETYPE_DRIVER',
> - 'UEFI_APPLICATION' : 'EFI_FV_FILETYPE_APPLICATION',
> + SUP_MODULE_UEFI_APPLICATION : 'EFI_FV_FILETYPE_APPLICATION',
> 'SMM_CORE' : 'EFI_FV_FILETYPE_SMM_CORE',
> 'MM_STANDALONE' : 'EFI_FV_FILETYPE_MM_STANDALONE',
> 'MM_CORE_STANDALONE' :
> 'EFI_FV_FILETYPE_MM_CORE_STANDALONE'
> diff --git a/BaseTools/Source/Python/Workspace/InfBuildData.py
> b/BaseTools/Source/Python/Workspace/InfBuildData.py
> index 53aa6acf5862..c1841487f64f 100644
> --- a/BaseTools/Source/Python/Workspace/InfBuildData.py
> +++ b/BaseTools/Source/Python/Workspace/InfBuildData.py
> @@ -17,7 +17,7 @@ from Common.DataType import * from Common.Misc
> import * from types import * from MetaFileParser import * -from
> Common.DataType import TAB_ARCH_COMMON,TAB_ARCH_COMMON
> +from Common.DataType import
> +TAB_ARCH_COMMON,TAB_ARCH_COMMON,SUP_MODULE_UEFI_APPLIC
> ATION
>
> from Workspace.BuildClassObject import ModuleBuildClassObject,
> LibraryClassObject, PcdClassObject ## Module build information from INF
> file @@ -82,7 +82,7 @@ class InfBuildData(ModuleBuildClassObject):
> # "SMM_DRIVER" : "DXE_SMM_DRIVER",
> # "BS_DRIVER" : "DXE_SMM_DRIVER",
> # "BS_DRIVER" : "UEFI_DRIVER",
> - "APPLICATION" : "UEFI_APPLICATION",
> + "APPLICATION" : SUP_MODULE_UEFI_APPLICATION,
> "LOGO" : "BASE",
> }
>
> diff --git a/BaseTools/Source/Python/build/BuildReport.py
> b/BaseTools/Source/Python/build/BuildReport.py
> index 966a2aa5abf1..190b58cfa44e 100644
> --- a/BaseTools/Source/Python/build/BuildReport.py
> +++ b/BaseTools/Source/Python/build/BuildReport.py
> @@ -47,6 +47,7 @@ from Common.String import NormPath from
> Common.DataType import * import collections from Common.Expression
> import *
> +from Common.DataType import SUP_MODULE_UEFI_APPLICATION
>
> ## Pattern to extract contents in EDK DXS files gDxsDependencyPattern =
> re.compile(r"DEPENDENCY_START(.+)DEPENDENCY_END", re.DOTALL) @@ -
> 117,7 +118,7 @@ gDriverTypeMap = {
> 'DXE_SMM_DRIVER' : '0x7 (DRIVER)',
> 'DXE_RUNTIME_DRIVER': '0x7 (DRIVER)',
> 'UEFI_DRIVER' : '0x7 (DRIVER)',
> - 'UEFI_APPLICATION' : '0x9 (APPLICATION)',
> + SUP_MODULE_UEFI_APPLICATION : '0x9 (APPLICATION)',
> 'SMM_CORE' : '0xD (SMM_CORE)',
> 'SMM_DRIVER' : '0xA (SMM)', # Extension of module type to support PI
> 1.1 SMM drivers
> 'MM_STANDALONE' : '0xE (MM_STANDALONE)',
> @@ -410,7 +411,7 @@ class DepexReport(object):
> if not ModuleType:
> ModuleType =
> gComponentType2ModuleType.get(M.ComponentType, "")
>
> - if ModuleType in ["SEC", "PEI_CORE", "DXE_CORE", "SMM_CORE",
> "MM_CORE_STANDALONE", "UEFI_APPLICATION"]:
> + if ModuleType in ["SEC", "PEI_CORE", "DXE_CORE", "SMM_CORE",
> "MM_CORE_STANDALONE", SUP_MODULE_UEFI_APPLICATION]:
> return
>
> for Source in M.SourceFileList:
> --
> 2.16.2.windows.1
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v1 2/3] BaseTools: use predefined constants instead of local strings
2018-04-10 14:20 ` [PATCH v1 2/3] BaseTools: use predefined constants instead of local strings Jaben Carsey
@ 2018-04-16 1:43 ` Zhu, Yonghong
0 siblings, 0 replies; 8+ messages in thread
From: Zhu, Yonghong @ 2018-04-16 1:43 UTC (permalink / raw)
To: Carsey, Jaben, edk2-devel@lists.01.org; +Cc: Gao, Liming, Zhu, Yonghong
Hi Jaben,
One comment on this patch, in InfBuildData.py, MetaFileParser.py and MetaFileTable.py add "from Common.DataType import TAB_ARCH_COMMON,TAB_ARCH_COMMON", the " TAB_ARCH_COMMON" was wrote twice, but in the code it use TAB_ARCH_COMMON and TAB_COMMON.
Current it still build pass because in those files it also have " from Common.DataType import *".
So you will send out a V2 or update this import statement when push the patch?
Other patch are fine to me.
Best Regards,
Zhu Yonghong
-----Original Message-----
From: Carsey, Jaben
Sent: Tuesday, April 10, 2018 10:20 PM
To: edk2-devel@lists.01.org
Cc: Gao, Liming <liming.gao@intel.com>; Zhu, Yonghong <yonghong.zhu@intel.com>
Subject: [PATCH v1 2/3] BaseTools: use predefined constants instead of local strings
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>
---
BaseTools/Source/Python/AutoGen/AutoGen.py | 24 +--
BaseTools/Source/Python/AutoGen/BuildEngine.py | 23 +--
BaseTools/Source/Python/AutoGen/GenPcdDb.py | 15 +-
BaseTools/Source/Python/AutoGen/GenVar.py | 15 +-
BaseTools/Source/Python/Common/DataType.py | 2 +
BaseTools/Source/Python/GenFds/AprioriSection.py | 3 +-
BaseTools/Source/Python/GenFds/FdfParser.py | 29 ++--
BaseTools/Source/Python/GenFds/FfsInfStatement.py | 5 +-
BaseTools/Source/Python/GenFds/GenFds.py | 13 +-
BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py | 9 +-
BaseTools/Source/Python/GenFds/Section.py | 3 +-
BaseTools/Source/Python/Workspace/DecBuildData.py | 5 +-
BaseTools/Source/Python/Workspace/DscBuildData.py | 154 ++++++++++----------
BaseTools/Source/Python/Workspace/InfBuildData.py | 7 +-
BaseTools/Source/Python/Workspace/MetaFileParser.py | 34 ++---
BaseTools/Source/Python/Workspace/MetaFileTable.py | 22 +--
BaseTools/Source/Python/Workspace/WorkspaceDatabase.py | 6 +-
17 files changed, 196 insertions(+), 173 deletions(-)
diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py b/BaseTools/Source/Python/AutoGen/AutoGen.py
index 3384fdb70b7e..abdddec5ed6a 100644
--- a/BaseTools/Source/Python/AutoGen/AutoGen.py
+++ b/BaseTools/Source/Python/AutoGen/AutoGen.py
@@ -45,6 +45,8 @@ import InfSectionParser
import datetime
import hashlib
from GenVar import VariableMgr,var_info
+from Common.DataType import TAB_DEFAULT
+from Common.DataType import TAB_COMMON
## Regular expression for splitting Dependency Expression string into tokens
gDepexTokenPattern = re.compile("(\(|\)|\w+| \S+\.inf)")
@@ -253,7 +255,7 @@ class WorkspaceAutoGen(AutoGen):
self.BuildDatabase = MetaFileDb
self.MetaFile = ActivePlatform
self.WorkspaceDir = WorkspaceDir
- self.Platform = self.BuildDatabase[self.MetaFile, 'COMMON', Target, Toolchain]
+ self.Platform = self.BuildDatabase[self.MetaFile, TAB_COMMON, Target, Toolchain]
GlobalData.gActivePlatform = self.Platform
self.BuildTarget = Target
self.ToolChain = Toolchain
@@ -803,7 +805,7 @@ class WorkspaceAutoGen(AutoGen):
# Here we just need to get FILE_GUID from INF file, use 'COMMON' as ARCH attribute. and use
# BuildObject from one of AutoGenObjectList is enough.
#
- InfObj = self.AutoGenObjectList[0].BuildDatabase.WorkspaceDb.BuildObject[PathClassObj, 'COMMON', self.BuildTarget, self.ToolChain]
+ InfObj = self.AutoGenObjectList[0].BuildDatabase.WorkspaceDb.BuildObject[PathClassObj, TAB_COMMON, self.BuildTarget, self.ToolChain]
if not InfObj.Guid.upper() in _GuidDict.keys():
_GuidDict[InfObj.Guid.upper()] = FfsFile
else:
@@ -1355,7 +1357,7 @@ class PlatformAutoGen(AutoGen):
EdkLogger.error("build", FILE_READ_FAILURE, "Can not find VPD map file %s to fix up VPD offset." % VpdMapFilePath)
NvStoreOffset = int(NvStoreOffset,16) if NvStoreOffset.upper().startswith("0X") else int(NvStoreOffset)
- default_skuobj = PcdNvStoreDfBuffer[0].SkuInfoList.get("DEFAULT")
+ default_skuobj = PcdNvStoreDfBuffer[0].SkuInfoList.get(TAB_DEFAULT)
maxsize = self.VariableInfo.VpdRegionSize - NvStoreOffset if self.VariableInfo.VpdRegionSize else len(default_skuobj.DefaultValue.split(","))
var_data = self.VariableInfo.PatchNVStoreDefaultMaxSize(maxsize)
@@ -1363,7 +1365,7 @@ class PlatformAutoGen(AutoGen):
default_skuobj.DefaultValue = var_data
PcdNvStoreDfBuffer[0].DefaultValue = var_data
PcdNvStoreDfBuffer[0].SkuInfoList.clear()
- PcdNvStoreDfBuffer[0].SkuInfoList['DEFAULT'] = default_skuobj
+ PcdNvStoreDfBuffer[0].SkuInfoList[TAB_DEFAULT] = default_skuobj
PcdNvStoreDfBuffer[0].MaxDatumSize = str(len(default_skuobj.DefaultValue.split(",")))
return OrgVpdFile
@@ -1603,12 +1605,12 @@ class PlatformAutoGen(AutoGen):
PcdKey in VpdPcdDict:
Pcd = VpdPcdDict[PcdKey]
SkuValueMap = {}
- DefaultSku = Pcd.SkuInfoList.get('DEFAULT')
+ DefaultSku = Pcd.SkuInfoList.get(TAB_DEFAULT)
if DefaultSku:
PcdValue = DefaultSku.DefaultValue
if PcdValue not in SkuValueMap:
SkuValueMap[PcdValue] = []
- VpdFile.Add(Pcd, 'DEFAULT',DefaultSku.VpdOffset)
+ VpdFile.Add(Pcd, TAB_DEFAULT,DefaultSku.VpdOffset)
SkuValueMap[PcdValue].append(DefaultSku)
for (SkuName,Sku) in Pcd.SkuInfoList.items():
@@ -1667,9 +1669,9 @@ class PlatformAutoGen(AutoGen):
# just pick the a value to determine whether is unicode string type
SkuValueMap = {}
SkuObjList = DscPcdEntry.SkuInfoList.items()
- DefaultSku = DscPcdEntry.SkuInfoList.get('DEFAULT')
+ DefaultSku = DscPcdEntry.SkuInfoList.get(TAB_DEFAULT)
if DefaultSku:
- defaultindex = SkuObjList.index(('DEFAULT',DefaultSku))
+ defaultindex = SkuObjList.index((TAB_DEFAULT,DefaultSku))
SkuObjList[0],SkuObjList[defaultindex] = SkuObjList[defaultindex],SkuObjList[0]
for (SkuName,Sku) in SkuObjList:
Sku.VpdOffset = Sku.VpdOffset.strip()
@@ -1793,7 +1795,7 @@ class PlatformAutoGen(AutoGen):
for (SkuName,SkuId) in allskuset:
if type(SkuId) in (str,unicode) and eval(SkuId) == 0 or SkuId == 0:
continue
- pcd.SkuInfoList[SkuName] = copy.deepcopy(pcd.SkuInfoList['DEFAULT'])
+ pcd.SkuInfoList[SkuName] = copy.deepcopy(pcd.SkuInfoList[TAB_DEFAULT])
pcd.SkuInfoList[SkuName].SkuId = SkuId
self.AllPcdList = self._NonDynamicPcdList + self._DynamicPcdList
@@ -2420,7 +2422,7 @@ class PlatformAutoGen(AutoGen):
if self.Platform.SkuName in self.Platform.SkuIds:
SkuName = self.Platform.SkuName
else:
- SkuName = 'DEFAULT'
+ SkuName = TAB_DEFAULT
ToPcd.SkuInfoList = {
SkuName : SkuInfoClass(SkuName, self.Platform.SkuIds[SkuName][0], '', '', '', '', '', ToPcd.DefaultValue)
}
@@ -3458,7 +3460,7 @@ class ModuleAutoGen(AutoGen):
if self._BinaryFileList is None:
self._BinaryFileList = []
for F in self.Module.Binaries:
- if F.Target not in ['COMMON', '*'] and F.Target != self.BuildTarget:
+ if F.Target not in [TAB_COMMON, '*'] and F.Target != self.BuildTarget:
continue
self._BinaryFileList.append(F)
self._ApplyBuildRule(F, F.Type)
diff --git a/BaseTools/Source/Python/AutoGen/BuildEngine.py b/BaseTools/Source/Python/AutoGen/BuildEngine.py
index 0daed7da610d..8e32312a8018 100644
--- a/BaseTools/Source/Python/AutoGen/BuildEngine.py
+++ b/BaseTools/Source/Python/AutoGen/BuildEngine.py
@@ -27,6 +27,7 @@ from Common.String import NormPath
from Common.DataType import *
import Common.EdkLogger as EdkLogger
+from Common.DataType import TAB_COMMON
## Convert file type to file list macro name
#
@@ -375,7 +376,7 @@ class BuildRule:
self.Parse()
# some intrinsic rules
- self.RuleDatabase[TAB_DEFAULT_BINARY_FILE, "COMMON", "COMMON", "COMMON"] = self._BinaryFileRule
+ self.RuleDatabase[TAB_DEFAULT_BINARY_FILE, TAB_COMMON, TAB_COMMON, TAB_COMMON] = self._BinaryFileRule
self.FileTypeList.add(TAB_DEFAULT_BINARY_FILE)
## Parse the build rule strings
@@ -434,9 +435,9 @@ class BuildRule:
## Merge section information just got into rule database
def EndOfSection(self):
Database = self.RuleDatabase
- # if there's specific toochain family, 'COMMON' doesn't make sense any more
- if len(self._TotalToolChainFamilySet) > 1 and 'COMMON' in self._TotalToolChainFamilySet:
- self._TotalToolChainFamilySet.remove('COMMON')
+ # if there's specific toochain family, TAB_COMMON doesn't make sense any more
+ if len(self._TotalToolChainFamilySet) > 1 and TAB_COMMON in self._TotalToolChainFamilySet:
+ self._TotalToolChainFamilySet.remove(TAB_COMMON)
for Family in self._TotalToolChainFamilySet:
Input = self._RuleInfo[Family, self._InputFile]
Output = self._RuleInfo[Family, self._OutputFile]
@@ -463,8 +464,8 @@ class BuildRule:
FileType = ''
RuleNameList = self.RuleContent[LineIndex][1:-1].split(',')
for RuleName in RuleNameList:
- Arch = 'COMMON'
- BuildType = 'COMMON'
+ Arch = TAB_COMMON
+ BuildType = TAB_COMMON
TokenList = [Token.strip().upper() for Token in RuleName.split('.')]
# old format: Build.File-Type
if TokenList[0] == "BUILD":
@@ -499,12 +500,12 @@ class BuildRule:
if Arch not in self._ArchList:
self._ArchList.append(Arch)
- if 'COMMON' in self._BuildTypeList and len(self._BuildTypeList) > 1:
+ if TAB_COMMON in self._BuildTypeList and len(self._BuildTypeList) > 1:
EdkLogger.error("build", FORMAT_INVALID,
"Specific build types must not be mixed with common one",
File=self.RuleFile, Line=LineIndex + 1,
ExtraData=self.RuleContent[LineIndex])
- if 'COMMON' in self._ArchList and len(self._ArchList) > 1:
+ if TAB_COMMON in self._ArchList and len(self._ArchList) > 1:
EdkLogger.error("build", FORMAT_INVALID,
"Specific ARCH must not be mixed with common one",
File=self.RuleFile, Line=LineIndex + 1,
@@ -537,7 +538,7 @@ class BuildRule:
if len(TokenList) > 1:
Family = TokenList[1].strip().upper()
else:
- Family = "COMMON"
+ Family = TAB_COMMON
if Family not in FamilyList:
FamilyList.append(Family)
@@ -545,7 +546,7 @@ class BuildRule:
self._FamilyList = FamilyList
self._TotalToolChainFamilySet.update(FamilyList)
self._State = SectionType.upper()
- if 'COMMON' in FamilyList and len(FamilyList) > 1:
+ if TAB_COMMON in FamilyList and len(FamilyList) > 1:
EdkLogger.error("build", FORMAT_INVALID,
"Specific tool chain family should not be mixed with general one",
File=self.RuleFile, Line=LineIndex + 1,
@@ -637,7 +638,7 @@ if __name__ == '__main__':
print
print str(Br[".ac", "ACPI_TABLE", "IA32", "MSFT"][1])
print
- print str(Br[".s", "SEC", "IPF", "COMMON"][1])
+ print str(Br[".s", "SEC", "IPF", TAB_COMMON][1])
print
print str(Br[".s", "SEC"][1])
diff --git a/BaseTools/Source/Python/AutoGen/GenPcdDb.py b/BaseTools/Source/Python/AutoGen/GenPcdDb.py
index a2c4fb39ec85..88f646b2522c 100644
--- a/BaseTools/Source/Python/AutoGen/GenPcdDb.py
+++ b/BaseTools/Source/Python/AutoGen/GenPcdDb.py
@@ -20,6 +20,7 @@ from ValidCheckingInfoObject import VAR_VALID_OBJECT_FACTORY
from Common.VariableAttributes import VariableAttributes
import copy
from struct import unpack
+from Common.DataType import TAB_DEFAULT
DATABASE_VERSION = 7
@@ -981,14 +982,14 @@ def CreatePcdDataBase(PcdDBData):
delta = {}
basedata = {}
for skuname,skuid in PcdDBData:
- if len(PcdDBData[(skuname,skuid)][1]) != len(PcdDBData[("DEFAULT","0")][1]):
+ if len(PcdDBData[(skuname,skuid)][1]) != len(PcdDBData[(TAB_DEFAULT,"0")][1]):
EdkLogger.ERROR("The size of each sku in one pcd are not same")
for skuname,skuid in PcdDBData:
- if skuname == "DEFAULT":
+ if skuname == TAB_DEFAULT:
continue
- delta[(skuname,skuid)] = [(index,data,hex(data)) for index,data in enumerate(PcdDBData[(skuname,skuid)][1]) if PcdDBData[(skuname,skuid)][1][index] != PcdDBData[("DEFAULT","0")][1][index]]
- basedata[(skuname,skuid)] = [(index,PcdDBData[("DEFAULT","0")][1][index],hex(PcdDBData[("DEFAULT","0")][1][index])) for index,data in enumerate(PcdDBData[(skuname,skuid)][1]) if PcdDBData[(skuname,skuid)][1][index] != PcdDBData[("DEFAULT","0")][1][index]]
- databasebuff = PcdDBData[("DEFAULT","0")][0]
+ delta[(skuname,skuid)] = [(index,data,hex(data)) for index,data in enumerate(PcdDBData[(skuname,skuid)][1]) if PcdDBData[(skuname,skuid)][1][index] != PcdDBData[(TAB_DEFAULT,"0")][1][index]]
+ basedata[(skuname,skuid)] = [(index,PcdDBData[(TAB_DEFAULT,"0")][1][index],hex(PcdDBData[(TAB_DEFAULT,"0")][1][index])) for index,data in enumerate(PcdDBData[(skuname,skuid)][1]) if PcdDBData[(skuname,skuid)][1][index] != PcdDBData[(TAB_DEFAULT,"0")][1][index]]
+ databasebuff = PcdDBData[(TAB_DEFAULT,"0")][0]
for skuname,skuid in delta:
# 8 byte align
@@ -1011,7 +1012,7 @@ def CreatePcdDataBase(PcdDBData):
return newbuffer
def CreateVarCheckBin(VarCheckTab):
- return VarCheckTab[('DEFAULT',"0")]
+ return VarCheckTab[(TAB_DEFAULT,"0")]
def CreateAutoGen(PcdDriverAutoGenData):
autogenC = TemplateString()
for skuname,skuid in PcdDriverAutoGenData:
@@ -1062,7 +1063,7 @@ def NewCreatePcdDatabasePhaseSpecificAutoGen(Platform,Phase):
final_data = ()
for item in PcdDbBuffer:
final_data += unpack("B",item)
- PcdDBData[("DEFAULT","0")] = (PcdDbBuffer, final_data)
+ PcdDBData[(TAB_DEFAULT,"0")] = (PcdDbBuffer, final_data)
return AdditionalAutoGenH, AdditionalAutoGenC, CreatePcdDataBase(PcdDBData)
## Create PCD database in DXE or PEI phase
diff --git a/BaseTools/Source/Python/AutoGen/GenVar.py b/BaseTools/Source/Python/AutoGen/GenVar.py
index d222e6ed5e7e..686258c77c90 100644
--- a/BaseTools/Source/Python/AutoGen/GenVar.py
+++ b/BaseTools/Source/Python/AutoGen/GenVar.py
@@ -20,6 +20,7 @@ import copy
from Common.VariableAttributes import VariableAttributes
from Common.Misc import *
import collections
+from Common.DataType import TAB_DEFAULT
var_info = collections.namedtuple("uefi_var", "pcdindex,pcdname,defaultstoragename,skuname,var_name, var_guid, var_offset,var_attribute,pcd_default_value, default_value, data_type")
NvStorageHeaderSize = 28
@@ -141,7 +142,7 @@ class VariableMgr(object):
default_data_buffer = ""
others_data_buffer = ""
tail = None
- default_sku_default = indexedvarinfo.get(index).get(("DEFAULT","STANDARD"))
+ default_sku_default = indexedvarinfo.get(index).get((TAB_DEFAULT,"STANDARD"))
if default_sku_default.data_type not in ["UINT8","UINT16","UINT32","UINT64","BOOLEAN"]:
var_max_len = max([len(var_item.default_value.split(",")) for var_item in sku_var_info.values()])
@@ -154,13 +155,13 @@ class VariableMgr(object):
for item in default_data_buffer:
default_data_array += unpack("B",item)
- if ("DEFAULT","STANDARD") not in var_data:
- var_data[("DEFAULT","STANDARD")] = collections.OrderedDict()
- var_data[("DEFAULT","STANDARD")][index] = (default_data_buffer,sku_var_info[("DEFAULT","STANDARD")])
+ if (TAB_DEFAULT,"STANDARD") not in var_data:
+ var_data[(TAB_DEFAULT,"STANDARD")] = collections.OrderedDict()
+ var_data[(TAB_DEFAULT,"STANDARD")][index] = (default_data_buffer,sku_var_info[(TAB_DEFAULT,"STANDARD")])
for (skuid,defaultstoragename) in indexedvarinfo.get(index):
tail = None
- if (skuid,defaultstoragename) == ("DEFAULT","STANDARD"):
+ if (skuid,defaultstoragename) == (TAB_DEFAULT,"STANDARD"):
continue
other_sku_other = indexedvarinfo.get(index).get((skuid,defaultstoragename))
@@ -189,7 +190,7 @@ class VariableMgr(object):
if not var_data:
return []
- pcds_default_data = var_data.get(("DEFAULT","STANDARD"),{})
+ pcds_default_data = var_data.get((TAB_DEFAULT,"STANDARD"),{})
NvStoreDataBuffer = ""
var_data_offset = collections.OrderedDict()
offset = NvStorageHeaderSize
@@ -219,7 +220,7 @@ class VariableMgr(object):
data_delta_structure_buffer = ""
for skuname,defaultstore in var_data:
- if (skuname,defaultstore) == ("DEFAULT","STANDARD"):
+ if (skuname,defaultstore) == (TAB_DEFAULT,"STANDARD"):
continue
pcds_sku_data = var_data.get((skuname,defaultstore))
delta_data_set = []
diff --git a/BaseTools/Source/Python/Common/DataType.py b/BaseTools/Source/Python/Common/DataType.py
index 0bc2306ea61a..89d95c8a0bde 100644
--- a/BaseTools/Source/Python/Common/DataType.py
+++ b/BaseTools/Source/Python/Common/DataType.py
@@ -312,6 +312,8 @@ TAB_DEFINE = 'DEFINE'
TAB_NMAKE = 'Nmake'
TAB_USER_EXTENSIONS = 'UserExtensions'
TAB_INCLUDE = '!include'
+TAB_DEFAULT = 'DEFAULT'
+TAB_COMMON = 'COMMON'
#
# Common Define
diff --git a/BaseTools/Source/Python/GenFds/AprioriSection.py b/BaseTools/Source/Python/GenFds/AprioriSection.py
index 92a74670ed25..e6b8aa151b31 100644
--- a/BaseTools/Source/Python/GenFds/AprioriSection.py
+++ b/BaseTools/Source/Python/GenFds/AprioriSection.py
@@ -25,6 +25,7 @@ from Common.String import *
from Common.Misc import SaveFileOnChange,PathClass
from Common import EdkLogger
from Common.BuildToolError import *
+from Common.DataType import TAB_COMMON
## process APRIORI file data and generate PEI/DXE APRIORI file
#
@@ -84,7 +85,7 @@ class AprioriSection (AprioriSectionClassObject):
Guid = Inf.Guid
else:
- Inf = GenFdsGlobalVariable.WorkSpace.BuildObject[PathClass(InfFileName, GenFdsGlobalVariable.WorkSpaceDir), 'COMMON', GenFdsGlobalVariable.TargetName, GenFdsGlobalVariable.ToolChainTag]
+ Inf = GenFdsGlobalVariable.WorkSpace.BuildObject[PathClass(InfFileName, GenFdsGlobalVariable.WorkSpaceDir), TAB_COMMON, GenFdsGlobalVariable.TargetName, GenFdsGlobalVariable.ToolChainTag]
Guid = Inf.Guid
self.BinFileList = Inf.Module.Binaries
diff --git a/BaseTools/Source/Python/GenFds/FdfParser.py b/BaseTools/Source/Python/GenFds/FdfParser.py
index 9b7e898570a3..992dfea926d4 100644
--- a/BaseTools/Source/Python/GenFds/FdfParser.py
+++ b/BaseTools/Source/Python/GenFds/FdfParser.py
@@ -52,6 +52,12 @@ from Common.String import NormPath
import Common.GlobalData as GlobalData
from Common.Expression import *
from Common import GlobalData
+from Common.DataType import TAB_COMMON_DEFINES,SUP_MODULE_BASE, SUP_MODULE_SEC,\
+SUP_MODULE_PEI_CORE, SUP_MODULE_PEIM, SUP_MODULE_DXE_CORE,\
+SUP_MODULE_DXE_DRIVER,SUP_MODULE_DXE_RUNTIME_DRIVER, SUP_MODULE_DXE_SAL_DRIVER,\
+SUP_MODULE_DXE_SMM_DRIVER, SUP_MODULE_UEFI_DRIVER,SUP_MODULE_UEFI_APPLICATION,\
+SUP_MODULE_USER_DEFINED, SUP_MODULE_SMM_CORE, SUP_MODULE_MM_STANDALONE,\
+SUP_MODULE_MM_CORE_STANDALONE,TAB_DEFAULT,TAB_COMMON,ARCH_LIST_FULL
from Common.String import ReplaceMacro
import uuid
from Common.Misc import tdict
@@ -509,8 +515,8 @@ class FdfParser:
if Item == '' or Item == 'RULE':
return
- if Item == 'DEFINES':
- self.__CurSection = ['COMMON', 'COMMON', 'COMMON']
+ if Item == TAB_COMMON_DEFINES.upper():
+ self.__CurSection = [TAB_COMMON, TAB_COMMON, TAB_COMMON]
elif Item == 'VTF' and len(ItemList) == 3:
UiName = ItemList[2]
Pos = UiName.find(',')
@@ -518,9 +524,9 @@ class FdfParser:
UiName = UiName[:Pos]
self.__CurSection = ['VTF', UiName, ItemList[1]]
elif len(ItemList) > 1:
- self.__CurSection = [ItemList[0], ItemList[1], 'COMMON']
+ self.__CurSection = [ItemList[0], ItemList[1], TAB_COMMON]
elif len(ItemList) > 0:
- self.__CurSection = [ItemList[0], 'DUMMY', 'COMMON']
+ self.__CurSection = [ItemList[0], 'DUMMY', TAB_COMMON]
## PreprocessFile() method
#
@@ -884,7 +890,7 @@ class FdfParser:
if self.__CurSection:
# Defines macro
- ScopeMacro = self.__MacroDict['COMMON', 'COMMON', 'COMMON']
+ ScopeMacro = self.__MacroDict[TAB_COMMON, TAB_COMMON, TAB_COMMON]
if ScopeMacro:
MacroDict.update(ScopeMacro)
@@ -3586,7 +3592,7 @@ class FdfParser:
raise Warning("expected '.'", self.FileName, self.CurrentLineNumber)
Arch = self.__SkippedChars.rstrip(".")
- if Arch.upper() not in ("IA32", "X64", "IPF", "EBC", "ARM", "AARCH64", "COMMON"):
+ if Arch.upper() not in ARCH_LIST_FULL:
raise Warning("Unknown Arch '%s'" % Arch, self.FileName, self.CurrentLineNumber)
ModuleType = self.__GetModuleType()
@@ -3632,12 +3638,13 @@ class FdfParser:
if not self.__GetNextWord():
raise Warning("expected Module type", self.FileName, self.CurrentLineNumber)
- if self.__Token.upper() not in ("SEC", "PEI_CORE", "PEIM", "DXE_CORE", \
- "DXE_DRIVER", "DXE_SAL_DRIVER", \
- "DXE_SMM_DRIVER", "DXE_RUNTIME_DRIVER", \
- "UEFI_DRIVER", "UEFI_APPLICATION", "USER_DEFINED", "DEFAULT", "BASE", \
+ if self.__Token.upper() not in (SUP_MODULE_SEC, SUP_MODULE_PEI_CORE, SUP_MODULE_PEIM, SUP_MODULE_DXE_CORE, \
+ SUP_MODULE_DXE_DRIVER, SUP_MODULE_DXE_SAL_DRIVER, \
+ SUP_MODULE_DXE_SMM_DRIVER, SUP_MODULE_DXE_RUNTIME_DRIVER, \
+ SUP_MODULE_UEFI_DRIVER, SUP_MODULE_UEFI_APPLICATION, SUP_MODULE_USER_DEFINED, TAB_DEFAULT, SUP_MODULE_BASE, \
"SECURITY_CORE", "COMBINED_PEIM_DRIVER", "PIC_PEIM", "RELOCATABLE_PEIM", \
- "PE32_PEIM", "BS_DRIVER", "RT_DRIVER", "SAL_RT_DRIVER", "APPLICATION", "ACPITABLE", "SMM_CORE", "MM_STANDALONE", "MM_CORE_STANDALONE"):
+ "PE32_PEIM", "BS_DRIVER", "RT_DRIVER", "SAL_RT_DRIVER", "APPLICATION", "ACPITABLE", \
+ SUP_MODULE_SMM_CORE, SUP_MODULE_MM_STANDALONE, SUP_MODULE_MM_CORE_STANDALONE):
raise Warning("Unknown Module type '%s'" % self.__Token, self.FileName, self.CurrentLineNumber)
return self.__Token
diff --git a/BaseTools/Source/Python/GenFds/FfsInfStatement.py b/BaseTools/Source/Python/GenFds/FfsInfStatement.py
index 0dbffffc9a15..0994b7f8aa6c 100644
--- a/BaseTools/Source/Python/GenFds/FfsInfStatement.py
+++ b/BaseTools/Source/Python/GenFds/FfsInfStatement.py
@@ -47,6 +47,7 @@ import Common.GlobalData as GlobalData
from DepexSection import DepexSection
from Common.Misc import SaveFileOnChange
from Common.Expression import *
+from Common.DataType import TAB_COMMON
## generate FFS from INF
#
@@ -205,7 +206,7 @@ class FfsInfStatement(FfsInfStatementClassObject):
self.ShadowFromInfFile = Inf.Shadow
else:
- Inf = GenFdsGlobalVariable.WorkSpace.BuildObject[PathClassObj, 'COMMON', GenFdsGlobalVariable.TargetName, GenFdsGlobalVariable.ToolChainTag]
+ Inf = GenFdsGlobalVariable.WorkSpace.BuildObject[PathClassObj, TAB_COMMON, GenFdsGlobalVariable.TargetName, GenFdsGlobalVariable.ToolChainTag]
self.BaseName = Inf.BaseName
self.ModuleGuid = Inf.Guid
self.ModuleType = Inf.ModuleType
@@ -568,7 +569,7 @@ class FfsInfStatement(FfsInfStatementClassObject):
RuleName = 'RULE' + \
'.' + \
- 'COMMON' + \
+ TAB_COMMON + \
'.' + \
self.ModuleType.upper()
diff --git a/BaseTools/Source/Python/GenFds/GenFds.py b/BaseTools/Source/Python/GenFds/GenFds.py
index 49e26424bbfc..de6905de8e1f 100644
--- a/BaseTools/Source/Python/GenFds/GenFds.py
+++ b/BaseTools/Source/Python/GenFds/GenFds.py
@@ -43,6 +43,7 @@ from Common.MultipleWorkspace import MultipleWorkspace as mws
import FfsFileStatement
import glob
from struct import unpack
+from Common.DataType import TAB_COMMON
## Version and Copyright
versionNumber = "1.0" + ' ' + gBUILD_VERSION
@@ -239,11 +240,11 @@ def main():
ArchList = Options.archList.split(',')
else:
# EdkLogger.error("GenFds", OPTION_MISSING, "Missing build ARCH")
- ArchList = BuildWorkSpace.BuildObject[GenFdsGlobalVariable.ActivePlatform, 'COMMON', Options.BuildTarget, Options.ToolChain].SupArchList
+ ArchList = BuildWorkSpace.BuildObject[GenFdsGlobalVariable.ActivePlatform, TAB_COMMON, Options.BuildTarget, Options.ToolChain].SupArchList
- TargetArchList = set(BuildWorkSpace.BuildObject[GenFdsGlobalVariable.ActivePlatform, 'COMMON', Options.BuildTarget, Options.ToolChain].SupArchList) & set(ArchList)
+ TargetArchList = set(BuildWorkSpace.BuildObject[GenFdsGlobalVariable.ActivePlatform, TAB_COMMON, Options.BuildTarget, Options.ToolChain].SupArchList) & set(ArchList)
if len(TargetArchList) == 0:
- EdkLogger.error("GenFds", GENFDS_ERROR, "Target ARCH %s not in platform supported ARCH %s" % (str(ArchList), str(BuildWorkSpace.BuildObject[GenFdsGlobalVariable.ActivePlatform, 'COMMON'].SupArchList)))
+ EdkLogger.error("GenFds", GENFDS_ERROR, "Target ARCH %s not in platform supported ARCH %s" % (str(ArchList), str(BuildWorkSpace.BuildObject[GenFdsGlobalVariable.ActivePlatform, TAB_COMMON].SupArchList)))
for Arch in ArchList:
GenFdsGlobalVariable.OutputDirFromDscDict[Arch] = NormPath(BuildWorkSpace.BuildObject[GenFdsGlobalVariable.ActivePlatform, Arch, Options.BuildTarget, Options.ToolChain].OutputDirectory)
@@ -675,7 +676,7 @@ class GenFds :
# @retval None
#
def PreprocessImage(BuildDb, DscFile):
- PcdDict = BuildDb.BuildObject[DscFile, 'COMMON', GenFdsGlobalVariable.TargetName, GenFdsGlobalVariable.ToolChainTag].Pcds
+ PcdDict = BuildDb.BuildObject[DscFile, TAB_COMMON, GenFdsGlobalVariable.TargetName, GenFdsGlobalVariable.ToolChainTag].Pcds
PcdValue = ''
for Key in PcdDict:
PcdObj = PcdDict[Key]
@@ -694,9 +695,9 @@ class GenFds :
if Int64PcdValue > 0:
TopAddress = Int64PcdValue
- ModuleDict = BuildDb.BuildObject[DscFile, 'COMMON', GenFdsGlobalVariable.TargetName, GenFdsGlobalVariable.ToolChainTag].Modules
+ ModuleDict = BuildDb.BuildObject[DscFile, TAB_COMMON, GenFdsGlobalVariable.TargetName, GenFdsGlobalVariable.ToolChainTag].Modules
for Key in ModuleDict:
- ModuleObj = BuildDb.BuildObject[Key, 'COMMON', GenFdsGlobalVariable.TargetName, GenFdsGlobalVariable.ToolChainTag]
+ ModuleObj = BuildDb.BuildObject[Key, TAB_COMMON, GenFdsGlobalVariable.TargetName, GenFdsGlobalVariable.ToolChainTag]
print ModuleObj.BaseName + ' ' + ModuleObj.ModuleType
def GenerateGuidXRefFile(BuildDb, ArchList, FdfParserObj):
diff --git a/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py b/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py
index fcb191981c95..68a0a09c7bbc 100644
--- a/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py
+++ b/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py
@@ -32,6 +32,7 @@ import Common.DataType as DataType
from Common.Misc import PathClass
from Common.LongFilePathSupport import OpenLongFilePath as open
from Common.MultipleWorkspace import MultipleWorkspace as mws
+from Common.DataType import TAB_COMMON
## Global variables
#
@@ -130,7 +131,7 @@ class GenFdsGlobalVariable:
@staticmethod
def GetBuildRules(Inf, Arch):
if not Arch:
- Arch = 'COMMON'
+ Arch = TAB_COMMON
if not Arch in GenFdsGlobalVariable.OutputDirDict:
return {}
@@ -217,7 +218,7 @@ class GenFdsGlobalVariable:
FileList.append((File, DataType.TAB_UNKNOWN_FILE))
for File in Inf.Binaries:
- if File.Target in ['COMMON', '*', GenFdsGlobalVariable.TargetName]:
+ if File.Target in [TAB_COMMON, '*', GenFdsGlobalVariable.TargetName]:
FileList.append((File, File.Type))
for File, FileType in FileList:
@@ -757,7 +758,7 @@ class GenFdsGlobalVariable:
# @param Str String that may contain macro
# @param MacroDict Dictionary that contains macro value pair
#
- def MacroExtend (Str, MacroDict={}, Arch='COMMON'):
+ def MacroExtend (Str, MacroDict={}, Arch=TAB_COMMON):
if Str is None :
return None
@@ -769,7 +770,7 @@ class GenFdsGlobalVariable:
'$(SPACE)' : ' '
}
OutputDir = GenFdsGlobalVariable.OutputDirFromDscDict[GenFdsGlobalVariable.ArchList[0]]
- if Arch != 'COMMON' and Arch in GenFdsGlobalVariable.ArchList:
+ if Arch != TAB_COMMON and Arch in GenFdsGlobalVariable.ArchList:
OutputDir = GenFdsGlobalVariable.OutputDirFromDscDict[Arch]
Dict['$(OUTPUT_DIRECTORY)'] = OutputDir
diff --git a/BaseTools/Source/Python/GenFds/Section.py b/BaseTools/Source/Python/GenFds/Section.py
index 5e0b4bee7d1c..a2b85f651cd5 100644
--- a/BaseTools/Source/Python/GenFds/Section.py
+++ b/BaseTools/Source/Python/GenFds/Section.py
@@ -20,6 +20,7 @@ from GenFdsGlobalVariable import GenFdsGlobalVariable
import Common.LongFilePathOs as os, glob
from Common import EdkLogger
from Common.BuildToolError import *
+from Common.DataType import TAB_COMMON
## section base class
#
@@ -128,7 +129,7 @@ class Section (SectionClassObject):
FileList = []
if FileType is not None:
for File in FfsInf.BinFileList:
- if File.Arch == "COMMON" or FfsInf.CurrentArch == File.Arch:
+ if File.Arch == TAB_COMMON or FfsInf.CurrentArch == File.Arch:
if File.Type == FileType or (int(FfsInf.PiSpecVersion, 16) >= 0x0001000A \
and FileType == 'DXE_DPEX'and File.Type == 'SMM_DEPEX') \
or (FileType == 'TE'and File.Type == 'PE32'):
diff --git a/BaseTools/Source/Python/Workspace/DecBuildData.py b/BaseTools/Source/Python/Workspace/DecBuildData.py
index 49ef1df4aa76..db3ac83ae057 100644
--- a/BaseTools/Source/Python/Workspace/DecBuildData.py
+++ b/BaseTools/Source/Python/Workspace/DecBuildData.py
@@ -16,6 +16,7 @@ from Common.DataType import *
from Common.Misc import *
from types import *
from collections import OrderedDict
+from Common.DataType import TAB_ARCH_COMMON,TAB_COMMON
from Workspace.BuildClassObject import PackageBuildClassObject, StructurePcd, PcdClassObject
@@ -63,7 +64,7 @@ class DecBuildData(PackageBuildClassObject):
# @param Platform (not used for DecBuildData)
# @param Macros Macros used for replacement in DSC file
#
- def __init__(self, File, RawData, BuildDataBase, Arch='COMMON', Target=None, Toolchain=None):
+ def __init__(self, File, RawData, BuildDataBase, Arch=TAB_ARCH_COMMON, Target=None, Toolchain=None):
self.MetaFile = File
self._PackageDir = File.Dir
self._RawData = RawData
@@ -327,7 +328,7 @@ class DecBuildData(PackageBuildClassObject):
PublicInclues.append(File)
if File in self._PrivateIncludes:
EdkLogger.error('build', OPTION_CONFLICT, "Can't determine %s's attribute, it is both defined as Private and non-Private attribute in DEC file." % File, File=self.MetaFile, Line=LineNo)
- if Record[3] == "COMMON":
+ if Record[3] == TAB_COMMON:
self._CommonIncludes.append(File)
return self._Includes
diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py b/BaseTools/Source/Python/Workspace/DscBuildData.py
index 35ef15262a09..8d460891fbe0 100644
--- a/BaseTools/Source/Python/Workspace/DscBuildData.py
+++ b/BaseTools/Source/Python/Workspace/DscBuildData.py
@@ -36,6 +36,8 @@ import re
from Common.Parsing import IsValidWord
from Common.VariableAttributes import VariableAttributes
import Common.GlobalData as GlobalData
+from Common.DataType import TAB_DEFAULT
+from Common.DataType import TAB_ARCH_COMMON,TAB_COMMON
import subprocess
from Common.Misc import SaveFileOnChange
from Workspace.BuildClassObject import PlatformBuildClassObject, StructurePcd, PcdClassObject, ModuleBuildClassObject
@@ -208,7 +210,7 @@ class DscBuildData(PlatformBuildClassObject):
# @param Platform (not used for DscBuildData)
# @param Macros Macros used for replacement in DSC file
#
- def __init__(self, FilePath, RawData, BuildDataBase, Arch='COMMON', Target=None, Toolchain=None):
+ def __init__(self, FilePath, RawData, BuildDataBase, Arch=TAB_ARCH_COMMON, Target=None, Toolchain=None):
self.MetaFile = FilePath
self._RawData = RawData
self._Bdb = BuildDataBase
@@ -509,7 +511,7 @@ class DscBuildData(PlatformBuildClassObject):
if self._Header is None:
self._GetHeaderInfo()
if self._SkuName is None:
- self._SkuName = 'DEFAULT'
+ self._SkuName = TAB_DEFAULT
return self._SkuName
## Override SKUID_IDENTIFIER
@@ -653,10 +655,10 @@ class DscBuildData(PlatformBuildClassObject):
EdkLogger.error('build', FORMAT_INVALID, "The format of the Sku ID name is invalid. The correct format is '(a-zA-Z0-9_)(a-zA-Z0-9_-.)*'",
File=self.MetaFile, Line=Record[-1])
self._SkuIds[Record[1].upper()] = (str(self.ToInt(Record[0])), Record[1].upper(), Record[2].upper())
- if 'DEFAULT' not in self._SkuIds:
- self._SkuIds['DEFAULT'] = ("0","DEFAULT","DEFAULT")
- if 'COMMON' not in self._SkuIds:
- self._SkuIds['COMMON'] = ("0","DEFAULT","DEFAULT")
+ if TAB_DEFAULT not in self._SkuIds:
+ self._SkuIds[TAB_DEFAULT] = ("0",TAB_DEFAULT,TAB_DEFAULT)
+ if TAB_COMMON not in self._SkuIds:
+ self._SkuIds[TAB_COMMON] = ("0",TAB_DEFAULT,TAB_DEFAULT)
return self._SkuIds
def ToInt(self,intstr):
return int(intstr,16) if intstr.upper().startswith("0X") else int(intstr)
@@ -708,7 +710,7 @@ class DscBuildData(PlatformBuildClassObject):
ExtraData=ErrorInfo)
# Check duplication
# If arch is COMMON, no duplicate module is checked since all modules in all component sections are selected
- if self._Arch != 'COMMON' and ModuleFile in self._Modules:
+ if self._Arch != TAB_ARCH_COMMON and ModuleFile in self._Modules:
DuplicatedFile = True
Module = ModuleBuildClassObject()
@@ -817,7 +819,7 @@ class DscBuildData(PlatformBuildClassObject):
EdkLogger.error('build', ErrorCode, File=self.MetaFile, Line=LineNo,
ExtraData=ErrorInfo)
- if ModuleType != 'COMMON' and ModuleType not in SUP_MODULE_LIST:
+ if ModuleType != TAB_COMMON and ModuleType not in SUP_MODULE_LIST:
EdkLogger.error('build', OPTION_UNKNOWN, "Unknown module type [%s]" % ModuleType,
File=self.MetaFile, ExtraData=LibraryInstance, Line=LineNo)
LibraryClassDict[Arch, ModuleType, LibraryClass] = LibraryInstance
@@ -929,9 +931,9 @@ class DscBuildData(PlatformBuildClassObject):
if sku_usage == SkuClass.SINGLE:
for pcdname in Pcds:
pcd = Pcds[pcdname]
- Pcds[pcdname].SkuInfoList = {"DEFAULT":pcd.SkuInfoList[skuid] for skuid in pcd.SkuInfoList if skuid in available_sku}
+ Pcds[pcdname].SkuInfoList = {TAB_DEFAULT:pcd.SkuInfoList[skuid] for skuid in pcd.SkuInfoList if skuid in available_sku}
if type(pcd) is StructurePcd and pcd.SkuOverrideValues:
- Pcds[pcdname].SkuOverrideValues = {"DEFAULT":pcd.SkuOverrideValues[skuid] for skuid in pcd.SkuOverrideValues if skuid in available_sku}
+ Pcds[pcdname].SkuOverrideValues = {TAB_DEFAULT:pcd.SkuOverrideValues[skuid] for skuid in pcd.SkuOverrideValues if skuid in available_sku}
else:
for pcdname in Pcds:
pcd = Pcds[pcdname]
@@ -957,9 +959,9 @@ class DscBuildData(PlatformBuildClassObject):
self._PCD_TYPE_STRING_[MODEL_PCD_PATCHABLE_IN_MODULE]]:
pcd.PcdValueFromComm = pcd.DefaultValue
elif pcd.Type in [self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_HII], self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_EX_HII]]:
- pcd.PcdValueFromComm = pcd.SkuInfoList.get("DEFAULT").HiiDefaultValue
+ pcd.PcdValueFromComm = pcd.SkuInfoList.get(TAB_DEFAULT).HiiDefaultValue
else:
- pcd.PcdValueFromComm = pcd.SkuInfoList.get("DEFAULT").DefaultValue
+ pcd.PcdValueFromComm = pcd.SkuInfoList.get(TAB_DEFAULT).DefaultValue
for pcd in self._Pcds:
if isinstance(self._Pcds[pcd],StructurePcd) and (self._Pcds[pcd].PcdValueFromComm or self._Pcds[pcd].PcdFieldValueFromComm):
UpdateCommandLineValue(self._Pcds[pcd])
@@ -1162,7 +1164,7 @@ class DscBuildData(PlatformBuildClassObject):
for CodeBase in (EDKII_NAME, EDK_NAME):
RecordList = self._RawData[MODEL_META_DATA_BUILD_OPTION, self._Arch, CodeBase]
for ToolChainFamily, ToolChain, Option, Dummy1, Dummy2, Dummy3, Dummy4,Dummy5 in RecordList:
- if Dummy3.upper() != 'COMMON':
+ if Dummy3.upper() != TAB_COMMON:
continue
CurKey = (ToolChainFamily, ToolChain, CodeBase)
#
@@ -1182,7 +1184,7 @@ class DscBuildData(PlatformBuildClassObject):
options = sdict()
self._ModuleTypeOptions[Edk, ModuleType] = options
DriverType = '%s.%s' % (Edk, ModuleType)
- CommonDriverType = '%s.%s' % ('COMMON', ModuleType)
+ CommonDriverType = '%s.%s' % (TAB_COMMON, ModuleType)
RecordList = self._RawData[MODEL_META_DATA_BUILD_OPTION, self._Arch]
for ToolChainFamily, ToolChain, Option, Dummy1, Dummy2, Dummy3, Dummy4,Dummy5 in RecordList:
Type = Dummy2 + '.' + Dummy3
@@ -1282,7 +1284,7 @@ class DscBuildData(PlatformBuildClassObject):
Pcds = AllPcds
DefaultStoreMgr = DefaultStore(self.DefaultStores)
SkuIds = self.SkuIdMgr.AvailableSkuIdSet
- SkuIds.update({'DEFAULT':0})
+ SkuIds.update({TAB_DEFAULT:0})
DefaultStores = set([storename for pcdobj in AllPcds.values() for skuobj in pcdobj.SkuInfoList.values() for storename in skuobj.DefaultStoreDict.keys()])
S_PcdSet = []
@@ -1295,7 +1297,7 @@ class DscBuildData(PlatformBuildClassObject):
for TokenSpaceGuid, PcdCName, Setting, Arch, SkuName, default_store, Dummy4,Dummy5 in RecordList:
SkuName = SkuName.upper()
default_store = default_store.upper()
- SkuName = 'DEFAULT' if SkuName == 'COMMON' else SkuName
+ SkuName = TAB_DEFAULT if SkuName == TAB_COMMON else SkuName
if SkuName not in SkuIds:
continue
@@ -1323,7 +1325,7 @@ class DscBuildData(PlatformBuildClassObject):
str_pcd_obj_str.DefaultFromDSC = {skuname:{defaultstore: str_pcd_obj.SkuInfoList[skuname].DefaultStoreDict.get(defaultstore, str_pcd_obj.SkuInfoList[skuname].DefaultValue) for defaultstore in DefaultStores} for skuname in str_pcd_obj.SkuInfoList}
for str_pcd_data in StrPcdSet[str_pcd]:
if str_pcd_data[3] in SkuIds:
- str_pcd_obj_str.AddOverrideValue(str_pcd_data[2], str(str_pcd_data[6]), 'DEFAULT' if str_pcd_data[3] == 'COMMON' else str_pcd_data[3],'STANDARD' if str_pcd_data[4] == 'COMMON' else str_pcd_data[4], self.MetaFile.File if self.WorkspaceDir not in self.MetaFile.File else self.MetaFile.File[len(self.WorkspaceDir) if self.WorkspaceDir.endswith(os.path.sep) else len(self.WorkspaceDir)+1:],LineNo=str_pcd_data[5])
+ str_pcd_obj_str.AddOverrideValue(str_pcd_data[2], str(str_pcd_data[6]), TAB_DEFAULT if str_pcd_data[3] == TAB_COMMON else str_pcd_data[3],'STANDARD' if str_pcd_data[4] == TAB_COMMON else str_pcd_data[4], self.MetaFile.File if self.WorkspaceDir not in self.MetaFile.File else self.MetaFile.File[len(self.WorkspaceDir) if self.WorkspaceDir.endswith(os.path.sep) else len(self.WorkspaceDir)+1:],LineNo=str_pcd_data[5])
S_pcd_set[str_pcd[1], str_pcd[0]] = str_pcd_obj_str
else:
EdkLogger.error('build', PARSER_ERROR,
@@ -1353,7 +1355,7 @@ class DscBuildData(PlatformBuildClassObject):
NoDefault = False
if skuid not in stru_pcd.SkuOverrideValues:
while nextskuid not in stru_pcd.SkuOverrideValues:
- if nextskuid == "DEFAULT":
+ if nextskuid == TAB_DEFAULT:
NoDefault = True
break
nextskuid = self.SkuIdMgr.GetNextSkuId(nextskuid)
@@ -1366,7 +1368,7 @@ class DscBuildData(PlatformBuildClassObject):
NoDefault = False
if skuid not in stru_pcd.SkuOverrideValues:
while nextskuid not in stru_pcd.SkuOverrideValues:
- if nextskuid == "DEFAULT":
+ if nextskuid == TAB_DEFAULT:
NoDefault = True
break
nextskuid = self.SkuIdMgr.GetNextSkuId(nextskuid)
@@ -1396,14 +1398,14 @@ class DscBuildData(PlatformBuildClassObject):
str_pcd_obj.SkuInfoList[skuname].DefaultStoreDict.update({StoreName:PcdValue})
elif str_pcd_obj.Type in [self._PCD_TYPE_STRING_[MODEL_PCD_FIXED_AT_BUILD],
self._PCD_TYPE_STRING_[MODEL_PCD_PATCHABLE_IN_MODULE]]:
- if skuname in (self.SkuIdMgr.SystemSkuId, 'DEFAULT', 'COMMON'):
+ if skuname in (self.SkuIdMgr.SystemSkuId, TAB_DEFAULT, TAB_COMMON):
str_pcd_obj.DefaultValue = PcdValue
else:
if skuname not in str_pcd_obj.SkuInfoList:
nextskuid = self.SkuIdMgr.GetNextSkuId(skuname)
NoDefault = False
while nextskuid not in str_pcd_obj.SkuInfoList:
- if nextskuid == "DEFAULT":
+ if nextskuid == TAB_DEFAULT:
NoDefault = True
break
nextskuid = self.SkuIdMgr.GetNextSkuId(nextskuid)
@@ -1428,11 +1430,11 @@ class DscBuildData(PlatformBuildClassObject):
for pcdkey in Pcds:
pcd = Pcds[pcdkey]
- if 'DEFAULT' not in pcd.SkuInfoList and 'COMMON' in pcd.SkuInfoList:
- pcd.SkuInfoList['DEFAULT'] = pcd.SkuInfoList['COMMON']
- del pcd.SkuInfoList['COMMON']
- elif 'DEFAULT' in pcd.SkuInfoList and 'COMMON' in pcd.SkuInfoList:
- del pcd.SkuInfoList['COMMON']
+ if TAB_DEFAULT not in pcd.SkuInfoList and TAB_COMMON in pcd.SkuInfoList:
+ pcd.SkuInfoList[TAB_DEFAULT] = pcd.SkuInfoList[TAB_COMMON]
+ del pcd.SkuInfoList[TAB_COMMON]
+ elif TAB_DEFAULT in pcd.SkuInfoList and TAB_COMMON in pcd.SkuInfoList:
+ del pcd.SkuInfoList[TAB_COMMON]
map(self.FilterSkuSettings,[Pcds[pcdkey] for pcdkey in Pcds if Pcds[pcdkey].Type in DynamicPcdType])
return Pcds
@@ -1458,11 +1460,11 @@ class DscBuildData(PlatformBuildClassObject):
PcdValueDict = sdict()
for TokenSpaceGuid, PcdCName, Setting, Arch, SkuName, Dummy3, Dummy4,Dummy5 in RecordList:
SkuName = SkuName.upper()
- SkuName = 'DEFAULT' if SkuName == 'COMMON' else SkuName
+ SkuName = TAB_DEFAULT if SkuName == TAB_COMMON else SkuName
if SkuName not in AvailableSkuIdSet:
EdkLogger.error('build ', PARAMETER_INVALID, 'Sku %s is not defined in [SkuIds] section' % SkuName,
File=self.MetaFile, Line=Dummy5)
- if SkuName in (self.SkuIdMgr.SystemSkuId, 'DEFAULT', 'COMMON'):
+ if SkuName in (self.SkuIdMgr.SystemSkuId, TAB_DEFAULT, TAB_COMMON):
if "." not in TokenSpaceGuid:
PcdSet.add((PcdCName, TokenSpaceGuid, SkuName, Dummy5))
PcdDict[Arch, PcdCName, TokenSpaceGuid, SkuName] = Setting
@@ -1481,10 +1483,10 @@ class DscBuildData(PlatformBuildClassObject):
PcdValue = None
DatumType = None
MaxDatumSize = None
- if 'COMMON' in PcdSetting:
- PcdValue, DatumType, MaxDatumSize = PcdSetting['COMMON']
- if 'DEFAULT' in PcdSetting:
- PcdValue, DatumType, MaxDatumSize = PcdSetting['DEFAULT']
+ if TAB_COMMON in PcdSetting:
+ PcdValue, DatumType, MaxDatumSize = PcdSetting[TAB_COMMON]
+ if TAB_DEFAULT in PcdSetting:
+ PcdValue, DatumType, MaxDatumSize = PcdSetting[TAB_DEFAULT]
if self.SkuIdMgr.SystemSkuId in PcdSetting:
PcdValue, DatumType, MaxDatumSize = PcdSetting[self.SkuIdMgr.SystemSkuId]
@@ -1615,7 +1617,7 @@ class DscBuildData(PlatformBuildClassObject):
FieldName = FieldName.rsplit('[', 1)[0]
CApp = CApp + ' __FLEXIBLE_SIZE(*Size, %s, %s, %d); // From %s Line %d Value %s\n' % (Pcd.DatumType, FieldName.strip("."), ArrayIndex + 1, FieldList[FieldName_ori][1], FieldList[FieldName_ori][2], FieldList[FieldName_ori][0])
for skuname in Pcd.SkuOverrideValues:
- if skuname == "COMMON":
+ if skuname == TAB_COMMON:
continue
for defaultstorenameitem in Pcd.SkuOverrideValues[skuname]:
CApp = CApp + "// SkuName: %s, DefaultStoreName: %s \n" % (skuname, defaultstorenameitem)
@@ -1739,10 +1741,10 @@ class DscBuildData(PlatformBuildClassObject):
CApp = CApp + ' UINT32 FieldSize;\n'
CApp = CApp + ' CHAR8 *Value;\n'
- CApp = CApp + "// SkuName: %s, DefaultStoreName: %s \n" % ('DEFAULT', 'STANDARD')
+ CApp = CApp + "// SkuName: %s, DefaultStoreName: %s \n" % (TAB_DEFAULT, 'STANDARD')
inherit_OverrideValues = Pcd.SkuOverrideValues[SkuName]
- if (SkuName,DefaultStoreName) == ('DEFAULT','STANDARD'):
- pcddefaultvalue = Pcd.DefaultFromDSC.get('DEFAULT',{}).get('STANDARD', Pcd.DefaultValue) if Pcd.DefaultFromDSC else Pcd.DefaultValue
+ if (SkuName,DefaultStoreName) == (TAB_DEFAULT,'STANDARD'):
+ pcddefaultvalue = Pcd.DefaultFromDSC.get(TAB_DEFAULT,{}).get('STANDARD', Pcd.DefaultValue) if Pcd.DefaultFromDSC else Pcd.DefaultValue
else:
if not Pcd.DscRawValue:
# handle the case that structure pcd is not appear in DSC
@@ -1761,14 +1763,14 @@ class DscBuildData(PlatformBuildClassObject):
(Pcd.TokenSpaceGuidCName, Pcd.TokenCName, FieldList))
Value, ValueSize = ParseFieldValue (FieldList)
- if (SkuName,DefaultStoreName) == ('DEFAULT','STANDARD'):
+ if (SkuName,DefaultStoreName) == (TAB_DEFAULT,'STANDARD'):
if isinstance(Value, str):
- CApp = CApp + ' Pcd = %s; // From DSC Default Value %s\n' % (Value, Pcd.DefaultFromDSC.get('DEFAULT',{}).get('STANDARD', Pcd.DefaultValue) if Pcd.DefaultFromDSC else Pcd.DefaultValue)
+ CApp = CApp + ' Pcd = %s; // From DSC Default Value %s\n' % (Value, Pcd.DefaultFromDSC.get(TAB_DEFAULT,{}).get('STANDARD', Pcd.DefaultValue) if Pcd.DefaultFromDSC else Pcd.DefaultValue)
elif IsArray:
#
# Use memcpy() to copy value into field
#
- CApp = CApp + ' Value = %s; // From DSC Default Value %s\n' % (self.IntToCString(Value, ValueSize), Pcd.DefaultFromDSC.get('DEFAULT',{}).get('STANDARD', Pcd.DefaultValue) if Pcd.DefaultFromDSC else Pcd.DefaultValue)
+ CApp = CApp + ' Value = %s; // From DSC Default Value %s\n' % (self.IntToCString(Value, ValueSize), Pcd.DefaultFromDSC.get(TAB_DEFAULT,{}).get('STANDARD', Pcd.DefaultValue) if Pcd.DefaultFromDSC else Pcd.DefaultValue)
CApp = CApp + ' memcpy (Pcd, Value, %d);\n' % (ValueSize)
else:
if isinstance(Value, str):
@@ -1780,7 +1782,7 @@ class DscBuildData(PlatformBuildClassObject):
CApp = CApp + ' Value = %s; // From DSC Default Value %s\n' % (self.IntToCString(Value, ValueSize), Pcd.DscRawValue.get(SkuName,{}).get(DefaultStoreName))
CApp = CApp + ' memcpy (Pcd, Value, %d);\n' % (ValueSize)
continue
- if (SkuName,DefaultStoreName) == ('DEFAULT','STANDARD') or (( (SkuName,'') not in Pcd.ValueChain) and ( (SkuName,DefaultStoreName) not in Pcd.ValueChain )):
+ if (SkuName,DefaultStoreName) == (TAB_DEFAULT,'STANDARD') or (( (SkuName,'') not in Pcd.ValueChain) and ( (SkuName,DefaultStoreName) not in Pcd.ValueChain )):
for FieldName in FieldList:
IsArray = IsFieldValueAnArray(FieldList[FieldName][0])
if IsArray:
@@ -2239,7 +2241,7 @@ class DscBuildData(PlatformBuildClassObject):
for TokenSpaceGuid, PcdCName, Setting, Arch, SkuName, Dummy3, Dummy4,Dummy5 in RecordList:
SkuName = SkuName.upper()
- SkuName = 'DEFAULT' if SkuName == 'COMMON' else SkuName
+ SkuName = TAB_DEFAULT if SkuName == TAB_COMMON else SkuName
if SkuName not in AvailableSkuIdSet:
EdkLogger.error('build', PARAMETER_INVALID, 'Sku %s is not defined in [SkuIds] section' % SkuName,
File=self.MetaFile, Line=Dummy5)
@@ -2289,15 +2291,15 @@ class DscBuildData(PlatformBuildClassObject):
for sku in pcd.SkuInfoList.values():
if (sku.DefaultValue == "" or sku.DefaultValue==None):
sku.DefaultValue = pcdDecObject.DefaultValue
- if 'DEFAULT' not in pcd.SkuInfoList and 'COMMON' not in pcd.SkuInfoList:
+ if TAB_DEFAULT not in pcd.SkuInfoList and TAB_COMMON not in pcd.SkuInfoList:
valuefromDec = pcdDecObject.DefaultValue
- SkuInfo = SkuInfoClass('DEFAULT', '0', '', '', '', '', '', valuefromDec)
- pcd.SkuInfoList['DEFAULT'] = SkuInfo
- elif 'DEFAULT' not in pcd.SkuInfoList and 'COMMON' in pcd.SkuInfoList:
- pcd.SkuInfoList['DEFAULT'] = pcd.SkuInfoList['COMMON']
- del pcd.SkuInfoList['COMMON']
- elif 'DEFAULT' in pcd.SkuInfoList and 'COMMON' in pcd.SkuInfoList:
- del pcd.SkuInfoList['COMMON']
+ SkuInfo = SkuInfoClass(TAB_DEFAULT, '0', '', '', '', '', '', valuefromDec)
+ pcd.SkuInfoList[TAB_DEFAULT] = SkuInfo
+ elif TAB_DEFAULT not in pcd.SkuInfoList and TAB_COMMON in pcd.SkuInfoList:
+ pcd.SkuInfoList[TAB_DEFAULT] = pcd.SkuInfoList[TAB_COMMON]
+ del pcd.SkuInfoList[TAB_COMMON]
+ elif TAB_DEFAULT in pcd.SkuInfoList and TAB_COMMON in pcd.SkuInfoList:
+ del pcd.SkuInfoList[TAB_COMMON]
map(self.FilterSkuSettings,Pcds.values())
@@ -2306,14 +2308,14 @@ class DscBuildData(PlatformBuildClassObject):
def FilterSkuSettings(self, PcdObj):
if self.SkuIdMgr.SkuUsageType == self.SkuIdMgr.SINGLE:
- if 'DEFAULT' in PcdObj.SkuInfoList and self.SkuIdMgr.SystemSkuId not in PcdObj.SkuInfoList:
- PcdObj.SkuInfoList[self.SkuIdMgr.SystemSkuId] = PcdObj.SkuInfoList['DEFAULT']
- PcdObj.SkuInfoList = {'DEFAULT':PcdObj.SkuInfoList[self.SkuIdMgr.SystemSkuId]}
- PcdObj.SkuInfoList['DEFAULT'].SkuIdName = 'DEFAULT'
- PcdObj.SkuInfoList['DEFAULT'].SkuId = '0'
+ if TAB_DEFAULT in PcdObj.SkuInfoList and self.SkuIdMgr.SystemSkuId not in PcdObj.SkuInfoList:
+ PcdObj.SkuInfoList[self.SkuIdMgr.SystemSkuId] = PcdObj.SkuInfoList[TAB_DEFAULT]
+ PcdObj.SkuInfoList = {TAB_DEFAULT:PcdObj.SkuInfoList[self.SkuIdMgr.SystemSkuId]}
+ PcdObj.SkuInfoList[TAB_DEFAULT].SkuIdName = TAB_DEFAULT
+ PcdObj.SkuInfoList[TAB_DEFAULT].SkuId = '0'
elif self.SkuIdMgr.SkuUsageType == self.SkuIdMgr.DEFAULT:
- PcdObj.SkuInfoList = {'DEFAULT':PcdObj.SkuInfoList['DEFAULT']}
+ PcdObj.SkuInfoList = {TAB_DEFAULT:PcdObj.SkuInfoList[TAB_DEFAULT]}
return PcdObj
@@ -2346,7 +2348,7 @@ class DscBuildData(PlatformBuildClassObject):
def CompletePcdValues(self,PcdSet):
Pcds = {}
DefaultStoreObj = DefaultStore(self._GetDefaultStores())
- SkuIds = {skuname:skuid for skuname,skuid in self.SkuIdMgr.AvailableSkuIdSet.items() if skuname !='COMMON'}
+ SkuIds = {skuname:skuid for skuname,skuid in self.SkuIdMgr.AvailableSkuIdSet.items() if skuname !=TAB_COMMON}
DefaultStores = set([storename for pcdobj in PcdSet.values() for skuobj in pcdobj.SkuInfoList.values() for storename in skuobj.DefaultStoreDict.keys()])
for PcdCName, TokenSpaceGuid in PcdSet:
PcdObj = PcdSet[(PcdCName, TokenSpaceGuid)]
@@ -2377,7 +2379,7 @@ class DscBuildData(PlatformBuildClassObject):
PcdObj.SkuInfoList[skuname].SkuId = skuid
PcdObj.SkuInfoList[skuname].SkuIdName = skuname
if PcdType in [self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_HII], self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_EX_HII]]:
- PcdObj.DefaultValue = PcdObj.SkuInfoList.values()[0].HiiDefaultValue if self.SkuIdMgr.SkuUsageType == self.SkuIdMgr.SINGLE else PcdObj.SkuInfoList["DEFAULT"].HiiDefaultValue
+ PcdObj.DefaultValue = PcdObj.SkuInfoList.values()[0].HiiDefaultValue if self.SkuIdMgr.SkuUsageType == self.SkuIdMgr.SINGLE else PcdObj.SkuInfoList[TAB_DEFAULT].HiiDefaultValue
Pcds[PcdCName, TokenSpaceGuid]= PcdObj
return Pcds
## Retrieve dynamic HII PCD settings
@@ -2404,9 +2406,9 @@ class DscBuildData(PlatformBuildClassObject):
for TokenSpaceGuid, PcdCName, Setting, Arch, SkuName, DefaultStore, Dummy4,Dummy5 in RecordList:
SkuName = SkuName.upper()
- SkuName = 'DEFAULT' if SkuName == 'COMMON' else SkuName
+ SkuName = TAB_DEFAULT if SkuName == TAB_COMMON else SkuName
DefaultStore = DefaultStore.upper()
- if DefaultStore == "COMMON":
+ if DefaultStore == TAB_COMMON:
DefaultStore = "STANDARD"
if SkuName not in AvailableSkuIdSet:
EdkLogger.error('build', PARAMETER_INVALID, 'Sku %s is not defined in [SkuIds] section' % SkuName,
@@ -2498,15 +2500,15 @@ class DscBuildData(PlatformBuildClassObject):
for default_store in sku.DefaultStoreDict:
sku.DefaultStoreDict[default_store]=pcdDecObject.DefaultValue
pcd.DefaultValue = pcdDecObject.DefaultValue
- if 'DEFAULT' not in pcd.SkuInfoList and 'COMMON' not in pcd.SkuInfoList:
+ if TAB_DEFAULT not in pcd.SkuInfoList and TAB_COMMON not in pcd.SkuInfoList:
valuefromDec = pcdDecObject.DefaultValue
- SkuInfo = SkuInfoClass('DEFAULT', '0', SkuInfoObj.VariableName, SkuInfoObj.VariableGuid, SkuInfoObj.VariableOffset, valuefromDec,VariableAttribute=SkuInfoObj.VariableAttribute,DefaultStore={DefaultStore:valuefromDec})
- pcd.SkuInfoList['DEFAULT'] = SkuInfo
- elif 'DEFAULT' not in pcd.SkuInfoList and 'COMMON' in pcd.SkuInfoList:
- pcd.SkuInfoList['DEFAULT'] = pcd.SkuInfoList['COMMON']
- del pcd.SkuInfoList['COMMON']
- elif 'DEFAULT' in pcd.SkuInfoList and 'COMMON' in pcd.SkuInfoList:
- del pcd.SkuInfoList['COMMON']
+ SkuInfo = SkuInfoClass(TAB_DEFAULT, '0', SkuInfoObj.VariableName, SkuInfoObj.VariableGuid, SkuInfoObj.VariableOffset, valuefromDec,VariableAttribute=SkuInfoObj.VariableAttribute,DefaultStore={DefaultStore:valuefromDec})
+ pcd.SkuInfoList[TAB_DEFAULT] = SkuInfo
+ elif TAB_DEFAULT not in pcd.SkuInfoList and TAB_COMMON in pcd.SkuInfoList:
+ pcd.SkuInfoList[TAB_DEFAULT] = pcd.SkuInfoList[TAB_COMMON]
+ del pcd.SkuInfoList[TAB_COMMON]
+ elif TAB_DEFAULT in pcd.SkuInfoList and TAB_COMMON in pcd.SkuInfoList:
+ del pcd.SkuInfoList[TAB_COMMON]
if pcd.MaxDatumSize.strip():
MaxSize = int(pcd.MaxDatumSize, 0)
@@ -2566,7 +2568,7 @@ class DscBuildData(PlatformBuildClassObject):
for TokenSpaceGuid, PcdCName, Setting, Arch, SkuName, Dummy3, Dummy4,Dummy5 in RecordList:
SkuName = SkuName.upper()
- SkuName = 'DEFAULT' if SkuName == 'COMMON' else SkuName
+ SkuName = TAB_DEFAULT if SkuName == TAB_COMMON else SkuName
if SkuName not in AvailableSkuIdSet:
EdkLogger.error('build', PARAMETER_INVALID, 'Sku %s is not defined in [SkuIds] section' % SkuName,
File=self.MetaFile, Line=Dummy5)
@@ -2621,15 +2623,15 @@ class DscBuildData(PlatformBuildClassObject):
for sku in pcd.SkuInfoList.values():
if (sku.DefaultValue == "" or sku.DefaultValue==None):
sku.DefaultValue = pcdDecObject.DefaultValue
- if 'DEFAULT' not in pcd.SkuInfoList and 'COMMON' not in pcd.SkuInfoList:
+ if TAB_DEFAULT not in pcd.SkuInfoList and TAB_COMMON not in pcd.SkuInfoList:
valuefromDec = pcdDecObject.DefaultValue
- SkuInfo = SkuInfoClass('DEFAULT', '0', '', '', '', '', SkuInfoObj.VpdOffset, valuefromDec)
- pcd.SkuInfoList['DEFAULT'] = SkuInfo
- elif 'DEFAULT' not in pcd.SkuInfoList and 'COMMON' in pcd.SkuInfoList:
- pcd.SkuInfoList['DEFAULT'] = pcd.SkuInfoList['COMMON']
- del pcd.SkuInfoList['COMMON']
- elif 'DEFAULT' in pcd.SkuInfoList and 'COMMON' in pcd.SkuInfoList:
- del pcd.SkuInfoList['COMMON']
+ SkuInfo = SkuInfoClass(TAB_DEFAULT, '0', '', '', '', '', SkuInfoObj.VpdOffset, valuefromDec)
+ pcd.SkuInfoList[TAB_DEFAULT] = SkuInfo
+ elif TAB_DEFAULT not in pcd.SkuInfoList and TAB_COMMON in pcd.SkuInfoList:
+ pcd.SkuInfoList[TAB_DEFAULT] = pcd.SkuInfoList[TAB_COMMON]
+ del pcd.SkuInfoList[TAB_COMMON]
+ elif TAB_DEFAULT in pcd.SkuInfoList and TAB_COMMON in pcd.SkuInfoList:
+ del pcd.SkuInfoList[TAB_COMMON]
map(self.FilterSkuSettings,Pcds.values())
diff --git a/BaseTools/Source/Python/Workspace/InfBuildData.py b/BaseTools/Source/Python/Workspace/InfBuildData.py
index ded8f610c9c1..53aa6acf5862 100644
--- a/BaseTools/Source/Python/Workspace/InfBuildData.py
+++ b/BaseTools/Source/Python/Workspace/InfBuildData.py
@@ -17,6 +17,7 @@ from Common.DataType import *
from Common.Misc import *
from types import *
from MetaFileParser import *
+from Common.DataType import TAB_ARCH_COMMON,TAB_ARCH_COMMON
from Workspace.BuildClassObject import ModuleBuildClassObject, LibraryClassObject, PcdClassObject
## Module build information from INF file
@@ -106,7 +107,7 @@ class InfBuildData(ModuleBuildClassObject):
# @param Platform The name of platform employing this module
# @param Macros Macros used for replacement in DSC file
#
- def __init__(self, FilePath, RawData, BuildDatabase, Arch='COMMON', Target=None, Toolchain=None):
+ def __init__(self, FilePath, RawData, BuildDatabase, Arch=TAB_ARCH_COMMON, Target=None, Toolchain=None):
self.MetaFile = FilePath
self._ModuleDir = FilePath.Dir
self._RawData = RawData
@@ -114,7 +115,7 @@ class InfBuildData(ModuleBuildClassObject):
self._Arch = Arch
self._Target = Target
self._Toolchain = Toolchain
- self._Platform = 'COMMON'
+ self._Platform = TAB_COMMON
self._SourceOverridePath = None
if FilePath.Key in GlobalData.gOverrideDir:
self._SourceOverridePath = GlobalData.gOverrideDir[FilePath.Key]
@@ -608,7 +609,7 @@ class InfBuildData(ModuleBuildClassObject):
for Record in RecordList:
FileType = Record[0]
LineNo = Record[-1]
- Target = 'COMMON'
+ Target = TAB_COMMON
FeatureFlag = []
if Record[2]:
TokenList = GetSplitValueList(Record[2], TAB_VALUE_SPLIT)
diff --git a/BaseTools/Source/Python/Workspace/MetaFileParser.py b/BaseTools/Source/Python/Workspace/MetaFileParser.py
index f4c1868483d9..79c10fc9fdc6 100644
--- a/BaseTools/Source/Python/Workspace/MetaFileParser.py
+++ b/BaseTools/Source/Python/Workspace/MetaFileParser.py
@@ -31,7 +31,7 @@ from Common.Misc import GuidStructureStringToGuidString, CheckPcdDatum, PathClas
from Common.Expression import *
from CommonDataClass.Exceptions import *
from Common.LongFilePathSupport import OpenLongFilePath as open
-
+from Common.DataType import TAB_ARCH_COMMON,TAB_ARCH_COMMON
from MetaFileTable import MetaFileStorage
from MetaFileCommentParser import CheckInfComment
@@ -219,7 +219,7 @@ class MetaFileParser(object):
NewRecordList = []
for Record in RecordList:
Arch = Record[3]
- if Arch == 'COMMON' or Arch == FilterArch:
+ if Arch == TAB_ARCH_COMMON or Arch == FilterArch:
NewRecordList.append(Record)
return NewRecordList
@@ -319,7 +319,7 @@ class MetaFileParser(object):
if len(ItemList) > 1:
S1 = ItemList[1].upper()
else:
- S1 = 'COMMON'
+ S1 = TAB_ARCH_COMMON
ArchList.add(S1)
# S2 may be Platform or ModuleType
@@ -329,15 +329,15 @@ class MetaFileParser(object):
else:
S2 = ItemList[2].upper()
else:
- S2 = 'COMMON'
+ S2 = TAB_COMMON
if len(ItemList) > 3:
S3 = ItemList[3]
else:
- S3 = "COMMON"
+ S3 = TAB_COMMON
self._Scope.append([S1, S2, S3])
# 'COMMON' must not be used with specific ARCHs at the same section
- if 'COMMON' in ArchList and len(ArchList) > 1:
+ if TAB_ARCH_COMMON in ArchList and len(ArchList) > 1:
EdkLogger.error('Parser', FORMAT_INVALID, "'common' ARCH must not be used with specific ARCHs",
File=self.MetaFile, Line=self._LineIndex + 1, ExtraData=self._CurrentLine)
# If the section information is needed later, it should be stored in database
@@ -455,12 +455,12 @@ class MetaFileParser(object):
for ActiveScope in self._Scope:
Scope0, Scope1,Scope2 = ActiveScope[0], ActiveScope[1],ActiveScope[2]
- if(Scope0, Scope1,Scope2) not in Scope and (Scope0, "COMMON","COMMON") not in Scope and ("COMMON", Scope1,"COMMON") not in Scope:
+ if(Scope0, Scope1,Scope2) not in Scope and (Scope0, TAB_COMMON,TAB_COMMON) not in Scope and (TAB_COMMON, Scope1,TAB_COMMON) not in Scope:
break
else:
ComSpeMacroDict.update(self._SectionsMacroDict[(SectionType, Scope)])
- if ("COMMON", "COMMON","COMMON") in Scope:
+ if (TAB_COMMON, TAB_COMMON,TAB_COMMON) in Scope:
ComComMacroDict.update(self._SectionsMacroDict[(SectionType, Scope)])
Macros.update(ComComMacroDict)
@@ -568,8 +568,8 @@ class InfParser(MetaFileParser):
if Line[0] == TAB_SECTION_START and Line[-1] == TAB_SECTION_END:
if not GetHeaderComment:
for Cmt, LNo in Comments:
- self._Store(MODEL_META_DATA_HEADER_COMMENT, Cmt, '', '', 'COMMON',
- 'COMMON', self._Owner[-1], LNo, -1, LNo, -1, 0)
+ self._Store(MODEL_META_DATA_HEADER_COMMENT, Cmt, '', '', TAB_COMMON,
+ TAB_COMMON, self._Owner[-1], LNo, -1, LNo, -1, 0)
GetHeaderComment = True
else:
TailComments.extend(SectionComments + Comments)
@@ -658,8 +658,8 @@ class InfParser(MetaFileParser):
# If there are tail comments in INF file, save to database whatever the comments are
for Comment in TailComments:
- self._Store(MODEL_META_DATA_TAIL_COMMENT, Comment[0], '', '', 'COMMON',
- 'COMMON', self._Owner[-1], -1, -1, -1, -1, 0)
+ self._Store(MODEL_META_DATA_TAIL_COMMENT, Comment[0], '', '', TAB_COMMON,
+ TAB_COMMON, self._Owner[-1], -1, -1, -1, -1, 0)
self._Done()
## Data parser for the format in which there's path
@@ -1022,7 +1022,7 @@ class DscParser(MetaFileParser):
ExtraData=self._CurrentLine)
ItemType = self.DataType[DirectiveName]
- Scope = [['COMMON', 'COMMON','COMMON']]
+ Scope = [[TAB_COMMON, TAB_COMMON,TAB_COMMON]]
if ItemType == MODEL_META_DATA_INCLUDE:
Scope = self._Scope
if ItemType == MODEL_META_DATA_CONDITIONAL_STATEMENT_ENDIF:
@@ -1832,7 +1832,7 @@ class DecParser(MetaFileParser):
if len(ItemList) > 1:
S1 = ItemList[1].upper()
else:
- S1 = 'COMMON'
+ S1 = TAB_ARCH_COMMON
ArchList.add(S1)
# S2 may be Platform or ModuleType
if len(ItemList) > 2:
@@ -1843,18 +1843,18 @@ class DecParser(MetaFileParser):
EdkLogger.error("Parser", FORMAT_INVALID, 'Please use keyword "Private" as section tag modifier.',
File=self.MetaFile, Line=self._LineIndex + 1, ExtraData=self._CurrentLine)
else:
- S2 = 'COMMON'
+ S2 = TAB_COMMON
PrivateList.add(S2)
if [S1, S2, self.DataType[self._SectionName]] not in self._Scope:
self._Scope.append([S1, S2, self.DataType[self._SectionName]])
# 'COMMON' must not be used with specific ARCHs at the same section
- if 'COMMON' in ArchList and len(ArchList) > 1:
+ if TAB_ARCH_COMMON in ArchList and len(ArchList) > 1:
EdkLogger.error('Parser', FORMAT_INVALID, "'common' ARCH must not be used with specific ARCHs",
File=self.MetaFile, Line=self._LineIndex + 1, ExtraData=self._CurrentLine)
# It is not permissible to mix section tags without the Private attribute with section tags with the Private attribute
- if 'COMMON' in PrivateList and len(PrivateList) > 1:
+ if TAB_COMMON in PrivateList and len(PrivateList) > 1:
EdkLogger.error('Parser', FORMAT_INVALID, "Can't mix section tags without the Private attribute with section tags with the Private attribute",
File=self.MetaFile, Line=self._LineIndex + 1, ExtraData=self._CurrentLine)
diff --git a/BaseTools/Source/Python/Workspace/MetaFileTable.py b/BaseTools/Source/Python/Workspace/MetaFileTable.py
index be3fb3d68856..33d390253b2a 100644
--- a/BaseTools/Source/Python/Workspace/MetaFileTable.py
+++ b/BaseTools/Source/Python/Workspace/MetaFileTable.py
@@ -1,7 +1,7 @@
## @file
# This file is used to create/update/query/erase a meta file table
#
-# Copyright (c) 2008 - 2016, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2008 - 2018, Intel Corporation. All rights reserved.<BR>
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
@@ -18,7 +18,7 @@ import uuid
import Common.EdkLogger as EdkLogger
from Common.BuildToolError import FORMAT_INVALID
-
+from Common.DataType import TAB_ARCH_COMMON,TAB_ARCH_COMMON
from MetaDataTable import Table, TableFile
from MetaDataTable import ConvertToSqlString
from CommonDataClass.DataClass import MODEL_FILE_DSC, MODEL_FILE_DEC, MODEL_FILE_INF, \
@@ -109,7 +109,7 @@ class ModuleTable(MetaFileTable):
# @param EndColumn: EndColumn of a Inf item
# @param Enabled: If this item enabled
#
- def Insert(self, Model, Value1, Value2, Value3, Scope1='COMMON', Scope2='COMMON',
+ def Insert(self, Model, Value1, Value2, Value3, Scope1=TAB_ARCH_COMMON, Scope2=TAB_COMMON,
BelongsToItem=-1, StartLine=-1, StartColumn=-1, EndLine=-1, EndColumn=-1, Enabled=0):
(Value1, Value2, Value3, Scope1, Scope2) = ConvertToSqlString((Value1, Value2, Value3, Scope1, Scope2))
return Table.Insert(
@@ -140,9 +140,9 @@ class ModuleTable(MetaFileTable):
ConditionString = "Model=%s AND Enabled>=0" % Model
ValueString = "Value1,Value2,Value3,Scope1,Scope2,ID,StartLine"
- if Arch is not None and Arch != 'COMMON':
+ if Arch is not None and Arch != TAB_ARCH_COMMON:
ConditionString += " AND (Scope1='%s' OR Scope1='COMMON')" % Arch
- if Platform is not None and Platform != 'COMMON':
+ if Platform is not None and Platform != TAB_COMMON:
ConditionString += " AND (Scope2='%s' OR Scope2='COMMON' OR Scope2='DEFAULT')" % Platform
if BelongsToItem is not None:
ConditionString += " AND BelongsToItem=%s" % BelongsToItem
@@ -191,7 +191,7 @@ class PackageTable(MetaFileTable):
# @param EndColumn: EndColumn of a Dec item
# @param Enabled: If this item enabled
#
- def Insert(self, Model, Value1, Value2, Value3, Scope1='COMMON', Scope2='COMMON',
+ def Insert(self, Model, Value1, Value2, Value3, Scope1=TAB_ARCH_COMMON, Scope2=TAB_COMMON,
BelongsToItem=-1, StartLine=-1, StartColumn=-1, EndLine=-1, EndColumn=-1, Enabled=0):
(Value1, Value2, Value3, Scope1, Scope2) = ConvertToSqlString((Value1, Value2, Value3, Scope1, Scope2))
return Table.Insert(
@@ -221,7 +221,7 @@ class PackageTable(MetaFileTable):
ConditionString = "Model=%s AND Enabled>=0" % Model
ValueString = "Value1,Value2,Value3,Scope1,Scope2,ID,StartLine"
- if Arch is not None and Arch != 'COMMON':
+ if Arch is not None and Arch != TAB_ARCH_COMMON:
ConditionString += " AND (Scope1='%s' OR Scope1='COMMON')" % Arch
SqlCommand = "SELECT %s FROM %s WHERE %s" % (ValueString, self.Table, ConditionString)
@@ -306,7 +306,7 @@ class PlatformTable(MetaFileTable):
# @param EndColumn: EndColumn of a Dsc item
# @param Enabled: If this item enabled
#
- def Insert(self, Model, Value1, Value2, Value3, Scope1='COMMON', Scope2='COMMON', Scope3=TAB_DEFAULT_STORES_DEFAULT,BelongsToItem=-1,
+ def Insert(self, Model, Value1, Value2, Value3, Scope1=TAB_ARCH_COMMON, Scope2=TAB_COMMON, Scope3=TAB_DEFAULT_STORES_DEFAULT,BelongsToItem=-1,
FromItem=-1, StartLine=-1, StartColumn=-1, EndLine=-1, EndColumn=-1, Enabled=1):
(Value1, Value2, Value3, Scope1, Scope2,Scope3) = ConvertToSqlString((Value1, Value2, Value3, Scope1, Scope2,Scope3))
return Table.Insert(
@@ -341,13 +341,13 @@ class PlatformTable(MetaFileTable):
ConditionString = "Model=%s AND Enabled>0" % Model
ValueString = "Value1,Value2,Value3,Scope1,Scope2,Scope3,ID,StartLine"
- if Scope1 is not None and Scope1 != 'COMMON':
+ if Scope1 is not None and Scope1 != TAB_ARCH_COMMON:
ConditionString += " AND (Scope1='%s' OR Scope1='COMMON')" % Scope1
- if Scope2 is not None and Scope2 != 'COMMON':
+ if Scope2 is not None and Scope2 != TAB_COMMON:
# Cover the case that CodeBase is 'COMMON' for BuildOptions section
if '.' in Scope2:
Index = Scope2.index('.')
- NewScope = 'COMMON'+ Scope2[Index:]
+ NewScope = TAB_COMMON+ Scope2[Index:]
ConditionString += " AND (Scope2='%s' OR Scope2='COMMON' OR Scope2='DEFAULT' OR Scope2='%s')" % (Scope2, NewScope)
else:
ConditionString += " AND (Scope2='%s' OR Scope2='COMMON' OR Scope2='DEFAULT')" % Scope2
diff --git a/BaseTools/Source/Python/Workspace/WorkspaceDatabase.py b/BaseTools/Source/Python/Workspace/WorkspaceDatabase.py
index 2b888c0610c3..6c52817d95b3 100644
--- a/BaseTools/Source/Python/Workspace/WorkspaceDatabase.py
+++ b/BaseTools/Source/Python/Workspace/WorkspaceDatabase.py
@@ -1,7 +1,7 @@
## @file
# 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>
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
@@ -305,7 +305,7 @@ determine whether database file is out of date!\n")
PlatformList = []
for PlatformFile in self.TblFile.GetFileList(MODEL_FILE_DSC):
try:
- Platform = self.BuildObject[PathClass(PlatformFile), 'COMMON']
+ Platform = self.BuildObject[PathClass(PlatformFile), TAB_COMMON]
except:
Platform = None
if Platform is not None:
@@ -313,7 +313,7 @@ determine whether database file is out of date!\n")
return PlatformList
def _MapPlatform(self, Dscfile):
- Platform = self.BuildObject[PathClass(Dscfile), 'COMMON']
+ Platform = self.BuildObject[PathClass(Dscfile), TAB_COMMON]
if Platform is None:
EdkLogger.error('build', PARSER_ERROR, "Failed to parser DSC file: %s" % Dscfile)
return Platform
--
2.16.2.windows.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH v1 1/3] BaseTools: refactor and remove more keys() usage
2018-04-10 14:20 ` [PATCH v1 1/3] BaseTools: refactor and remove more keys() usage Jaben Carsey
@ 2018-04-18 8:48 ` Zhu, Yonghong
0 siblings, 0 replies; 8+ messages in thread
From: Zhu, Yonghong @ 2018-04-18 8:48 UTC (permalink / raw)
To: Carsey, Jaben, edk2-devel@lists.01.org; +Cc: Gao, Liming, Zhu, Yonghong
Hi Jaben,
One bug on this patch. Original code it use PcdCName, now it change to use PcdName , it will cause PcdObject incorrect.
- PcdsKeys = PcdValueDict.keys()
- for PcdCName, TokenSpaceGuid in PcdsKeys:
-
- PcdSetting = PcdValueDict[PcdCName, TokenSpaceGuid]
+ for ((PcdName,TokenSpaceGuid),PcdSetting) in PcdValueDict.iteritems():
Best Regards,
Zhu Yonghong
-----Original Message-----
From: Carsey, Jaben
Sent: Tuesday, April 10, 2018 10:20 PM
To: edk2-devel@lists.01.org
Cc: Gao, Liming <liming.gao@intel.com>; Zhu, Yonghong <yonghong.zhu@intel.com>
Subject: [PATCH v1 1/3] BaseTools: refactor and remove more keys() usage
this is no longer required to make dictionary objects iterable.
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>
---
BaseTools/Source/Python/Workspace/DscBuildData.py | 59 +++++++++-----------
1 file changed, 27 insertions(+), 32 deletions(-)
diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py b/BaseTools/Source/Python/Workspace/DscBuildData.py
index cf9608651269..35ef15262a09 100644
--- a/BaseTools/Source/Python/Workspace/DscBuildData.py
+++ b/BaseTools/Source/Python/Workspace/DscBuildData.py
@@ -593,7 +593,7 @@ class DscBuildData(PlatformBuildClassObject):
#
# If command line defined, should override the value in DSC file.
#
- if 'FIX_LOAD_TOP_MEMORY_ADDRESS' in GlobalData.gCommandLineDefines.keys():
+ if 'FIX_LOAD_TOP_MEMORY_ADDRESS' in GlobalData.gCommandLineDefines:
try:
self._LoadFixAddress = int(GlobalData.gCommandLineDefines['FIX_LOAD_TOP_MEMORY_ADDRESS'], 0)
except:
@@ -682,9 +682,7 @@ class DscBuildData(PlatformBuildClassObject):
self.DefaultStores[Record[1].upper()] = (self.ToInt(Record[0]),Record[1].upper())
if TAB_DEFAULT_STORES_DEFAULT not in self.DefaultStores:
self.DefaultStores[TAB_DEFAULT_STORES_DEFAULT] = (0,TAB_DEFAULT_STORES_DEFAULT)
- GlobalData.gDefaultStores = self.DefaultStores.keys()
- if GlobalData.gDefaultStores:
- GlobalData.gDefaultStores.sort()
+ GlobalData.gDefaultStores =
+ sorted(self.DefaultStores.keys())
return self.DefaultStores
## Retrieve [Components] section information @@ -1430,11 +1428,11 @@ class DscBuildData(PlatformBuildClassObject):
for pcdkey in Pcds:
pcd = Pcds[pcdkey]
- if 'DEFAULT' not in pcd.SkuInfoList.keys() and 'COMMON' in pcd.SkuInfoList.keys():
+ if 'DEFAULT' not in pcd.SkuInfoList and 'COMMON' in pcd.SkuInfoList:
pcd.SkuInfoList['DEFAULT'] = pcd.SkuInfoList['COMMON']
- del(pcd.SkuInfoList['COMMON'])
- elif 'DEFAULT' in pcd.SkuInfoList.keys() and 'COMMON' in pcd.SkuInfoList.keys():
- del(pcd.SkuInfoList['COMMON'])
+ del pcd.SkuInfoList['COMMON']
+ elif 'DEFAULT' in pcd.SkuInfoList and 'COMMON' in pcd.SkuInfoList:
+ del pcd.SkuInfoList['COMMON']
map(self.FilterSkuSettings,[Pcds[pcdkey] for pcdkey in Pcds if Pcds[pcdkey].Type in DynamicPcdType])
return Pcds
@@ -1479,10 +1477,7 @@ class DscBuildData(PlatformBuildClassObject):
else:
PcdValueDict[PcdCName, TokenSpaceGuid] = {SkuName:(PcdValue, DatumType, MaxDatumSize)}
- PcdsKeys = PcdValueDict.keys()
- for PcdCName, TokenSpaceGuid in PcdsKeys:
-
- PcdSetting = PcdValueDict[PcdCName, TokenSpaceGuid]
+ for ((PcdName,TokenSpaceGuid),PcdSetting) in PcdValueDict.iteritems():
PcdValue = None
DatumType = None
MaxDatumSize = None
@@ -1883,7 +1878,7 @@ class DscBuildData(PlatformBuildClassObject):
OverrideValues = {DefaultStore:""}
if Pcd.SkuOverrideValues:
OverrideValues = Pcd.SkuOverrideValues[SkuName]
- for DefaultStoreName in OverrideValues.keys():
+ for DefaultStoreName in OverrideValues:
CApp = CApp + 'void\n'
CApp = CApp + 'Initialize_%s_%s_%s_%s(\n' % (SkuName, DefaultStoreName, Pcd.TokenSpaceGuidCName, Pcd.TokenCName)
CApp = CApp + ' void\n'
@@ -2261,7 +2256,7 @@ class DscBuildData(PlatformBuildClassObject):
PcdValue, DatumType, MaxDatumSize = self._ValidatePcd(PcdCName, TokenSpaceGuid, Setting, Type, Dummy4)
SkuInfo = SkuInfoClass(SkuName, self.SkuIds[SkuName][0], '', '', '', '', '', PcdValue)
- if (PcdCName, TokenSpaceGuid) in Pcds.keys():
+ if (PcdCName, TokenSpaceGuid) in Pcds:
pcdObject = Pcds[PcdCName, TokenSpaceGuid]
pcdObject.SkuInfoList[SkuName] = SkuInfo
if MaxDatumSize.strip():
@@ -2294,15 +2289,15 @@ class DscBuildData(PlatformBuildClassObject):
for sku in pcd.SkuInfoList.values():
if (sku.DefaultValue == "" or sku.DefaultValue==None):
sku.DefaultValue = pcdDecObject.DefaultValue
- if 'DEFAULT' not in pcd.SkuInfoList.keys() and 'COMMON' not in pcd.SkuInfoList.keys():
+ if 'DEFAULT' not in pcd.SkuInfoList and 'COMMON' not in pcd.SkuInfoList:
valuefromDec = pcdDecObject.DefaultValue
SkuInfo = SkuInfoClass('DEFAULT', '0', '', '', '', '', '', valuefromDec)
pcd.SkuInfoList['DEFAULT'] = SkuInfo
- elif 'DEFAULT' not in pcd.SkuInfoList.keys() and 'COMMON' in pcd.SkuInfoList.keys():
+ elif 'DEFAULT' not in pcd.SkuInfoList and 'COMMON' in pcd.SkuInfoList:
pcd.SkuInfoList['DEFAULT'] = pcd.SkuInfoList['COMMON']
- del(pcd.SkuInfoList['COMMON'])
- elif 'DEFAULT' in pcd.SkuInfoList.keys() and 'COMMON' in pcd.SkuInfoList.keys():
- del(pcd.SkuInfoList['COMMON'])
+ del pcd.SkuInfoList['COMMON']
+ elif 'DEFAULT' in pcd.SkuInfoList and 'COMMON' in pcd.SkuInfoList:
+ del pcd.SkuInfoList['COMMON']
map(self.FilterSkuSettings,Pcds.values())
@@ -2311,7 +2306,7 @@ class DscBuildData(PlatformBuildClassObject):
def FilterSkuSettings(self, PcdObj):
if self.SkuIdMgr.SkuUsageType == self.SkuIdMgr.SINGLE:
- if 'DEFAULT' in PcdObj.SkuInfoList.keys() and self.SkuIdMgr.SystemSkuId not in PcdObj.SkuInfoList.keys():
+ if 'DEFAULT' in PcdObj.SkuInfoList and self.SkuIdMgr.SystemSkuId not in PcdObj.SkuInfoList:
PcdObj.SkuInfoList[self.SkuIdMgr.SystemSkuId] = PcdObj.SkuInfoList['DEFAULT']
PcdObj.SkuInfoList = {'DEFAULT':PcdObj.SkuInfoList[self.SkuIdMgr.SystemSkuId]}
PcdObj.SkuInfoList['DEFAULT'].SkuIdName = 'DEFAULT'
@@ -2465,7 +2460,7 @@ class DscBuildData(PlatformBuildClassObject):
EdkLogger.error('Build', PCD_VARIABLE_ATTRIBUTES_CONFLICT_ERROR, "The variable %s.%s for DynamicHii PCDs has conflicting attributes [%s] and [%s] " % (VariableGuid, VariableName, VarAttribute, VariableAttrs[(VariableName, VariableGuid)]))
pcdDecObject = self._DecPcds[PcdCName, TokenSpaceGuid]
- if (PcdCName, TokenSpaceGuid) in Pcds.keys():
+ if (PcdCName, TokenSpaceGuid) in Pcds:
pcdObject = Pcds[PcdCName, TokenSpaceGuid]
if SkuName in pcdObject.SkuInfoList:
Skuitem = pcdObject.SkuInfoList[SkuName] @@ -2503,15 +2498,15 @@ class DscBuildData(PlatformBuildClassObject):
for default_store in sku.DefaultStoreDict:
sku.DefaultStoreDict[default_store]=pcdDecObject.DefaultValue
pcd.DefaultValue = pcdDecObject.DefaultValue
- if 'DEFAULT' not in pcd.SkuInfoList.keys() and 'COMMON' not in pcd.SkuInfoList.keys():
+ if 'DEFAULT' not in pcd.SkuInfoList and 'COMMON' not in pcd.SkuInfoList:
valuefromDec = pcdDecObject.DefaultValue
SkuInfo = SkuInfoClass('DEFAULT', '0', SkuInfoObj.VariableName, SkuInfoObj.VariableGuid, SkuInfoObj.VariableOffset, valuefromDec,VariableAttribute=SkuInfoObj.VariableAttribute,DefaultStore={DefaultStore:valuefromDec})
pcd.SkuInfoList['DEFAULT'] = SkuInfo
- elif 'DEFAULT' not in pcd.SkuInfoList.keys() and 'COMMON' in pcd.SkuInfoList.keys():
+ elif 'DEFAULT' not in pcd.SkuInfoList and 'COMMON' in pcd.SkuInfoList:
pcd.SkuInfoList['DEFAULT'] = pcd.SkuInfoList['COMMON']
- del(pcd.SkuInfoList['COMMON'])
- elif 'DEFAULT' in pcd.SkuInfoList.keys() and 'COMMON' in pcd.SkuInfoList.keys():
- del(pcd.SkuInfoList['COMMON'])
+ del pcd.SkuInfoList['COMMON']
+ elif 'DEFAULT' in pcd.SkuInfoList and 'COMMON' in pcd.SkuInfoList:
+ del pcd.SkuInfoList['COMMON']
if pcd.MaxDatumSize.strip():
MaxSize = int(pcd.MaxDatumSize, 0) @@ -2592,7 +2587,7 @@ class DscBuildData(PlatformBuildClassObject):
#
VpdOffset, MaxDatumSize, InitialValue = self._ValidatePcd(PcdCName, TokenSpaceGuid, Setting, Type, Dummy4)
SkuInfo = SkuInfoClass(SkuName, self.SkuIds[SkuName][0], '', '', '', '', VpdOffset, InitialValue)
- if (PcdCName, TokenSpaceGuid) in Pcds.keys():
+ if (PcdCName, TokenSpaceGuid) in Pcds:
pcdObject = Pcds[PcdCName, TokenSpaceGuid]
pcdObject.SkuInfoList[SkuName] = SkuInfo
if MaxDatumSize.strip():
@@ -2626,15 +2621,15 @@ class DscBuildData(PlatformBuildClassObject):
for sku in pcd.SkuInfoList.values():
if (sku.DefaultValue == "" or sku.DefaultValue==None):
sku.DefaultValue = pcdDecObject.DefaultValue
- if 'DEFAULT' not in pcd.SkuInfoList.keys() and 'COMMON' not in pcd.SkuInfoList.keys():
+ if 'DEFAULT' not in pcd.SkuInfoList and 'COMMON' not in pcd.SkuInfoList:
valuefromDec = pcdDecObject.DefaultValue
SkuInfo = SkuInfoClass('DEFAULT', '0', '', '', '', '', SkuInfoObj.VpdOffset, valuefromDec)
pcd.SkuInfoList['DEFAULT'] = SkuInfo
- elif 'DEFAULT' not in pcd.SkuInfoList.keys() and 'COMMON' in pcd.SkuInfoList.keys():
+ elif 'DEFAULT' not in pcd.SkuInfoList and 'COMMON' in pcd.SkuInfoList:
pcd.SkuInfoList['DEFAULT'] = pcd.SkuInfoList['COMMON']
- del(pcd.SkuInfoList['COMMON'])
- elif 'DEFAULT' in pcd.SkuInfoList.keys() and 'COMMON' in pcd.SkuInfoList.keys():
- del(pcd.SkuInfoList['COMMON'])
+ del pcd.SkuInfoList['COMMON']
+ elif 'DEFAULT' in pcd.SkuInfoList and 'COMMON' in pcd.SkuInfoList:
+ del pcd.SkuInfoList['COMMON']
map(self.FilterSkuSettings,Pcds.values())
--
2.16.2.windows.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
end of thread, other threads:[~2018-04-18 8:48 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-04-10 14:20 [PATCH v1 0/3] BaseTools: refactor to remove redundant Jaben Carsey
2018-04-10 14:20 ` [PATCH v1 1/3] BaseTools: refactor and remove more keys() usage Jaben Carsey
2018-04-18 8:48 ` Zhu, Yonghong
2018-04-10 14:20 ` [PATCH v1 2/3] BaseTools: use predefined constants instead of local strings Jaben Carsey
2018-04-16 1:43 ` Zhu, Yonghong
2018-04-10 14:20 ` [PATCH v1 3/3] BaseTools: use existing contrants to replace raw strings in python code Jaben Carsey
2018-04-11 1:07 ` Zhu, Yonghong
2018-04-11 14:20 ` Carsey, Jaben
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox