when not needed, change from our custom TemplateString class to a simple list of strings. this is the .Append->.append changes and "".join(<splat>) changes. this parimary affects variables named AutoGenC and AutoGenH change GenMake dependency searching to not double search. remove unused sdict class
Cc: Liming Gao <liming....@intel.com> Cc: Yonghong Zhu <yonghong....@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Jaben Carsey <jaben.car...@intel.com> --- BaseTools/Source/Python/AutoGen/AutoGen.py | 38 +- BaseTools/Source/Python/AutoGen/GenC.py | 454 ++++++++++---------- BaseTools/Source/Python/AutoGen/GenMake.py | 59 ++- BaseTools/Source/Python/AutoGen/GenPcdDb.py | 48 +-- BaseTools/Source/Python/Common/Misc.py | 207 +-------- 5 files changed, 314 insertions(+), 492 deletions(-) diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py b/BaseTools/Source/Python/AutoGen/AutoGen.py index 9a57b9abd992..37398e42a9e1 100644 --- a/BaseTools/Source/Python/AutoGen/AutoGen.py +++ b/BaseTools/Source/Python/AutoGen/AutoGen.py @@ -3588,23 +3588,28 @@ class ModuleAutoGen(AutoGen): # @retval list The list of auto-generated file # def _GetAutoGenFileList(self): - UniStringAutoGenC = True - IdfStringAutoGenC = True - UniStringBinBuffer = StringIO() - IdfGenBinBuffer = StringIO() - if self.BuildType == 'UEFI_HII': - UniStringAutoGenC = False - IdfStringAutoGenC = False - if self._AutoGenFileList is None: + if not self._AutoGenFileList: + UniStringBinBuffer = StringIO() + IdfGenBinBuffer = StringIO() + if self.BuildType == 'UEFI_HII': + UniStringAutoGenC = False + IdfStringAutoGenC = False + else: + UniStringAutoGenC = True + IdfStringAutoGenC = True self._AutoGenFileList = {} - AutoGenC = TemplateString() - AutoGenH = TemplateString() - StringH = TemplateString() - StringIdf = TemplateString() + AutoGenC = [] + AutoGenH = [] + StringH = [] + StringIdf = [] GenC.CreateCode(self, AutoGenC, AutoGenH, StringH, UniStringAutoGenC, UniStringBinBuffer, StringIdf, IdfStringAutoGenC, IdfGenBinBuffer) # # AutoGen.c is generated if there are library classes in inf, or there are object files # + AutoGenC = "".join(AutoGenC) + AutoGenH = "".join(AutoGenH) + StringH = "".join(StringH) + StringIdf = "".join(StringIdf) if str(AutoGenC) != "" and (len(self.Module.LibraryClasses) > 0 or TAB_OBJECT_FILE in self.FileTypes): AutoFile = PathClass(gAutoGenCodeFileName, self.DebugDir) @@ -4269,10 +4274,7 @@ class ModuleAutoGen(AutoGen): if DepexExpresion: AsBuiltInfDict['depexsection_item'] = DepexExpresion - AsBuiltInf = TemplateString() - AsBuiltInf.Append(gAsBuiltInfHeaderString.Replace(AsBuiltInfDict)) - - SaveFileOnChange(os.path.join(self.OutputDir, self.Name + '.inf'), str(AsBuiltInf), False) + SaveFileOnChange(os.path.join(self.OutputDir, self.Name + '.inf'), gAsBuiltInfHeaderString.Replace(AsBuiltInfDict), False) self.IsAsBuiltInfCreated = True if GlobalData.gBinCacheDest: @@ -4317,7 +4319,7 @@ class ModuleAutoGen(AutoGen): File = path.join(root, f) shutil.copy2(File, self.OutputDir) if self.Name == "PcdPeim" or self.Name == "PcdDxe": - CreatePcdDatabaseCode(self, TemplateString(), TemplateString()) + CreatePcdDatabaseCode(self) return True return False @@ -4371,7 +4373,7 @@ class ModuleAutoGen(AutoGen): # Need to generate PcdDatabase even PcdDriver is binarymodule if self.IsBinaryModule and self.PcdIsDriver != '': - CreatePcdDatabaseCode(self, TemplateString(), TemplateString()) + CreatePcdDatabaseCode(self) return if self.IsBinaryModule: if self.IsLibrary: diff --git a/BaseTools/Source/Python/AutoGen/GenC.py b/BaseTools/Source/Python/AutoGen/GenC.py index 1be27d2b89e0..7f94fff382ce 100644 --- a/BaseTools/Source/Python/AutoGen/GenC.py +++ b/BaseTools/Source/Python/AutoGen/GenC.py @@ -802,7 +802,7 @@ def DynExPcdTokenNumberMapping(Info, AutoGenH): PcdExList.append(Pcd) if len(ExTokenCNameList) == 0: return - AutoGenH.Append('\n#define COMPAREGUID(Guid1, Guid2) (BOOLEAN)(*(CONST UINT64*)Guid1 == *(CONST UINT64*)Guid2 && *((CONST UINT64*)Guid1 + 1) == *((CONST UINT64*)Guid2 + 1))\n') + AutoGenH.append('\n#define COMPAREGUID(Guid1, Guid2) (BOOLEAN)(*(CONST UINT64*)Guid1 == *(CONST UINT64*)Guid2 && *((CONST UINT64*)Guid1 + 1) == *((CONST UINT64*)Guid2 + 1))\n') # AutoGen for each PCD listed in a [PcdEx] section of a Module/Lib INF file. # Auto generate a macro for each TokenName that takes a Guid pointer as a parameter. # Use the Guid pointer to see if it matches any of the token space GUIDs. @@ -821,14 +821,14 @@ def DynExPcdTokenNumberMapping(Info, AutoGenH): if Pcd.TokenCName == TokenCName: Index = Index + 1 if Index == 1: - AutoGenH.Append('\n#define __PCD_%s_ADDR_CMP(GuidPtr) (' % (RealTokenCName)) - AutoGenH.Append('\\\n (GuidPtr == &%s) ? _PCD_TOKEN_%s_%s:' + AutoGenH.append('\n#define __PCD_%s_ADDR_CMP(GuidPtr) (' % (RealTokenCName)) + AutoGenH.append('\\\n (GuidPtr == &%s) ? _PCD_TOKEN_%s_%s:' % (Pcd.TokenSpaceGuidCName, Pcd.TokenSpaceGuidCName, RealTokenCName)) else: - AutoGenH.Append('\\\n (GuidPtr == &%s) ? _PCD_TOKEN_%s_%s:' + AutoGenH.append('\\\n (GuidPtr == &%s) ? _PCD_TOKEN_%s_%s:' % (Pcd.TokenSpaceGuidCName, Pcd.TokenSpaceGuidCName, RealTokenCName)) if Index == Count: - AutoGenH.Append('0 \\\n )\n') + AutoGenH.append('0 \\\n )\n') TokenCNameList.add(TokenCName) TokenCNameList = set() @@ -846,20 +846,20 @@ def DynExPcdTokenNumberMapping(Info, AutoGenH): if Pcd.Type in PCD_DYNAMIC_EX_TYPE_SET and Pcd.TokenCName == TokenCName: Index = Index + 1 if Index == 1: - AutoGenH.Append('\n#define __PCD_%s_VAL_CMP(GuidPtr) (' % (RealTokenCName)) - AutoGenH.Append('\\\n (GuidPtr == NULL) ? 0:') - AutoGenH.Append('\\\n COMPAREGUID (GuidPtr, &%s) ? _PCD_TOKEN_%s_%s:' + AutoGenH.append('\n#define __PCD_%s_VAL_CMP(GuidPtr) (' % (RealTokenCName)) + AutoGenH.append('\\\n (GuidPtr == NULL) ? 0:') + AutoGenH.append('\\\n COMPAREGUID (GuidPtr, &%s) ? _PCD_TOKEN_%s_%s:' % (Pcd.TokenSpaceGuidCName, Pcd.TokenSpaceGuidCName, RealTokenCName)) else: - AutoGenH.Append('\\\n COMPAREGUID (GuidPtr, &%s) ? _PCD_TOKEN_%s_%s:' + AutoGenH.append('\\\n COMPAREGUID (GuidPtr, &%s) ? _PCD_TOKEN_%s_%s:' % (Pcd.TokenSpaceGuidCName, Pcd.TokenSpaceGuidCName, RealTokenCName)) if Index == Count: - AutoGenH.Append('0 \\\n )\n') + AutoGenH.append('0 \\\n )\n') # Autogen internal worker macro to compare GUIDs. Guid1 is a pointer to a GUID. # Guid2 is a C name for a GUID. Compare pointers first because optimizing compiler # can do this at build time on CONST GUID pointers and optimize away call to COMPAREGUID(). # COMPAREGUID() will only be used if the Guid passed in is local to the module. - AutoGenH.Append('#define _PCD_TOKEN_EX_%s(GuidPtr) __PCD_%s_ADDR_CMP(GuidPtr) ? __PCD_%s_ADDR_CMP(GuidPtr) : __PCD_%s_VAL_CMP(GuidPtr) \n' + AutoGenH.append('#define _PCD_TOKEN_EX_%s(GuidPtr) __PCD_%s_ADDR_CMP(GuidPtr) ? __PCD_%s_ADDR_CMP(GuidPtr) : __PCD_%s_VAL_CMP(GuidPtr) \n' % (RealTokenCName, RealTokenCName, RealTokenCName, RealTokenCName)) TokenCNameList.add(TokenCName) @@ -896,7 +896,7 @@ def CreateModulePcdCode(Info, AutoGenC, AutoGenH, Pcd): # Add TokenSpaceGuidValue value to PcdTokenName to discriminate the DynamicEx PCDs with # different Guids but same TokenCName PcdExTokenName = '_PCD_TOKEN_' + Pcd.TokenSpaceGuidCName + '_' + TokenCName - AutoGenH.Append('\n#define %s %dU\n' % (PcdExTokenName, TokenNumber)) + AutoGenH.append('\n#define %s %dU\n' % (PcdExTokenName, TokenNumber)) else: if (Pcd.TokenCName, Pcd.TokenSpaceGuidCName) not in PcdTokenNumber: # If one of the Source built modules listed in the DSC is not listed in FDF modules, @@ -915,7 +915,7 @@ def CreateModulePcdCode(Info, AutoGenC, AutoGenH, Pcd): ExtraData="[%s]" % str(Info)) else: TokenNumber = PcdTokenNumber[Pcd.TokenCName, Pcd.TokenSpaceGuidCName] - AutoGenH.Append('\n#define %s %dU\n' % (PcdTokenName, TokenNumber)) + AutoGenH.append('\n#define %s %dU\n' % (PcdTokenName, TokenNumber)) EdkLogger.debug(EdkLogger.DEBUG_3, "Creating code for " + TokenCName + "." + Pcd.TokenSpaceGuidCName) if Pcd.Type not in gItemTypeStringDatabase: @@ -946,26 +946,26 @@ def CreateModulePcdCode(Info, AutoGenC, AutoGenH, Pcd): # If only PcdToken and PcdGet/Set used in all Pcds with different CName, it should succeed to build. # If PcdToken and PcdGet/Set used in the Pcds with different Guids but same CName, it should failed to build. if PcdExCNameTest > 1: - AutoGenH.Append('// Disabled the macros, as PcdToken and PcdGet/Set are not allowed in the case that more than one DynamicEx Pcds are different Guids but same CName.\n') - AutoGenH.Append('// #define %s %s\n' % (PcdTokenName, PcdExTokenName)) - AutoGenH.Append('// #define %s LibPcdGetEx%s(&%s, %s)\n' % (GetModeName, DatumSizeLib, Pcd.TokenSpaceGuidCName, PcdTokenName)) - AutoGenH.Append('// #define %s LibPcdGetExSize(&%s, %s)\n' % (GetModeSizeName,Pcd.TokenSpaceGuidCName, PcdTokenName)) + AutoGenH.append('// Disabled the macros, as PcdToken and PcdGet/Set are not allowed in the case that more than one DynamicEx Pcds are different Guids but same CName.\n') + AutoGenH.append('// #define %s %s\n' % (PcdTokenName, PcdExTokenName)) + AutoGenH.append('// #define %s LibPcdGetEx%s(&%s, %s)\n' % (GetModeName, DatumSizeLib, Pcd.TokenSpaceGuidCName, PcdTokenName)) + AutoGenH.append('// #define %s LibPcdGetExSize(&%s, %s)\n' % (GetModeSizeName,Pcd.TokenSpaceGuidCName, PcdTokenName)) if Pcd.DatumType not in TAB_PCD_NUMERIC_TYPES: - AutoGenH.Append('// #define %s(SizeOfBuffer, Buffer) LibPcdSetEx%s(&%s, %s, (SizeOfBuffer), (Buffer))\n' % (SetModeName, DatumSizeLib, Pcd.TokenSpaceGuidCName, PcdTokenName)) - AutoGenH.Append('// #define %s(SizeOfBuffer, Buffer) LibPcdSetEx%sS(&%s, %s, (SizeOfBuffer), (Buffer))\n' % (SetModeStatusName, DatumSizeLib, Pcd.TokenSpaceGuidCName, PcdTokenName)) + AutoGenH.append('// #define %s(SizeOfBuffer, Buffer) LibPcdSetEx%s(&%s, %s, (SizeOfBuffer), (Buffer))\n' % (SetModeName, DatumSizeLib, Pcd.TokenSpaceGuidCName, PcdTokenName)) + AutoGenH.append('// #define %s(SizeOfBuffer, Buffer) LibPcdSetEx%sS(&%s, %s, (SizeOfBuffer), (Buffer))\n' % (SetModeStatusName, DatumSizeLib, Pcd.TokenSpaceGuidCName, PcdTokenName)) else: - AutoGenH.Append('// #define %s(Value) LibPcdSetEx%s(&%s, %s, (Value))\n' % (SetModeName, DatumSizeLib, Pcd.TokenSpaceGuidCName, PcdTokenName)) - AutoGenH.Append('// #define %s(Value) LibPcdSetEx%sS(&%s, %s, (Value))\n' % (SetModeStatusName, DatumSizeLib, Pcd.TokenSpaceGuidCName, PcdTokenName)) + AutoGenH.append('// #define %s(Value) LibPcdSetEx%s(&%s, %s, (Value))\n' % (SetModeName, DatumSizeLib, Pcd.TokenSpaceGuidCName, PcdTokenName)) + AutoGenH.append('// #define %s(Value) LibPcdSetEx%sS(&%s, %s, (Value))\n' % (SetModeStatusName, DatumSizeLib, Pcd.TokenSpaceGuidCName, PcdTokenName)) else: - AutoGenH.Append('#define %s %s\n' % (PcdTokenName, PcdExTokenName)) - AutoGenH.Append('#define %s LibPcdGetEx%s(&%s, %s)\n' % (GetModeName, DatumSizeLib, Pcd.TokenSpaceGuidCName, PcdTokenName)) - AutoGenH.Append('#define %s LibPcdGetExSize(&%s, %s)\n' % (GetModeSizeName,Pcd.TokenSpaceGuidCName, PcdTokenName)) + AutoGenH.append('#define %s %s\n' % (PcdTokenName, PcdExTokenName)) + AutoGenH.append('#define %s LibPcdGetEx%s(&%s, %s)\n' % (GetModeName, DatumSizeLib, Pcd.TokenSpaceGuidCName, PcdTokenName)) + AutoGenH.append('#define %s LibPcdGetExSize(&%s, %s)\n' % (GetModeSizeName,Pcd.TokenSpaceGuidCName, PcdTokenName)) if Pcd.DatumType not in TAB_PCD_NUMERIC_TYPES: - AutoGenH.Append('#define %s(SizeOfBuffer, Buffer) LibPcdSetEx%s(&%s, %s, (SizeOfBuffer), (Buffer))\n' % (SetModeName, DatumSizeLib, Pcd.TokenSpaceGuidCName, PcdTokenName)) - AutoGenH.Append('#define %s(SizeOfBuffer, Buffer) LibPcdSetEx%sS(&%s, %s, (SizeOfBuffer), (Buffer))\n' % (SetModeStatusName, DatumSizeLib, Pcd.TokenSpaceGuidCName, PcdTokenName)) + AutoGenH.append('#define %s(SizeOfBuffer, Buffer) LibPcdSetEx%s(&%s, %s, (SizeOfBuffer), (Buffer))\n' % (SetModeName, DatumSizeLib, Pcd.TokenSpaceGuidCName, PcdTokenName)) + AutoGenH.append('#define %s(SizeOfBuffer, Buffer) LibPcdSetEx%sS(&%s, %s, (SizeOfBuffer), (Buffer))\n' % (SetModeStatusName, DatumSizeLib, Pcd.TokenSpaceGuidCName, PcdTokenName)) else: - AutoGenH.Append('#define %s(Value) LibPcdSetEx%s(&%s, %s, (Value))\n' % (SetModeName, DatumSizeLib, Pcd.TokenSpaceGuidCName, PcdTokenName)) - AutoGenH.Append('#define %s(Value) LibPcdSetEx%sS(&%s, %s, (Value))\n' % (SetModeStatusName, DatumSizeLib, Pcd.TokenSpaceGuidCName, PcdTokenName)) + AutoGenH.append('#define %s(Value) LibPcdSetEx%s(&%s, %s, (Value))\n' % (SetModeName, DatumSizeLib, Pcd.TokenSpaceGuidCName, PcdTokenName)) + AutoGenH.append('#define %s(Value) LibPcdSetEx%sS(&%s, %s, (Value))\n' % (SetModeStatusName, DatumSizeLib, Pcd.TokenSpaceGuidCName, PcdTokenName)) elif Pcd.Type in PCD_DYNAMIC_TYPE_SET: PcdCNameTest = 0 for PcdModule in Info.LibraryPcdList + Info.ModulePcdList: @@ -977,14 +977,14 @@ def CreateModulePcdCode(Info, AutoGenC, AutoGenH, Pcd): if PcdCNameTest > 1: EdkLogger.error("build", AUTOGEN_ERROR, "More than one Dynamic Pcds [%s] are different Guids but same CName. They need to be changed to DynamicEx type to avoid the confliction.\n" % (TokenCName), ExtraData="[%s]" % str(Info.MetaFile.Path)) else: - AutoGenH.Append('#define %s LibPcdGet%s(%s)\n' % (GetModeName, DatumSizeLib, PcdTokenName)) - AutoGenH.Append('#define %s LibPcdGetSize(%s)\n' % (GetModeSizeName, PcdTokenName)) + AutoGenH.append('#define %s LibPcdGet%s(%s)\n' % (GetModeName, DatumSizeLib, PcdTokenName)) + AutoGenH.append('#define %s LibPcdGetSize(%s)\n' % (GetModeSizeName, PcdTokenName)) if Pcd.DatumType not in TAB_PCD_NUMERIC_TYPES: - AutoGenH.Append('#define %s(SizeOfBuffer, Buffer) LibPcdSet%s(%s, (SizeOfBuffer), (Buffer))\n' %(SetModeName, DatumSizeLib, PcdTokenName)) - AutoGenH.Append('#define %s(SizeOfBuffer, Buffer) LibPcdSet%sS(%s, (SizeOfBuffer), (Buffer))\n' % (SetModeStatusName, DatumSizeLib, PcdTokenName)) + AutoGenH.append('#define %s(SizeOfBuffer, Buffer) LibPcdSet%s(%s, (SizeOfBuffer), (Buffer))\n' %(SetModeName, DatumSizeLib, PcdTokenName)) + AutoGenH.append('#define %s(SizeOfBuffer, Buffer) LibPcdSet%sS(%s, (SizeOfBuffer), (Buffer))\n' % (SetModeStatusName, DatumSizeLib, PcdTokenName)) else: - AutoGenH.Append('#define %s(Value) LibPcdSet%s(%s, (Value))\n' % (SetModeName, DatumSizeLib, PcdTokenName)) - AutoGenH.Append('#define %s(Value) LibPcdSet%sS(%s, (Value))\n' % (SetModeStatusName, DatumSizeLib, PcdTokenName)) + AutoGenH.append('#define %s(Value) LibPcdSet%s(%s, (Value))\n' % (SetModeName, DatumSizeLib, PcdTokenName)) + AutoGenH.append('#define %s(Value) LibPcdSet%sS(%s, (Value))\n' % (SetModeStatusName, DatumSizeLib, PcdTokenName)) else: PcdVariableName = '_gPcd_' + gItemTypeStringDatabase[Pcd.Type] + '_' + TokenCName Const = 'const' @@ -1107,57 +1107,57 @@ def CreateModulePcdCode(Info, AutoGenC, AutoGenH, Pcd): # # For unicode, UINT16 array will be generated, so the alignment of unicode is guaranteed. # - AutoGenH.Append('#define %s %s%s\n' %(PcdValueName, Type, PcdVariableName)) + AutoGenH.append('#define %s %s%s\n' %(PcdValueName, Type, PcdVariableName)) if Unicode: - AutoGenC.Append('GLOBAL_REMOVE_IF_UNREFERENCED %s UINT16 %s%s = %s;\n' % (Const, PcdVariableName, Array, Value)) - AutoGenH.Append('extern %s UINT16 %s%s;\n' %(Const, PcdVariableName, Array)) + AutoGenC.append('GLOBAL_REMOVE_IF_UNREFERENCED %s UINT16 %s%s = %s;\n' % (Const, PcdVariableName, Array, Value)) + AutoGenH.append('extern %s UINT16 %s%s;\n' %(Const, PcdVariableName, Array)) else: - AutoGenC.Append('GLOBAL_REMOVE_IF_UNREFERENCED %s UINT8 %s%s = %s;\n' % (Const, PcdVariableName, Array, Value)) - AutoGenH.Append('extern %s UINT8 %s%s;\n' %(Const, PcdVariableName, Array)) - AutoGenH.Append('#define %s %s%s\n' %(GetModeName, Type, PcdVariableName)) + AutoGenC.append('GLOBAL_REMOVE_IF_UNREFERENCED %s UINT8 %s%s = %s;\n' % (Const, PcdVariableName, Array, Value)) + AutoGenH.append('extern %s UINT8 %s%s;\n' %(Const, PcdVariableName, Array)) + AutoGenH.append('#define %s %s%s\n' %(GetModeName, Type, PcdVariableName)) PcdDataSize = Pcd.GetPcdSize() if Pcd.Type == TAB_PCDS_FIXED_AT_BUILD: - AutoGenH.Append('#define %s %s\n' % (FixPcdSizeTokenName, PcdDataSize)) - AutoGenH.Append('#define %s %s \n' % (GetModeSizeName,FixPcdSizeTokenName)) - AutoGenC.Append('GLOBAL_REMOVE_IF_UNREFERENCED const UINTN %s = %s;\n' % (FixedPcdSizeVariableName,PcdDataSize)) + AutoGenH.append('#define %s %s\n' % (FixPcdSizeTokenName, PcdDataSize)) + AutoGenH.append('#define %s %s \n' % (GetModeSizeName,FixPcdSizeTokenName)) + AutoGenC.append('GLOBAL_REMOVE_IF_UNREFERENCED const UINTN %s = %s;\n' % (FixedPcdSizeVariableName,PcdDataSize)) if Pcd.Type == TAB_PCDS_PATCHABLE_IN_MODULE: - AutoGenH.Append('#define %s %s\n' % (PatchPcdSizeTokenName, Pcd.MaxDatumSize)) - AutoGenH.Append('#define %s %s \n' % (GetModeSizeName,PatchPcdSizeVariableName)) - AutoGenH.Append('extern UINTN %s; \n' % PatchPcdSizeVariableName) - AutoGenC.Append('GLOBAL_REMOVE_IF_UNREFERENCED UINTN %s = %s;\n' % (PatchPcdSizeVariableName,PcdDataSize)) - AutoGenC.Append('GLOBAL_REMOVE_IF_UNREFERENCED const UINTN %s = %s;\n' % (PatchPcdMaxSizeVariable,Pcd.MaxDatumSize)) + AutoGenH.append('#define %s %s\n' % (PatchPcdSizeTokenName, Pcd.MaxDatumSize)) + AutoGenH.append('#define %s %s \n' % (GetModeSizeName,PatchPcdSizeVariableName)) + AutoGenH.append('extern UINTN %s; \n' % PatchPcdSizeVariableName) + AutoGenC.append('GLOBAL_REMOVE_IF_UNREFERENCED UINTN %s = %s;\n' % (PatchPcdSizeVariableName,PcdDataSize)) + AutoGenC.append('GLOBAL_REMOVE_IF_UNREFERENCED const UINTN %s = %s;\n' % (PatchPcdMaxSizeVariable,Pcd.MaxDatumSize)) elif Pcd.Type == TAB_PCDS_PATCHABLE_IN_MODULE: - AutoGenH.Append('#define %s %s\n' %(PcdValueName, Value)) - AutoGenC.Append('volatile %s %s %s = %s;\n' %(Const, Pcd.DatumType, PcdVariableName, PcdValueName)) - AutoGenH.Append('extern volatile %s %s %s%s;\n' % (Const, Pcd.DatumType, PcdVariableName, Array)) - AutoGenH.Append('#define %s %s%s\n' % (GetModeName, Type, PcdVariableName)) + AutoGenH.append('#define %s %s\n' %(PcdValueName, Value)) + AutoGenC.append('volatile %s %s %s = %s;\n' %(Const, Pcd.DatumType, PcdVariableName, PcdValueName)) + AutoGenH.append('extern volatile %s %s %s%s;\n' % (Const, Pcd.DatumType, PcdVariableName, Array)) + AutoGenH.append('#define %s %s%s\n' % (GetModeName, Type, PcdVariableName)) PcdDataSize = Pcd.GetPcdSize() - AutoGenH.Append('#define %s %s\n' % (PatchPcdSizeTokenName, PcdDataSize)) + AutoGenH.append('#define %s %s\n' % (PatchPcdSizeTokenName, PcdDataSize)) - AutoGenH.Append('#define %s %s \n' % (GetModeSizeName,PatchPcdSizeVariableName)) - AutoGenH.Append('extern UINTN %s; \n' % PatchPcdSizeVariableName) - AutoGenC.Append('GLOBAL_REMOVE_IF_UNREFERENCED UINTN %s = %s;\n' % (PatchPcdSizeVariableName,PcdDataSize)) + AutoGenH.append('#define %s %s \n' % (GetModeSizeName,PatchPcdSizeVariableName)) + AutoGenH.append('extern UINTN %s; \n' % PatchPcdSizeVariableName) + AutoGenC.append('GLOBAL_REMOVE_IF_UNREFERENCED UINTN %s = %s;\n' % (PatchPcdSizeVariableName,PcdDataSize)) else: PcdDataSize = Pcd.GetPcdSize() - AutoGenH.Append('#define %s %s\n' % (FixPcdSizeTokenName, PcdDataSize)) - AutoGenH.Append('#define %s %s \n' % (GetModeSizeName,FixPcdSizeTokenName)) + AutoGenH.append('#define %s %s\n' % (FixPcdSizeTokenName, PcdDataSize)) + AutoGenH.append('#define %s %s \n' % (GetModeSizeName,FixPcdSizeTokenName)) - AutoGenH.Append('#define %s %s\n' %(PcdValueName, Value)) - AutoGenC.Append('GLOBAL_REMOVE_IF_UNREFERENCED %s %s %s = %s;\n' %(Const, Pcd.DatumType, PcdVariableName, PcdValueName)) - AutoGenH.Append('extern %s %s %s%s;\n' % (Const, Pcd.DatumType, PcdVariableName, Array)) - AutoGenH.Append('#define %s %s%s\n' % (GetModeName, Type, PcdVariableName)) + AutoGenH.append('#define %s %s\n' %(PcdValueName, Value)) + AutoGenC.append('GLOBAL_REMOVE_IF_UNREFERENCED %s %s %s = %s;\n' %(Const, Pcd.DatumType, PcdVariableName, PcdValueName)) + AutoGenH.append('extern %s %s %s%s;\n' % (Const, Pcd.DatumType, PcdVariableName, Array)) + AutoGenH.append('#define %s %s%s\n' % (GetModeName, Type, PcdVariableName)) if Pcd.Type == TAB_PCDS_PATCHABLE_IN_MODULE: if Pcd.DatumType not in TAB_PCD_NUMERIC_TYPES: - AutoGenH.Append('#define %s(SizeOfBuffer, Buffer) LibPatchPcdSetPtrAndSize((VOID *)_gPcd_BinaryPatch_%s, &_gPcd_BinaryPatch_Size_%s, (UINTN)_PCD_PATCHABLE_%s_SIZE, (SizeOfBuffer), (Buffer))\n' % (SetModeName, Pcd.TokenCName, Pcd.TokenCName, Pcd.TokenCName)) - AutoGenH.Append('#define %s(SizeOfBuffer, Buffer) LibPatchPcdSetPtrAndSizeS((VOID *)_gPcd_BinaryPatch_%s, &_gPcd_BinaryPatch_Size_%s, (UINTN)_PCD_PATCHABLE_%s_SIZE, (SizeOfBuffer), (Buffer))\n' % (SetModeStatusName, Pcd.TokenCName, Pcd.TokenCName, Pcd.TokenCName)) + AutoGenH.append('#define %s(SizeOfBuffer, Buffer) LibPatchPcdSetPtrAndSize((VOID *)_gPcd_BinaryPatch_%s, &_gPcd_BinaryPatch_Size_%s, (UINTN)_PCD_PATCHABLE_%s_SIZE, (SizeOfBuffer), (Buffer))\n' % (SetModeName, Pcd.TokenCName, Pcd.TokenCName, Pcd.TokenCName)) + AutoGenH.append('#define %s(SizeOfBuffer, Buffer) LibPatchPcdSetPtrAndSizeS((VOID *)_gPcd_BinaryPatch_%s, &_gPcd_BinaryPatch_Size_%s, (UINTN)_PCD_PATCHABLE_%s_SIZE, (SizeOfBuffer), (Buffer))\n' % (SetModeStatusName, Pcd.TokenCName, Pcd.TokenCName, Pcd.TokenCName)) else: - AutoGenH.Append('#define %s(Value) (%s = (Value))\n' % (SetModeName, PcdVariableName)) - AutoGenH.Append('#define %s(Value) ((%s = (Value)), RETURN_SUCCESS) \n' % (SetModeStatusName, PcdVariableName)) + AutoGenH.append('#define %s(Value) (%s = (Value))\n' % (SetModeName, PcdVariableName)) + AutoGenH.append('#define %s(Value) ((%s = (Value)), RETURN_SUCCESS) \n' % (SetModeStatusName, PcdVariableName)) else: - AutoGenH.Append('//#define %s ASSERT(FALSE) // It is not allowed to set value for a FIXED_AT_BUILD PCD\n' % SetModeName) + AutoGenH.append('//#define %s ASSERT(FALSE) // It is not allowed to set value for a FIXED_AT_BUILD PCD\n' % SetModeName) ## Create code for library module PCDs # @@ -1229,7 +1229,7 @@ def CreateLibraryPcdCode(Info, AutoGenC, AutoGenH, Pcd): PcdItemType = Pcd.Type if PcdItemType in PCD_DYNAMIC_EX_TYPE_SET: PcdExTokenName = '_PCD_TOKEN_' + TokenSpaceGuidCName + '_' + TokenCName - AutoGenH.Append('\n#define %s %dU\n' % (PcdExTokenName, TokenNumber)) + AutoGenH.append('\n#define %s %dU\n' % (PcdExTokenName, TokenNumber)) if Info.IsLibrary: PcdList = Info.LibraryPcdList @@ -1246,28 +1246,28 @@ def CreateLibraryPcdCode(Info, AutoGenC, AutoGenH, Pcd): # If only PcdGet/Set used in all Pcds with different CName, it should succeed to build. # If PcdGet/Set used in the Pcds with different Guids but same CName, it should failed to build. if PcdExCNameTest > 1: - AutoGenH.Append('// Disabled the macros, as PcdToken and PcdGet/Set are not allowed in the case that more than one DynamicEx Pcds are different Guids but same CName.\n') - AutoGenH.Append('// #define %s %s\n' % (PcdTokenName, PcdExTokenName)) - AutoGenH.Append('// #define %s LibPcdGetEx%s(&%s, %s)\n' % (GetModeName, DatumSizeLib, Pcd.TokenSpaceGuidCName, PcdTokenName)) - AutoGenH.Append('// #define %s LibPcdGetExSize(&%s, %s)\n' % (GetModeSizeName,Pcd.TokenSpaceGuidCName, PcdTokenName)) + AutoGenH.append('// Disabled the macros, as PcdToken and PcdGet/Set are not allowed in the case that more than one DynamicEx Pcds are different Guids but same CName.\n') + AutoGenH.append('// #define %s %s\n' % (PcdTokenName, PcdExTokenName)) + AutoGenH.append('// #define %s LibPcdGetEx%s(&%s, %s)\n' % (GetModeName, DatumSizeLib, Pcd.TokenSpaceGuidCName, PcdTokenName)) + AutoGenH.append('// #define %s LibPcdGetExSize(&%s, %s)\n' % (GetModeSizeName,Pcd.TokenSpaceGuidCName, PcdTokenName)) if Pcd.DatumType not in TAB_PCD_NUMERIC_TYPES: - AutoGenH.Append('// #define %s(SizeOfBuffer, Buffer) LibPcdSetEx%s(&%s, %s, (SizeOfBuffer), (Buffer))\n' % (SetModeName, DatumSizeLib, Pcd.TokenSpaceGuidCName, PcdTokenName)) - AutoGenH.Append('// #define %s(SizeOfBuffer, Buffer) LibPcdSetEx%sS(&%s, %s, (SizeOfBuffer), (Buffer))\n' % (SetModeStatusName, DatumSizeLib, Pcd.TokenSpaceGuidCName, PcdTokenName)) + AutoGenH.append('// #define %s(SizeOfBuffer, Buffer) LibPcdSetEx%s(&%s, %s, (SizeOfBuffer), (Buffer))\n' % (SetModeName, DatumSizeLib, Pcd.TokenSpaceGuidCName, PcdTokenName)) + AutoGenH.append('// #define %s(SizeOfBuffer, Buffer) LibPcdSetEx%sS(&%s, %s, (SizeOfBuffer), (Buffer))\n' % (SetModeStatusName, DatumSizeLib, Pcd.TokenSpaceGuidCName, PcdTokenName)) else: - AutoGenH.Append('// #define %s(Value) LibPcdSetEx%s(&%s, %s, (Value))\n' % (SetModeName, DatumSizeLib, Pcd.TokenSpaceGuidCName, PcdTokenName)) - AutoGenH.Append('// #define %s(Value) LibPcdSetEx%sS(&%s, %s, (Value))\n' % (SetModeStatusName, DatumSizeLib, Pcd.TokenSpaceGuidCName, PcdTokenName)) + AutoGenH.append('// #define %s(Value) LibPcdSetEx%s(&%s, %s, (Value))\n' % (SetModeName, DatumSizeLib, Pcd.TokenSpaceGuidCName, PcdTokenName)) + AutoGenH.append('// #define %s(Value) LibPcdSetEx%sS(&%s, %s, (Value))\n' % (SetModeStatusName, DatumSizeLib, Pcd.TokenSpaceGuidCName, PcdTokenName)) else: - AutoGenH.Append('#define %s %s\n' % (PcdTokenName, PcdExTokenName)) - AutoGenH.Append('#define %s LibPcdGetEx%s(&%s, %s)\n' % (GetModeName, DatumSizeLib, Pcd.TokenSpaceGuidCName, PcdTokenName)) - AutoGenH.Append('#define %s LibPcdGetExSize(&%s, %s)\n' % (GetModeSizeName,Pcd.TokenSpaceGuidCName, PcdTokenName)) + AutoGenH.append('#define %s %s\n' % (PcdTokenName, PcdExTokenName)) + AutoGenH.append('#define %s LibPcdGetEx%s(&%s, %s)\n' % (GetModeName, DatumSizeLib, Pcd.TokenSpaceGuidCName, PcdTokenName)) + AutoGenH.append('#define %s LibPcdGetExSize(&%s, %s)\n' % (GetModeSizeName,Pcd.TokenSpaceGuidCName, PcdTokenName)) if Pcd.DatumType not in TAB_PCD_NUMERIC_TYPES: - AutoGenH.Append('#define %s(SizeOfBuffer, Buffer) LibPcdSetEx%s(&%s, %s, (SizeOfBuffer), (Buffer))\n' % (SetModeName, DatumSizeLib, Pcd.TokenSpaceGuidCName, PcdTokenName)) - AutoGenH.Append('#define %s(SizeOfBuffer, Buffer) LibPcdSetEx%sS(&%s, %s, (SizeOfBuffer), (Buffer))\n' % (SetModeStatusName, DatumSizeLib, Pcd.TokenSpaceGuidCName, PcdTokenName)) + AutoGenH.append('#define %s(SizeOfBuffer, Buffer) LibPcdSetEx%s(&%s, %s, (SizeOfBuffer), (Buffer))\n' % (SetModeName, DatumSizeLib, Pcd.TokenSpaceGuidCName, PcdTokenName)) + AutoGenH.append('#define %s(SizeOfBuffer, Buffer) LibPcdSetEx%sS(&%s, %s, (SizeOfBuffer), (Buffer))\n' % (SetModeStatusName, DatumSizeLib, Pcd.TokenSpaceGuidCName, PcdTokenName)) else: - AutoGenH.Append('#define %s(Value) LibPcdSetEx%s(&%s, %s, (Value))\n' % (SetModeName, DatumSizeLib, Pcd.TokenSpaceGuidCName, PcdTokenName)) - AutoGenH.Append('#define %s(Value) LibPcdSetEx%sS(&%s, %s, (Value))\n' % (SetModeStatusName, DatumSizeLib, Pcd.TokenSpaceGuidCName, PcdTokenName)) + AutoGenH.append('#define %s(Value) LibPcdSetEx%s(&%s, %s, (Value))\n' % (SetModeName, DatumSizeLib, Pcd.TokenSpaceGuidCName, PcdTokenName)) + AutoGenH.append('#define %s(Value) LibPcdSetEx%sS(&%s, %s, (Value))\n' % (SetModeStatusName, DatumSizeLib, Pcd.TokenSpaceGuidCName, PcdTokenName)) else: - AutoGenH.Append('#define _PCD_TOKEN_%s %dU\n' % (TokenCName, TokenNumber)) + AutoGenH.append('#define _PCD_TOKEN_%s %dU\n' % (TokenCName, TokenNumber)) if PcdItemType in PCD_DYNAMIC_TYPE_SET: PcdList = [] PcdCNameList = [] @@ -1279,14 +1279,14 @@ def CreateLibraryPcdCode(Info, AutoGenC, AutoGenH, Pcd): if PcdCNameList.count(Pcd.TokenCName) > 1: EdkLogger.error("build", AUTOGEN_ERROR, "More than one Dynamic Pcds [%s] are different Guids but same CName.They need to be changed to DynamicEx type to avoid the confliction.\n" % (TokenCName), ExtraData="[%s]" % str(Info.MetaFile.Path)) else: - AutoGenH.Append('#define %s LibPcdGet%s(%s)\n' % (GetModeName, DatumSizeLib, PcdTokenName)) - AutoGenH.Append('#define %s LibPcdGetSize(%s)\n' % (GetModeSizeName, PcdTokenName)) + AutoGenH.append('#define %s LibPcdGet%s(%s)\n' % (GetModeName, DatumSizeLib, PcdTokenName)) + AutoGenH.append('#define %s LibPcdGetSize(%s)\n' % (GetModeSizeName, PcdTokenName)) if DatumType not in TAB_PCD_NUMERIC_TYPES: - AutoGenH.Append('#define %s(SizeOfBuffer, Buffer) LibPcdSet%s(%s, (SizeOfBuffer), (Buffer))\n' %(SetModeName, DatumSizeLib, PcdTokenName)) - AutoGenH.Append('#define %s(SizeOfBuffer, Buffer) LibPcdSet%sS(%s, (SizeOfBuffer), (Buffer))\n' % (SetModeStatusName, DatumSizeLib, PcdTokenName)) + AutoGenH.append('#define %s(SizeOfBuffer, Buffer) LibPcdSet%s(%s, (SizeOfBuffer), (Buffer))\n' %(SetModeName, DatumSizeLib, PcdTokenName)) + AutoGenH.append('#define %s(SizeOfBuffer, Buffer) LibPcdSet%sS(%s, (SizeOfBuffer), (Buffer))\n' % (SetModeStatusName, DatumSizeLib, PcdTokenName)) else: - AutoGenH.Append('#define %s(Value) LibPcdSet%s(%s, (Value))\n' % (SetModeName, DatumSizeLib, PcdTokenName)) - AutoGenH.Append('#define %s(Value) LibPcdSet%sS(%s, (Value))\n' % (SetModeStatusName, DatumSizeLib, PcdTokenName)) + AutoGenH.append('#define %s(Value) LibPcdSet%s(%s, (Value))\n' % (SetModeName, DatumSizeLib, PcdTokenName)) + AutoGenH.append('#define %s(Value) LibPcdSet%sS(%s, (Value))\n' % (SetModeStatusName, DatumSizeLib, PcdTokenName)) if PcdItemType == TAB_PCDS_PATCHABLE_IN_MODULE: GetModeMaxSizeName = '_PCD_GET_MODE_MAXSIZE' + '_' + TokenCName PcdVariableName = '_gPcd_' + gItemTypeStringDatabase[TAB_PCDS_PATCHABLE_IN_MODULE] + '_' + TokenCName @@ -1295,23 +1295,23 @@ def CreateLibraryPcdCode(Info, AutoGenC, AutoGenH, Pcd): DatumType = [TAB_UINT8, TAB_UINT16][Pcd.DefaultValue[0] == 'L'] else: DatumType = TAB_UINT8 - AutoGenH.Append('extern %s _gPcd_BinaryPatch_%s%s;\n' %(DatumType, TokenCName, Array)) + AutoGenH.append('extern %s _gPcd_BinaryPatch_%s%s;\n' %(DatumType, TokenCName, Array)) else: - AutoGenH.Append('extern volatile %s %s%s;\n' % (DatumType, PcdVariableName, Array)) - AutoGenH.Append('#define %s %s_gPcd_BinaryPatch_%s\n' %(GetModeName, Type, TokenCName)) + AutoGenH.append('extern volatile %s %s%s;\n' % (DatumType, PcdVariableName, Array)) + AutoGenH.append('#define %s %s_gPcd_BinaryPatch_%s\n' %(GetModeName, Type, TokenCName)) PcdDataSize = Pcd.GetPcdSize() if Pcd.DatumType not in TAB_PCD_NUMERIC_TYPES: - AutoGenH.Append('#define %s(SizeOfBuffer, Buffer) LibPatchPcdSetPtrAndSize((VOID *)_gPcd_BinaryPatch_%s, &%s, %s, (SizeOfBuffer), (Buffer))\n' % (SetModeName, TokenCName, PatchPcdSizeVariableName, PatchPcdMaxSizeVariable)) - AutoGenH.Append('#define %s(SizeOfBuffer, Buffer) LibPatchPcdSetPtrAndSizeS((VOID *)_gPcd_BinaryPatch_%s, &%s, %s, (SizeOfBuffer), (Buffer))\n' % (SetModeStatusName, TokenCName, PatchPcdSizeVariableName, PatchPcdMaxSizeVariable)) - AutoGenH.Append('#define %s %s\n' % (GetModeMaxSizeName, PatchPcdMaxSizeVariable)) - AutoGenH.Append('extern const UINTN %s; \n' % PatchPcdMaxSizeVariable) + AutoGenH.append('#define %s(SizeOfBuffer, Buffer) LibPatchPcdSetPtrAndSize((VOID *)_gPcd_BinaryPatch_%s, &%s, %s, (SizeOfBuffer), (Buffer))\n' % (SetModeName, TokenCName, PatchPcdSizeVariableName, PatchPcdMaxSizeVariable)) + AutoGenH.append('#define %s(SizeOfBuffer, Buffer) LibPatchPcdSetPtrAndSizeS((VOID *)_gPcd_BinaryPatch_%s, &%s, %s, (SizeOfBuffer), (Buffer))\n' % (SetModeStatusName, TokenCName, PatchPcdSizeVariableName, PatchPcdMaxSizeVariable)) + AutoGenH.append('#define %s %s\n' % (GetModeMaxSizeName, PatchPcdMaxSizeVariable)) + AutoGenH.append('extern const UINTN %s; \n' % PatchPcdMaxSizeVariable) else: - AutoGenH.Append('#define %s(Value) (%s = (Value))\n' % (SetModeName, PcdVariableName)) - AutoGenH.Append('#define %s(Value) ((%s = (Value)), RETURN_SUCCESS)\n' % (SetModeStatusName, PcdVariableName)) - AutoGenH.Append('#define %s %s\n' % (PatchPcdSizeTokenName, PcdDataSize)) + AutoGenH.append('#define %s(Value) (%s = (Value))\n' % (SetModeName, PcdVariableName)) + AutoGenH.append('#define %s(Value) ((%s = (Value)), RETURN_SUCCESS)\n' % (SetModeStatusName, PcdVariableName)) + AutoGenH.append('#define %s %s\n' % (PatchPcdSizeTokenName, PcdDataSize)) - AutoGenH.Append('#define %s %s\n' % (GetModeSizeName,PatchPcdSizeVariableName)) - AutoGenH.Append('extern UINTN %s; \n' % PatchPcdSizeVariableName) + AutoGenH.append('#define %s %s\n' % (GetModeSizeName,PatchPcdSizeVariableName)) + AutoGenH.append('extern UINTN %s; \n' % PatchPcdSizeVariableName) if PcdItemType == TAB_PCDS_FIXED_AT_BUILD or PcdItemType == TAB_PCDS_FEATURE_FLAG: key = ".".join((Pcd.TokenSpaceGuidCName,Pcd.TokenCName)) @@ -1320,9 +1320,9 @@ def CreateLibraryPcdCode(Info, AutoGenC, AutoGenH, Pcd): DatumType = [TAB_UINT8, TAB_UINT16][Pcd.DefaultValue[0] == 'L'] if DatumType not in TAB_PCD_NUMERIC_TYPES_VOID: DatumType = TAB_UINT8 - AutoGenH.Append('extern const %s _gPcd_FixedAtBuild_%s%s;\n' %(DatumType, TokenCName, Array)) - AutoGenH.Append('#define %s %s_gPcd_FixedAtBuild_%s\n' %(GetModeName, Type, TokenCName)) - AutoGenH.Append('//#define %s ASSERT(FALSE) // It is not allowed to set value for a FIXED_AT_BUILD PCD\n' % SetModeName) + AutoGenH.append('extern const %s _gPcd_FixedAtBuild_%s%s;\n' %(DatumType, TokenCName, Array)) + AutoGenH.append('#define %s %s_gPcd_FixedAtBuild_%s\n' %(GetModeName, Type, TokenCName)) + AutoGenH.append('//#define %s ASSERT(FALSE) // It is not allowed to set value for a FIXED_AT_BUILD PCD\n' % SetModeName) ConstFixedPcd = False if PcdItemType == TAB_PCDS_FIXED_AT_BUILD and (key in Info.ConstPcd or (Info.IsLibrary and not Info._ReferenceModules)): @@ -1330,22 +1330,22 @@ def CreateLibraryPcdCode(Info, AutoGenC, AutoGenH, Pcd): if key in Info.ConstPcd: Pcd.DefaultValue = Info.ConstPcd[key] if Pcd.DatumType not in TAB_PCD_NUMERIC_TYPES: - AutoGenH.Append('#define _PCD_VALUE_%s %s%s\n' %(TokenCName, Type, PcdVariableName)) + AutoGenH.append('#define _PCD_VALUE_%s %s%s\n' %(TokenCName, Type, PcdVariableName)) else: - AutoGenH.Append('#define _PCD_VALUE_%s %s\n' %(TokenCName, Pcd.DefaultValue)) + AutoGenH.append('#define _PCD_VALUE_%s %s\n' %(TokenCName, Pcd.DefaultValue)) PcdDataSize = Pcd.GetPcdSize() if PcdItemType == TAB_PCDS_FIXED_AT_BUILD: if Pcd.DatumType not in TAB_PCD_NUMERIC_TYPES: if ConstFixedPcd: - AutoGenH.Append('#define %s %s\n' % (FixPcdSizeTokenName, PcdDataSize)) - AutoGenH.Append('#define %s %s\n' % (GetModeSizeName,FixPcdSizeTokenName)) + AutoGenH.append('#define %s %s\n' % (FixPcdSizeTokenName, PcdDataSize)) + AutoGenH.append('#define %s %s\n' % (GetModeSizeName,FixPcdSizeTokenName)) else: - AutoGenH.Append('#define %s %s\n' % (GetModeSizeName,FixedPcdSizeVariableName)) - AutoGenH.Append('#define %s %s\n' % (FixPcdSizeTokenName,FixedPcdSizeVariableName)) - AutoGenH.Append('extern const UINTN %s; \n' % FixedPcdSizeVariableName) + AutoGenH.append('#define %s %s\n' % (GetModeSizeName,FixedPcdSizeVariableName)) + AutoGenH.append('#define %s %s\n' % (FixPcdSizeTokenName,FixedPcdSizeVariableName)) + AutoGenH.append('extern const UINTN %s; \n' % FixedPcdSizeVariableName) else: - AutoGenH.Append('#define %s %s\n' % (FixPcdSizeTokenName, PcdDataSize)) - AutoGenH.Append('#define %s %s\n' % (GetModeSizeName,FixPcdSizeTokenName)) + AutoGenH.append('#define %s %s\n' % (FixPcdSizeTokenName, PcdDataSize)) + AutoGenH.append('#define %s %s\n' % (GetModeSizeName,FixPcdSizeTokenName)) ## Create code for library constructor # @@ -1357,8 +1357,8 @@ def CreateLibraryConstructorCode(Info, AutoGenC, AutoGenH): # # Library Constructors # - ConstructorPrototypeString = TemplateString() - ConstructorCallingString = TemplateString() + ConstructorPrototypeString = [] + ConstructorCallingString = [] if Info.IsLibrary: DependentLibraryList = [Info.Module] else: @@ -1368,27 +1368,21 @@ def CreateLibraryConstructorCode(Info, AutoGenC, AutoGenH): continue Dict = {'Function':Lib.ConstructorList} if Lib.ModuleType in [SUP_MODULE_BASE, SUP_MODULE_SEC]: - ConstructorPrototypeString.Append(gLibraryStructorPrototype[SUP_MODULE_BASE].Replace(Dict)) - ConstructorCallingString.Append(gLibraryStructorCall[SUP_MODULE_BASE].Replace(Dict)) + ConstructorPrototypeString.append(gLibraryStructorPrototype[SUP_MODULE_BASE].Replace(Dict)) + ConstructorCallingString.append(gLibraryStructorCall[SUP_MODULE_BASE].Replace(Dict)) elif Lib.ModuleType in SUP_MODULE_SET_PEI: - ConstructorPrototypeString.Append(gLibraryStructorPrototype['PEI'].Replace(Dict)) - ConstructorCallingString.Append(gLibraryStructorCall['PEI'].Replace(Dict)) + ConstructorPrototypeString.append(gLibraryStructorPrototype['PEI'].Replace(Dict)) + ConstructorCallingString.append(gLibraryStructorCall['PEI'].Replace(Dict)) elif Lib.ModuleType in [SUP_MODULE_DXE_CORE,SUP_MODULE_DXE_DRIVER,SUP_MODULE_DXE_SMM_DRIVER,SUP_MODULE_DXE_RUNTIME_DRIVER, SUP_MODULE_DXE_SAL_DRIVER,SUP_MODULE_UEFI_DRIVER,SUP_MODULE_UEFI_APPLICATION,SUP_MODULE_SMM_CORE]: - ConstructorPrototypeString.Append(gLibraryStructorPrototype['DXE'].Replace(Dict)) - ConstructorCallingString.Append(gLibraryStructorCall['DXE'].Replace(Dict)) + ConstructorPrototypeString.append(gLibraryStructorPrototype['DXE'].Replace(Dict)) + ConstructorCallingString.append(gLibraryStructorCall['DXE'].Replace(Dict)) elif Lib.ModuleType in [SUP_MODULE_MM_STANDALONE,SUP_MODULE_MM_CORE_STANDALONE]: - ConstructorPrototypeString.Append(gLibraryStructorPrototype['MM'].Replace(Dict)) - ConstructorCallingString.Append(gLibraryStructorCall['MM'].Replace(Dict)) + ConstructorPrototypeString.append(gLibraryStructorPrototype['MM'].Replace(Dict)) + ConstructorCallingString.append(gLibraryStructorCall['MM'].Replace(Dict)) - if str(ConstructorPrototypeString) == '': - ConstructorPrototypeList = [] - else: - ConstructorPrototypeList = [str(ConstructorPrototypeString)] - if str(ConstructorCallingString) == '': - ConstructorCallingList = [] - else: - ConstructorCallingList = [str(ConstructorCallingString)] + ConstructorPrototypeList = ["".join(ConstructorPrototypeString)] + ConstructorCallingList = ["".join(ConstructorCallingString)] Dict = { 'Type' : 'Constructor', @@ -1396,17 +1390,17 @@ def CreateLibraryConstructorCode(Info, AutoGenC, AutoGenH): 'FunctionCall' : ConstructorCallingList } if Info.IsLibrary: - AutoGenH.Append("${BEGIN}${FunctionPrototype}${END}", Dict) + AutoGenH.append(TemplateString("${BEGIN}${FunctionPrototype}${END}").Replace(Dict)) else: if Info.ModuleType in [SUP_MODULE_BASE, SUP_MODULE_SEC]: - AutoGenC.Append(gLibraryString[SUP_MODULE_BASE].Replace(Dict)) + AutoGenC.append(gLibraryString[SUP_MODULE_BASE].Replace(Dict)) elif Info.ModuleType in SUP_MODULE_SET_PEI: - AutoGenC.Append(gLibraryString['PEI'].Replace(Dict)) + AutoGenC.append(gLibraryString['PEI'].Replace(Dict)) elif Info.ModuleType in [SUP_MODULE_DXE_CORE,SUP_MODULE_DXE_DRIVER,SUP_MODULE_DXE_SMM_DRIVER,SUP_MODULE_DXE_RUNTIME_DRIVER, SUP_MODULE_DXE_SAL_DRIVER,SUP_MODULE_UEFI_DRIVER,SUP_MODULE_UEFI_APPLICATION,SUP_MODULE_SMM_CORE]: - AutoGenC.Append(gLibraryString['DXE'].Replace(Dict)) + AutoGenC.append(gLibraryString['DXE'].Replace(Dict)) elif Info.ModuleType in [SUP_MODULE_MM_STANDALONE,SUP_MODULE_MM_CORE_STANDALONE]: - AutoGenC.Append(gLibraryString['MM'].Replace(Dict)) + AutoGenC.append(gLibraryString['MM'].Replace(Dict)) ## Create code for library destructor # @@ -1458,17 +1452,17 @@ def CreateLibraryDestructorCode(Info, AutoGenC, AutoGenH): 'FunctionCall' : DestructorCallingList } if Info.IsLibrary: - AutoGenH.Append("${BEGIN}${FunctionPrototype}${END}", Dict) + AutoGenH.append(TemplateString("${BEGIN}${FunctionPrototype}${END}").Replace(Dict)) else: if Info.ModuleType in [SUP_MODULE_BASE, SUP_MODULE_SEC]: - AutoGenC.Append(gLibraryString[SUP_MODULE_BASE].Replace(Dict)) + AutoGenC.append(gLibraryString[SUP_MODULE_BASE].Replace(Dict)) elif Info.ModuleType in SUP_MODULE_SET_PEI: - AutoGenC.Append(gLibraryString['PEI'].Replace(Dict)) + AutoGenC.append(gLibraryString['PEI'].Replace(Dict)) elif Info.ModuleType in [SUP_MODULE_DXE_CORE,SUP_MODULE_DXE_DRIVER,SUP_MODULE_DXE_SMM_DRIVER,SUP_MODULE_DXE_RUNTIME_DRIVER, SUP_MODULE_DXE_SAL_DRIVER,SUP_MODULE_UEFI_DRIVER,SUP_MODULE_UEFI_APPLICATION,SUP_MODULE_SMM_CORE]: - AutoGenC.Append(gLibraryString['DXE'].Replace(Dict)) + AutoGenC.append(gLibraryString['DXE'].Replace(Dict)) elif Info.ModuleType in [SUP_MODULE_MM_STANDALONE,SUP_MODULE_MM_CORE_STANDALONE]: - AutoGenC.Append(gLibraryString['MM'].Replace(Dict)) + AutoGenC.append(gLibraryString['MM'].Replace(Dict)) ## Create code for ModuleEntryPoint @@ -1509,47 +1503,47 @@ def CreateModuleEntryPointCode(Info, AutoGenC, AutoGenH): ExtraData= ", ".join(Info.Module.ModuleEntryPointList) ) if Info.ModuleType == SUP_MODULE_PEI_CORE: - AutoGenC.Append(gPeiCoreEntryPointString.Replace(Dict)) - AutoGenH.Append(gPeiCoreEntryPointPrototype.Replace(Dict)) + AutoGenC.append(gPeiCoreEntryPointString.Replace(Dict)) + AutoGenH.append(gPeiCoreEntryPointPrototype.Replace(Dict)) elif Info.ModuleType == SUP_MODULE_DXE_CORE: - AutoGenC.Append(gDxeCoreEntryPointString.Replace(Dict)) - AutoGenH.Append(gDxeCoreEntryPointPrototype.Replace(Dict)) + AutoGenC.append(gDxeCoreEntryPointString.Replace(Dict)) + AutoGenH.append(gDxeCoreEntryPointPrototype.Replace(Dict)) elif Info.ModuleType == SUP_MODULE_SMM_CORE: - AutoGenC.Append(gSmmCoreEntryPointString.Replace(Dict)) - AutoGenH.Append(gSmmCoreEntryPointPrototype.Replace(Dict)) + AutoGenC.append(gSmmCoreEntryPointString.Replace(Dict)) + AutoGenH.append(gSmmCoreEntryPointPrototype.Replace(Dict)) elif Info.ModuleType == SUP_MODULE_MM_CORE_STANDALONE: - AutoGenC.Append(gMmCoreStandaloneEntryPointString.Replace(Dict)) - AutoGenH.Append(gMmCoreStandaloneEntryPointPrototype.Replace(Dict)) + AutoGenC.append(gMmCoreStandaloneEntryPointString.Replace(Dict)) + AutoGenH.append(gMmCoreStandaloneEntryPointPrototype.Replace(Dict)) elif Info.ModuleType == SUP_MODULE_PEIM: if NumEntryPoints < 2: - AutoGenC.Append(gPeimEntryPointString[NumEntryPoints].Replace(Dict)) + AutoGenC.append(gPeimEntryPointString[NumEntryPoints].Replace(Dict)) else: - AutoGenC.Append(gPeimEntryPointString[2].Replace(Dict)) - AutoGenH.Append(gPeimEntryPointPrototype.Replace(Dict)) + AutoGenC.append(gPeimEntryPointString[2].Replace(Dict)) + AutoGenH.append(gPeimEntryPointPrototype.Replace(Dict)) elif Info.ModuleType in [SUP_MODULE_DXE_RUNTIME_DRIVER,SUP_MODULE_DXE_DRIVER,SUP_MODULE_DXE_SAL_DRIVER,SUP_MODULE_UEFI_DRIVER]: if NumEntryPoints < 2: - AutoGenC.Append(gUefiDriverEntryPointString[NumEntryPoints].Replace(Dict)) + AutoGenC.append(gUefiDriverEntryPointString[NumEntryPoints].Replace(Dict)) else: - AutoGenC.Append(gUefiDriverEntryPointString[2].Replace(Dict)) - AutoGenH.Append(gUefiDriverEntryPointPrototype.Replace(Dict)) + AutoGenC.append(gUefiDriverEntryPointString[2].Replace(Dict)) + AutoGenH.append(gUefiDriverEntryPointPrototype.Replace(Dict)) elif Info.ModuleType == SUP_MODULE_DXE_SMM_DRIVER: if NumEntryPoints == 0: - AutoGenC.Append(gDxeSmmEntryPointString[0].Replace(Dict)) + AutoGenC.append(gDxeSmmEntryPointString[0].Replace(Dict)) else: - AutoGenC.Append(gDxeSmmEntryPointString[1].Replace(Dict)) - AutoGenH.Append(gDxeSmmEntryPointPrototype.Replace(Dict)) + AutoGenC.append(gDxeSmmEntryPointString[1].Replace(Dict)) + AutoGenH.append(gDxeSmmEntryPointPrototype.Replace(Dict)) elif Info.ModuleType == SUP_MODULE_MM_STANDALONE: if NumEntryPoints < 2: - AutoGenC.Append(gMmStandaloneEntryPointString[NumEntryPoints].Replace(Dict)) + AutoGenC.append(gMmStandaloneEntryPointString[NumEntryPoints].Replace(Dict)) else: - AutoGenC.Append(gMmStandaloneEntryPointString[2].Replace(Dict)) - AutoGenH.Append(gMmStandaloneEntryPointPrototype.Replace(Dict)) + AutoGenC.append(gMmStandaloneEntryPointString[2].Replace(Dict)) + AutoGenH.append(gMmStandaloneEntryPointPrototype.Replace(Dict)) elif Info.ModuleType == SUP_MODULE_UEFI_APPLICATION: if NumEntryPoints < 2: - AutoGenC.Append(gUefiApplicationEntryPointString[NumEntryPoints].Replace(Dict)) + AutoGenC.append(gUefiApplicationEntryPointString[NumEntryPoints].Replace(Dict)) else: - AutoGenC.Append(gUefiApplicationEntryPointString[2].Replace(Dict)) - AutoGenH.Append(gUefiApplicationEntryPointPrototype.Replace(Dict)) + AutoGenC.append(gUefiApplicationEntryPointString[2].Replace(Dict)) + AutoGenH.append(gUefiApplicationEntryPointPrototype.Replace(Dict)) ## Create code for ModuleUnloadImage # @@ -1566,10 +1560,10 @@ def CreateModuleUnloadImageCode(Info, AutoGenC, AutoGenH): NumUnloadImage = len(Info.Module.ModuleUnloadImageList) Dict = {'Count':str(NumUnloadImage) + 'U', 'Function':Info.Module.ModuleUnloadImageList} if NumUnloadImage < 2: - AutoGenC.Append(gUefiUnloadImageString[NumUnloadImage].Replace(Dict)) + AutoGenC.append(gUefiUnloadImageString[NumUnloadImage].Replace(Dict)) else: - AutoGenC.Append(gUefiUnloadImageString[2].Replace(Dict)) - AutoGenH.Append(gUefiUnloadImagePrototype.Replace(Dict)) + AutoGenC.append(gUefiUnloadImageString[2].Replace(Dict)) + AutoGenH.append(gUefiUnloadImagePrototype.Replace(Dict)) ## Create code for GUID # @@ -1585,15 +1579,15 @@ def CreateGuidDefinitionCode(Info, AutoGenC, AutoGenH): if Info.GuidList: if not Info.IsLibrary: - AutoGenC.Append("\n// Guids\n") - AutoGenH.Append("\n// Guids\n") + AutoGenC.append("\n// Guids\n") + AutoGenH.append("\n// Guids\n") # # GUIDs # for Key in Info.GuidList: if not Info.IsLibrary: - AutoGenC.Append('GLOBAL_REMOVE_IF_UNREFERENCED %s %s = %s;\n' % (GuidType, Key, Info.GuidList[Key])) - AutoGenH.Append('extern %s %s;\n' % (GuidType, Key)) + AutoGenC.append('GLOBAL_REMOVE_IF_UNREFERENCED %s %s = %s;\n' % (GuidType, Key, Info.GuidList[Key])) + AutoGenH.append('extern %s %s;\n' % (GuidType, Key)) ## Create code for protocol # @@ -1609,15 +1603,15 @@ def CreateProtocolDefinitionCode(Info, AutoGenC, AutoGenH): if Info.ProtocolList: if not Info.IsLibrary: - AutoGenC.Append("\n// Protocols\n") - AutoGenH.Append("\n// Protocols\n") + AutoGenC.append("\n// Protocols\n") + AutoGenH.append("\n// Protocols\n") # # Protocol GUIDs # for Key in Info.ProtocolList: if not Info.IsLibrary: - AutoGenC.Append('GLOBAL_REMOVE_IF_UNREFERENCED %s %s = %s;\n' % (GuidType, Key, Info.ProtocolList[Key])) - AutoGenH.Append('extern %s %s;\n' % (GuidType, Key)) + AutoGenC.append('GLOBAL_REMOVE_IF_UNREFERENCED %s %s = %s;\n' % (GuidType, Key, Info.ProtocolList[Key])) + AutoGenH.append('extern %s %s;\n' % (GuidType, Key)) ## Create code for PPI # @@ -1633,15 +1627,15 @@ def CreatePpiDefinitionCode(Info, AutoGenC, AutoGenH): if Info.PpiList: if not Info.IsLibrary: - AutoGenC.Append("\n// PPIs\n") - AutoGenH.Append("\n// PPIs\n") + AutoGenC.append("\n// PPIs\n") + AutoGenH.append("\n// PPIs\n") # # PPI GUIDs # for Key in Info.PpiList: if not Info.IsLibrary: - AutoGenC.Append('GLOBAL_REMOVE_IF_UNREFERENCED %s %s = %s;\n' % (GuidType, Key, Info.PpiList[Key])) - AutoGenH.Append('extern %s %s;\n' % (GuidType, Key)) + AutoGenC.append('GLOBAL_REMOVE_IF_UNREFERENCED %s %s = %s;\n' % (GuidType, Key, Info.PpiList[Key])) + AutoGenH.append('extern %s %s;\n' % (GuidType, Key)) ## Create code for PCD # @@ -1658,36 +1652,36 @@ def CreatePcdCode(Info, AutoGenC, AutoGenH): TokenSpaceList += [Pcd.TokenSpaceGuidCName] SkuMgr = Info.Workspace.Platform.SkuIdMgr - AutoGenH.Append("\n// Definition of SkuId Array\n") - AutoGenH.Append("extern UINT64 _gPcd_SkuId_Array[];\n") + AutoGenH.append("\n// Definition of SkuId Array\n") + AutoGenH.append("extern UINT64 _gPcd_SkuId_Array[];\n") # Add extern declarations to AutoGen.h if one or more Token Space GUIDs were found if TokenSpaceList: - AutoGenH.Append("\n// Definition of PCD Token Space GUIDs used in this module\n\n") + AutoGenH.append("\n// Definition of PCD Token Space GUIDs used in this module\n\n") if Info.ModuleType in [SUP_MODULE_USER_DEFINED, SUP_MODULE_BASE]: GuidType = TAB_GUID else: GuidType = "EFI_GUID" for Item in TokenSpaceList: - AutoGenH.Append('extern %s %s;\n' % (GuidType, Item)) + AutoGenH.append('extern %s %s;\n' % (GuidType, Item)) if Info.IsLibrary: if Info.ModulePcdList: - AutoGenH.Append("\n// PCD definitions\n") + AutoGenH.append("\n// PCD definitions\n") for Pcd in Info.ModulePcdList: CreateLibraryPcdCode(Info, AutoGenC, AutoGenH, Pcd) DynExPcdTokenNumberMapping (Info, AutoGenH) else: - AutoGenC.Append("\n// Definition of SkuId Array\n") - AutoGenC.Append("GLOBAL_REMOVE_IF_UNREFERENCED UINT64 _gPcd_SkuId_Array[] = %s;\n" % SkuMgr.DumpSkuIdArrary()) + AutoGenC.append("\n// Definition of SkuId Array\n") + AutoGenC.append("GLOBAL_REMOVE_IF_UNREFERENCED UINT64 _gPcd_SkuId_Array[] = %s;\n" % SkuMgr.DumpSkuIdArrary()) if Info.ModulePcdList: - AutoGenH.Append("\n// Definition of PCDs used in this module\n") - AutoGenC.Append("\n// Definition of PCDs used in this module\n") + AutoGenH.append("\n// Definition of PCDs used in this module\n") + AutoGenC.append("\n// Definition of PCDs used in this module\n") for Pcd in Info.ModulePcdList: CreateModulePcdCode(Info, AutoGenC, AutoGenH, Pcd) DynExPcdTokenNumberMapping (Info, AutoGenH) if Info.LibraryPcdList: - AutoGenH.Append("\n// Definition of PCDs used in libraries is in AutoGen.c\n") - AutoGenC.Append("\n// Definition of PCDs used in libraries\n") + AutoGenH.append("\n// Definition of PCDs used in libraries is in AutoGen.c\n") + AutoGenC.append("\n// Definition of PCDs used in libraries\n") for Pcd in Info.LibraryPcdList: CreateModulePcdCode(Info, AutoGenC, AutoGenC, Pcd) CreatePcdDatabaseCode(Info, AutoGenC, AutoGenH) @@ -1749,13 +1743,13 @@ def CreateUnicodeStringCode(Info, AutoGenC, AutoGenH, UniGenCFlag, UniGenBinBuff FilterInfo = [EDK2Module] + [Info.PlatformInfo.Platform.ISOLanguages] Header, Code = GetStringFiles(Info.UnicodeFileList, SrcList, IncList, Info.IncludePathList, ['.uni', '.inf'], Info.Name, CompatibleMode, ShellMode, UniGenCFlag, UniGenBinBuffer, FilterInfo) if CompatibleMode or UniGenCFlag: - AutoGenC.Append("\n//\n//Unicode String Pack Definition\n//\n") - AutoGenC.Append(Code) - AutoGenC.Append("\n") - AutoGenH.Append("\n//\n//Unicode String ID\n//\n") - AutoGenH.Append(Header) + AutoGenC.append("\n//\n//Unicode String Pack Definition\n//\n") + AutoGenC.append(Code) + AutoGenC.append("\n") + AutoGenH.append("\n//\n//Unicode String ID\n//\n") + AutoGenH.append(Header) if CompatibleMode or UniGenCFlag: - AutoGenH.Append("\n#define STRING_ARRAY_NAME %sStrings\n" % Info.Name) + AutoGenH.append("\n#define STRING_ARRAY_NAME %sStrings\n" % Info.Name) os.chdir(WorkingDir) def CreateIdfFileCode(Info, AutoGenC, StringH, IdfGenCFlag, IdfGenBinBuffer): @@ -1769,7 +1763,7 @@ def CreateIdfFileCode(Info, AutoGenC, StringH, IdfGenCFlag, IdfGenBinBuffer): SkipList = ['.jpg', '.png', '.bmp', '.inf', '.idf'] FileList = GetFileList(SrcList, IncList, SkipList) ValueStartPtr = 60 - StringH.Append("\n//\n//Image ID\n//\n") + StringH.append("\n//\n//Image ID\n//\n") ImageInfoOffset = 0 PaletteInfoOffset = 0 ImageBuffer = pack('x') @@ -1810,7 +1804,7 @@ def CreateIdfFileCode(Info, AutoGenC, StringH, IdfGenCFlag, IdfGenBinBuffer): BufferStr = WriteLine(BufferStr, '// %s: %s: %s' % (DecToHexStr(Index, 4), ID, DecToHexStr(Index, 4))) TempBufferList = AscToHexList(DuplicateBlock) BufferStr = WriteLine(BufferStr, CreateArrayItem(TempBufferList, 16) + '\n') - StringH.Append(Line) + StringH.append(Line) Index += 1 continue @@ -1843,7 +1837,7 @@ def CreateIdfFileCode(Info, AutoGenC, StringH, IdfGenCFlag, IdfGenBinBuffer): TempBufferList = AscToHexList(TempBuffer) BufferStr = WriteLine(BufferStr, CreateArrayItem(TempBufferList, 16) + '\n') - StringH.Append(Line) + StringH.append(Line) Index += 1 BufferStr = WriteLine(BufferStr, '// End of the Image Info') @@ -1881,7 +1875,7 @@ def CreateIdfFileCode(Info, AutoGenC, StringH, IdfGenCFlag, IdfGenBinBuffer): if IdfGenCFlag: TotalLength = EFI_HII_ARRAY_SIZE_LENGTH + PACKAGE_HEADER_Length - AutoGenC.Append("\n//\n//Image Pack Definition\n//\n") + AutoGenC.append("\n//\n//Image Pack Definition\n//\n") AllStr = WriteLine('', CHAR_ARRAY_DEFIN + ' ' + Info.Module.BaseName + 'Images' + '[] = {\n') AllStr = WriteLine(AllStr, '// STRGATHER_OUTPUT_HEADER') AllStr = WriteLine(AllStr, CreateArrayItem(DecToHexList(TotalLength)) + '\n') @@ -1899,10 +1893,10 @@ def CreateIdfFileCode(Info, AutoGenC, StringH, IdfGenCFlag, IdfGenBinBuffer): AllStr = WriteLine(AllStr, '// Palette Data\n') AllStr = WriteLine(AllStr, PaletteStr) AllStr = WriteLine(AllStr, '};') - AutoGenC.Append(AllStr) - AutoGenC.Append("\n") - StringH.Append('\nextern unsigned char ' + Info.Module.BaseName + 'Images[];\n') - StringH.Append("\n#define IMAGE_ARRAY_NAME %sImages\n" % Info.Module.BaseName) + AutoGenC.append(AllStr) + AutoGenC.append("\n") + StringH.append('\nextern unsigned char ' + Info.Module.BaseName + 'Images[];\n') + StringH.append("\n#define IMAGE_ARRAY_NAME %sImages\n" % Info.Module.BaseName) # typedef struct _EFI_HII_IMAGE_PACKAGE_HDR { # EFI_HII_PACKAGE_HEADER Header; # Standard package header, where Header.Type = EFI_HII_PACKAGE_IMAGES @@ -2007,48 +2001,48 @@ def BmpImageDecoder(File, Buffer, PaletteIndex, TransParent): # def CreateHeaderCode(Info, AutoGenC, AutoGenH): # file header - AutoGenH.Append(gAutoGenHeaderString.Replace({'FileName':'AutoGen.h'})) + AutoGenH.append(gAutoGenHeaderString.Replace({'FileName':'AutoGen.h'})) # header file Prologue - AutoGenH.Append(gAutoGenHPrologueString.Replace({'File':'AUTOGENH','Guid':Info.Guid.replace('-','_')})) - AutoGenH.Append(gAutoGenHCppPrologueString) + AutoGenH.append(gAutoGenHPrologueString.Replace({'File':'AUTOGENH','Guid':Info.Guid.replace('-','_')})) + AutoGenH.append(gAutoGenHCppPrologueString) if Info.AutoGenVersion >= 0x00010005: # header files includes - AutoGenH.Append("#include <%s>\n" % gBasicHeaderFile) + AutoGenH.append("#include <%s>\n" % gBasicHeaderFile) if Info.ModuleType in gModuleTypeHeaderFile \ and gModuleTypeHeaderFile[Info.ModuleType][0] != gBasicHeaderFile: - AutoGenH.Append("#include <%s>\n" % gModuleTypeHeaderFile[Info.ModuleType][0]) + AutoGenH.append("#include <%s>\n" % gModuleTypeHeaderFile[Info.ModuleType][0]) # # if either PcdLib in [LibraryClasses] sections or there exist Pcd section, add PcdLib.h # As if modules only uses FixedPcd, then PcdLib is not needed in [LibraryClasses] section. # if 'PcdLib' in Info.Module.LibraryClasses or Info.Module.Pcds: - AutoGenH.Append("#include <Library/PcdLib.h>\n") + AutoGenH.append("#include <Library/PcdLib.h>\n") - AutoGenH.Append('\nextern GUID gEfiCallerIdGuid;') - AutoGenH.Append('\nextern CHAR8 *gEfiCallerBaseName;\n\n') + AutoGenH.append('\nextern GUID gEfiCallerIdGuid;') + AutoGenH.append('\nextern CHAR8 *gEfiCallerBaseName;\n\n') if Info.IsLibrary: return - AutoGenH.Append("#define EFI_CALLER_ID_GUID \\\n %s\n" % GuidStringToGuidStructureString(Info.Guid)) + AutoGenH.append("#define EFI_CALLER_ID_GUID \\\n %s\n" % GuidStringToGuidStructureString(Info.Guid)) if Info.IsLibrary: return # C file header - AutoGenC.Append(gAutoGenHeaderString.Replace({'FileName':'AutoGen.c'})) + AutoGenC.append(gAutoGenHeaderString.Replace({'FileName':'AutoGen.c'})) if Info.AutoGenVersion >= 0x00010005: # C file header files includes if Info.ModuleType in gModuleTypeHeaderFile: for Inc in gModuleTypeHeaderFile[Info.ModuleType]: - AutoGenC.Append("#include <%s>\n" % Inc) + AutoGenC.append("#include <%s>\n" % Inc) else: - AutoGenC.Append("#include <%s>\n" % gBasicHeaderFile) + AutoGenC.append("#include <%s>\n" % gBasicHeaderFile) # # Publish the CallerId Guid # - AutoGenC.Append('\nGLOBAL_REMOVE_IF_UNREFERENCED GUID gEfiCallerIdGuid = %s;\n' % GuidStringToGuidStructureString(Info.Guid)) - AutoGenC.Append('\nGLOBAL_REMOVE_IF_UNREFERENCED CHAR8 *gEfiCallerBaseName = "%s";\n' % Info.Name) + AutoGenC.append('\nGLOBAL_REMOVE_IF_UNREFERENCED GUID gEfiCallerIdGuid = %s;\n' % GuidStringToGuidStructureString(Info.Guid)) + AutoGenC.append('\nGLOBAL_REMOVE_IF_UNREFERENCED CHAR8 *gEfiCallerBaseName = "%s";\n' % Info.Name) ## Create common code for header file # @@ -2057,7 +2051,7 @@ def CreateHeaderCode(Info, AutoGenC, AutoGenH): # @param AutoGenH The TemplateString object for header file # def CreateFooterCode(Info, AutoGenC, AutoGenH): - AutoGenH.Append(gAutoGenHEpilogueString) + AutoGenH.append(gAutoGenHEpilogueString) ## Create code for a module # @@ -2086,8 +2080,8 @@ def CreateCode(Info, AutoGenC, AutoGenH, StringH, UniGenCFlag, UniGenBinBuffer, if Info.UnicodeFileList: FileName = "%sStrDefs.h" % Info.Name - StringH.Append(gAutoGenHeaderString.Replace({'FileName':FileName})) - StringH.Append(gAutoGenHPrologueString.Replace({'File':'STRDEFS', 'Guid':Info.Guid.replace('-','_')})) + StringH.append(gAutoGenHeaderString.Replace({'FileName':FileName})) + StringH.append(gAutoGenHPrologueString.Replace({'File':'STRDEFS', 'Guid':Info.Guid.replace('-','_')})) CreateUnicodeStringCode(Info, AutoGenC, StringH, UniGenCFlag, UniGenBinBuffer) GuidMacros = [] @@ -2124,25 +2118,25 @@ def CreateCode(Info, AutoGenC, AutoGenH, StringH, UniGenCFlag, UniGenBinBuffer, GuidMacros.append('#include "%sImgDefs.h"' % Info.Name) if GuidMacros: - StringH.Append('\n#ifdef VFRCOMPILE\n%s\n#endif\n' % '\n'.join(GuidMacros)) + StringH.append('\n#ifdef VFRCOMPILE\n%s\n#endif\n' % '\n'.join(GuidMacros)) - StringH.Append("\n#endif\n") - AutoGenH.Append('#include "%s"\n' % FileName) + StringH.append("\n#endif\n") + AutoGenH.append('#include "%s"\n' % FileName) if Info.IdfFileList: FileName = "%sImgDefs.h" % Info.Name - StringIdf.Append(gAutoGenHeaderString.Replace({'FileName':FileName})) - StringIdf.Append(gAutoGenHPrologueString.Replace({'File':'IMAGEDEFS', 'Guid':Info.Guid.replace('-','_')})) + StringIdf.append(gAutoGenHeaderString.Replace({'FileName':FileName})) + StringIdf.append(gAutoGenHPrologueString.Replace({'File':'IMAGEDEFS', 'Guid':Info.Guid.replace('-','_')})) CreateIdfFileCode(Info, AutoGenC, StringIdf, IdfGenCFlag, IdfGenBinBuffer) - StringIdf.Append("\n#endif\n") - AutoGenH.Append('#include "%s"\n' % FileName) + StringIdf.append("\n#endif\n") + AutoGenH.append('#include "%s"\n' % FileName) CreateFooterCode(Info, AutoGenC, AutoGenH) # no generation of AutoGen.c for Edk modules without unicode file if Info.AutoGenVersion < 0x00010005 and len(Info.UnicodeFileList) == 0: - AutoGenC.String = '' + AutoGenC = [] ## Create the code file # diff --git a/BaseTools/Source/Python/AutoGen/GenMake.py b/BaseTools/Source/Python/AutoGen/GenMake.py index 6e83b3d73e61..7a088d68df60 100644 --- a/BaseTools/Source/Python/AutoGen/GenMake.py +++ b/BaseTools/Source/Python/AutoGen/GenMake.py @@ -34,6 +34,10 @@ gIncludePattern = re.compile(r"^[ \t]*#?[ \t]*include(?:[ \t]*(?:\\(?:\r\n|\r|\n gMacroPattern = re.compile("([_A-Z][_A-Z0-9]*)[ \t]*\((.+)\)", re.UNICODE) gIsFileMap = {} +gMacroPatternfindall = gMacroPattern.findall +ospathnormpath = os.path.normpath +ospathjoin = os.path.join +ospathisfile = os.path.isfile ## pattern for include style in Edk.x code gProtocolDefinition = "Protocol/%(HeaderKey)s/%(HeaderKey)s.h" @@ -879,10 +883,10 @@ cleanlib: if File.Ext == '.h': ForceIncludedFile.append(File) SourceFileList = [] - OutPutFileList = [] + OutPutFileList = set() for Target in self._AutoGenObject.IntroTargetList: SourceFileList.extend(Target.Inputs) - OutPutFileList.extend(Target.Outputs) + OutPutFileList.union(Target.Outputs) if OutPutFileList: for Item in OutPutFileList: @@ -986,10 +990,7 @@ cleanlib: # @retval dict The mapping between source file path and its dependencies # def GetFileDependency(self, FileList, ForceInculeList, SearchPathList): - Dependency = {} - for F in FileList: - Dependency[F] = self.GetDependencyList(F, ForceInculeList, SearchPathList) - return Dependency + return {F:self.GetDependencyList(F, ForceInculeList, SearchPathList) for F in FileList} ## Find dependencies for one source file # @@ -1005,25 +1006,23 @@ cleanlib: # def GetDependencyList(self, File, ForceList, SearchPathList): EdkLogger.debug(EdkLogger.DEBUG_1, "Try to get dependency files for %s" % File) - FileStack = [File] + ForceList - DependencySet = set() + DependencySet = set([File] + ForceList) + FileStack = set(DependencySet) if self._AutoGenObject.Arch not in gDependencyDatabase: gDependencyDatabase[self._AutoGenObject.Arch] = {} DepDb = gDependencyDatabase[self._AutoGenObject.Arch] - while len(FileStack) > 0: + while FileStack: F = FileStack.pop() - FullPathDependList = [] + # check the module specific cache if this file was already done. if F in self.FileCache: - for CacheFile in self.FileCache[F]: - FullPathDependList.append(CacheFile) - if CacheFile not in DependencySet: - FileStack.append(CacheFile) - DependencySet.update(FullPathDependList) + FullPathDependSet = self.FileCache[F] + # extend FileStack with all not already in DependencySet or FileStack (analyzed for previous component) + FileStack.update(FullPathDependSet.difference(DependencySet)) + DependencySet.update(FullPathDependSet) continue - CurrentFileDependencyList = [] if F in DepDb: CurrentFileDependencyList = DepDb[F] @@ -1038,14 +1037,14 @@ cleanlib: if len(FileContent) == 0: continue - if FileContent[0] == 0xff or FileContent[0] == 0xfe: + if FileContent[0] in {0xff,0xfe}: FileContent = unicode(FileContent, "utf-16") IncludedFileList = gIncludePattern.findall(FileContent) for Inc in IncludedFileList: Inc = Inc.strip() # if there's macro used to reference header file, expand it - HeaderList = gMacroPattern.findall(Inc) + HeaderList = gMacroPatternfindall(Inc) if len(HeaderList) == 1 and len(HeaderList[0]) == 2: HeaderType = HeaderList[0][0] HeaderKey = HeaderList[0][1] @@ -1056,42 +1055,40 @@ cleanlib: # returning a empty dependency self.FileCache[File] = [] return [] - Inc = os.path.normpath(Inc) + Inc = ospathnormpath(Inc) CurrentFileDependencyList.append(Inc) DepDb[F] = CurrentFileDependencyList CurrentFilePath = F.Dir PathList = [CurrentFilePath] + SearchPathList + FullPathDependSet = set() for Inc in CurrentFileDependencyList: for SearchPath in PathList: - FilePath = os.path.join(SearchPath, Inc) + FilePath = ospathjoin(SearchPath, Inc) if FilePath in gIsFileMap: if not gIsFileMap[FilePath]: continue # If isfile is called too many times, the performance is slow down. - elif not os.path.isfile(FilePath): + elif not ospathisfile(FilePath): gIsFileMap[FilePath] = False continue else: gIsFileMap[FilePath] = True FilePath = PathClass(FilePath) - FullPathDependList.append(FilePath) + FullPathDependSet.add(FilePath) if FilePath not in DependencySet: - FileStack.append(FilePath) + FileStack.add(FilePath) break else: EdkLogger.debug(EdkLogger.DEBUG_9, "%s included by %s was not found "\ "in any given path:\n\t%s" % (Inc, F, "\n\t".join(SearchPathList))) - self.FileCache[F] = FullPathDependList - DependencySet.update(FullPathDependList) + self.FileCache[F] = FullPathDependSet + DependencySet.update(FullPathDependSet) - DependencySet.update(ForceList) - if File in DependencySet: - DependencySet.remove(File) - DependencyList = list(DependencySet) # remove duplicate ones - - return DependencyList + # now remove the initial file + DependencySet.remove(File) + return list(DependencySet) _TemplateDict = property(_CreateTemplateDict) diff --git a/BaseTools/Source/Python/AutoGen/GenPcdDb.py b/BaseTools/Source/Python/AutoGen/GenPcdDb.py index 2e05b77e14c2..4390dfe840bd 100644 --- a/BaseTools/Source/Python/AutoGen/GenPcdDb.py +++ b/BaseTools/Source/Python/AutoGen/GenPcdDb.py @@ -10,7 +10,6 @@ # THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. # -from StringIO import StringIO from Common.Misc import * from Common.StringUtils import StringToArray from struct import pack @@ -865,7 +864,7 @@ def BuildExDataBase(Dict): # @param AutoGenC The TemplateString object for C code # @param AutoGenH The TemplateString object for header file # -def CreatePcdDatabaseCode (Info, AutoGenC, AutoGenH): +def CreatePcdDatabaseCode (Info, AutoGenC=None, AutoGenH=None): if Info.PcdIsDriver == "": return if Info.PcdIsDriver not in gPcdPhaseMap: @@ -873,24 +872,26 @@ def CreatePcdDatabaseCode (Info, AutoGenC, AutoGenH): ExtraData="[%s]" % str(Info)) AdditionalAutoGenH, AdditionalAutoGenC, PcdDbBuffer = NewCreatePcdDatabasePhaseSpecificAutoGen (Info.PlatformInfo, 'PEI') - AutoGenH.Append(AdditionalAutoGenH.String) + if AutoGenH: + AutoGenH += AdditionalAutoGenH Phase = gPcdPhaseMap[Info.PcdIsDriver] - if Phase == 'PEI': - AutoGenC.Append(AdditionalAutoGenC.String) + if Phase == 'PEI' and AutoGenC: + AutoGenC += AdditionalAutoGenC - if Phase == 'DXE': + if Phase == 'DXE' and (AutoGenC or AutoGenH): AdditionalAutoGenH, AdditionalAutoGenC, PcdDbBuffer = NewCreatePcdDatabasePhaseSpecificAutoGen (Info.PlatformInfo, Phase) - AutoGenH.Append(AdditionalAutoGenH.String) - AutoGenC.Append(AdditionalAutoGenC.String) + if AutoGenH: + AutoGenH += AdditionalAutoGenH + if AutoGenC: + AutoGenC += AdditionalAutoGenC if Info.IsBinaryModule: DbFileName = os.path.join(Info.PlatformInfo.BuildDir, TAB_FV_DIRECTORY, Phase + "PcdDataBase.raw") else: DbFileName = os.path.join(Info.OutputDir, Phase + "PcdDataBase.raw") - DbFile = StringIO() - DbFile.write(PcdDbBuffer) - Changed = SaveFileOnChange(DbFileName, DbFile.getvalue(), True) + Changed = SaveFileOnChange(DbFileName, PcdDbBuffer, True) + def CreatePcdDataBase(PcdDBData): delta = {} for skuname,skuid in PcdDBData: @@ -923,15 +924,13 @@ def CreatePcdDataBase(PcdDBData): return newbuffer -def CreateVarCheckBin(VarCheckTab): - return VarCheckTab[(TAB_DEFAULT,"0")] - def CreateAutoGen(PcdDriverAutoGenData): - autogenC = TemplateString() + autogenC = [] for skuname,skuid in PcdDriverAutoGenData: - autogenC.Append("//SKUID: %s" % skuname) - autogenC.Append(PcdDriverAutoGenData[(skuname,skuid)][1].String) - return (PcdDriverAutoGenData[(skuname,skuid)][0],autogenC) + autogenC.append("//SKUID: %s" % skuname) + autogenC += PcdDriverAutoGenData[(skuname,skuid)][1] + return PcdDriverAutoGenData[(skuname,skuid)][0],autogenC + def NewCreatePcdDatabasePhaseSpecificAutoGen(Platform,Phase): def prune_sku(pcd,skuname): new_pcd = copy.deepcopy(pcd) @@ -968,7 +967,7 @@ def NewCreatePcdDatabasePhaseSpecificAutoGen(Platform,Phase): VarCheckTableData[(skuname,skuid)] = VarCheckTab if Platform.Platform.VarCheckFlag: dest = os.path.join(Platform.BuildDir, TAB_FV_DIRECTORY) - VarCheckTable = CreateVarCheckBin(VarCheckTableData) + VarCheckTable = VarCheckTableData[(TAB_DEFAULT,"0")] VarCheckTable.dump(dest, Phase) AdditionalAutoGenH, AdditionalAutoGenC = CreateAutoGen(PcdDriverAutoGenData) else: @@ -986,9 +985,6 @@ def NewCreatePcdDatabasePhaseSpecificAutoGen(Platform,Phase): # respectively # def CreatePcdDatabasePhaseSpecificAutoGen (Platform, DynamicPcdList, Phase): - AutoGenC = TemplateString() - AutoGenH = TemplateString() - Dict = { 'PHASE' : Phase, 'SERVICE_DRIVER_VERSION' : DATABASE_VERSION, @@ -1562,9 +1558,9 @@ def CreatePcdDatabasePhaseSpecificAutoGen (Platform, DynamicPcdList, Phase): Dict['SKUID_VALUE'].append(AvailableSkuNumber) Dict['SKUID_VALUE'][0] = len(Dict['SKUID_VALUE']) - 1 - AutoGenH.Append(gPcdDatabaseAutoGenH.Replace(Dict)) + AutoGenC = [] if NumberOfLocalTokens == 0: - AutoGenC.Append(gEmptyPcdDatabaseAutoGenC.Replace(Dict)) + AutoGenC.append(gEmptyPcdDatabaseAutoGenC.Replace(Dict)) else: # # Update Size Table to the right order, it should be same with LocalTokenNumberTable @@ -1595,12 +1591,12 @@ def CreatePcdDatabasePhaseSpecificAutoGen (Platform, DynamicPcdList, Phase): Dict['SIZE_TABLE_CURRENT_LENGTH'][Count] = SizeCurLenTempList[Count] Dict['SIZE_TABLE_MAXIMUM_LENGTH'][Count] = SizeMaxLenTempList[Count] - AutoGenC.Append(gPcdDatabaseAutoGenC.Replace(Dict)) + AutoGenC.append(gPcdDatabaseAutoGenC.Replace(Dict)) # print Phase Buffer = BuildExDataBase(Dict) - return AutoGenH, AutoGenC, Buffer,VarCheckTab + return [gPcdDatabaseAutoGenH.Replace(Dict)], AutoGenC, Buffer,VarCheckTab def GetOrderedDynamicPcdList(DynamicPcdList, PcdTokenNumberList): ReorderedDyPcdList = [None for i in range(len(DynamicPcdList))] diff --git a/BaseTools/Source/Python/Common/Misc.py b/BaseTools/Source/Python/Common/Misc.py index 90350f863826..4e1953f6f427 100644 --- a/BaseTools/Source/Python/Common/Misc.py +++ b/BaseTools/Source/Python/Common/Misc.py @@ -14,6 +14,7 @@ ## # Import Modules # +from collections import deque import Common.LongFilePathOs as os import sys import string @@ -25,8 +26,6 @@ import cPickle import array import shutil from struct import pack -from UserDict import IterableUserDict -from UserList import UserList from Common import EdkLogger as EdkLogger from Common import GlobalData as GlobalData @@ -737,7 +736,7 @@ class TemplateString(object): if PlaceHolder not in PlaceHolderValues: continue Value = PlaceHolderValues[PlaceHolder] - if type(Value) in self._LIST_TYPES: + if type(Value) in TemplateString.Section._LIST_TYPES: if RepeatTime < 0: RepeatTime = len(Value) elif RepeatTime != len(Value): @@ -774,11 +773,9 @@ class TemplateString(object): return "".join(StringList) ## Constructor - def __init__(self, Template=None): + def __init__(self, Template = ''): self.String = '' - self.IsBinary = False - self._Template = Template - self._TemplateSectionList = self._Parse(Template) + self._TemplateSectionList = TemplateString._Parse(Template) ## str() operator # @@ -791,38 +788,34 @@ class TemplateString(object): # # @retval list A list of TemplateString.Section objects # - def _Parse(self, Template): + @staticmethod + def _Parse(Template): SectionStart = 0 SearchFrom = 0 - MatchEnd = 0 PlaceHolderList = [] TemplateSectionList = [] - while Template: + while True: MatchObj = gPlaceholderPattern.search(Template, SearchFrom) if not MatchObj: - if MatchEnd <= len(Template): - TemplateSection = TemplateString.Section(Template[SectionStart:], PlaceHolderList) - TemplateSectionList.append(TemplateSection) + if SearchFrom <= len(Template): + TemplateSectionList.append(TemplateString.Section(Template[SectionStart:], PlaceHolderList)) break MatchString = MatchObj.group(1) MatchStart = MatchObj.start() - MatchEnd = MatchObj.end() + SearchFrom = MatchObj.end() - if MatchString == self._REPEAT_START_FLAG: + if MatchString == TemplateString._REPEAT_START_FLAG: if MatchStart > SectionStart: - TemplateSection = TemplateString.Section(Template[SectionStart:MatchStart], PlaceHolderList) - TemplateSectionList.append(TemplateSection) - SectionStart = MatchEnd + TemplateSectionList.append(TemplateString.Section(Template[SectionStart:MatchStart], PlaceHolderList)) + SectionStart = SearchFrom PlaceHolderList = [] - elif MatchString == self._REPEAT_END_FLAG: - TemplateSection = TemplateString.Section(Template[SectionStart:MatchStart], PlaceHolderList) - TemplateSectionList.append(TemplateSection) - SectionStart = MatchEnd + elif MatchString == TemplateString._REPEAT_END_FLAG: + TemplateSectionList.append(TemplateString.Section(Template[SectionStart:MatchStart], PlaceHolderList)) + SectionStart = SearchFrom PlaceHolderList = [] else: - PlaceHolderList.append((MatchString, MatchStart - SectionStart, MatchEnd - SectionStart)) - SearchFrom = MatchEnd + PlaceHolderList.append((MatchString, MatchStart - SectionStart, SearchFrom - SectionStart)) return TemplateSectionList ## Replace the string template with dictionary of placeholders and append it to previous one @@ -832,7 +825,7 @@ class TemplateString(object): # def Append(self, AppendString, Dictionary=None): if Dictionary: - SectionList = self._Parse(AppendString) + SectionList = TemplateString._Parse(AppendString) self.String += "".join(S.Instantiate(Dictionary) for S in SectionList) else: self.String += AppendString @@ -919,166 +912,6 @@ class Progressor: Progressor._ProgressThread.join() Progressor._ProgressThread = None -## A dict which can access its keys and/or values orderly -# -# The class implements a new kind of dict which its keys or values can be -# accessed in the order they are added into the dict. It guarantees the order -# by making use of an internal list to keep a copy of keys. -# -class sdict(IterableUserDict): - ## Constructor - def __init__(self): - IterableUserDict.__init__(self) - self._key_list = [] - - ## [] operator - def __setitem__(self, key, value): - if key not in self._key_list: - self._key_list.append(key) - IterableUserDict.__setitem__(self, key, value) - - ## del operator - def __delitem__(self, key): - self._key_list.remove(key) - IterableUserDict.__delitem__(self, key) - - ## used in "for k in dict" loop to ensure the correct order - def __iter__(self): - return self.iterkeys() - - ## len() support - def __len__(self): - return len(self._key_list) - - ## "in" test support - def __contains__(self, key): - return key in self._key_list - - ## indexof support - def index(self, key): - return self._key_list.index(key) - - ## insert support - def insert(self, key, newkey, newvalue, order): - index = self._key_list.index(key) - if order == 'BEFORE': - self._key_list.insert(index, newkey) - IterableUserDict.__setitem__(self, newkey, newvalue) - elif order == 'AFTER': - self._key_list.insert(index + 1, newkey) - IterableUserDict.__setitem__(self, newkey, newvalue) - - ## append support - def append(self, sdict): - for key in sdict: - if key not in self._key_list: - self._key_list.append(key) - IterableUserDict.__setitem__(self, key, sdict[key]) - - def has_key(self, key): - return key in self._key_list - - ## Empty the dict - def clear(self): - self._key_list = [] - IterableUserDict.clear(self) - - ## Return a copy of keys - def keys(self): - keys = [] - for key in self._key_list: - keys.append(key) - return keys - - ## Return a copy of values - def values(self): - values = [] - for key in self._key_list: - values.append(self[key]) - return values - - ## Return a copy of (key, value) list - def items(self): - items = [] - for key in self._key_list: - items.append((key, self[key])) - return items - - ## Iteration support - def iteritems(self): - return iter(self.items()) - - ## Keys interation support - def iterkeys(self): - return iter(self.keys()) - - ## Values interation support - def itervalues(self): - return iter(self.values()) - - ## Return value related to a key, and remove the (key, value) from the dict - def pop(self, key, *dv): - value = None - if key in self._key_list: - value = self[key] - self.__delitem__(key) - elif len(dv) != 0 : - value = kv[0] - return value - - ## Return (key, value) pair, and remove the (key, value) from the dict - def popitem(self): - key = self._key_list[-1] - value = self[key] - self.__delitem__(key) - return key, value - - def update(self, dict=None, **kwargs): - if dict is not None: - for k, v in dict.items(): - self[k] = v - if len(kwargs): - for k, v in kwargs.items(): - self[k] = v - -## Dictionary with restricted keys -# -class rdict(dict): - ## Constructor - def __init__(self, KeyList): - for Key in KeyList: - dict.__setitem__(self, Key, "") - - ## []= operator - def __setitem__(self, key, value): - if key not in self: - EdkLogger.error("RestrictedDict", ATTRIBUTE_SET_FAILURE, "Key [%s] is not allowed" % key, - ExtraData=", ".join(dict.keys(self))) - dict.__setitem__(self, key, value) - - ## =[] operator - def __getitem__(self, key): - if key not in self: - return "" - return dict.__getitem__(self, key) - - ## del operator - def __delitem__(self, key): - EdkLogger.error("RestrictedDict", ATTRIBUTE_ACCESS_DENIED, ExtraData="del") - - ## Empty the dict - def clear(self): - for Key in self: - self.__setitem__(Key, "") - - ## Return value related to a key, and remove the (key, value) from the dict - def pop(self, key, *dv): - EdkLogger.error("RestrictedDict", ATTRIBUTE_ACCESS_DENIED, ExtraData="pop") - - ## Return (key, value) pair, and remove the (key, value) from the dict - def popitem(self): - EdkLogger.error("RestrictedDict", ATTRIBUTE_ACCESS_DENIED, ExtraData="popitem") - ## Dictionary using prioritized list as key # class tdict: @@ -1956,11 +1789,11 @@ class SkuClass(): ExtraData = "SKU-ID [%s] value %s exceeds the max value of UINT64" % (SkuName, SkuId)) - self.AvailableSkuIds = sdict() + self.AvailableSkuIds = {} self.SkuIdSet = [] self.SkuIdNumberSet = [] self.SkuData = SkuIds - self.__SkuInherit = {} + self.__SkuInherit = None self.__SkuIdentifier = SkuIdentifier if SkuIdentifier == '' or SkuIdentifier is None: self.SkuIdSet = ['DEFAULT'] -- 2.16.2.windows.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel