X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=BaseTools%2FSource%2FPython%2Fbuild%2FBuildReport.py;h=6b26f1c3b012d1c9eb18aa3ab72c2d183c275c94;hb=0970a80583a9a0595eb357f380e604b57136fa26;hp=e4a87898364ecba2fcd8f6e0c9b0e3a0fbde7bb1;hpb=22c4de1ac8f1fc72e8d72af6a315e584490a44b0;p=mirror_edk2.git diff --git a/BaseTools/Source/Python/build/BuildReport.py b/BaseTools/Source/Python/build/BuildReport.py index e4a8789836..6b26f1c3b0 100644 --- a/BaseTools/Source/Python/build/BuildReport.py +++ b/BaseTools/Source/Python/build/BuildReport.py @@ -5,13 +5,7 @@ # build all target completes successfully. # # Copyright (c) 2010 - 2018, Intel Corporation. All rights reserved.
-# This program and the accompanying materials -# are licensed and made available under the terms and conditions of the BSD License -# which accompanies this distribution. The full text of the license may be found at -# http://opensource.org/licenses/bsd-license.php -# -# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# SPDX-License-Identifier: BSD-2-Clause-Patent # ## Import Modules @@ -28,7 +22,7 @@ import hashlib import subprocess import threading from datetime import datetime -from io import StringIO +from io import BytesIO from Common import EdkLogger from Common.Misc import SaveFileOnChange from Common.Misc import GuidStructureByteArrayToGuidString @@ -40,12 +34,13 @@ from Common.BuildToolError import FORMAT_INVALID from Common.LongFilePathSupport import OpenLongFilePath as open from Common.MultipleWorkspace import MultipleWorkspace as mws import Common.GlobalData as GlobalData -from AutoGen.AutoGen import ModuleAutoGen +from AutoGen.ModuleAutoGen import ModuleAutoGen from Common.Misc import PathClass from Common.StringUtils import NormPath from Common.DataType import * import collections from Common.Expression import * +from GenFds.AprioriSection import DXE_APRIORI_GUID, PEI_APRIORI_GUID ## Pattern to extract contents in EDK DXS files gDxsDependencyPattern = re.compile(r"DEPENDENCY_START(.+)DEPENDENCY_END", re.DOTALL) @@ -79,7 +74,7 @@ gGlueLibEntryPoint = re.compile(r"__EDKII_GLUE_MODULE_ENTRY_POINT__\s*=\s*(\w+)" gLineMaxLength = 120 ## Tags for end of line in report -gEndOfLine = "\n" +gEndOfLine = "\r\n" ## Tags for section start, end and separator gSectionStart = ">" + "=" * (gLineMaxLength - 2) + "<" @@ -126,6 +121,9 @@ gDriverTypeMap = { ## The look up table of the supported opcode in the dependency expression binaries gOpCodeList = ["BEFORE", "AFTER", "PUSH", "AND", "OR", "NOT", "TRUE", "FALSE", "END", "SOR"] +## Save VPD Pcd +VPDPcdList = [] + ## # Writes a string to the file object. # @@ -139,13 +137,13 @@ gOpCodeList = ["BEFORE", "AFTER", "PUSH", "AND", "OR", "NOT", "TRUE", "FALSE", " def FileWrite(File, String, Wrapper=False): if Wrapper: String = textwrap.fill(String, 120) - File.write(String + gEndOfLine) + File.append(String + gEndOfLine) def ByteArrayForamt(Value): IsByteArray = False SplitNum = 16 ArrayList = [] - if Value.startswith('{') and Value.endswith('}'): + if Value.startswith('{') and Value.endswith('}') and not Value.startswith("{CODE("): Value = Value[1:-1] ValueList = Value.split(',') if len(ValueList) >= SplitNum: @@ -246,7 +244,7 @@ def FileLinesSplit(Content=None, MaxLength=None): for NewLine in NewContentList: NewContent += NewLine + TAB_LINE_BREAK - NewContent = NewContent.replace(TAB_LINE_BREAK, gEndOfLine).replace('\r\r\n', gEndOfLine) + NewContent = NewContent.replace(gEndOfLine, TAB_LINE_BREAK).replace('\r\r\n', gEndOfLine) return NewContent @@ -328,10 +326,6 @@ class LibraryReport(object): # def __init__(self, M): self.LibraryList = [] - if int(str(M.AutoGenVersion), 0) >= 0x00010005: - self._EdkIIModule = True - else: - self._EdkIIModule = False for Lib in M.DependentLibraryList: LibInfPath = str(Lib) @@ -364,28 +358,23 @@ class LibraryReport(object): LibInfPath = LibraryItem[0] FileWrite(File, LibInfPath) - # - # Report library class, library constructor and destructor for - # EDKII style module. - # - if self._EdkIIModule: - LibClass = LibraryItem[1] - EdkIILibInfo = "" - LibConstructor = " ".join(LibraryItem[2]) - if LibConstructor: - EdkIILibInfo += " C = " + LibConstructor - LibDestructor = " ".join(LibraryItem[3]) - if LibDestructor: - EdkIILibInfo += " D = " + LibDestructor - LibDepex = " ".join(LibraryItem[4]) - if LibDepex: - EdkIILibInfo += " Depex = " + LibDepex - if LibraryItem[5]: - EdkIILibInfo += " Time = " + LibraryItem[5] - if EdkIILibInfo: - FileWrite(File, "{%s: %s}" % (LibClass, EdkIILibInfo)) - else: - FileWrite(File, "{%s}" % LibClass) + LibClass = LibraryItem[1] + EdkIILibInfo = "" + LibConstructor = " ".join(LibraryItem[2]) + if LibConstructor: + EdkIILibInfo += " C = " + LibConstructor + LibDestructor = " ".join(LibraryItem[3]) + if LibDestructor: + EdkIILibInfo += " D = " + LibDestructor + LibDepex = " ".join(LibraryItem[4]) + if LibDepex: + EdkIILibInfo += " Depex = " + LibDepex + if LibraryItem[5]: + EdkIILibInfo += " Time = " + LibraryItem[5] + if EdkIILibInfo: + FileWrite(File, "{%s: %s}" % (LibClass, EdkIILibInfo)) + else: + FileWrite(File, "{%s}" % LibClass) FileWrite(File, gSubSectionEnd) @@ -569,6 +558,7 @@ class ModuleReport(object): def __init__(self, M, ReportType): self.ModuleName = M.Module.BaseName self.ModuleInfPath = M.MetaFile.File + self.ModuleArch = M.Arch self.FileGuid = M.Guid self.Size = 0 self.BuildTimeStamp = None @@ -600,7 +590,7 @@ class ModuleReport(object): # Collect all module used PCD set: module INF referenced directly or indirectly. # It also saves module INF default values of them in case they exist. # - for Pcd in list(M.ModulePcdList) + list(M.LibraryPcdList): + for Pcd in M.ModulePcdList + M.LibraryPcdList: self.ModulePcdSet.setdefault((Pcd.TokenCName, Pcd.TokenSpaceGuidCName, Pcd.Type), (Pcd.InfDefaultValue, Pcd.DefaultValue)) self.LibraryReport = None @@ -631,10 +621,10 @@ class ModuleReport(object): def GenerateReport(self, File, GlobalPcdReport, GlobalPredictionReport, GlobalDepexParser, ReportType): FileWrite(File, gSectionStart) - FwReportFileName = os.path.join(self._BuildDir, "DEBUG", self.ModuleName + ".txt") + FwReportFileName = os.path.join(self._BuildDir, "OUTPUT", self.ModuleName + ".txt") if os.path.isfile(FwReportFileName): try: - FileContents = open(FwReportFileName, 'r').read() + FileContents = open(FwReportFileName).read() Match = gModuleSizePattern.search(FileContents) if Match: self.Size = int(Match.group(1)) @@ -679,6 +669,7 @@ class ModuleReport(object): FileWrite(File, "Module Summary") FileWrite(File, "Module Name: %s" % self.ModuleName) + FileWrite(File, "Module Arch: %s" % self.ModuleArch) FileWrite(File, "Module INF Path: %s" % self.ModuleInfPath) FileWrite(File, "File GUID: %s" % self.FileGuid) if self.Size: @@ -785,6 +776,13 @@ class PcdReport(object): # Collect the PCD defined in DSC/FDF file, but not used in module # UnusedPcdFullList = [] + StructPcdDict = GlobalData.gStructurePcd.get(self.Arch, collections.OrderedDict()) + for Name, Guid in StructPcdDict: + if (Name, Guid) not in Pa.Platform.Pcds: + Pcd = StructPcdDict[(Name, Guid)] + PcdList = self.AllPcds.setdefault(Guid, {}).setdefault(Pcd.Type, []) + if Pcd not in PcdList and Pcd not in UnusedPcdFullList: + UnusedPcdFullList.append(Pcd) for item in Pa.Platform.Pcds: Pcd = Pa.Platform.Pcds[item] if not Pcd.Type: @@ -853,7 +851,7 @@ class PcdReport(object): # # Collect module override PCDs # - for ModulePcd in list(Module.M.ModulePcdList) + list(Module.M.LibraryPcdList): + for ModulePcd in Module.M.ModulePcdList + Module.M.LibraryPcdList: TokenCName = ModulePcd.TokenCName TokenSpaceGuid = ModulePcd.TokenSpaceGuidCName ModuleDefault = ModulePcd.DefaultValue @@ -1031,29 +1029,35 @@ class PcdReport(object): if Pcd.DatumType in TAB_PCD_NUMERIC_TYPES: - try: - PcdValueNumber = int(PcdValue.strip(), 0) - except: - PcdValueNumber = int(PcdValue.lstrip('0')) + if PcdValue.startswith('0') and not PcdValue.lower().startswith('0x') and \ + len(PcdValue) > 1 and PcdValue.lstrip('0'): + PcdValue = PcdValue.lstrip('0') + PcdValueNumber = int(PcdValue.strip(), 0) if DecDefaultValue is None: DecMatch = True else: + if DecDefaultValue.startswith('0') and not DecDefaultValue.lower().startswith('0x') and \ + len(DecDefaultValue) > 1 and DecDefaultValue.lstrip('0'): + DecDefaultValue = DecDefaultValue.lstrip('0') DecDefaultValueNumber = int(DecDefaultValue.strip(), 0) DecMatch = (DecDefaultValueNumber == PcdValueNumber) if InfDefaultValue is None: InfMatch = True else: + if InfDefaultValue.startswith('0') and not InfDefaultValue.lower().startswith('0x') and \ + len(InfDefaultValue) > 1 and InfDefaultValue.lstrip('0'): + InfDefaultValue = InfDefaultValue.lstrip('0') InfDefaultValueNumber = int(InfDefaultValue.strip(), 0) InfMatch = (InfDefaultValueNumber == PcdValueNumber) if DscDefaultValue is None: DscMatch = True else: - try: - DscDefaultValueNumber = int(DscDefaultValue.strip(), 0) - except: - DscDefaultValueNumber = int(DscDefaultValue.lstrip('0')) + if DscDefaultValue.startswith('0') and not DscDefaultValue.lower().startswith('0x') and \ + len(DscDefaultValue) > 1 and DscDefaultValue.lstrip('0'): + DscDefaultValue = DscDefaultValue.lstrip('0') + DscDefaultValueNumber = int(DscDefaultValue.strip(), 0) DscMatch = (DscDefaultValueNumber == PcdValueNumber) else: if DecDefaultValue is None: @@ -1080,42 +1084,51 @@ class PcdReport(object): Pcd.DatumType = Pcd.StructName if TypeName in ('DYNVPD', 'DEXVPD'): Pcd.SkuInfoList = SkuInfoList - if Pcd.PcdFieldValueFromComm: + if Pcd.PcdValueFromComm or Pcd.PcdFieldValueFromComm: BuildOptionMatch = True DecMatch = False + elif Pcd.PcdValueFromFdf or Pcd.PcdFieldValueFromFdf: + DscDefaultValue = True + DscMatch = True + DecMatch = False elif Pcd.SkuOverrideValues: DscOverride = False - if not Pcd.SkuInfoList: - OverrideValues = Pcd.SkuOverrideValues - if OverrideValues: - Keys = list(OverrideValues.keys()) - Data = OverrideValues[Keys[0]] - Struct = list(Data.values())[0] - DscOverride = self.ParseStruct(Struct) + if Pcd.DefaultFromDSC: + DscOverride = True else: - SkuList = sorted(Pcd.SkuInfoList.keys()) - for Sku in SkuList: - SkuInfo = Pcd.SkuInfoList[Sku] - if TypeName in ('DYNHII', 'DEXHII'): - if SkuInfo.DefaultStoreDict: - DefaultStoreList = sorted(SkuInfo.DefaultStoreDict.keys()) - for DefaultStore in DefaultStoreList: - OverrideValues = Pcd.SkuOverrideValues[Sku] - DscOverride = self.ParseStruct(OverrideValues[DefaultStore]) - if DscOverride: + DictLen = 0 + for item in Pcd.SkuOverrideValues: + DictLen += len(Pcd.SkuOverrideValues[item]) + if not DictLen: + DscOverride = False + else: + if not Pcd.SkuInfoList: + OverrideValues = Pcd.SkuOverrideValues + if OverrideValues: + for Data in OverrideValues.values(): + Struct = list(Data.values()) + if Struct: + DscOverride = self.ParseStruct(Struct[0]) break else: - OverrideValues = Pcd.SkuOverrideValues[Sku] - if OverrideValues: - Keys = list(OverrideValues.keys()) - OverrideFieldStruct = self.OverrideFieldValue(Pcd, OverrideValues[Keys[0]]) - DscOverride = self.ParseStruct(OverrideFieldStruct) - if DscOverride: - break + SkuList = sorted(Pcd.SkuInfoList.keys()) + for Sku in SkuList: + SkuInfo = Pcd.SkuInfoList[Sku] + if SkuInfo.DefaultStoreDict: + DefaultStoreList = sorted(SkuInfo.DefaultStoreDict.keys()) + for DefaultStore in DefaultStoreList: + OverrideValues = Pcd.SkuOverrideValues[Sku] + DscOverride = self.ParseStruct(OverrideValues[DefaultStore]) + if DscOverride: + break + if DscOverride: + break if DscOverride: DscDefaultValue = True DscMatch = True DecMatch = False + else: + DecMatch = True else: DscDefaultValue = True DscMatch = True @@ -1158,10 +1171,10 @@ class PcdReport(object): for ModulePath in ModuleOverride: ModuleDefault = ModuleOverride[ModulePath] if Pcd.DatumType in TAB_PCD_NUMERIC_TYPES: - try: - ModulePcdDefaultValueNumber = int(ModuleDefault.strip(), 0) - except: - ModulePcdDefaultValueNumber = int(ModuleDefault.lstrip('0')) + if ModuleDefault.startswith('0') and not ModuleDefault.lower().startswith('0x') and \ + len(ModuleDefault) > 1 and ModuleDefault.lstrip('0'): + ModuleDefault = ModuleDefault.lstrip('0') + ModulePcdDefaultValueNumber = int(ModuleDefault.strip(), 0) Match = (ModulePcdDefaultValueNumber == PcdValueNumber) if Pcd.DatumType == 'BOOLEAN': ModuleDefault = str(ModulePcdDefaultValueNumber) @@ -1192,9 +1205,12 @@ class PcdReport(object): def ParseStruct(self, struct): HasDscOverride = False if struct: - for _, Values in struct.items(): - if Values[1] and Values[1].endswith('.dsc'): - HasDscOverride = True + for _, Values in list(struct.items()): + for Key, value in Values.items(): + if value[1] and value[1].endswith('.dsc'): + HasDscOverride = True + break + if HasDscOverride == True: break return HasDscOverride @@ -1240,15 +1256,14 @@ class PcdReport(object): if Value.startswith(('0x', '0X')): Value = '{} ({:d})'.format(Value, int(Value, 0)) else: - try: - Value = "0x{:X} ({})".format(int(Value, 0), Value) - except: - Value = "0x{:X} ({})".format(int(Value.lstrip('0')), Value) + Value = "0x{:X} ({})".format(int(Value, 0), Value) FileWrite(File, ' %*s = %s' % (self.MaxLen + 19, 'DEC DEFAULT', Value)) if IsStructure: - self.PrintStructureInfo(File, Pcd.DefaultValues) + for filedvalues in Pcd.DefaultValues.values(): + self.PrintStructureInfo(File, filedvalues) if DecMatch and IsStructure: - self.PrintStructureInfo(File, Pcd.DefaultValues) + for filedvalues in Pcd.DefaultValues.values(): + self.PrintStructureInfo(File, filedvalues) def PrintPcdValue(self, File, Pcd, PcdTokenCName, TypeName, IsStructure, DscMatch, DscDefaultValue, InfMatch, InfDefaultValue, DecMatch, DecDefaultValue, Flag = ' '): if not Pcd.SkuInfoList: @@ -1260,18 +1275,29 @@ class PcdReport(object): FileWrite(File, Array) else: if Pcd.DatumType in TAB_PCD_CLEAN_NUMERIC_TYPES: + if Value.startswith('0') and not Value.lower().startswith('0x') and len(Value) > 1 and Value.lstrip('0'): + Value = Value.lstrip('0') if Value.startswith(('0x', '0X')): Value = '{} ({:d})'.format(Value, int(Value, 0)) else: Value = "0x{:X} ({})".format(int(Value, 0), Value) FileWrite(File, ' %-*s : %6s %10s = %s' % (self.MaxLen, Flag + ' ' + PcdTokenCName, TypeName, '(' + Pcd.DatumType + ')', Value)) if IsStructure: - OverrideValues = Pcd.SkuOverrideValues + FiledOverrideFlag = False + if (Pcd.TokenCName,Pcd.TokenSpaceGuidCName) in GlobalData.gPcdSkuOverrides: + OverrideValues = GlobalData.gPcdSkuOverrides[(Pcd.TokenCName,Pcd.TokenSpaceGuidCName)] + else: + OverrideValues = Pcd.SkuOverrideValues if OverrideValues: - Keys = list(OverrideValues.keys()) - Data = OverrideValues[Keys[0]] - Struct = list(Data.values())[0] - OverrideFieldStruct = self.OverrideFieldValue(Pcd, Struct) + for Data in OverrideValues.values(): + Struct = list(Data.values()) + if Struct: + OverrideFieldStruct = self.OverrideFieldValue(Pcd, Struct[0]) + self.PrintStructureInfo(File, OverrideFieldStruct) + FiledOverrideFlag = True + break + if not FiledOverrideFlag and (Pcd.PcdFieldValueFromComm or Pcd.PcdFieldValueFromFdf): + OverrideFieldStruct = self.OverrideFieldValue(Pcd, {}) self.PrintStructureInfo(File, OverrideFieldStruct) self.PrintPcdDefault(File, Pcd, IsStructure, DscMatch, DscDefaultValue, InfMatch, InfDefaultValue, DecMatch, DecDefaultValue) else: @@ -1391,20 +1417,29 @@ class PcdReport(object): FileWrite(File, ' %-*s : %6s %10s %10s = %s' % (self.MaxLen, ' ', TypeName, '(' + Pcd.DatumType + ')', '(' + SkuIdName + ')', Value)) if TypeName in ('DYNVPD', 'DEXVPD'): FileWrite(File, '%*s' % (self.MaxLen + 4, SkuInfo.VpdOffset)) + VPDPcdItem = (Pcd.TokenSpaceGuidCName + '.' + PcdTokenCName, SkuIdName, SkuInfo.VpdOffset, Pcd.MaxDatumSize, SkuInfo.DefaultValue) + if VPDPcdItem not in VPDPcdList: + VPDPcdList.append(VPDPcdItem) if IsStructure: + FiledOverrideFlag = False OverrideValues = Pcd.SkuOverrideValues[Sku] if OverrideValues: Keys = list(OverrideValues.keys()) OverrideFieldStruct = self.OverrideFieldValue(Pcd, OverrideValues[Keys[0]]) self.PrintStructureInfo(File, OverrideFieldStruct) + FiledOverrideFlag = True + if not FiledOverrideFlag and (Pcd.PcdFieldValueFromComm or Pcd.PcdFieldValueFromFdf): + OverrideFieldStruct = self.OverrideFieldValue(Pcd, {}) + self.PrintStructureInfo(File, OverrideFieldStruct) self.PrintPcdDefault(File, Pcd, IsStructure, DscMatch, DscDefaultValue, InfMatch, InfDefaultValue, DecMatch, DecDefaultValue) def OverrideFieldValue(self, Pcd, OverrideStruct): OverrideFieldStruct = collections.OrderedDict() if OverrideStruct: - for Key, Values in OverrideStruct.items(): - if Values[1] and Values[1].endswith('.dsc'): - OverrideFieldStruct[Key] = Values + for _, Values in OverrideStruct.items(): + for Key,value in Values.items(): + if value[1] and value[1].endswith('.dsc'): + OverrideFieldStruct[Key] = value if Pcd.PcdFieldValueFromFdf: for Key, Values in Pcd.PcdFieldValueFromFdf.items(): if Key in OverrideFieldStruct and Values[0] == OverrideFieldStruct[Key][0]: @@ -1523,15 +1558,8 @@ class PredictionReport(object): if Module.Guid and not Module.IsLibrary: EntryPoint = " ".join(Module.Module.ModuleEntryPointList) - if int(str(Module.AutoGenVersion), 0) >= 0x00010005: - RealEntryPoint = "_ModuleEntryPoint" - else: - RealEntryPoint = EntryPoint - if EntryPoint == "_ModuleEntryPoint": - CCFlags = Module.BuildOption.get("CC", {}).get("FLAGS", "") - Match = gGlueLibEntryPoint.search(CCFlags) - if Match: - EntryPoint = Match.group(1) + + RealEntryPoint = "_ModuleEntryPoint" self._FfsEntryPoint[Module.Guid.upper()] = (EntryPoint, RealEntryPoint) @@ -1616,14 +1644,14 @@ class PredictionReport(object): GuidList = os.path.join(self._EotDir, "GuidList.txt") DispatchList = os.path.join(self._EotDir, "Dispatch.txt") - TempFile = open(SourceList, "w+") + TempFile = [] for Item in self._SourceList: FileWrite(TempFile, Item) - TempFile.close() - TempFile = open(GuidList, "w+") + SaveFileOnChange(SourceList, "".join(TempFile), False) + TempFile = [] for Key in self._GuidMap: FileWrite(TempFile, "%s %s" % (Key, self._GuidMap[Key])) - TempFile.close() + SaveFileOnChange(GuidList, "".join(TempFile), False) try: from Eot.EotMain import Eot @@ -1852,8 +1880,8 @@ class FdRegionReport(object): # # Add PEI and DXE a priori files GUIDs defined in PI specification. # - self._GuidsDb["1B45CC0A-156A-428A-AF62-49864DA0E6E6"] = "PEI Apriori" - self._GuidsDb["FC510EE7-FFDC-11D4-BD41-0080C73C8881"] = "DXE Apriori" + self._GuidsDb[PEI_APRIORI_GUID] = "PEI Apriori" + self._GuidsDb[DXE_APRIORI_GUID] = "DXE Apriori" # # Add ACPI table storage file # @@ -2002,35 +2030,14 @@ class FdReport(object): self.Size = Fd.Size self.FdRegionList = [FdRegionReport(FdRegion, Wa) for FdRegion in Fd.RegionList] self.FvPath = os.path.join(Wa.BuildDir, TAB_FV_DIRECTORY) - self.VpdFilePath = os.path.join(self.FvPath, "%s.map" % Wa.Platform.VpdToolGuid) self.VPDBaseAddress = 0 self.VPDSize = 0 - self.VPDInfoList = [] for index, FdRegion in enumerate(Fd.RegionList): if str(FdRegion.RegionType) is 'FILE' and Wa.Platform.VpdToolGuid in str(FdRegion.RegionDataList): self.VPDBaseAddress = self.FdRegionList[index].BaseAddress self.VPDSize = self.FdRegionList[index].Size break - if os.path.isfile(self.VpdFilePath): - fd = open(self.VpdFilePath, "r") - Lines = fd.readlines() - for Line in Lines: - Line = Line.strip() - if len(Line) == 0 or Line.startswith("#"): - continue - try: - PcdName, SkuId, Offset, Size, Value = Line.split("#")[0].split("|") - PcdName, SkuId, Offset, Size, Value = PcdName.strip(), SkuId.strip(), Offset.strip(), Size.strip(), Value.strip() - if Offset.lower().startswith('0x'): - Offset = '0x%08X' % (int(Offset, 16) + self.VPDBaseAddress) - else: - Offset = '0x%08X' % (int(Offset, 10) + self.VPDBaseAddress) - self.VPDInfoList.append("%s | %s | %s | %s | %s" % (PcdName, SkuId, Offset, Size, Value)) - except: - EdkLogger.error("BuildReport", CODE_ERROR, "Fail to parse VPD information file %s" % self.VpdFilePath) - fd.close() - ## # Generate report for the firmware device. # @@ -2050,23 +2057,26 @@ class FdReport(object): for FdRegionItem in self.FdRegionList: FdRegionItem.GenerateReport(File) - if len(self.VPDInfoList) > 0: + if VPDPcdList: + VPDPcdList.sort(key=lambda x: int(x[2], 0)) FileWrite(File, gSubSectionStart) FileWrite(File, "FD VPD Region") FileWrite(File, "Base Address: 0x%X" % self.VPDBaseAddress) FileWrite(File, "Size: 0x%X (%.0fK)" % (self.VPDSize, self.VPDSize / 1024.0)) FileWrite(File, gSubSectionSep) - for item in self.VPDInfoList: - ValueList = item.split('|') - Value = ValueList[-1].strip() - IsByteArray, ArrayList = ByteArrayForamt(Value) + for item in VPDPcdList: + # Add BaseAddress for offset + Offset = '0x%08X' % (int(item[2], 16) + self.VPDBaseAddress) + IsByteArray, ArrayList = ByteArrayForamt(item[-1]) + Skuinfo = item[1] + if len(GlobalData.gSkuids) == 1 : + Skuinfo = GlobalData.gSkuids[0] if IsByteArray: - ValueList[-1] = ' {' - FileWrite(File, '|'.join(ValueList)) + FileWrite(File, "%s | %s | %s | %s | %s" % (item[0], Skuinfo, Offset, item[3], '{')) for Array in ArrayList: FileWrite(File, Array) else: - FileWrite(File, item) + FileWrite(File, "%s | %s | %s | %s | %s" % (item[0], Skuinfo, Offset, item[3], item[-1])) FileWrite(File, gSubSectionEnd) FileWrite(File, gSectionEnd) @@ -2132,7 +2142,7 @@ class PlatformReport(object): INFList = GlobalData.gFdfParser.Profile.InfDict[Pa.Arch] for InfName in INFList: InfClass = PathClass(NormPath(InfName), Wa.WorkspaceDir, Pa.Arch) - Ma = ModuleAutoGen(Wa, InfClass, Pa.BuildTarget, Pa.ToolChain, Pa.Arch, Wa.MetaFile) + Ma = ModuleAutoGen(Wa, InfClass, Pa.BuildTarget, Pa.ToolChain, Pa.Arch, Wa.MetaFile, Pa.DataPipe) if Ma is None: continue if Ma not in ModuleAutoGenList: @@ -2258,18 +2268,17 @@ class BuildReport(object): def GenerateReport(self, BuildDuration, AutoGenTime, MakeTime, GenFdsTime): if self.ReportFile: try: - File = StringIO('') + File = [] for (Wa, MaList) in self.ReportList: PlatformReport(Wa, MaList, self.ReportType).GenerateReport(File, BuildDuration, AutoGenTime, MakeTime, GenFdsTime, self.ReportType) - Content = FileLinesSplit(File.getvalue(), gLineMaxLength) - SaveFileOnChange(self.ReportFile, Content, True) + Content = FileLinesSplit(''.join(File), gLineMaxLength) + SaveFileOnChange(self.ReportFile, Content, False) EdkLogger.quiet("Build report can be found at %s" % os.path.abspath(self.ReportFile)) except IOError: EdkLogger.error(None, FILE_WRITE_FAILURE, ExtraData=self.ReportFile) except: EdkLogger.error("BuildReport", CODE_ERROR, "Unknown fatal error when generating build report", ExtraData=self.ReportFile, RaiseError=False) EdkLogger.quiet("(Python %s on %s\n%s)" % (platform.python_version(), sys.platform, traceback.format_exc())) - File.close() # This acts like the main() function for the script, unless it is 'import'ed into another script. if __name__ == '__main__':