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> Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
This commit is contained in:
committed by
Yonghong Zhu
parent
5a693b89a1
commit
55c84777ee
@@ -259,7 +259,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
|
||||
@@ -788,7 +788,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:
|
||||
@@ -1338,7 +1338,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)
|
||||
|
||||
@@ -1346,7 +1346,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
|
||||
@@ -1577,12 +1577,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():
|
||||
@@ -1641,9 +1641,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()
|
||||
@@ -1767,7 +1767,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
|
||||
|
||||
@@ -2390,7 +2390,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)
|
||||
}
|
||||
@@ -3420,7 +3420,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)
|
||||
|
@@ -1,7 +1,7 @@
|
||||
## @file
|
||||
# The engine for building files
|
||||
#
|
||||
# Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.<BR>
|
||||
# Copyright (c) 2007 - 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
|
||||
@@ -364,7 +364,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
|
||||
@@ -424,8 +424,8 @@ class BuildRule:
|
||||
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 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]
|
||||
@@ -452,8 +452,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":
|
||||
@@ -486,12 +486,12 @@ class BuildRule:
|
||||
self._BuildTypeList.add(BuildType)
|
||||
self._ArchList.add(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,
|
||||
@@ -524,7 +524,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)
|
||||
@@ -532,7 +532,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,
|
||||
|
@@ -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
|
||||
@@ -1010,8 +1011,10 @@ def CreatePcdDataBase(PcdDBData):
|
||||
newbuffer += databasebuff[i]
|
||||
|
||||
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 +1065,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
|
||||
|
@@ -1,4 +1,4 @@
|
||||
# Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
|
||||
# Copyright (c) 2017 - 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
|
||||
@@ -142,7 +142,7 @@ class VariableMgr(object):
|
||||
default_data_buffer = ""
|
||||
others_data_buffer = ""
|
||||
tail = None
|
||||
default_sku_default = indexedvarinfo.get(index).get(("DEFAULT",DataType.TAB_DEFAULT_STORES_DEFAULT))
|
||||
default_sku_default = indexedvarinfo.get(index).get((DataType.TAB_DEFAULT,DataType.TAB_DEFAULT_STORES_DEFAULT))
|
||||
|
||||
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()])
|
||||
@@ -155,13 +155,13 @@ class VariableMgr(object):
|
||||
for item in default_data_buffer:
|
||||
default_data_array += unpack("B",item)
|
||||
|
||||
if ("DEFAULT",DataType.TAB_DEFAULT_STORES_DEFAULT) not in var_data:
|
||||
var_data[("DEFAULT",DataType.TAB_DEFAULT_STORES_DEFAULT)] = collections.OrderedDict()
|
||||
var_data[("DEFAULT",DataType.TAB_DEFAULT_STORES_DEFAULT)][index] = (default_data_buffer,sku_var_info[("DEFAULT",DataType.TAB_DEFAULT_STORES_DEFAULT)])
|
||||
if (DataType.TAB_DEFAULT,DataType.TAB_DEFAULT_STORES_DEFAULT) not in var_data:
|
||||
var_data[(DataType.TAB_DEFAULT,DataType.TAB_DEFAULT_STORES_DEFAULT)] = collections.OrderedDict()
|
||||
var_data[(DataType.TAB_DEFAULT,DataType.TAB_DEFAULT_STORES_DEFAULT)][index] = (default_data_buffer,sku_var_info[(DataType.TAB_DEFAULT,DataType.TAB_DEFAULT_STORES_DEFAULT)])
|
||||
|
||||
for (skuid,defaultstoragename) in indexedvarinfo.get(index):
|
||||
tail = None
|
||||
if (skuid,defaultstoragename) == ("DEFAULT",DataType.TAB_DEFAULT_STORES_DEFAULT):
|
||||
if (skuid,defaultstoragename) == (DataType.TAB_DEFAULT,DataType.TAB_DEFAULT_STORES_DEFAULT):
|
||||
continue
|
||||
other_sku_other = indexedvarinfo.get(index).get((skuid,defaultstoragename))
|
||||
|
||||
@@ -190,7 +190,7 @@ class VariableMgr(object):
|
||||
if not var_data:
|
||||
return []
|
||||
|
||||
pcds_default_data = var_data.get(("DEFAULT",DataType.TAB_DEFAULT_STORES_DEFAULT),{})
|
||||
pcds_default_data = var_data.get((DataType.TAB_DEFAULT,DataType.TAB_DEFAULT_STORES_DEFAULT),{})
|
||||
NvStoreDataBuffer = ""
|
||||
var_data_offset = collections.OrderedDict()
|
||||
offset = NvStorageHeaderSize
|
||||
@@ -220,7 +220,7 @@ class VariableMgr(object):
|
||||
|
||||
data_delta_structure_buffer = ""
|
||||
for skuname,defaultstore in var_data:
|
||||
if (skuname,defaultstore) == ("DEFAULT",DataType.TAB_DEFAULT_STORES_DEFAULT):
|
||||
if (skuname,defaultstore) == (DataType.TAB_DEFAULT,DataType.TAB_DEFAULT_STORES_DEFAULT):
|
||||
continue
|
||||
pcds_sku_data = var_data.get((skuname,defaultstore))
|
||||
delta_data_set = []
|
||||
|
Reference in New Issue
Block a user