BaseTools: Clean up source files
1. Do not use tab characters 2. No trailing white space in one line 3. All files must end with CRLF Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Liming Gao <liming.gao@intel.com> Cc: Yonghong Zhu <yonghong.zhu@intel.com> Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
This commit is contained in:
@ -1,9 +1,9 @@
|
||||
## @file
|
||||
#
|
||||
#
|
||||
# This package manage the VPD PCD information file which will be generated
|
||||
# by build tool's autogen.
|
||||
# The VPD PCD information file will be input for third-party BPDG tool which
|
||||
# is pointed by *_*_*_VPD_TOOL_GUID in conf/tools_def.txt
|
||||
# is pointed by *_*_*_VPD_TOOL_GUID in conf/tools_def.txt
|
||||
#
|
||||
#
|
||||
# Copyright (c) 2010 - 2018, Intel Corporation. All rights reserved.<BR>
|
||||
@ -33,8 +33,8 @@ FILE_COMMENT_TEMPLATE = \
|
||||
# THIS IS AUTO-GENERATED FILE BY BUILD TOOLS AND PLEASE DO NOT MAKE MODIFICATION.
|
||||
#
|
||||
# This file lists all VPD informations for a platform collected by build.exe.
|
||||
#
|
||||
# Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>
|
||||
#
|
||||
# Copyright (c) 2010 - 2018, Intel Corporation. All rights reserved.<BR>
|
||||
# This program and the accompanying materials
|
||||
# are licensed and made available under the terms and conditions of the BSD License
|
||||
# which accompanies this distribution. The full text of the license may be found at
|
||||
@ -70,17 +70,17 @@ FILE_COMMENT_TEMPLATE = \
|
||||
#
|
||||
class VpdInfoFile:
|
||||
|
||||
_rVpdPcdLine = None
|
||||
_rVpdPcdLine = None
|
||||
## Constructor
|
||||
def __init__(self):
|
||||
## Dictionary for VPD in following format
|
||||
#
|
||||
# Key : PcdClassObject instance.
|
||||
# Key : PcdClassObject instance.
|
||||
# @see BuildClassObject.PcdClassObject
|
||||
# Value : offset in different SKU such as [sku1_offset, sku2_offset]
|
||||
self._VpdArray = {}
|
||||
self._VpdInfo = {}
|
||||
|
||||
|
||||
## Add a VPD PCD collected from platform's autogen when building.
|
||||
#
|
||||
# @param vpds The list of VPD PCD collected for a platform.
|
||||
@ -91,40 +91,40 @@ class VpdInfoFile:
|
||||
def Add(self, Vpd, skuname, Offset):
|
||||
if (Vpd is None):
|
||||
EdkLogger.error("VpdInfoFile", BuildToolError.ATTRIBUTE_UNKNOWN_ERROR, "Invalid VPD PCD entry.")
|
||||
|
||||
|
||||
if not (Offset >= 0 or Offset == "*"):
|
||||
EdkLogger.error("VpdInfoFile", BuildToolError.PARAMETER_INVALID, "Invalid offset parameter: %s." % Offset)
|
||||
|
||||
|
||||
if Vpd.DatumType == TAB_VOID:
|
||||
if Vpd.MaxDatumSize <= 0:
|
||||
EdkLogger.error("VpdInfoFile", BuildToolError.PARAMETER_INVALID,
|
||||
EdkLogger.error("VpdInfoFile", BuildToolError.PARAMETER_INVALID,
|
||||
"Invalid max datum size for VPD PCD %s.%s" % (Vpd.TokenSpaceGuidCName, Vpd.TokenCName))
|
||||
elif Vpd.DatumType in TAB_PCD_NUMERIC_TYPES:
|
||||
elif Vpd.DatumType in TAB_PCD_NUMERIC_TYPES:
|
||||
if not Vpd.MaxDatumSize:
|
||||
Vpd.MaxDatumSize = MAX_SIZE_TYPE[Vpd.DatumType]
|
||||
else:
|
||||
if Vpd.MaxDatumSize <= 0:
|
||||
EdkLogger.error("VpdInfoFile", BuildToolError.PARAMETER_INVALID,
|
||||
"Invalid max datum size for VPD PCD %s.%s" % (Vpd.TokenSpaceGuidCName, Vpd.TokenCName))
|
||||
|
||||
|
||||
if Vpd not in self._VpdArray:
|
||||
#
|
||||
# If there is no Vpd instance in dict, that imply this offset for a given SKU is a new one
|
||||
# If there is no Vpd instance in dict, that imply this offset for a given SKU is a new one
|
||||
#
|
||||
self._VpdArray[Vpd] = {}
|
||||
|
||||
self._VpdArray[Vpd].update({skuname:Offset})
|
||||
|
||||
|
||||
|
||||
|
||||
## Generate VPD PCD information into a text file
|
||||
#
|
||||
#
|
||||
# If parameter FilePath is invalid, then assert.
|
||||
# If
|
||||
# If
|
||||
# @param FilePath The given file path which would hold VPD information
|
||||
def Write(self, FilePath):
|
||||
if not (FilePath is not None or len(FilePath) != 0):
|
||||
EdkLogger.error("VpdInfoFile", BuildToolError.PARAMETER_INVALID,
|
||||
"Invalid parameter FilePath: %s." % FilePath)
|
||||
EdkLogger.error("VpdInfoFile", BuildToolError.PARAMETER_INVALID,
|
||||
"Invalid parameter FilePath: %s." % FilePath)
|
||||
|
||||
Content = FILE_COMMENT_TEMPLATE
|
||||
Pcds = sorted(self._VpdArray.keys())
|
||||
@ -155,15 +155,15 @@ class VpdInfoFile:
|
||||
try:
|
||||
fd = open(FilePath, "r")
|
||||
except:
|
||||
EdkLogger.error("VpdInfoFile",
|
||||
BuildToolError.FILE_OPEN_FAILURE,
|
||||
EdkLogger.error("VpdInfoFile",
|
||||
BuildToolError.FILE_OPEN_FAILURE,
|
||||
"Fail to open file %s for written." % FilePath)
|
||||
Lines = fd.readlines()
|
||||
for Line in Lines:
|
||||
Line = Line.strip()
|
||||
if len(Line) == 0 or Line.startswith("#"):
|
||||
continue
|
||||
|
||||
|
||||
#
|
||||
# the line must follow output format defined in BPDG spec.
|
||||
#
|
||||
@ -173,9 +173,9 @@ class VpdInfoFile:
|
||||
TokenSpaceName, PcdTokenName = PcdName.split(".")
|
||||
except:
|
||||
EdkLogger.error("BPDG", BuildToolError.PARSER_ERROR, "Fail to parse VPD information file %s" % FilePath)
|
||||
|
||||
|
||||
Found = False
|
||||
|
||||
|
||||
if (TokenSpaceName, PcdTokenName) not in self._VpdInfo:
|
||||
self._VpdInfo[(TokenSpaceName, PcdTokenName)] = []
|
||||
self._VpdInfo[(TokenSpaceName, PcdTokenName)].append((SkuId, Offset, Value))
|
||||
@ -188,62 +188,62 @@ class VpdInfoFile:
|
||||
if VpdObject.TokenSpaceGuidCName == TokenSpaceName and VpdObjectTokenCName == PcdTokenName.strip() and sku == SkuId:
|
||||
if self._VpdArray[VpdObject][sku] == "*":
|
||||
if Offset == "*":
|
||||
EdkLogger.error("BPDG", BuildToolError.FORMAT_INVALID, "The offset of %s has not been fixed up by third-party BPDG tool." % PcdName)
|
||||
EdkLogger.error("BPDG", BuildToolError.FORMAT_INVALID, "The offset of %s has not been fixed up by third-party BPDG tool." % PcdName)
|
||||
self._VpdArray[VpdObject][sku] = Offset
|
||||
Found = True
|
||||
if not Found:
|
||||
EdkLogger.error("BPDG", BuildToolError.PARSER_ERROR, "Can not find PCD defined in VPD guid file.")
|
||||
|
||||
|
||||
## Get count of VPD PCD collected from platform's autogen when building.
|
||||
#
|
||||
# @return The integer count value
|
||||
# @return The integer count value
|
||||
def GetCount(self):
|
||||
Count = 0
|
||||
for OffsetList in self._VpdArray.values():
|
||||
Count += len(OffsetList)
|
||||
|
||||
|
||||
return Count
|
||||
|
||||
|
||||
## Get an offset value for a given VPD PCD
|
||||
#
|
||||
# Because BPDG only support one Sku, so only return offset for SKU default.
|
||||
# Because BPDG only support one Sku, so only return offset for SKU default.
|
||||
#
|
||||
# @param vpd A given VPD PCD
|
||||
# @param vpd A given VPD PCD
|
||||
def GetOffset(self, vpd):
|
||||
if vpd not in self._VpdArray:
|
||||
return None
|
||||
|
||||
|
||||
if len(self._VpdArray[vpd]) == 0:
|
||||
return None
|
||||
|
||||
|
||||
return self._VpdArray[vpd]
|
||||
def GetVpdInfo(self, arg):
|
||||
(PcdTokenName, TokenSpaceName) = arg
|
||||
return self._VpdInfo.get((TokenSpaceName, PcdTokenName))
|
||||
|
||||
|
||||
## Call external BPDG tool to process VPD file
|
||||
#
|
||||
#
|
||||
# @param ToolPath The string path name for BPDG tool
|
||||
# @param VpdFileName The string path name for VPD information guid.txt
|
||||
#
|
||||
#
|
||||
def CallExtenalBPDGTool(ToolPath, VpdFileName):
|
||||
assert ToolPath is not None, "Invalid parameter ToolPath"
|
||||
assert VpdFileName is not None and os.path.exists(VpdFileName), "Invalid parameter VpdFileName"
|
||||
|
||||
|
||||
OutputDir = os.path.dirname(VpdFileName)
|
||||
FileName = os.path.basename(VpdFileName)
|
||||
BaseName, ext = os.path.splitext(FileName)
|
||||
OutputMapFileName = os.path.join(OutputDir, "%s.map" % BaseName)
|
||||
OutputBinFileName = os.path.join(OutputDir, "%s.bin" % BaseName)
|
||||
|
||||
|
||||
try:
|
||||
PopenObject = subprocess.Popen(' '.join([ToolPath,
|
||||
'-o', OutputBinFileName,
|
||||
'-o', OutputBinFileName,
|
||||
'-m', OutputMapFileName,
|
||||
'-q',
|
||||
'-f',
|
||||
VpdFileName]),
|
||||
stdout=subprocess.PIPE,
|
||||
stdout=subprocess.PIPE,
|
||||
stderr= subprocess.PIPE,
|
||||
shell=True)
|
||||
except Exception as X:
|
||||
@ -252,11 +252,11 @@ def CallExtenalBPDGTool(ToolPath, VpdFileName):
|
||||
print(out)
|
||||
while PopenObject.returncode is None :
|
||||
PopenObject.wait()
|
||||
|
||||
|
||||
if PopenObject.returncode != 0:
|
||||
if PopenObject.returncode != 0:
|
||||
EdkLogger.debug(EdkLogger.DEBUG_1, "Fail to call BPDG tool", str(error))
|
||||
EdkLogger.error("BPDG", BuildToolError.COMMAND_FAILURE, "Fail to execute BPDG tool with exit code: %d, the error message is: \n %s" % \
|
||||
(PopenObject.returncode, str(error)))
|
||||
|
||||
|
||||
return PopenObject.returncode
|
||||
|
Reference in New Issue
Block a user