From 55c84777ee638be8735a5c421941e7eb71633bdf Mon Sep 17 00:00:00 2001 From: "Carsey, Jaben" Date: Mon, 16 Apr 2018 21:52:13 +0800 Subject: [PATCH] BaseTools: use predefined constants instead of local strings Cc: Liming Gao Cc: Yonghong Zhu Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Jaben Carsey Reviewed-by: Yonghong Zhu --- BaseTools/Source/Python/AutoGen/AutoGen.py | 22 +-- .../Source/Python/AutoGen/BuildEngine.py | 20 +-- BaseTools/Source/Python/AutoGen/GenPcdDb.py | 17 +- BaseTools/Source/Python/AutoGen/GenVar.py | 16 +- BaseTools/Source/Python/Common/DataType.py | 4 +- .../Source/Python/GenFds/AprioriSection.py | 5 +- BaseTools/Source/Python/GenFds/FdfParser.py | 13 +- .../Source/Python/GenFds/FfsInfStatement.py | 5 +- BaseTools/Source/Python/GenFds/GenFds.py | 12 +- .../Python/GenFds/GenFdsGlobalVariable.py | 8 +- BaseTools/Source/Python/GenFds/Section.py | 5 +- .../Source/Python/Workspace/DecBuildData.py | 4 +- .../Source/Python/Workspace/DscBuildData.py | 152 +++++++++--------- .../Source/Python/Workspace/InfBuildData.py | 6 +- .../Source/Python/Workspace/MetaFileParser.py | 32 ++-- .../Source/Python/Workspace/MetaFileTable.py | 20 +-- .../Python/Workspace/WorkspaceDatabase.py | 4 +- 17 files changed, 177 insertions(+), 168 deletions(-) diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py b/BaseTools/Source/Python/AutoGen/AutoGen.py index 69c1ef4eba..bd443fe626 100644 --- a/BaseTools/Source/Python/AutoGen/AutoGen.py +++ b/BaseTools/Source/Python/AutoGen/AutoGen.py @@ -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) diff --git a/BaseTools/Source/Python/AutoGen/BuildEngine.py b/BaseTools/Source/Python/AutoGen/BuildEngine.py index 1663ddd21b..bbd1a4d5b2 100644 --- a/BaseTools/Source/Python/AutoGen/BuildEngine.py +++ b/BaseTools/Source/Python/AutoGen/BuildEngine.py @@ -1,7 +1,7 @@ ## @file # The engine for building files # -# Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.
+# Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.
# 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, diff --git a/BaseTools/Source/Python/AutoGen/GenPcdDb.py b/BaseTools/Source/Python/AutoGen/GenPcdDb.py index e415cae290..5937558e70 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 @@ -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 diff --git a/BaseTools/Source/Python/AutoGen/GenVar.py b/BaseTools/Source/Python/AutoGen/GenVar.py index 7a29a0edca..1c66a9eb05 100644 --- a/BaseTools/Source/Python/AutoGen/GenVar.py +++ b/BaseTools/Source/Python/AutoGen/GenVar.py @@ -1,4 +1,4 @@ -# Copyright (c) 2017, Intel Corporation. All rights reserved.
+# Copyright (c) 2017 - 2018, Intel Corporation. All rights reserved.
# 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 = [] diff --git a/BaseTools/Source/Python/Common/DataType.py b/BaseTools/Source/Python/Common/DataType.py index 1199f82ad1..c0db8d02e1 100644 --- a/BaseTools/Source/Python/Common/DataType.py +++ b/BaseTools/Source/Python/Common/DataType.py @@ -1,7 +1,7 @@ ## @file # This file is used to define common static strings used by INF/DEC/DSC files # -# Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.
+# Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.
# Portions copyright (c) 2011 - 2013, ARM Ltd. All rights reserved.
# This program and the accompanying materials # are licensed and made available under the terms and conditions of the BSD License @@ -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 92a74670ed..7cf792b5b2 100644 --- a/BaseTools/Source/Python/GenFds/AprioriSection.py +++ b/BaseTools/Source/Python/GenFds/AprioriSection.py @@ -1,7 +1,7 @@ ## @file # process APRIORI file data and generate PEI/DXE APRIORI file # -# Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.
+# Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.
# # This program and the accompanying materials # are licensed and made available under the terms and conditions of the BSD License @@ -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 dce41701a5..bff1d47393 100644 --- a/BaseTools/Source/Python/GenFds/FdfParser.py +++ b/BaseTools/Source/Python/GenFds/FdfParser.py @@ -52,6 +52,7 @@ from Common.String import NormPath import Common.GlobalData as GlobalData from Common.Expression import * from Common import GlobalData +from Common.DataType import * from Common.String import ReplaceMacro import uuid from Common.Misc import tdict @@ -511,8 +512,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(',') @@ -520,9 +521,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 # @@ -886,7 +887,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 +3587,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() diff --git a/BaseTools/Source/Python/GenFds/FfsInfStatement.py b/BaseTools/Source/Python/GenFds/FfsInfStatement.py index 8ae29b285d..8f5a1bfd10 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 @@ -570,7 +571,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 810a1f86e9..c507b0148a 100644 --- a/BaseTools/Source/Python/GenFds/GenFds.py +++ b/BaseTools/Source/Python/GenFds/GenFds.py @@ -238,11 +238,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) @@ -674,7 +674,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] @@ -693,9 +693,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 2f9d58f6bf..5e5dc4c948 100644 --- a/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py +++ b/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py @@ -130,7 +130,7 @@ class GenFdsGlobalVariable: @staticmethod def GetBuildRules(Inf, Arch): if not Arch: - Arch = 'COMMON' + Arch = DataType.TAB_COMMON if not Arch in GenFdsGlobalVariable.OutputDirDict: return {} @@ -217,7 +217,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 [DataType.TAB_COMMON, '*', GenFdsGlobalVariable.TargetName]: FileList.append((File, File.Type)) for File, FileType in FileList: @@ -759,7 +759,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=DataType.TAB_COMMON): if Str is None : return None @@ -771,7 +771,7 @@ class GenFdsGlobalVariable: '$(SPACE)' : ' ' } OutputDir = GenFdsGlobalVariable.OutputDirFromDscDict[GenFdsGlobalVariable.ArchList[0]] - if Arch != 'COMMON' and Arch in GenFdsGlobalVariable.ArchList: + if Arch != DataType.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 6335c249a6..4b368b3ada 100644 --- a/BaseTools/Source/Python/GenFds/Section.py +++ b/BaseTools/Source/Python/GenFds/Section.py @@ -1,7 +1,7 @@ ## @file # section base class # -# Copyright (c) 2007-2017, Intel Corporation. All rights reserved.
+# Copyright (c) 2007-2018, Intel Corporation. All rights reserved.
# # This program and the accompanying materials # are licensed and made available under the terms and conditions of the BSD License @@ -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_ARCH_COMMON ## section base class # @@ -125,7 +126,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_ARCH_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 ccd6cc6a37..31870e078c 100644 --- a/BaseTools/Source/Python/Workspace/DecBuildData.py +++ b/BaseTools/Source/Python/Workspace/DecBuildData.py @@ -63,7 +63,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 +327,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 ccca971b06..1ca8109b48 100644 --- a/BaseTools/Source/Python/Workspace/DscBuildData.py +++ b/BaseTools/Source/Python/Workspace/DscBuildData.py @@ -211,7 +211,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 @@ -510,7 +510,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 @@ -652,10 +652,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(DscBuildData.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 @staticmethod @@ -708,7 +708,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 +817,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 +929,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 +957,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]) @@ -1152,7 +1152,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) # @@ -1172,7 +1172,7 @@ class DscBuildData(PlatformBuildClassObject): options = OrderedDict() 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 @@ -1275,7 +1275,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 = [] @@ -1288,7 +1288,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 @@ -1316,7 +1316,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],TAB_DEFAULT_STORES_DEFAULT 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],TAB_DEFAULT_STORES_DEFAULT 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, @@ -1346,7 +1346,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) @@ -1359,7 +1359,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) @@ -1389,14 +1389,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) @@ -1421,11 +1421,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 @@ -1451,11 +1451,11 @@ class DscBuildData(PlatformBuildClassObject): PcdValueDict = OrderedDict() 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 @@ -1474,10 +1474,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] @@ -1592,7 +1592,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) @@ -1722,10 +1722,10 @@ class DscBuildData(PlatformBuildClassObject): CApp = CApp + ' UINT32 FieldSize;\n' CApp = CApp + ' CHAR8 *Value;\n' - CApp = CApp + "// SkuName: %s, DefaultStoreName: %s \n" % ('DEFAULT', TAB_DEFAULT_STORES_DEFAULT) + CApp = CApp + "// SkuName: %s, DefaultStoreName: %s \n" % (TAB_DEFAULT, TAB_DEFAULT_STORES_DEFAULT) inherit_OverrideValues = Pcd.SkuOverrideValues[SkuName] - if (SkuName,DefaultStoreName) == ('DEFAULT',TAB_DEFAULT_STORES_DEFAULT): - pcddefaultvalue = Pcd.DefaultFromDSC.get('DEFAULT',{}).get(TAB_DEFAULT_STORES_DEFAULT, Pcd.DefaultValue) if Pcd.DefaultFromDSC else Pcd.DefaultValue + if (SkuName,DefaultStoreName) == (TAB_DEFAULT,TAB_DEFAULT_STORES_DEFAULT): + pcddefaultvalue = Pcd.DefaultFromDSC.get(TAB_DEFAULT,{}).get(TAB_DEFAULT_STORES_DEFAULT, Pcd.DefaultValue) if Pcd.DefaultFromDSC else Pcd.DefaultValue else: if not Pcd.DscRawValue: # handle the case that structure pcd is not appear in DSC @@ -1744,14 +1744,14 @@ class DscBuildData(PlatformBuildClassObject): (Pcd.TokenSpaceGuidCName, Pcd.TokenCName, FieldList)) Value, ValueSize = ParseFieldValue (FieldList) - if (SkuName,DefaultStoreName) == ('DEFAULT',TAB_DEFAULT_STORES_DEFAULT): + if (SkuName,DefaultStoreName) == (TAB_DEFAULT,TAB_DEFAULT_STORES_DEFAULT): if isinstance(Value, str): - CApp = CApp + ' Pcd = %s; // From DSC Default Value %s\n' % (Value, Pcd.DefaultFromDSC.get('DEFAULT',{}).get(TAB_DEFAULT_STORES_DEFAULT, 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(TAB_DEFAULT_STORES_DEFAULT, 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' % (DscBuildData.IntToCString(Value, ValueSize), Pcd.DefaultFromDSC.get('DEFAULT',{}).get(TAB_DEFAULT_STORES_DEFAULT, Pcd.DefaultValue) if Pcd.DefaultFromDSC else Pcd.DefaultValue) + CApp = CApp + ' Value = %s; // From DSC Default Value %s\n' % (DscBuildData.IntToCString(Value, ValueSize), Pcd.DefaultFromDSC.get(TAB_DEFAULT,{}).get(TAB_DEFAULT_STORES_DEFAULT, Pcd.DefaultValue) if Pcd.DefaultFromDSC else Pcd.DefaultValue) CApp = CApp + ' memcpy (Pcd, Value, %d);\n' % (ValueSize) else: if isinstance(Value, str): @@ -1763,7 +1763,7 @@ class DscBuildData(PlatformBuildClassObject): CApp = CApp + ' Value = %s; // From DSC Default Value %s\n' % (DscBuildData.IntToCString(Value, ValueSize), Pcd.DscRawValue.get(SkuName,{}).get(DefaultStoreName)) CApp = CApp + ' memcpy (Pcd, Value, %d);\n' % (ValueSize) continue - if (SkuName,DefaultStoreName) == ('DEFAULT',TAB_DEFAULT_STORES_DEFAULT) or (( (SkuName,'') not in Pcd.ValueChain) and ( (SkuName,DefaultStoreName) not in Pcd.ValueChain )): + if (SkuName,DefaultStoreName) == (TAB_DEFAULT,TAB_DEFAULT_STORES_DEFAULT) or (( (SkuName,'') not in Pcd.ValueChain) and ( (SkuName,DefaultStoreName) not in Pcd.ValueChain )): for FieldName in FieldList: IsArray = IsFieldValueAnArray(FieldList[FieldName][0]) if IsArray: @@ -2229,7 +2229,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) @@ -2279,15 +2279,15 @@ class DscBuildData(PlatformBuildClassObject): for sku in pcd.SkuInfoList.values(): if not sku.DefaultValue: 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()) @@ -2296,14 +2296,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 @@ -2337,7 +2337,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)] @@ -2368,7 +2368,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 @@ -2395,9 +2395,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 = TAB_DEFAULT_STORES_DEFAULT if SkuName not in AvailableSkuIdSet: EdkLogger.error('build', PARAMETER_INVALID, 'Sku %s is not defined in [SkuIds] section' % SkuName, @@ -2489,15 +2489,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) @@ -2558,7 +2558,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) @@ -2613,15 +2613,15 @@ class DscBuildData(PlatformBuildClassObject): for sku in pcd.SkuInfoList.values(): if not sku.DefaultValue: 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 38165cb8a7..bf3da028c6 100644 --- a/BaseTools/Source/Python/Workspace/InfBuildData.py +++ b/BaseTools/Source/Python/Workspace/InfBuildData.py @@ -107,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 @@ -115,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] @@ -602,7 +602,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 f4c1868483..ae8cf57e38 100644 --- a/BaseTools/Source/Python/Workspace/MetaFileParser.py +++ b/BaseTools/Source/Python/Workspace/MetaFileParser.py @@ -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 be3fb3d688..3c8dae0e62 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.
+# Copyright (c) 2008 - 2018, Intel Corporation. All rights reserved.
# 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 @@ -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 e554d84326..14dcb1ae81 100644 --- a/BaseTools/Source/Python/Workspace/WorkspaceDatabase.py +++ b/BaseTools/Source/Python/Workspace/WorkspaceDatabase.py @@ -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.39.2