BaseTools: refactor and remove un-needed use of .keys() on dictionaries

sometimes just delete it.
sometimes the loop needed .values() instead

Cc: Liming Gao <liming.gao@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jaben Carsey <jaben.carsey@intel.com>
Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
This commit is contained in:
Carsey, Jaben
2018-04-17 22:40:15 +08:00
committed by Yonghong Zhu
parent 55c84777ee
commit 9eb87141ec
27 changed files with 137 additions and 159 deletions

View File

@ -762,7 +762,7 @@ class WorkspaceAutoGen(AutoGen):
for Module in Pa.ModuleAutoGenList: for Module in Pa.ModuleAutoGenList:
if path.normpath(Module.MetaFile.File) == path.normpath(FfsFile.InfFileName): if path.normpath(Module.MetaFile.File) == path.normpath(FfsFile.InfFileName):
InfFoundFlag = True InfFoundFlag = True
if not Module.Guid.upper() in _GuidDict.keys(): if Module.Guid.upper() not in _GuidDict:
_GuidDict[Module.Guid.upper()] = FfsFile _GuidDict[Module.Guid.upper()] = FfsFile
break break
else: else:
@ -789,7 +789,7 @@ class WorkspaceAutoGen(AutoGen):
# BuildObject from one of AutoGenObjectList is enough. # BuildObject from one of AutoGenObjectList is enough.
# #
InfObj = self.AutoGenObjectList[0].BuildDatabase.WorkspaceDb.BuildObject[PathClassObj, TAB_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(): if InfObj.Guid.upper() not in _GuidDict:
_GuidDict[InfObj.Guid.upper()] = FfsFile _GuidDict[InfObj.Guid.upper()] = FfsFile
else: else:
EdkLogger.error("build", EdkLogger.error("build",
@ -837,7 +837,7 @@ class WorkspaceAutoGen(AutoGen):
"The format of PCD value is incorrect. PCD: %s , Value: %s\n" % (_PcdName, PcdItem.DefaultValue), "The format of PCD value is incorrect. PCD: %s , Value: %s\n" % (_PcdName, PcdItem.DefaultValue),
ExtraData=self.FdfFile) ExtraData=self.FdfFile)
if not _PcdGuidString.upper() in _GuidDict.keys(): if _PcdGuidString.upper() not in _GuidDict:
_GuidDict[_PcdGuidString.upper()] = FfsFile _GuidDict[_PcdGuidString.upper()] = FfsFile
PcdFoundFlag = True PcdFoundFlag = True
break break
@ -851,7 +851,7 @@ class WorkspaceAutoGen(AutoGen):
FfsFile.NameGuid.upper()), FfsFile.NameGuid.upper()),
ExtraData=self.FdfFile) ExtraData=self.FdfFile)
if not FfsFile.NameGuid.upper() in _GuidDict.keys(): if FfsFile.NameGuid.upper() not in _GuidDict:
_GuidDict[FfsFile.NameGuid.upper()] = FfsFile _GuidDict[FfsFile.NameGuid.upper()] = FfsFile
else: else:
# #
@ -1402,10 +1402,8 @@ class PlatformAutoGen(AutoGen):
PcdFromModule.IsFromBinaryInf = True PcdFromModule.IsFromBinaryInf = True
# Check the PCD from DSC or not # Check the PCD from DSC or not
if (PcdFromModule.TokenCName, PcdFromModule.TokenSpaceGuidCName) in self.Platform.Pcds.keys(): PcdFromModule.IsFromDsc = (PcdFromModule.TokenCName, PcdFromModule.TokenSpaceGuidCName) in self.Platform.Pcds
PcdFromModule.IsFromDsc = True
else:
PcdFromModule.IsFromDsc = False
if PcdFromModule.Type in GenC.gDynamicPcd or PcdFromModule.Type in GenC.gDynamicExPcd: if PcdFromModule.Type in GenC.gDynamicPcd or PcdFromModule.Type in GenC.gDynamicExPcd:
if F.Path not in FdfModuleList: if F.Path not in FdfModuleList:
# If one of the Source built modules listed in the DSC is not listed # If one of the Source built modules listed in the DSC is not listed
@ -1532,8 +1530,8 @@ class PlatformAutoGen(AutoGen):
VpdFile = VpdInfoFile.VpdInfoFile() VpdFile = VpdInfoFile.VpdInfoFile()
NeedProcessVpdMapFile = False NeedProcessVpdMapFile = False
for pcd in self.Platform.Pcds.keys(): for pcd in self.Platform.Pcds:
if pcd not in self._PlatformPcds.keys(): if pcd not in self._PlatformPcds:
self._PlatformPcds[pcd] = self.Platform.Pcds[pcd] self._PlatformPcds[pcd] = self.Platform.Pcds[pcd]
for item in self._PlatformPcds: for item in self._PlatformPcds:
@ -1543,7 +1541,7 @@ class PlatformAutoGen(AutoGen):
if (self.Workspace.ArchList[-1] == self.Arch): if (self.Workspace.ArchList[-1] == self.Arch):
for Pcd in self._DynamicPcdList: for Pcd in self._DynamicPcdList:
# just pick the a value to determine whether is unicode string type # just pick the a value to determine whether is unicode string type
Sku = Pcd.SkuInfoList[Pcd.SkuInfoList.keys()[0]] Sku = Pcd.SkuInfoList.values()[0]
Sku.VpdOffset = Sku.VpdOffset.strip() Sku.VpdOffset = Sku.VpdOffset.strip()
if Pcd.DatumType not in [TAB_UINT8, TAB_UINT16, TAB_UINT32, TAB_UINT64, TAB_VOID, "BOOLEAN"]: if Pcd.DatumType not in [TAB_UINT8, TAB_UINT16, TAB_UINT32, TAB_UINT64, TAB_VOID, "BOOLEAN"]:
@ -1630,7 +1628,7 @@ class PlatformAutoGen(AutoGen):
if DscPcdEntry.Type in [TAB_PCDS_DYNAMIC_VPD, TAB_PCDS_DYNAMIC_EX_VPD]: if DscPcdEntry.Type in [TAB_PCDS_DYNAMIC_VPD, TAB_PCDS_DYNAMIC_EX_VPD]:
if not (self.Platform.VpdToolGuid is None or self.Platform.VpdToolGuid == ''): if not (self.Platform.VpdToolGuid is None or self.Platform.VpdToolGuid == ''):
FoundFlag = False FoundFlag = False
for VpdPcd in VpdFile._VpdArray.keys(): for VpdPcd in VpdFile._VpdArray:
# This PCD has been referenced by module # This PCD has been referenced by module
if (VpdPcd.TokenSpaceGuidCName == DscPcdEntry.TokenSpaceGuidCName) and \ if (VpdPcd.TokenSpaceGuidCName == DscPcdEntry.TokenSpaceGuidCName) and \
(VpdPcd.TokenCName == DscPcdEntry.TokenCName): (VpdPcd.TokenCName == DscPcdEntry.TokenCName):
@ -1742,7 +1740,7 @@ class PlatformAutoGen(AutoGen):
# Delete the DynamicPcdList At the last time enter into this function # Delete the DynamicPcdList At the last time enter into this function
for Pcd in self._DynamicPcdList: for Pcd in self._DynamicPcdList:
# just pick the a value to determine whether is unicode string type # just pick the a value to determine whether is unicode string type
Sku = Pcd.SkuInfoList[Pcd.SkuInfoList.keys()[0]] Sku = Pcd.SkuInfoList.values()[0]
Sku.VpdOffset = Sku.VpdOffset.strip() Sku.VpdOffset = Sku.VpdOffset.strip()
if Pcd.DatumType not in [TAB_UINT8, TAB_UINT16, TAB_UINT32, TAB_UINT64, TAB_VOID, "BOOLEAN"]: if Pcd.DatumType not in [TAB_UINT8, TAB_UINT16, TAB_UINT32, TAB_UINT64, TAB_VOID, "BOOLEAN"]:
@ -2482,7 +2480,7 @@ class PlatformAutoGen(AutoGen):
for LibraryName in M.Libraries: for LibraryName in M.Libraries:
Library = self.Platform.LibraryClasses[LibraryName, ':dummy:'] Library = self.Platform.LibraryClasses[LibraryName, ':dummy:']
if Library is None: if Library is None:
for Key in self.Platform.LibraryClasses.data.keys(): for Key in self.Platform.LibraryClasses.data:
if LibraryName.upper() == Key.upper(): if LibraryName.upper() == Key.upper():
Library = self.Platform.LibraryClasses[Key, ':dummy:'] Library = self.Platform.LibraryClasses[Key, ':dummy:']
break break
@ -3105,7 +3103,7 @@ class ModuleAutoGen(AutoGen):
InfObj = InfSectionParser.InfSectionParser(Filename) InfObj = InfSectionParser.InfSectionParser(Filename)
DepexExpresionList = InfObj.GetDepexExpresionList() DepexExpresionList = InfObj.GetDepexExpresionList()
for DepexExpresion in DepexExpresionList: for DepexExpresion in DepexExpresionList:
for key in DepexExpresion.keys(): for key in DepexExpresion:
Arch, ModuleType = key Arch, ModuleType = key
DepexExpr = [x for x in DepexExpresion[key] if not str(x).startswith('#')] DepexExpr = [x for x in DepexExpresion[key] if not str(x).startswith('#')]
# the type of build module is USER_DEFINED. # the type of build module is USER_DEFINED.
@ -3123,7 +3121,7 @@ class ModuleAutoGen(AutoGen):
#the type of build module is USER_DEFINED. #the type of build module is USER_DEFINED.
if self.ModuleType.upper() == SUP_MODULE_USER_DEFINED: if self.ModuleType.upper() == SUP_MODULE_USER_DEFINED:
for Depex in DepexList: for Depex in DepexList:
for key in Depex.keys(): for key in Depex:
DepexStr += '[Depex.%s.%s]\n' % key DepexStr += '[Depex.%s.%s]\n' % key
DepexStr += '\n'.join(['# '+ val for val in Depex[key]]) DepexStr += '\n'.join(['# '+ val for val in Depex[key]])
DepexStr += '\n\n' DepexStr += '\n\n'
@ -3233,7 +3231,7 @@ class ModuleAutoGen(AutoGen):
InfObj = InfSectionParser.InfSectionParser(Filename) InfObj = InfSectionParser.InfSectionParser(Filename)
TianoCoreUserExtenList = InfObj.GetUserExtensionTianoCore() TianoCoreUserExtenList = InfObj.GetUserExtensionTianoCore()
for TianoCoreUserExtent in TianoCoreUserExtenList: for TianoCoreUserExtent in TianoCoreUserExtenList:
for Section in TianoCoreUserExtent.keys(): for Section in TianoCoreUserExtent:
ItemList = Section.split(TAB_SPLIT) ItemList = Section.split(TAB_SPLIT)
Arch = self.Arch Arch = self.Arch
if len(ItemList) == 4: if len(ItemList) == 4:

View File

@ -495,11 +495,11 @@ cleanlib:
if k not in self._AutoGenObject.Macros: if k not in self._AutoGenObject.Macros:
self._AutoGenObject.Macros[k] = v self._AutoGenObject.Macros[k] = v
if 'MODULE_ENTRY_POINT' not in self._AutoGenObject.Macros.keys(): if 'MODULE_ENTRY_POINT' not in self._AutoGenObject.Macros:
self._AutoGenObject.Macros['MODULE_ENTRY_POINT'] = ModuleEntryPoint self._AutoGenObject.Macros['MODULE_ENTRY_POINT'] = ModuleEntryPoint
if 'ARCH_ENTRY_POINT' not in self._AutoGenObject.Macros.keys(): if 'ARCH_ENTRY_POINT' not in self._AutoGenObject.Macros:
self._AutoGenObject.Macros['ARCH_ENTRY_POINT'] = ArchEntryPoint self._AutoGenObject.Macros['ARCH_ENTRY_POINT'] = ArchEntryPoint
if 'IMAGE_ENTRY_POINT' not in self._AutoGenObject.Macros.keys(): if 'IMAGE_ENTRY_POINT' not in self._AutoGenObject.Macros:
self._AutoGenObject.Macros['IMAGE_ENTRY_POINT'] = ImageEntryPoint self._AutoGenObject.Macros['IMAGE_ENTRY_POINT'] = ImageEntryPoint
PCI_COMPRESS_Flag = False PCI_COMPRESS_Flag = False
@ -540,7 +540,7 @@ cleanlib:
RespFileList = os.path.join(self._AutoGenObject.OutputDir, 'respfilelist.txt') RespFileList = os.path.join(self._AutoGenObject.OutputDir, 'respfilelist.txt')
if RespDict: if RespDict:
RespFileListContent = '' RespFileListContent = ''
for Resp in RespDict.keys(): for Resp in RespDict:
RespFile = os.path.join(self._AutoGenObject.OutputDir, str(Resp).lower() + '.txt') RespFile = os.path.join(self._AutoGenObject.OutputDir, str(Resp).lower() + '.txt')
StrList = RespDict[Resp].split(' ') StrList = RespDict[Resp].split(' ')
UnexpandMacro = [] UnexpandMacro = []
@ -794,7 +794,7 @@ cleanlib:
SingleCommandLength = len(SingleCommand) SingleCommandLength = len(SingleCommand)
SingleCommandList = SingleCommand.split() SingleCommandList = SingleCommand.split()
if len(SingleCommandList) > 0: if len(SingleCommandList) > 0:
for Flag in FlagDict.keys(): for Flag in FlagDict:
if '$('+ Flag +')' in SingleCommandList[0]: if '$('+ Flag +')' in SingleCommandList[0]:
Tool = Flag Tool = Flag
break break
@ -807,12 +807,12 @@ cleanlib:
if 'FLAGS' not in self._AutoGenObject._BuildOption[Tool]: if 'FLAGS' not in self._AutoGenObject._BuildOption[Tool]:
EdkLogger.error("build", AUTOGEN_ERROR, "%s_FLAGS doesn't exist in %s ToolChain and %s Arch." %(Tool, self._AutoGenObject.ToolChain, self._AutoGenObject.Arch), ExtraData="[%s]" % str(self._AutoGenObject)) EdkLogger.error("build", AUTOGEN_ERROR, "%s_FLAGS doesn't exist in %s ToolChain and %s Arch." %(Tool, self._AutoGenObject.ToolChain, self._AutoGenObject.Arch), ExtraData="[%s]" % str(self._AutoGenObject))
Str = self._AutoGenObject._BuildOption[Tool]['FLAGS'] Str = self._AutoGenObject._BuildOption[Tool]['FLAGS']
for Option in self._AutoGenObject.BuildOption.keys(): for Option in self._AutoGenObject.BuildOption:
for Attr in self._AutoGenObject.BuildOption[Option]: for Attr in self._AutoGenObject.BuildOption[Option]:
if Str.find(Option + '_' + Attr) != -1: if Str.find(Option + '_' + Attr) != -1:
Str = Str.replace('$(' + Option + '_' + Attr + ')', self._AutoGenObject.BuildOption[Option][Attr]) Str = Str.replace('$(' + Option + '_' + Attr + ')', self._AutoGenObject.BuildOption[Option][Attr])
while(Str.find('$(') != -1): while(Str.find('$(') != -1):
for macro in self._AutoGenObject.Macros.keys(): for macro in self._AutoGenObject.Macros:
MacroName = '$('+ macro + ')' MacroName = '$('+ macro + ')'
if (Str.find(MacroName) != -1): if (Str.find(MacroName) != -1):
Str = Str.replace(MacroName, self._AutoGenObject.Macros[macro]) Str = Str.replace(MacroName, self._AutoGenObject.Macros[macro])
@ -824,12 +824,12 @@ cleanlib:
SingleCommandLength += self._AutoGenObject.IncludePathLength + len(IncPrefix) * len(self._AutoGenObject._IncludePathList) SingleCommandLength += self._AutoGenObject.IncludePathLength + len(IncPrefix) * len(self._AutoGenObject._IncludePathList)
elif item.find('$(') != -1: elif item.find('$(') != -1:
Str = item Str = item
for Option in self._AutoGenObject.BuildOption.keys(): for Option in self._AutoGenObject.BuildOption:
for Attr in self._AutoGenObject.BuildOption[Option]: for Attr in self._AutoGenObject.BuildOption[Option]:
if Str.find(Option + '_' + Attr) != -1: if Str.find(Option + '_' + Attr) != -1:
Str = Str.replace('$(' + Option + '_' + Attr + ')', self._AutoGenObject.BuildOption[Option][Attr]) Str = Str.replace('$(' + Option + '_' + Attr + ')', self._AutoGenObject.BuildOption[Option][Attr])
while(Str.find('$(') != -1): while(Str.find('$(') != -1):
for macro in self._AutoGenObject.Macros.keys(): for macro in self._AutoGenObject.Macros:
MacroName = '$('+ macro + ')' MacroName = '$('+ macro + ')'
if (Str.find(MacroName) != -1): if (Str.find(MacroName) != -1):
Str = Str.replace(MacroName, self._AutoGenObject.Macros[macro]) Str = Str.replace(MacroName, self._AutoGenObject.Macros[macro])
@ -842,19 +842,19 @@ cleanlib:
FlagDict[Tool]['Value'] = True FlagDict[Tool]['Value'] = True
# generate the response file content by combine the FLAGS and INC # generate the response file content by combine the FLAGS and INC
for Flag in FlagDict.keys(): for Flag in FlagDict:
if FlagDict[Flag]['Value']: if FlagDict[Flag]['Value']:
Key = Flag + '_RESP' Key = Flag + '_RESP'
RespMacro = FlagDict[Flag]['Macro'].replace('FLAGS', 'RESP') RespMacro = FlagDict[Flag]['Macro'].replace('FLAGS', 'RESP')
Value = self._AutoGenObject.BuildOption[Flag]['FLAGS'] Value = self._AutoGenObject.BuildOption[Flag]['FLAGS']
for inc in self._AutoGenObject._IncludePathList: for inc in self._AutoGenObject._IncludePathList:
Value += ' ' + IncPrefix + inc Value += ' ' + IncPrefix + inc
for Option in self._AutoGenObject.BuildOption.keys(): for Option in self._AutoGenObject.BuildOption:
for Attr in self._AutoGenObject.BuildOption[Option]: for Attr in self._AutoGenObject.BuildOption[Option]:
if Value.find(Option + '_' + Attr) != -1: if Value.find(Option + '_' + Attr) != -1:
Value = Value.replace('$(' + Option + '_' + Attr + ')', self._AutoGenObject.BuildOption[Option][Attr]) Value = Value.replace('$(' + Option + '_' + Attr + ')', self._AutoGenObject.BuildOption[Option][Attr])
while (Value.find('$(') != -1): while (Value.find('$(') != -1):
for macro in self._AutoGenObject.Macros.keys(): for macro in self._AutoGenObject.Macros:
MacroName = '$('+ macro + ')' MacroName = '$('+ macro + ')'
if (Value.find(MacroName) != -1): if (Value.find(MacroName) != -1):
Value = Value.replace(MacroName, self._AutoGenObject.Macros[macro]) Value = Value.replace(MacroName, self._AutoGenObject.Macros[macro])

View File

@ -114,8 +114,8 @@ class VariableMgr(object):
self.VarInfo = [item[0] for item in indexedvarinfo.values()] self.VarInfo = [item[0] for item in indexedvarinfo.values()]
def assemble_variable(self, valuelist): def assemble_variable(self, valuelist):
ordered_value = [valuelist[k] for k in sorted(valuelist.keys())]
ordered_offset = sorted(valuelist.keys()) ordered_offset = sorted(valuelist.keys())
ordered_value = [valuelist[k] for k in ordered_offset]
var_value = [] var_value = []
num = 0 num = 0
for offset in ordered_offset: for offset in ordered_offset:

View File

@ -1,7 +1,7 @@
## @file ## @file
# Parser a Inf file and Get specify section data. # Parser a Inf file and Get specify section data.
# #
# Copyright (c) 2007 - 2012, Intel Corporation. All rights reserved.<BR> # Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>
# This program and the accompanying materials # This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License # are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at # which accompanies this distribution. The full text of the license may be found at
@ -70,7 +70,7 @@ class InfSectionParser():
if not self._FileSectionDataList: if not self._FileSectionDataList:
return UserExtensionTianoCore return UserExtensionTianoCore
for SectionDataDict in self._FileSectionDataList: for SectionDataDict in self._FileSectionDataList:
for key in SectionDataDict.keys(): for key in SectionDataDict:
if key.lower().startswith("[userextensions") and key.lower().find('.tianocore.') > -1: if key.lower().startswith("[userextensions") and key.lower().find('.tianocore.') > -1:
SectionLine = key.lstrip(TAB_SECTION_START).rstrip(TAB_SECTION_END) SectionLine = key.lstrip(TAB_SECTION_START).rstrip(TAB_SECTION_END)
SubSectionList = [SectionLine] SubSectionList = [SectionLine]
@ -89,7 +89,7 @@ class InfSectionParser():
if not self._FileSectionDataList: if not self._FileSectionDataList:
return DepexExpresionList return DepexExpresionList
for SectionDataDict in self._FileSectionDataList: for SectionDataDict in self._FileSectionDataList:
for key in SectionDataDict.keys(): for key in SectionDataDict:
if key.lower() == "[depex]" or key.lower().startswith("[depex."): if key.lower() == "[depex]" or key.lower().startswith("[depex."):
SectionLine = key.lstrip(TAB_SECTION_START).rstrip(TAB_SECTION_END) SectionLine = key.lstrip(TAB_SECTION_START).rstrip(TAB_SECTION_END)
SubSectionList = [SectionLine] SubSectionList = [SectionLine]

View File

@ -120,7 +120,7 @@ class PcdEntry:
# #
# #
def _PackIntValue(self, IntValue, Size): def _PackIntValue(self, IntValue, Size):
if Size not in _FORMAT_CHAR.keys(): if Size not in _FORMAT_CHAR:
EdkLogger.error("BPDG", BuildToolError.FORMAT_INVALID, EdkLogger.error("BPDG", BuildToolError.FORMAT_INVALID,
"Invalid size %d for PCD %s in integer datum size(File: %s Line: %s)." % (Size, self.PcdCName, self.FileName, self.Lineno)) "Invalid size %d for PCD %s in integer datum size(File: %s Line: %s)." % (Size, self.PcdCName, self.FileName, self.Lineno))

View File

@ -1,7 +1,7 @@
## @file ## @file
# This is the base class for applications that operate on an EDK II Workspace # This is the base class for applications that operate on an EDK II Workspace
# #
# 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 # This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License # are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at # which accompanies this distribution. The full text of the license may be found at
@ -259,10 +259,7 @@ def ConvertDictionaryToTextFile(FileName, Dictionary, CommentCharacter, KeySplit
except: except:
Lines = [] Lines = []
Keys = Dictionary.keys() Keys = Dictionary.keys()
MaxLength = 0 MaxLength = max(map(len,Keys))
for Key in Keys:
if len(Key) > MaxLength:
MaxLength = len(Key)
Index = 0 Index = 0
for Line in Lines: for Line in Lines:
LineList = Line.split(KeySplitCharacter, 1) LineList = Line.split(KeySplitCharacter, 1)

View File

@ -151,7 +151,7 @@ def ReplaceExprMacro(String, Macros, ExceptionList = None):
InQuote = True InQuote = True
MacroStartPos = String.find('$(') MacroStartPos = String.find('$(')
if MacroStartPos < 0: if MacroStartPos < 0:
for Pcd in gPlatformPcds.keys(): for Pcd in gPlatformPcds:
if Pcd in String: if Pcd in String:
if Pcd not in gConditionalPcds: if Pcd not in gConditionalPcds:
gConditionalPcds.append(Pcd) gConditionalPcds.append(Pcd)
@ -908,7 +908,7 @@ class ValueExpressionEx(ValueExpression):
for Label in LabelList: for Label in LabelList:
if not IsValidCName(Label): if not IsValidCName(Label):
raise BadExpression('%s is not a valid c variable name' % Label) raise BadExpression('%s is not a valid c variable name' % Label)
if Label not in LabelDict.keys(): if Label not in LabelDict:
LabelDict[Label] = str(LabelOffset) LabelDict[Label] = str(LabelOffset)
if Item.startswith('UINT8'): if Item.startswith('UINT8'):
LabelOffset = LabelOffset + 1 LabelOffset = LabelOffset + 1

View File

@ -1918,7 +1918,7 @@ class DefaultStore():
if not self.DefaultStores or "0" in self.DefaultStores: if not self.DefaultStores or "0" in self.DefaultStores:
return "0",TAB_DEFAULT_STORES_DEFAULT return "0",TAB_DEFAULT_STORES_DEFAULT
else: else:
minvalue = min([int(value_str) for value_str in self.DefaultStores.keys()]) minvalue = min([int(value_str) for value_str in self.DefaultStores])
return (str(minvalue), self.DefaultStores[str(minvalue)]) return (str(minvalue), self.DefaultStores[str(minvalue)])
def GetMin(self,DefaultSIdList): def GetMin(self,DefaultSIdList):
if not DefaultSIdList: if not DefaultSIdList:

View File

@ -1,7 +1,7 @@
## @file ## @file
# This file is used to define common parsing related functions used in parsing INF/DEC/DSC process # This file is used to define common parsing related functions used in parsing INF/DEC/DSC process
# #
# Copyright (c) 2008 - 2014, Intel Corporation. All rights reserved.<BR> # Copyright (c) 2008 - 2018, Intel Corporation. All rights reserved.<BR>
# This program and the accompanying materials # This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License # are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at # which accompanies this distribution. The full text of the license may be found at
@ -37,16 +37,14 @@ def ParseDefineMacro2(Table, RecordSets, GlobalMacro):
# #
# Overrided by Global Macros # Overrided by Global Macros
# #
for Key in GlobalMacro.keys(): Macros.update(GlobalMacro)
Macros[Key] = GlobalMacro[Key]
# #
# Replace the Macros # Replace the Macros
# #
for Key in RecordSets.keys(): for Value in (v for v in RecordSets.values() if v):
if RecordSets[Key] != []: for Item in Value:
for Item in RecordSets[Key]: Item[0] = ReplaceMacro(Item[0], Macros)
Item[0] = ReplaceMacro(Item[0], Macros)
## ParseDefineMacro ## ParseDefineMacro
# #
@ -79,8 +77,7 @@ def ParseDefineMacro(Table, GlobalMacro):
# #
# Overrided by Global Macros # Overrided by Global Macros
# #
for Key in GlobalMacro.keys(): Macros.update(GlobalMacro)
Macros[Key] = GlobalMacro[Key]
# #
# Found all defined macro and replaced # Found all defined macro and replaced

View File

@ -1,7 +1,7 @@
## @file ## @file
# This file is used to define common string related functions used in parsing process # This file is used to define common string related functions used in parsing process
# #
# Copyright (c) 2007 - 2015, Intel Corporation. All rights reserved.<BR> # Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>
# This program and the accompanying materials # This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License # are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at # which accompanies this distribution. The full text of the license may be found at
@ -110,7 +110,7 @@ def GetSplitList(String, SplitStr=DataType.TAB_VALUE_SPLIT, MaxSplit= -1):
# @param Arch: The Arch to be added or merged # @param Arch: The Arch to be added or merged
# #
def MergeArches(Dict, Key, Arch): def MergeArches(Dict, Key, Arch):
if Key in Dict.keys(): if Key in Dict:
Dict[Key].append(Arch) Dict[Key].append(Arch)
else: else:
Dict[Key] = Arch.split() Dict[Key] = Arch.split()

View File

@ -6,7 +6,7 @@
# is pointed by *_*_*_VPD_TOOL_GUID in conf/tools_def.txt # is pointed by *_*_*_VPD_TOOL_GUID in conf/tools_def.txt
# #
# #
# Copyright (c) 2010 - 2016, Intel Corporation. All rights reserved.<BR> # Copyright (c) 2010 - 2018, Intel Corporation. All rights reserved.<BR>
# This program and the accompanying materials # This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License # are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at # which accompanies this distribution. The full text of the license may be found at
@ -107,7 +107,7 @@ class VpdInfoFile:
EdkLogger.error("VpdInfoFile", BuildToolError.PARAMETER_INVALID, EdkLogger.error("VpdInfoFile", BuildToolError.PARAMETER_INVALID,
"Invalid max datum size for VPD PCD %s.%s" % (Vpd.TokenSpaceGuidCName, Vpd.TokenCName)) "Invalid max datum size for VPD PCD %s.%s" % (Vpd.TokenSpaceGuidCName, Vpd.TokenCName))
if Vpd not in self._VpdArray.keys(): if Vpd not in self._VpdArray:
# #
# If there is no Vpd instance in dict, that imply this offset for a given SKU is a new one # If there is no Vpd instance in dict, that imply this offset for a given SKU is a new one
# #
@ -180,12 +180,12 @@ class VpdInfoFile:
if (TokenSpaceName, PcdTokenName) not in self._VpdInfo: if (TokenSpaceName, PcdTokenName) not in self._VpdInfo:
self._VpdInfo[(TokenSpaceName, PcdTokenName)] = [] self._VpdInfo[(TokenSpaceName, PcdTokenName)] = []
self._VpdInfo[(TokenSpaceName, PcdTokenName)].append((SkuId,Offset, Value)) self._VpdInfo[(TokenSpaceName, PcdTokenName)].append((SkuId,Offset, Value))
for VpdObject in self._VpdArray.keys(): for VpdObject in self._VpdArray:
VpdObjectTokenCName = VpdObject.TokenCName VpdObjectTokenCName = VpdObject.TokenCName
for PcdItem in GlobalData.MixedPcd: for PcdItem in GlobalData.MixedPcd:
if (VpdObject.TokenCName, VpdObject.TokenSpaceGuidCName) in GlobalData.MixedPcd[PcdItem]: if (VpdObject.TokenCName, VpdObject.TokenSpaceGuidCName) in GlobalData.MixedPcd[PcdItem]:
VpdObjectTokenCName = PcdItem[0] VpdObjectTokenCName = PcdItem[0]
for sku in VpdObject.SkuInfoList.keys(): for sku in VpdObject.SkuInfoList:
if VpdObject.TokenSpaceGuidCName == TokenSpaceName and VpdObjectTokenCName == PcdTokenName.strip() and sku == SkuId: if VpdObject.TokenSpaceGuidCName == TokenSpaceName and VpdObjectTokenCName == PcdTokenName.strip() and sku == SkuId:
if self._VpdArray[VpdObject][sku] == "*": if self._VpdArray[VpdObject][sku] == "*":
if Offset == "*": if Offset == "*":

View File

@ -1,7 +1,7 @@
## @file ## @file
# generate capsule # generate capsule
# #
# Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.<BR> # Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>
# #
# This program and the accompanying materials # This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License # are licensed and made available under the terms and conditions of the BSD License
@ -201,7 +201,7 @@ class Capsule (CapsuleClassObject) :
# @retval string Generated Capsule file path # @retval string Generated Capsule file path
# #
def GenCapsule(self): def GenCapsule(self):
if self.UiCapsuleName.upper() + 'cap' in GenFds.ImageBinDict.keys(): if self.UiCapsuleName.upper() + 'cap' in GenFds.ImageBinDict:
return GenFds.ImageBinDict[self.UiCapsuleName.upper() + 'cap'] return GenFds.ImageBinDict[self.UiCapsuleName.upper() + 'cap']
GenFdsGlobalVariable.InfLogger( "\nGenerate %s Capsule" %self.UiCapsuleName) GenFdsGlobalVariable.InfLogger( "\nGenerate %s Capsule" %self.UiCapsuleName)
@ -251,11 +251,11 @@ class Capsule (CapsuleClassObject) :
CapInfFile.writelines("[options]" + T_CHAR_LF) CapInfFile.writelines("[options]" + T_CHAR_LF)
for Item in self.TokensDict.keys(): for Item in self.TokensDict:
CapInfFile.writelines("EFI_" + \ CapInfFile.writelines("EFI_" + \
Item + \ Item + \
' = ' + \ ' = ' + \
self.TokensDict.get(Item) + \ self.TokensDict[Item] + \
T_CHAR_LF) T_CHAR_LF)
return CapInfFile return CapInfFile

View File

@ -1,7 +1,7 @@
## @file ## @file
# generate capsule # generate capsule
# #
# Copyright (c) 2007-2017, Intel Corporation. All rights reserved.<BR> # Copyright (c) 2007-2018, Intel Corporation. All rights reserved.<BR>
# #
# This program and the accompanying materials # This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License # are licensed and made available under the terms and conditions of the BSD License
@ -80,8 +80,8 @@ class CapsuleFv (CapsuleData):
# #
def GenCapsuleSubItem(self): def GenCapsuleSubItem(self):
if self.FvName.find('.fv') == -1: if self.FvName.find('.fv') == -1:
if self.FvName.upper() in GenFdsGlobalVariable.FdfParser.Profile.FvDict.keys(): if self.FvName.upper() in GenFdsGlobalVariable.FdfParser.Profile.FvDict:
FvObj = GenFdsGlobalVariable.FdfParser.Profile.FvDict.get(self.FvName.upper()) FvObj = GenFdsGlobalVariable.FdfParser.Profile.FvDict[self.FvName.upper()]
FdBuffer = StringIO.StringIO('') FdBuffer = StringIO.StringIO('')
FvObj.CapsuleName = self.CapsuleName FvObj.CapsuleName = self.CapsuleName
FvFile = FvObj.AddToBuffer(FdBuffer) FvFile = FvObj.AddToBuffer(FdBuffer)
@ -112,8 +112,8 @@ class CapsuleFd (CapsuleData):
# #
def GenCapsuleSubItem(self): def GenCapsuleSubItem(self):
if self.FdName.find('.fd') == -1: if self.FdName.find('.fd') == -1:
if self.FdName.upper() in GenFdsGlobalVariable.FdfParser.Profile.FdDict.keys(): if self.FdName.upper() in GenFdsGlobalVariable.FdfParser.Profile.FdDict:
FdObj = GenFdsGlobalVariable.FdfParser.Profile.FdDict.get(self.FdName.upper()) FdObj = GenFdsGlobalVariable.FdfParser.Profile.FdDict[self.FdName.upper()]
FdFile = FdObj.GenFd() FdFile = FdObj.GenFd()
return FdFile return FdFile
else: else:

View File

@ -1,7 +1,7 @@
## @file ## @file
# process FD generation # process FD generation
# #
# Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.<BR> # Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>
# #
# This program and the accompanying materials # This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License # are licensed and made available under the terms and conditions of the BSD License
@ -46,7 +46,7 @@ class FD(FDClassObject):
# @retval string Generated FD file name # @retval string Generated FD file name
# #
def GenFd (self, Flag = False): def GenFd (self, Flag = False):
if self.FdUiName.upper() + 'fd' in GenFds.ImageBinDict.keys(): if self.FdUiName.upper() + 'fd' in GenFds.ImageBinDict:
return GenFds.ImageBinDict[self.FdUiName.upper() + 'fd'] return GenFds.ImageBinDict[self.FdUiName.upper() + 'fd']
# #

View File

@ -3402,7 +3402,7 @@ class FdfParser:
if not self.__GetNextToken(): if not self.__GetNextToken():
raise Warning("expected FV name", self.FileName, self.CurrentLineNumber) raise Warning("expected FV name", self.FileName, self.CurrentLineNumber)
if self.__Token.upper() not in self.Profile.FvDict.keys(): if self.__Token.upper() not in self.Profile.FvDict:
raise Warning("FV name does not exist", self.FileName, self.CurrentLineNumber) raise Warning("FV name does not exist", self.FileName, self.CurrentLineNumber)
CapsuleFv = CapsuleData.CapsuleFv() CapsuleFv = CapsuleData.CapsuleFv()
@ -3436,7 +3436,7 @@ class FdfParser:
if not self.__GetNextToken(): if not self.__GetNextToken():
raise Warning("expected FD name", self.FileName, self.CurrentLineNumber) raise Warning("expected FD name", self.FileName, self.CurrentLineNumber)
if self.__Token.upper() not in self.Profile.FdDict.keys(): if self.__Token.upper() not in self.Profile.FdDict:
raise Warning("FD name does not exist", self.FileName, self.CurrentLineNumber) raise Warning("FD name does not exist", self.FileName, self.CurrentLineNumber)
CapsuleFd = CapsuleData.CapsuleFd() CapsuleFd = CapsuleData.CapsuleFd()
@ -4532,7 +4532,7 @@ class FdfParser:
def __GetCapInFd (self, FdName): def __GetCapInFd (self, FdName):
CapList = [] CapList = []
if FdName.upper() in self.Profile.FdDict.keys(): if FdName.upper() in self.Profile.FdDict:
FdObj = self.Profile.FdDict[FdName.upper()] FdObj = self.Profile.FdDict[FdName.upper()]
for elementRegion in FdObj.RegionList: for elementRegion in FdObj.RegionList:
if elementRegion.RegionType == 'CAPSULE': if elementRegion.RegionType == 'CAPSULE':
@ -4579,7 +4579,7 @@ class FdfParser:
def __GetFvInFd (self, FdName): def __GetFvInFd (self, FdName):
FvList = [] FvList = []
if FdName.upper() in self.Profile.FdDict.keys(): if FdName.upper() in self.Profile.FdDict:
FdObj = self.Profile.FdDict[FdName.upper()] FdObj = self.Profile.FdDict[FdName.upper()]
for elementRegion in FdObj.RegionList: for elementRegion in FdObj.RegionList:
if elementRegion.RegionType == 'FV': if elementRegion.RegionType == 'FV':
@ -4648,7 +4648,7 @@ class FdfParser:
# Check the cycle between FV and FD image # Check the cycle between FV and FD image
# #
MaxLength = len (self.Profile.FvDict) MaxLength = len (self.Profile.FvDict)
for FvName in self.Profile.FvDict.keys(): for FvName in self.Profile.FvDict:
LogStr = "\nCycle Reference Checking for FV: %s\n" % FvName LogStr = "\nCycle Reference Checking for FV: %s\n" % FvName
RefFvStack = [] RefFvStack = []
RefFvStack.append(FvName) RefFvStack.append(FvName)
@ -4658,7 +4658,7 @@ class FdfParser:
while RefFvStack != [] and Index < MaxLength: while RefFvStack != [] and Index < MaxLength:
Index = Index + 1 Index = Index + 1
FvNameFromStack = RefFvStack.pop() FvNameFromStack = RefFvStack.pop()
if FvNameFromStack.upper() in self.Profile.FvDict.keys(): if FvNameFromStack.upper() in self.Profile.FvDict:
FvObj = self.Profile.FvDict[FvNameFromStack.upper()] FvObj = self.Profile.FvDict[FvNameFromStack.upper()]
else: else:
continue continue
@ -4697,7 +4697,7 @@ class FdfParser:
# Check the cycle between Capsule and FD image # Check the cycle between Capsule and FD image
# #
MaxLength = len (self.Profile.CapsuleDict) MaxLength = len (self.Profile.CapsuleDict)
for CapName in self.Profile.CapsuleDict.keys(): for CapName in self.Profile.CapsuleDict:
# #
# Capsule image to be checked. # Capsule image to be checked.
# #
@ -4711,7 +4711,7 @@ class FdfParser:
while RefCapStack != [] and Index < MaxLength: while RefCapStack != [] and Index < MaxLength:
Index = Index + 1 Index = Index + 1
CapNameFromStack = RefCapStack.pop() CapNameFromStack = RefCapStack.pop()
if CapNameFromStack.upper() in self.Profile.CapsuleDict.keys(): if CapNameFromStack.upper() in self.Profile.CapsuleDict:
CapObj = self.Profile.CapsuleDict[CapNameFromStack.upper()] CapObj = self.Profile.CapsuleDict[CapNameFromStack.upper()]
else: else:
continue continue
@ -4756,7 +4756,7 @@ class FdfParser:
if RefFvName in FvAnalyzedList: if RefFvName in FvAnalyzedList:
continue continue
LogStr += "Capsule %s contains FV %s\n" % (CapNameFromStack, RefFvName) LogStr += "Capsule %s contains FV %s\n" % (CapNameFromStack, RefFvName)
if RefFvName.upper() in self.Profile.FvDict.keys(): if RefFvName.upper() in self.Profile.FvDict:
FvObj = self.Profile.FvDict[RefFvName.upper()] FvObj = self.Profile.FvDict[RefFvName.upper()]
else: else:
continue continue

View File

@ -1,7 +1,7 @@
## @file ## @file
# process FFS generation from FILE statement # process FFS generation from FILE statement
# #
# Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.<BR> # Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>
# #
# This program and the accompanying materials # This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License # are licensed and made available under the terms and conditions of the BSD License
@ -83,14 +83,14 @@ class FileStatement (FileStatementClassObject) :
SectionAlignments = None SectionAlignments = None
if self.FvName is not None : if self.FvName is not None :
Buffer = StringIO.StringIO('') Buffer = StringIO.StringIO('')
if self.FvName.upper() not in GenFdsGlobalVariable.FdfParser.Profile.FvDict.keys(): if self.FvName.upper() not in GenFdsGlobalVariable.FdfParser.Profile.FvDict:
EdkLogger.error("GenFds", GENFDS_ERROR, "FV (%s) is NOT described in FDF file!" % (self.FvName)) EdkLogger.error("GenFds", GENFDS_ERROR, "FV (%s) is NOT described in FDF file!" % (self.FvName))
Fv = GenFdsGlobalVariable.FdfParser.Profile.FvDict.get(self.FvName.upper()) Fv = GenFdsGlobalVariable.FdfParser.Profile.FvDict.get(self.FvName.upper())
FileName = Fv.AddToBuffer(Buffer) FileName = Fv.AddToBuffer(Buffer)
SectionFiles = [FileName] SectionFiles = [FileName]
elif self.FdName is not None: elif self.FdName is not None:
if self.FdName.upper() not in GenFdsGlobalVariable.FdfParser.Profile.FdDict.keys(): if self.FdName.upper() not in GenFdsGlobalVariable.FdfParser.Profile.FdDict:
EdkLogger.error("GenFds", GENFDS_ERROR, "FD (%s) is NOT described in FDF file!" % (self.FdName)) EdkLogger.error("GenFds", GENFDS_ERROR, "FD (%s) is NOT described in FDF file!" % (self.FdName))
Fd = GenFdsGlobalVariable.FdfParser.Profile.FdDict.get(self.FdName.upper()) Fd = GenFdsGlobalVariable.FdfParser.Profile.FdDict.get(self.FdName.upper())
FileName = Fd.GenFd() FileName = Fd.GenFd()

View File

@ -613,7 +613,7 @@ class FfsInfStatement(FfsInfStatementClassObject):
# the file name FILE_GUIDmodule.inf, then PlatformDataBase.Modules use FILE_GUIDmodule.inf as key, # the file name FILE_GUIDmodule.inf, then PlatformDataBase.Modules use FILE_GUIDmodule.inf as key,
# but the path (self.MetaFile.Path) is the real path # but the path (self.MetaFile.Path) is the real path
# #
for key in PlatformDataBase.Modules.keys(): for key in PlatformDataBase.Modules:
if InfFileKey == str((PlatformDataBase.Modules[key]).MetaFile.Path): if InfFileKey == str((PlatformDataBase.Modules[key]).MetaFile.Path):
DscArchList.append (Arch) DscArchList.append (Arch)
break break

View File

@ -70,7 +70,7 @@ class FV (FvClassObject):
# #
def AddToBuffer (self, Buffer, BaseAddress=None, BlockSize= None, BlockNum=None, ErasePloarity='1', VtfDict=None, MacroDict = {}, Flag=False) : def AddToBuffer (self, Buffer, BaseAddress=None, BlockSize= None, BlockNum=None, ErasePloarity='1', VtfDict=None, MacroDict = {}, Flag=False) :
if BaseAddress is None and self.UiFvName.upper() + 'fv' in GenFds.ImageBinDict.keys(): if BaseAddress is None and self.UiFvName.upper() + 'fv' in GenFds.ImageBinDict:
return GenFds.ImageBinDict[self.UiFvName.upper() + 'fv'] return GenFds.ImageBinDict[self.UiFvName.upper() + 'fv']
# #
@ -78,14 +78,13 @@ class FV (FvClassObject):
# If yes, return error. Doesn't support FV in Capsule image is also in FD flash region. # If yes, return error. Doesn't support FV in Capsule image is also in FD flash region.
# #
if self.CapsuleName is not None: if self.CapsuleName is not None:
for FdName in GenFdsGlobalVariable.FdfParser.Profile.FdDict.keys(): for FdObj in GenFdsGlobalVariable.FdfParser.Profile.FdDict.values():
FdObj = GenFdsGlobalVariable.FdfParser.Profile.FdDict[FdName]
for RegionObj in FdObj.RegionList: for RegionObj in FdObj.RegionList:
if RegionObj.RegionType == 'FV': if RegionObj.RegionType == 'FV':
for RegionData in RegionObj.RegionDataList: for RegionData in RegionObj.RegionDataList:
if RegionData.endswith(".fv"): if RegionData.endswith(".fv"):
continue continue
elif RegionData.upper() + 'fv' in GenFds.ImageBinDict.keys(): elif RegionData.upper() + 'fv' in GenFds.ImageBinDict:
continue continue
elif self.UiFvName.upper() == RegionData.upper(): elif self.UiFvName.upper() == RegionData.upper():
GenFdsGlobalVariable.ErrorLogger("Capsule %s in FD region can't contain a FV %s in FD region." % (self.CapsuleName, self.UiFvName.upper())) GenFdsGlobalVariable.ErrorLogger("Capsule %s in FD region can't contain a FV %s in FD region." % (self.CapsuleName, self.UiFvName.upper()))
@ -235,8 +234,7 @@ class FV (FvClassObject):
if self.BlockSizeList: if self.BlockSizeList:
return True return True
for FdName in GenFdsGlobalVariable.FdfParser.Profile.FdDict.keys(): for FdObj in GenFdsGlobalVariable.FdfParser.Profile.FdDict.values():
FdObj = GenFdsGlobalVariable.FdfParser.Profile.FdDict[FdName]
for RegionObj in FdObj.RegionList: for RegionObj in FdObj.RegionList:
if RegionObj.RegionType != 'FV': if RegionObj.RegionType != 'FV':
continue continue
@ -441,7 +439,7 @@ class FV (FvClassObject):
# Add [Files] # Add [Files]
# #
self.FvInfFile.writelines("[files]" + T_CHAR_LF) self.FvInfFile.writelines("[files]" + T_CHAR_LF)
if VtfDict is not None and self.UiFvName in VtfDict.keys(): if VtfDict is not None and self.UiFvName in VtfDict:
self.FvInfFile.writelines("EFI_FILE_NAME = " + \ self.FvInfFile.writelines("EFI_FILE_NAME = " + \
VtfDict.get(self.UiFvName) + \ VtfDict[self.UiFvName] + \
T_CHAR_LF) T_CHAR_LF)

View File

@ -92,7 +92,7 @@ def main():
else: else:
Workspace = os.path.normcase(Options.Workspace) Workspace = os.path.normcase(Options.Workspace)
GenFdsGlobalVariable.WorkSpaceDir = Workspace GenFdsGlobalVariable.WorkSpaceDir = Workspace
if 'EDK_SOURCE' in os.environ.keys(): if 'EDK_SOURCE' in os.environ:
GenFdsGlobalVariable.EdkSourceDir = os.path.normcase(os.environ['EDK_SOURCE']) GenFdsGlobalVariable.EdkSourceDir = os.path.normcase(os.environ['EDK_SOURCE'])
if (Options.debug): if (Options.debug):
GenFdsGlobalVariable.VerboseLogger("Using Workspace:" + Workspace) GenFdsGlobalVariable.VerboseLogger("Using Workspace:" + Workspace)
@ -156,7 +156,7 @@ def main():
# This also handles someone specifying the Conf directory in the workspace. Using --conf=Conf # This also handles someone specifying the Conf directory in the workspace. Using --conf=Conf
ConfDirectoryPath = os.path.join(GenFdsGlobalVariable.WorkSpaceDir, ConfDirectoryPath) ConfDirectoryPath = os.path.join(GenFdsGlobalVariable.WorkSpaceDir, ConfDirectoryPath)
else: else:
if "CONF_PATH" in os.environ.keys(): if "CONF_PATH" in os.environ:
ConfDirectoryPath = os.path.normcase(os.environ["CONF_PATH"]) ConfDirectoryPath = os.path.normcase(os.environ["CONF_PATH"])
else: else:
# Get standard WORKSPACE/Conf, use the absolute path to the WORKSPACE/Conf # Get standard WORKSPACE/Conf, use the absolute path to the WORKSPACE/Conf
@ -216,11 +216,11 @@ def main():
os.environ["WORKSPACE"] = Workspace os.environ["WORKSPACE"] = Workspace
# Use the -t and -b option as gGlobalDefines's TOOLCHAIN and TARGET if they are not defined # Use the -t and -b option as gGlobalDefines's TOOLCHAIN and TARGET if they are not defined
if "TARGET" not in GlobalData.gGlobalDefines.keys(): if "TARGET" not in GlobalData.gGlobalDefines:
GlobalData.gGlobalDefines["TARGET"] = GenFdsGlobalVariable.TargetName GlobalData.gGlobalDefines["TARGET"] = GenFdsGlobalVariable.TargetName
if "TOOLCHAIN" not in GlobalData.gGlobalDefines.keys(): if "TOOLCHAIN" not in GlobalData.gGlobalDefines:
GlobalData.gGlobalDefines["TOOLCHAIN"] = GenFdsGlobalVariable.ToolChainTag GlobalData.gGlobalDefines["TOOLCHAIN"] = GenFdsGlobalVariable.ToolChainTag
if "TOOL_CHAIN_TAG" not in GlobalData.gGlobalDefines.keys(): if "TOOL_CHAIN_TAG" not in GlobalData.gGlobalDefines:
GlobalData.gGlobalDefines['TOOL_CHAIN_TAG'] = GenFdsGlobalVariable.ToolChainTag GlobalData.gGlobalDefines['TOOL_CHAIN_TAG'] = GenFdsGlobalVariable.ToolChainTag
"""call Workspace build create database""" """call Workspace build create database"""
@ -278,21 +278,21 @@ def main():
EdkLogger.error("GenFds", FORMAT_NOT_SUPPORTED, "Cycle Reference Detected in FDF file") EdkLogger.error("GenFds", FORMAT_NOT_SUPPORTED, "Cycle Reference Detected in FDF file")
if (Options.uiFdName) : if (Options.uiFdName) :
if Options.uiFdName.upper() in FdfParserObj.Profile.FdDict.keys(): if Options.uiFdName.upper() in FdfParserObj.Profile.FdDict:
GenFds.OnlyGenerateThisFd = Options.uiFdName GenFds.OnlyGenerateThisFd = Options.uiFdName
else: else:
EdkLogger.error("GenFds", OPTION_VALUE_INVALID, EdkLogger.error("GenFds", OPTION_VALUE_INVALID,
"No such an FD in FDF file: %s" % Options.uiFdName) "No such an FD in FDF file: %s" % Options.uiFdName)
if (Options.uiFvName) : if (Options.uiFvName) :
if Options.uiFvName.upper() in FdfParserObj.Profile.FvDict.keys(): if Options.uiFvName.upper() in FdfParserObj.Profile.FvDict:
GenFds.OnlyGenerateThisFv = Options.uiFvName GenFds.OnlyGenerateThisFv = Options.uiFvName
else: else:
EdkLogger.error("GenFds", OPTION_VALUE_INVALID, EdkLogger.error("GenFds", OPTION_VALUE_INVALID,
"No such an FV in FDF file: %s" % Options.uiFvName) "No such an FV in FDF file: %s" % Options.uiFvName)
if (Options.uiCapName) : if (Options.uiCapName) :
if Options.uiCapName.upper() in FdfParserObj.Profile.CapsuleDict.keys(): if Options.uiCapName.upper() in FdfParserObj.Profile.CapsuleDict:
GenFds.OnlyGenerateThisCap = Options.uiCapName GenFds.OnlyGenerateThisCap = Options.uiCapName
else: else:
EdkLogger.error("GenFds", OPTION_VALUE_INVALID, EdkLogger.error("GenFds", OPTION_VALUE_INVALID,
@ -388,7 +388,7 @@ def FindExtendTool(KeyStringList, CurrentArchList, NameGuid):
KeyStringList.append(Target + '_' + ToolChain + '_' + Arch) KeyStringList.append(Target + '_' + ToolChain + '_' + Arch)
if GenFdsGlobalVariable.GuidToolDefinition: if GenFdsGlobalVariable.GuidToolDefinition:
if NameGuid in GenFdsGlobalVariable.GuidToolDefinition.keys(): if NameGuid in GenFdsGlobalVariable.GuidToolDefinition:
return GenFdsGlobalVariable.GuidToolDefinition[NameGuid] return GenFdsGlobalVariable.GuidToolDefinition[NameGuid]
ToolDefinition = ToolDefClassObject.ToolDefDict(GenFdsGlobalVariable.ConfDir).ToolsDefTxtDictionary ToolDefinition = ToolDefClassObject.ToolDefDict(GenFdsGlobalVariable.ConfDir).ToolsDefTxtDictionary
@ -450,10 +450,10 @@ def FindExtendTool(KeyStringList, CurrentArchList, NameGuid):
if Key in KeyStringList and KeyList[4] == 'GUID': if Key in KeyStringList and KeyList[4] == 'GUID':
ToolPathKey = Key + '_' + KeyList[3] + '_PATH' ToolPathKey = Key + '_' + KeyList[3] + '_PATH'
ToolOptionKey = Key + '_' + KeyList[3] + '_FLAGS' ToolOptionKey = Key + '_' + KeyList[3] + '_FLAGS'
if ToolPathKey in BuildOption.keys(): if ToolPathKey in BuildOption:
ToolPathTmp = BuildOption.get(ToolPathKey) ToolPathTmp = BuildOption[ToolPathKey]
if ToolOptionKey in BuildOption.keys(): if ToolOptionKey in BuildOption:
ToolOption = BuildOption.get(ToolOptionKey) ToolOption = BuildOption[ToolOptionKey]
GenFdsGlobalVariable.GuidToolDefinition[NameGuid] = (ToolPathTmp, ToolOption) GenFdsGlobalVariable.GuidToolDefinition[NameGuid] = (ToolPathTmp, ToolOption)
return ToolPathTmp, ToolOption return ToolPathTmp, ToolOption
@ -522,63 +522,56 @@ class GenFds :
GenFdsGlobalVariable.SetDir ('', FdfParser, WorkSpace, ArchList) GenFdsGlobalVariable.SetDir ('', FdfParser, WorkSpace, ArchList)
GenFdsGlobalVariable.VerboseLogger(" Generate all Fd images and their required FV and Capsule images!") GenFdsGlobalVariable.VerboseLogger(" Generate all Fd images and their required FV and Capsule images!")
if GenFds.OnlyGenerateThisCap is not None and GenFds.OnlyGenerateThisCap.upper() in GenFdsGlobalVariable.FdfParser.Profile.CapsuleDict.keys(): if GenFds.OnlyGenerateThisCap is not None and GenFds.OnlyGenerateThisCap.upper() in GenFdsGlobalVariable.FdfParser.Profile.CapsuleDict:
CapsuleObj = GenFdsGlobalVariable.FdfParser.Profile.CapsuleDict.get(GenFds.OnlyGenerateThisCap.upper()) CapsuleObj = GenFdsGlobalVariable.FdfParser.Profile.CapsuleDict[GenFds.OnlyGenerateThisCap.upper()]
if CapsuleObj is not None: if CapsuleObj is not None:
CapsuleObj.GenCapsule() CapsuleObj.GenCapsule()
return return
if GenFds.OnlyGenerateThisFd is not None and GenFds.OnlyGenerateThisFd.upper() in GenFdsGlobalVariable.FdfParser.Profile.FdDict.keys(): if GenFds.OnlyGenerateThisFd is not None and GenFds.OnlyGenerateThisFd.upper() in GenFdsGlobalVariable.FdfParser.Profile.FdDict:
FdObj = GenFdsGlobalVariable.FdfParser.Profile.FdDict.get(GenFds.OnlyGenerateThisFd.upper()) FdObj = GenFdsGlobalVariable.FdfParser.Profile.FdDict[GenFds.OnlyGenerateThisFd.upper()]
if FdObj is not None: if FdObj is not None:
FdObj.GenFd() FdObj.GenFd()
return return
elif GenFds.OnlyGenerateThisFd is None and GenFds.OnlyGenerateThisFv is None: elif GenFds.OnlyGenerateThisFd is None and GenFds.OnlyGenerateThisFv is None:
for FdName in GenFdsGlobalVariable.FdfParser.Profile.FdDict.keys(): for FdObj in GenFdsGlobalVariable.FdfParser.Profile.FdDict.values():
FdObj = GenFdsGlobalVariable.FdfParser.Profile.FdDict[FdName]
FdObj.GenFd() FdObj.GenFd()
GenFdsGlobalVariable.VerboseLogger("\n Generate other FV images! ") GenFdsGlobalVariable.VerboseLogger("\n Generate other FV images! ")
if GenFds.OnlyGenerateThisFv is not None and GenFds.OnlyGenerateThisFv.upper() in GenFdsGlobalVariable.FdfParser.Profile.FvDict.keys(): if GenFds.OnlyGenerateThisFv is not None and GenFds.OnlyGenerateThisFv.upper() in GenFdsGlobalVariable.FdfParser.Profile.FvDict:
FvObj = GenFdsGlobalVariable.FdfParser.Profile.FvDict.get(GenFds.OnlyGenerateThisFv.upper()) FvObj = GenFdsGlobalVariable.FdfParser.Profile.FvDict[GenFds.OnlyGenerateThisFv.upper()]
if FvObj is not None: if FvObj is not None:
Buffer = StringIO.StringIO() Buffer = StringIO.StringIO()
FvObj.AddToBuffer(Buffer) FvObj.AddToBuffer(Buffer)
Buffer.close() Buffer.close()
return return
elif GenFds.OnlyGenerateThisFv is None: elif GenFds.OnlyGenerateThisFv is None:
for FvName in GenFdsGlobalVariable.FdfParser.Profile.FvDict.keys(): for FvObj in GenFdsGlobalVariable.FdfParser.Profile.FvDict.values():
Buffer = StringIO.StringIO('') Buffer = StringIO.StringIO('')
FvObj = GenFdsGlobalVariable.FdfParser.Profile.FvDict[FvName]
FvObj.AddToBuffer(Buffer) FvObj.AddToBuffer(Buffer)
Buffer.close() Buffer.close()
if GenFds.OnlyGenerateThisFv is None and GenFds.OnlyGenerateThisFd is None and GenFds.OnlyGenerateThisCap is None: if GenFds.OnlyGenerateThisFv is None and GenFds.OnlyGenerateThisFd is None and GenFds.OnlyGenerateThisCap is None:
if GenFdsGlobalVariable.FdfParser.Profile.CapsuleDict != {}: if GenFdsGlobalVariable.FdfParser.Profile.CapsuleDict != {}:
GenFdsGlobalVariable.VerboseLogger("\n Generate other Capsule images!") GenFdsGlobalVariable.VerboseLogger("\n Generate other Capsule images!")
for CapsuleName in GenFdsGlobalVariable.FdfParser.Profile.CapsuleDict.keys(): for CapsuleObj in GenFdsGlobalVariable.FdfParser.Profile.CapsuleDict.values():
CapsuleObj = GenFdsGlobalVariable.FdfParser.Profile.CapsuleDict[CapsuleName]
CapsuleObj.GenCapsule() CapsuleObj.GenCapsule()
if GenFdsGlobalVariable.FdfParser.Profile.OptRomDict != {}: if GenFdsGlobalVariable.FdfParser.Profile.OptRomDict != {}:
GenFdsGlobalVariable.VerboseLogger("\n Generate all Option ROM!") GenFdsGlobalVariable.VerboseLogger("\n Generate all Option ROM!")
for DriverName in GenFdsGlobalVariable.FdfParser.Profile.OptRomDict.keys(): for OptRomObj in GenFdsGlobalVariable.FdfParser.Profile.OptRomDict.values():
OptRomObj = GenFdsGlobalVariable.FdfParser.Profile.OptRomDict[DriverName]
OptRomObj.AddToBuffer(None) OptRomObj.AddToBuffer(None)
@staticmethod @staticmethod
def GenFfsMakefile(OutputDir, FdfParser, WorkSpace, ArchList, GlobalData): def GenFfsMakefile(OutputDir, FdfParser, WorkSpace, ArchList, GlobalData):
GenFdsGlobalVariable.SetEnv(FdfParser, WorkSpace, ArchList, GlobalData) GenFdsGlobalVariable.SetEnv(FdfParser, WorkSpace, ArchList, GlobalData)
for FdName in GenFdsGlobalVariable.FdfParser.Profile.FdDict.keys(): for FdObj in GenFdsGlobalVariable.FdfParser.Profile.FdDict.values():
FdObj = GenFdsGlobalVariable.FdfParser.Profile.FdDict[FdName]
FdObj.GenFd(Flag=True) FdObj.GenFd(Flag=True)
for FvName in GenFdsGlobalVariable.FdfParser.Profile.FvDict.keys(): for FvObj in GenFdsGlobalVariable.FdfParser.Profile.FvDict.values():
FvObj = GenFdsGlobalVariable.FdfParser.Profile.FvDict[FvName]
FvObj.AddToBuffer(Buffer=None, Flag=True) FvObj.AddToBuffer(Buffer=None, Flag=True)
if GenFdsGlobalVariable.FdfParser.Profile.OptRomDict != {}: if GenFdsGlobalVariable.FdfParser.Profile.OptRomDict != {}:
for DriverName in GenFdsGlobalVariable.FdfParser.Profile.OptRomDict.keys(): for OptRomObj in GenFdsGlobalVariable.FdfParser.Profile.OptRomDict.values():
OptRomObj = GenFdsGlobalVariable.FdfParser.Profile.OptRomDict[DriverName]
OptRomObj.AddToBuffer(Buffer=None, Flag=True) OptRomObj.AddToBuffer(Buffer=None, Flag=True)
return GenFdsGlobalVariable.FfsCmdDict return GenFdsGlobalVariable.FfsCmdDict
@ -591,7 +584,7 @@ class GenFds :
def GetFvBlockSize(FvObj): def GetFvBlockSize(FvObj):
DefaultBlockSize = 0x1 DefaultBlockSize = 0x1
FdObj = None FdObj = None
if GenFds.OnlyGenerateThisFd is not None and GenFds.OnlyGenerateThisFd.upper() in GenFdsGlobalVariable.FdfParser.Profile.FdDict.keys(): if GenFds.OnlyGenerateThisFd is not None and GenFds.OnlyGenerateThisFd.upper() in GenFdsGlobalVariable.FdfParser.Profile.FdDict:
FdObj = GenFdsGlobalVariable.FdfParser.Profile.FdDict[GenFds.OnlyGenerateThisFd.upper()] FdObj = GenFdsGlobalVariable.FdfParser.Profile.FdDict[GenFds.OnlyGenerateThisFd.upper()]
if FdObj is None: if FdObj is None:
for ElementFd in GenFdsGlobalVariable.FdfParser.Profile.FdDict.values(): for ElementFd in GenFdsGlobalVariable.FdfParser.Profile.FdDict.values():

View File

@ -549,7 +549,7 @@ class GenFdsGlobalVariable:
GenFdsGlobalVariable.DebugLogger(EdkLogger.DEBUG_5, "%s needs update because of newer %s" % (Output, Input)) GenFdsGlobalVariable.DebugLogger(EdkLogger.DEBUG_5, "%s needs update because of newer %s" % (Output, Input))
if MakefilePath: if MakefilePath:
if (tuple(Cmd),tuple(GenFdsGlobalVariable.SecCmdList),tuple(GenFdsGlobalVariable.CopyList)) not in GenFdsGlobalVariable.FfsCmdDict.keys(): if (tuple(Cmd),tuple(GenFdsGlobalVariable.SecCmdList),tuple(GenFdsGlobalVariable.CopyList)) not in GenFdsGlobalVariable.FfsCmdDict:
GenFdsGlobalVariable.FfsCmdDict[tuple(Cmd), tuple(GenFdsGlobalVariable.SecCmdList), tuple(GenFdsGlobalVariable.CopyList)] = MakefilePath GenFdsGlobalVariable.FfsCmdDict[tuple(Cmd), tuple(GenFdsGlobalVariable.SecCmdList), tuple(GenFdsGlobalVariable.CopyList)] = MakefilePath
GenFdsGlobalVariable.SecCmdList = [] GenFdsGlobalVariable.SecCmdList = []
GenFdsGlobalVariable.CopyList = [] GenFdsGlobalVariable.CopyList = []
@ -779,7 +779,7 @@ class GenFdsGlobalVariable:
if MacroDict is not None and len (MacroDict) != 0: if MacroDict is not None and len (MacroDict) != 0:
Dict.update(MacroDict) Dict.update(MacroDict)
for key in Dict.keys(): for key in Dict:
if Str.find(key) >= 0 : if Str.find(key) >= 0 :
Str = Str.replace (key, Dict[key]) Str = Str.replace (key, Dict[key])

View File

@ -1,7 +1,7 @@
## @file ## @file
# process FD Region generation # process FD Region generation
# #
# Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.<BR> # Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>
# #
# This program and the accompanying materials # This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License # are licensed and made available under the terms and conditions of the BSD License
@ -102,7 +102,7 @@ class Region(RegionClassObject):
EdkLogger.error("GenFds", FILE_NOT_FOUND, ExtraData=RegionData) EdkLogger.error("GenFds", FILE_NOT_FOUND, ExtraData=RegionData)
FileName = RegionData FileName = RegionData
elif RegionData.upper() + 'fv' in ImageBinDict.keys(): elif RegionData.upper() + 'fv' in ImageBinDict:
if not Flag: if not Flag:
GenFdsGlobalVariable.InfLogger(' Region Name = FV') GenFdsGlobalVariable.InfLogger(' Region Name = FV')
FileName = ImageBinDict[RegionData.upper() + 'fv'] FileName = ImageBinDict[RegionData.upper() + 'fv']
@ -111,8 +111,8 @@ class Region(RegionClassObject):
# Generate FvImage. # Generate FvImage.
# #
FvObj = None FvObj = None
if RegionData.upper() in GenFdsGlobalVariable.FdfParser.Profile.FvDict.keys(): if RegionData.upper() in GenFdsGlobalVariable.FdfParser.Profile.FvDict:
FvObj = GenFdsGlobalVariable.FdfParser.Profile.FvDict.get(RegionData.upper()) FvObj = GenFdsGlobalVariable.FdfParser.Profile.FvDict[RegionData.upper()]
if FvObj is not None : if FvObj is not None :
if not Flag: if not Flag:
@ -182,7 +182,7 @@ class Region(RegionClassObject):
EdkLogger.error("GenFds", FILE_NOT_FOUND, ExtraData=RegionData) EdkLogger.error("GenFds", FILE_NOT_FOUND, ExtraData=RegionData)
FileName = RegionData FileName = RegionData
elif RegionData.upper() + 'cap' in ImageBinDict.keys(): elif RegionData.upper() + 'cap' in ImageBinDict:
GenFdsGlobalVariable.InfLogger(' Region Name = CAPSULE') GenFdsGlobalVariable.InfLogger(' Region Name = CAPSULE')
FileName = ImageBinDict[RegionData.upper() + 'cap'] FileName = ImageBinDict[RegionData.upper() + 'cap']
else: else:
@ -190,7 +190,7 @@ class Region(RegionClassObject):
# Generate Capsule image and Put it into FD buffer # Generate Capsule image and Put it into FD buffer
# #
CapsuleObj = None CapsuleObj = None
if RegionData.upper() in GenFdsGlobalVariable.FdfParser.Profile.CapsuleDict.keys(): if RegionData.upper() in GenFdsGlobalVariable.FdfParser.Profile.CapsuleDict:
CapsuleObj = GenFdsGlobalVariable.FdfParser.Profile.CapsuleDict[RegionData.upper()] CapsuleObj = GenFdsGlobalVariable.FdfParser.Profile.CapsuleDict[RegionData.upper()]
if CapsuleObj is not None : if CapsuleObj is not None :

View File

@ -1,7 +1,7 @@
## @file ## @file
# Target Tool Parser # Target Tool Parser
# #
# 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 # This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License # are licensed and made available under the terms and conditions of the BSD License
@ -65,7 +65,7 @@ class TargetTool():
LineList = Line.split(KeySplitCharacter,1) LineList = Line.split(KeySplitCharacter,1)
if len(LineList) >= 2: if len(LineList) >= 2:
Key = LineList[0].strip() Key = LineList[0].strip()
if Key.startswith(CommentCharacter) == False and Key in self.TargetTxtDictionary.keys(): if Key.startswith(CommentCharacter) == False and Key in self.TargetTxtDictionary:
if Key == TAB_TAT_DEFINES_ACTIVE_PLATFORM or Key == TAB_TAT_DEFINES_TOOL_CHAIN_CONF \ if Key == TAB_TAT_DEFINES_ACTIVE_PLATFORM or Key == TAB_TAT_DEFINES_TOOL_CHAIN_CONF \
or Key == TAB_TAT_DEFINES_MAX_CONCURRENT_THREAD_NUMBER \ or Key == TAB_TAT_DEFINES_MAX_CONCURRENT_THREAD_NUMBER \
or Key == TAB_TAT_DEFINES_ACTIVE_MODULE: or Key == TAB_TAT_DEFINES_ACTIVE_MODULE:
@ -105,7 +105,7 @@ class TargetTool():
LineList = Line.split(KeySplitCharacter,1) LineList = Line.split(KeySplitCharacter,1)
if len(LineList) >= 2: if len(LineList) >= 2:
Key = LineList[0].strip() Key = LineList[0].strip()
if Key.startswith(CommentCharacter) == False and Key in self.TargetTxtDictionary.keys(): if Key.startswith(CommentCharacter) == False and Key in self.TargetTxtDictionary:
if Key not in existKeys: if Key not in existKeys:
existKeys.append(Key) existKeys.append(Key)
else: else:
@ -118,7 +118,7 @@ class TargetTool():
if ret is not None: if ret is not None:
Line = ret Line = ret
fw.write(Line) fw.write(Line)
for key in self.TargetTxtDictionary.keys(): for key in self.TargetTxtDictionary:
if key not in existKeys: if key not in existKeys:
print "Warning: %s does not exist in original configuration file" % key print "Warning: %s does not exist in original configuration file" % key
Line = GetConfigureKeyValue(self, key) Line = GetConfigureKeyValue(self, key)

View File

@ -788,10 +788,7 @@ class InfBuildData(ModuleBuildClassObject):
self._Includes.append(self._SourceOverridePath) self._Includes.append(self._SourceOverridePath)
Macros = self._Macros Macros = self._Macros
if 'PROCESSOR' in GlobalData.gEdkGlobal.keys(): Macros['PROCESSOR'] = GlobalData.gEdkGlobal.get('PROCESSOR', self._Arch)
Macros['PROCESSOR'] = GlobalData.gEdkGlobal['PROCESSOR']
else:
Macros['PROCESSOR'] = self._Arch
RecordList = self._RawData[MODEL_EFI_INCLUDE, self._Arch, self._Platform] RecordList = self._RawData[MODEL_EFI_INCLUDE, self._Arch, self._Platform]
for Record in RecordList: for Record in RecordList:
if Record[0].find('EDK_SOURCE') > -1: if Record[0].find('EDK_SOURCE') > -1:

View File

@ -1504,12 +1504,12 @@ class DscParser(MetaFileParser):
# Allow using system environment variables in path after !include # Allow using system environment variables in path after !include
# #
__IncludeMacros['WORKSPACE'] = GlobalData.gGlobalDefines['WORKSPACE'] __IncludeMacros['WORKSPACE'] = GlobalData.gGlobalDefines['WORKSPACE']
if "ECP_SOURCE" in GlobalData.gGlobalDefines.keys(): if "ECP_SOURCE" in GlobalData.gGlobalDefines:
__IncludeMacros['ECP_SOURCE'] = GlobalData.gGlobalDefines['ECP_SOURCE'] __IncludeMacros['ECP_SOURCE'] = GlobalData.gGlobalDefines['ECP_SOURCE']
# #
# During GenFds phase call DSC parser, will go into this branch. # During GenFds phase call DSC parser, will go into this branch.
# #
elif "ECP_SOURCE" in GlobalData.gCommandLineDefines.keys(): elif "ECP_SOURCE" in GlobalData.gCommandLineDefines:
__IncludeMacros['ECP_SOURCE'] = GlobalData.gCommandLineDefines['ECP_SOURCE'] __IncludeMacros['ECP_SOURCE'] = GlobalData.gCommandLineDefines['ECP_SOURCE']
__IncludeMacros['EFI_SOURCE'] = GlobalData.gGlobalDefines['EFI_SOURCE'] __IncludeMacros['EFI_SOURCE'] = GlobalData.gGlobalDefines['EFI_SOURCE']

View File

@ -1,7 +1,7 @@
## @file ## @file
# Common routines used by workspace # Common routines used by workspace
# #
# Copyright (c) 2012 - 2017, Intel Corporation. All rights reserved.<BR> # Copyright (c) 2012 - 2018, Intel Corporation. All rights reserved.<BR>
# This program and the accompanying materials # This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License # are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at # which accompanies this distribution. The full text of the license may be found at
@ -63,11 +63,11 @@ def GetDeclaredPcd(Platform, BuildDatabase, Arch, Target, Toolchain,additionalPk
PcdCName = Pcd[0] PcdCName = Pcd[0]
PcdTokenName = Pcd[1] PcdTokenName = Pcd[1]
if GlobalData.MixedPcd: if GlobalData.MixedPcd:
for PcdItem in GlobalData.MixedPcd.keys(): for PcdItem in GlobalData.MixedPcd:
if (PcdCName, PcdTokenName) in GlobalData.MixedPcd[PcdItem]: if (PcdCName, PcdTokenName) in GlobalData.MixedPcd[PcdItem]:
PcdCName = PcdItem[0] PcdCName = PcdItem[0]
break break
if (PcdCName, PcdTokenName) not in DecPcds.keys(): if (PcdCName, PcdTokenName) not in DecPcds:
DecPcds[PcdCName, PcdTokenName] = Pkg.Pcds[Pcd] DecPcds[PcdCName, PcdTokenName] = Pkg.Pcds[Pcd]
return DecPcds, GuidDict return DecPcds, GuidDict
@ -243,7 +243,7 @@ def _ResolveLibraryReference(Module, Platform):
for LibraryName in M.Libraries: for LibraryName in M.Libraries:
Library = Platform.LibraryClasses[LibraryName, ':dummy:'] Library = Platform.LibraryClasses[LibraryName, ':dummy:']
if Library is None: if Library is None:
for Key in Platform.LibraryClasses.data.keys(): for Key in Platform.LibraryClasses.data:
if LibraryName.upper() == Key.upper(): if LibraryName.upper() == Key.upper():
Library = Platform.LibraryClasses[Key, ':dummy:'] Library = Platform.LibraryClasses[Key, ':dummy:']
break break

View File

@ -838,7 +838,7 @@ class PcdReport(object):
for PcdItem in GlobalData.gConditionalPcds: for PcdItem in GlobalData.gConditionalPcds:
if '.' in PcdItem: if '.' in PcdItem:
(TokenSpaceGuidCName, TokenCName) = PcdItem.split('.') (TokenSpaceGuidCName, TokenCName) = PcdItem.split('.')
if (TokenCName, TokenSpaceGuidCName) in Pa.Platform.Pcds.keys(): if (TokenCName, TokenSpaceGuidCName) in Pa.Platform.Pcds:
Pcd = Pa.Platform.Pcds[(TokenCName, TokenSpaceGuidCName)] Pcd = Pa.Platform.Pcds[(TokenCName, TokenSpaceGuidCName)]
PcdList = self.ConditionalPcds.setdefault(Pcd.TokenSpaceGuidCName, {}).setdefault(Pcd.Type, []) PcdList = self.ConditionalPcds.setdefault(Pcd.TokenSpaceGuidCName, {}).setdefault(Pcd.Type, [])
if Pcd not in PcdList: if Pcd not in PcdList:
@ -1043,7 +1043,7 @@ class PcdReport(object):
DscMatch = (DscDefaultValue.strip() == PcdValue.strip()) DscMatch = (DscDefaultValue.strip() == PcdValue.strip())
IsStructure = False IsStructure = False
if GlobalData.gStructurePcd and (self.Arch in GlobalData.gStructurePcd.keys()) and ((Pcd.TokenCName, Pcd.TokenSpaceGuidCName) in GlobalData.gStructurePcd[self.Arch]): if GlobalData.gStructurePcd and (self.Arch in GlobalData.gStructurePcd) and ((Pcd.TokenCName, Pcd.TokenSpaceGuidCName) in GlobalData.gStructurePcd[self.Arch]):
IsStructure = True IsStructure = True
if TypeName in ('DYNVPD', 'DEXVPD'): if TypeName in ('DYNVPD', 'DEXVPD'):
SkuInfoList = Pcd.SkuInfoList SkuInfoList = Pcd.SkuInfoList

View File

@ -53,7 +53,7 @@ import Common.EdkLogger
import Common.GlobalData as GlobalData import Common.GlobalData as GlobalData
from GenFds.GenFds import GenFds from GenFds.GenFds import GenFds
from collections import OrderedDict from collections import OrderedDict,defaultdict
# Version and Copyright # Version and Copyright
VersionNumber = "0.60" + ' ' + gBUILD_VERSION VersionNumber = "0.60" + ' ' + gBUILD_VERSION
@ -524,8 +524,7 @@ class BuildTask:
BuildTask._Thread.acquire(True) BuildTask._Thread.acquire(True)
# start a new build thread # start a new build thread
Bo = BuildTask._ReadyQueue.keys()[0] Bo,Bt = BuildTask._ReadyQueue.popitem()
Bt = BuildTask._ReadyQueue.pop(Bo)
# move into running queue # move into running queue
BuildTask._RunningQueueLock.acquire() BuildTask._RunningQueueLock.acquire()
@ -1000,7 +999,7 @@ class Build():
GlobalData.gGlobalDefines['TOOL_CHAIN_TAG'] = self.ToolChainList[0] GlobalData.gGlobalDefines['TOOL_CHAIN_TAG'] = self.ToolChainList[0]
if self.ToolChainFamily: if self.ToolChainFamily:
GlobalData.gGlobalDefines['FAMILY'] = self.ToolChainFamily[0] GlobalData.gGlobalDefines['FAMILY'] = self.ToolChainFamily[0]
if 'PREBUILD' in GlobalData.gCommandLineDefines.keys(): if 'PREBUILD' in GlobalData.gCommandLineDefines:
self.Prebuild = GlobalData.gCommandLineDefines.get('PREBUILD') self.Prebuild = GlobalData.gCommandLineDefines.get('PREBUILD')
else: else:
self.Db.InitDatabase() self.Db.InitDatabase()
@ -1041,7 +1040,7 @@ class Build():
self.Prebuild += self.PassCommandOption(self.BuildTargetList, self.ArchList, self.ToolChainList, self.PlatformFile, self.Target) self.Prebuild += self.PassCommandOption(self.BuildTargetList, self.ArchList, self.ToolChainList, self.PlatformFile, self.Target)
def InitPostBuild(self): def InitPostBuild(self):
if 'POSTBUILD' in GlobalData.gCommandLineDefines.keys(): if 'POSTBUILD' in GlobalData.gCommandLineDefines:
self.Postbuild = GlobalData.gCommandLineDefines.get('POSTBUILD') self.Postbuild = GlobalData.gCommandLineDefines.get('POSTBUILD')
else: else:
Platform = self.Db._MapPlatform(str(self.PlatformFile)) Platform = self.Db._MapPlatform(str(self.PlatformFile))
@ -1524,7 +1523,7 @@ class Build():
# First get the XIP base address for FV map file. # First get the XIP base address for FV map file.
GuidPattern = re.compile("[-a-fA-F0-9]+") GuidPattern = re.compile("[-a-fA-F0-9]+")
GuidName = re.compile("\(GUID=[-a-fA-F0-9]+") GuidName = re.compile("\(GUID=[-a-fA-F0-9]+")
for FvName in Wa.FdfProfile.FvDict.keys(): for FvName in Wa.FdfProfile.FvDict:
FvMapBuffer = os.path.join(Wa.FvDir, FvName + '.Fv.map') FvMapBuffer = os.path.join(Wa.FvDir, FvName + '.Fv.map')
if not os.path.exists(FvMapBuffer): if not os.path.exists(FvMapBuffer):
continue continue
@ -1961,15 +1960,14 @@ class Build():
self._SaveMapFile (MapBuffer, Wa) self._SaveMapFile (MapBuffer, Wa)
def _GenFfsCmd(self): def _GenFfsCmd(self):
CmdListDict = {} # convert dictionary of Cmd:(Inf,Arch)
# to a new dictionary of (Inf,Arch):Cmd,Cmd,Cmd...
CmdSetDict = defaultdict(set)
GenFfsDict = GenFds.GenFfsMakefile('', GlobalData.gFdfParser, self, self.ArchList, GlobalData) GenFfsDict = GenFds.GenFfsMakefile('', GlobalData.gFdfParser, self, self.ArchList, GlobalData)
for Cmd in GenFfsDict: for Cmd in GenFfsDict:
tmpInf, tmpArch = GenFfsDict[Cmd] tmpInf, tmpArch = GenFfsDict[Cmd]
if (tmpInf, tmpArch) not in CmdListDict.keys(): CmdSetDict[tmpInf, tmpArch].add(Cmd)
CmdListDict[tmpInf, tmpArch] = [Cmd] return CmdSetDict
else:
CmdListDict[tmpInf, tmpArch].append(Cmd)
return CmdListDict
## Build a platform in multi-thread mode ## Build a platform in multi-thread mode
# #