From e8a47801a1dfdb148b1bfcd5bdc8ebc3bf51f92d Mon Sep 17 00:00:00 2001 From: Liming Gao Date: Mon, 18 Nov 2013 07:41:21 +0000 Subject: Sync BaseTool trunk (version r2610) into EDKII BaseTools. Signed-off-by: Liming Gao git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@14856 6f19259b-4bc3-4df7-8a09-765794883524 --- BaseTools/Source/Python/Common/BuildVersion.py | 2 +- BaseTools/Source/Python/Common/DataType.py | 1 + BaseTools/Source/Python/Common/GlobalData.py | 19 ++++++ BaseTools/Source/Python/Common/Misc.py | 81 ++++++++++++++++++++------ BaseTools/Source/Python/Common/VpdInfoFile.py | 25 ++++---- 5 files changed, 99 insertions(+), 29 deletions(-) (limited to 'BaseTools/Source/Python/Common') diff --git a/BaseTools/Source/Python/Common/BuildVersion.py b/BaseTools/Source/Python/Common/BuildVersion.py index 25546cdfe9..2a3b0aa681 100644 --- a/BaseTools/Source/Python/Common/BuildVersion.py +++ b/BaseTools/Source/Python/Common/BuildVersion.py @@ -13,4 +13,4 @@ # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. # -gBUILD_VERSION = "Build 2601" +gBUILD_VERSION = "Build 2610" diff --git a/BaseTools/Source/Python/Common/DataType.py b/BaseTools/Source/Python/Common/DataType.py index 3a82362100..dbe7215f40 100644 --- a/BaseTools/Source/Python/Common/DataType.py +++ b/BaseTools/Source/Python/Common/DataType.py @@ -397,6 +397,7 @@ TAB_DSC_DEFINES_OUTPUT_DIRECTORY = 'OUTPUT_DIRECTORY' TAB_DSC_DEFINES_SUPPORTED_ARCHITECTURES = 'SUPPORTED_ARCHITECTURES' TAB_DSC_DEFINES_BUILD_TARGETS = 'BUILD_TARGETS' TAB_DSC_DEFINES_SKUID_IDENTIFIER = 'SKUID_IDENTIFIER' +TAB_DSC_DEFINES_PCD_INFO_GENERATION = 'PCD_INFO_GENERATION' TAB_DSC_DEFINES_FLASH_DEFINITION = 'FLASH_DEFINITION' TAB_DSC_DEFINES_BUILD_NUMBER = 'BUILD_NUMBER' TAB_DSC_DEFINES_MAKEFILE_NAME = 'MAKEFILE_NAME' diff --git a/BaseTools/Source/Python/Common/GlobalData.py b/BaseTools/Source/Python/Common/GlobalData.py index d566a57844..4fbe721823 100644 --- a/BaseTools/Source/Python/Common/GlobalData.py +++ b/BaseTools/Source/Python/Common/GlobalData.py @@ -50,3 +50,22 @@ gWideStringPattern = re.compile('(\W|\A)L"') # gAutoGenPhase = False +# +# The Conf dir outside the workspace dir +# +gConfDirectory = '' + +# +# The relative default database file path +# +gDatabasePath = ".cache/build.db" + +# +# Build flag for binary build +# +gIgnoreSource = False + +# +# FDF parser +# +gFdfParser = None diff --git a/BaseTools/Source/Python/Common/Misc.py b/BaseTools/Source/Python/Common/Misc.py index afdfb93ad6..960581581a 100644 --- a/BaseTools/Source/Python/Common/Misc.py +++ b/BaseTools/Source/Python/Common/Misc.py @@ -31,6 +31,7 @@ from Common import GlobalData as GlobalData from DataType import * from BuildToolError import * from CommonDataClass.DataClass import * +from Parsing import GetSplitValueList ## Regular expression used to find out place holders in string template gPlaceholderPattern = re.compile("\$\{([^$()\s]+)\}", re.MULTILINE|re.UNICODE) @@ -1248,8 +1249,13 @@ def AnalyzeDscPcd(Setting, PcdType, DataType=''): Size = Type = '' if len(FieldList) > 1: Type = FieldList[1] + else: + Type = DataType if len(FieldList) > 2: Size = FieldList[2] + else: + if Type == 'VOID*': + Size = str(len(Value)) if DataType == 'VOID*': IsValid = (len(FieldList) <= 3) else: @@ -1322,25 +1328,13 @@ def AnalyzePcdData(Setting): # # @retval ValueList: A List contaian VariableName, VariableGuid, VariableOffset, DefaultValue. # -def AnalyzeHiiPcdData(Setting): - ValueList = ['', '', '', ''] - - ValueRe = re.compile(r'^\s*L?\".*\|.*\"') - PtrValue = ValueRe.findall(Setting) - - ValueUpdateFlag = False - - if len(PtrValue) >= 1: - Setting = re.sub(ValueRe, '', Setting) - ValueUpdateFlag = True +def AnalyzeHiiPcdData(Setting): + ValueList = ['', '', '', ''] - TokenList = Setting.split(TAB_VALUE_SPLIT) + TokenList = GetSplitValueList(Setting) ValueList[0:len(TokenList)] = TokenList - - if ValueUpdateFlag: - ValueList[0] = PtrValue[0] - - return ValueList + + return ValueList ## AnalyzeVpdPcdData # @@ -1679,7 +1673,60 @@ class PeImageClass(): for index in range(len(ByteList) - 1, -1, -1): Value = (Value << 8) | int(ByteList[index]) return Value + + +class SkuClass(): + + DEFAULT = 0 + SINGLE = 1 + MULTIPLE =2 + + def __init__(self,SkuIdentifier='', SkuIds={}): + + self.AvailableSkuIds = sdict() + self.SkuIdSet = [] + + if SkuIdentifier == '' or SkuIdentifier is None: + self.SkuIdSet = ['DEFAULT'] + elif SkuIdentifier == 'ALL': + self.SkuIdSet = SkuIds.keys() + else: + r = SkuIdentifier.split('|') + self.SkuIdSet=[r[k].strip() for k in range(len(r))] + if len(self.SkuIdSet) == 2 and 'DEFAULT' in self.SkuIdSet and SkuIdentifier != 'ALL': + self.SkuIdSet.remove('DEFAULT') + + for each in self.SkuIdSet: + if each in SkuIds: + self.AvailableSkuIds[each] = SkuIds[each] + else: + EdkLogger.error("build", PARAMETER_INVALID, + ExtraData="SKU-ID [%s] is not supported by the platform. [Valid SKU-ID: %s]" + % (each, " ".join(SkuIds.keys()))) + def __SkuUsageType(self): + + if len(self.SkuIdSet) == 1: + if self.SkuIdSet[0] == 'DEFAULT': + return SkuClass.DEFAULT + else: + return SkuClass.SINGLE + else: + return SkuClass.MULTIPLE + + def __GetAvailableSkuIds(self): + return self.AvailableSkuIds + + def __GetSystemSkuID(self): + if self.__SkuUsageType() == SkuClass.SINGLE: + return self.SkuIdSet[0] + else: + return 'DEFAULT' + + SystemSkuId = property(__GetSystemSkuID) + AvailableSkuIdSet = property(__GetAvailableSkuIds) + SkuUsageType = property(__SkuUsageType) + ## # # This acts like the main() function for the script, unless it is 'import'ed into another diff --git a/BaseTools/Source/Python/Common/VpdInfoFile.py b/BaseTools/Source/Python/Common/VpdInfoFile.py index 207cc8735b..18f6f5663c 100644 --- a/BaseTools/Source/Python/Common/VpdInfoFile.py +++ b/BaseTools/Source/Python/Common/VpdInfoFile.py @@ -138,12 +138,14 @@ class VpdInfoFile: Pcds = self._VpdArray.keys() Pcds.sort() for Pcd in Pcds: + i = 0 for Offset in self._VpdArray[Pcd]: - PcdValue = str(Pcd.SkuInfoList[Pcd.SkuInfoList.keys()[0]].DefaultValue).strip() + PcdValue = str(Pcd.SkuInfoList[Pcd.SkuInfoList.keys()[i]].DefaultValue).strip() if PcdValue == "" : PcdValue = Pcd.DefaultValue - fd.write("%s.%s|%s|%s|%s \n" % (Pcd.TokenSpaceGuidCName, Pcd.TokenCName, str(Offset).strip(), str(Pcd.MaxDatumSize).strip(),PcdValue)) + fd.write("%s.%s|%s|%s|%s|%s \n" % (Pcd.TokenSpaceGuidCName, Pcd.TokenCName, str(Pcd.SkuInfoList.keys()[i]),str(Offset).strip(), str(Pcd.MaxDatumSize).strip(),PcdValue)) + i += 1 except: EdkLogger.error("VpdInfoFile", BuildToolError.FILE_WRITE_FAILURE, @@ -174,21 +176,22 @@ class VpdInfoFile: # the line must follow output format defined in BPDG spec. # try: - PcdName, Offset, Size, Value = Line.split("#")[0].split("|") + PcdName, SkuId,Offset, Size, Value = Line.split("#")[0].split("|") + PcdName, SkuId,Offset, Size, Value = PcdName.strip(), SkuId.strip(),Offset.strip(), Size.strip(), Value.strip() TokenSpaceName, PcdTokenName = PcdName.split(".") except: EdkLogger.error("BPDG", BuildToolError.PARSER_ERROR, "Fail to parse VPD information file %s" % FilePath) Found = False + for VpdObject in self._VpdArray.keys(): - if VpdObject.TokenSpaceGuidCName == TokenSpaceName and VpdObject.TokenCName == PcdTokenName.strip(): - if self._VpdArray[VpdObject][0] == "*": - if Offset == "*": - EdkLogger.error("BPDG", BuildToolError.FORMAT_INVALID, "The offset of %s has not been fixed up by third-party BPDG tool." % PcdName) - - self._VpdArray[VpdObject][0] = Offset - Found = True - break + for sku in VpdObject.SkuInfoList.keys(): + if VpdObject.TokenSpaceGuidCName == TokenSpaceName and VpdObject.TokenCName == PcdTokenName.strip() and sku == SkuId: + if self._VpdArray[VpdObject][VpdObject.SkuInfoList.keys().index(sku)] == "*": + if Offset == "*": + EdkLogger.error("BPDG", BuildToolError.FORMAT_INVALID, "The offset of %s has not been fixed up by third-party BPDG tool." % PcdName) + self._VpdArray[VpdObject][VpdObject.SkuInfoList.keys().index(sku)] = Offset + Found = True if not Found: EdkLogger.error("BPDG", BuildToolError.PARSER_ERROR, "Can not find PCD defined in VPD guid file.") -- cgit v1.2.3