From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.120; helo=mga04.intel.com; envelope-from=yonghong.zhu@intel.com; receiver=edk2-devel@lists.01.org Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 9344221164EEA for ; Mon, 15 Oct 2018 06:22:47 -0700 (PDT) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 15 Oct 2018 06:22:47 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,384,1534834800"; d="scan'208";a="78880442" Received: from shwdeopenpsi168.ccr.corp.intel.com ([10.239.158.127]) by fmsmga008.fm.intel.com with ESMTP; 15 Oct 2018 06:22:46 -0700 From: Yonghong Zhu To: edk2-devel@lists.01.org Date: Mon, 15 Oct 2018 21:22:45 +0800 Message-Id: <1539609765-7964-1-git-send-email-yonghong.zhu@intel.com> X-Mailer: git-send-email 2.6.1.windows.1 Subject: [Patch] BaseTools: Support to use struct name as datum type before max size X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 15 Oct 2018 13:22:47 -0000 Original it hard code to use "VOID*", this patch extend it to both support VOID* and valid struct name. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Yonghong Zhu --- BaseTools/Source/Python/Common/Misc.py | 4 +++- BaseTools/Source/Python/Workspace/MetaFileParser.py | 6 +++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/BaseTools/Source/Python/Common/Misc.py b/BaseTools/Source/Python/Common/Misc.py index 2cf9574..3c71dfc 100644 --- a/BaseTools/Source/Python/Common/Misc.py +++ b/BaseTools/Source/Python/Common/Misc.py @@ -47,10 +47,12 @@ startPatternGeneral = re.compile("^Start[' ']+Length[' ']+Name[' ']+Class") addressPatternGeneral = re.compile("^Address[' ']+Publics by Value[' ']+Rva\+Base") valuePatternGcc = re.compile('^([\w_\.]+) +([\da-fA-Fx]+) +([\da-fA-Fx]+)$') pcdPatternGcc = re.compile('^([\da-fA-Fx]+) +([\da-fA-Fx]+)') secReGeneral = re.compile('^([\da-fA-F]+):([\da-fA-F]+) +([\da-fA-F]+)[Hh]? +([.\w\$]+) +(\w+)', re.UNICODE) +StructPattern = re.compile(r'[_a-zA-Z][0-9A-Za-z_]*$') + ## Dictionary used to store file time stamp for quick re-access gFileTimeStampCache = {} # {file path : file time stamp} ## Dictionary used to store dependencies of files gDependencyDatabase = {} # arch : {file path : [dependent files list]} @@ -1461,11 +1463,11 @@ def AnalyzeDscPcd(Setting, PcdType, DataType=''): if PcdType in (MODEL_PCD_FIXED_AT_BUILD, MODEL_PCD_PATCHABLE_IN_MODULE, MODEL_PCD_DYNAMIC_DEFAULT, MODEL_PCD_DYNAMIC_EX_DEFAULT): Value = FieldList[0] Size = '' if len(FieldList) > 1 and FieldList[1]: DataType = FieldList[1] - if FieldList[1] != TAB_VOID: + if FieldList[1] != TAB_VOID and StructPattern.match(FieldList[1]) is None: IsValid = False if len(FieldList) > 2: Size = FieldList[2] if IsValid: if DataType == "": diff --git a/BaseTools/Source/Python/Workspace/MetaFileParser.py b/BaseTools/Source/Python/Workspace/MetaFileParser.py index 79e3180..f33b91c 100644 --- a/BaseTools/Source/Python/Workspace/MetaFileParser.py +++ b/BaseTools/Source/Python/Workspace/MetaFileParser.py @@ -27,11 +27,11 @@ import Common.EdkLogger as EdkLogger import Common.GlobalData as GlobalData from CommonDataClass.DataClass import * from Common.DataType import * from Common.StringUtils import * -from Common.Misc import GuidStructureStringToGuidString, CheckPcdDatum, PathClass, AnalyzePcdData, AnalyzeDscPcd, AnalyzePcdExpression, ParseFieldValue +from Common.Misc import GuidStructureStringToGuidString, CheckPcdDatum, PathClass, AnalyzePcdData, AnalyzeDscPcd, AnalyzePcdExpression, ParseFieldValue, StructPattern from Common.Expression import * from CommonDataClass.Exceptions import * from Common.LongFilePathSupport import OpenLongFilePath as open from collections import defaultdict from .MetaFileTable import MetaFileStorage @@ -1610,12 +1610,12 @@ class DscParser(MetaFileParser): return ValList, Valid, Index = AnalyzeDscPcd(self._ValueList[2], self._ItemType) if not Valid: if self._ItemType in (MODEL_PCD_DYNAMIC_DEFAULT, MODEL_PCD_DYNAMIC_EX_DEFAULT, MODEL_PCD_FIXED_AT_BUILD, MODEL_PCD_PATCHABLE_IN_MODULE): - if ValList[1] != TAB_VOID and ValList[2]: - EdkLogger.error('build', FORMAT_INVALID, "Pcd format incorrect. Only VOID* type PCD need the maxsize info.", File=self._FileWithError, + if ValList[1] != TAB_VOID and StructPattern.match(ValList[1]) is None and ValList[2]: + EdkLogger.error('build', FORMAT_INVALID, "Pcd format incorrect. The datum type info should be VOID* or a valid struct name.", File=self._FileWithError, Line=self._LineIndex + 1, ExtraData="%s.%s|%s" % (self._ValueList[0], self._ValueList[1], self._ValueList[2])) EdkLogger.error('build', FORMAT_INVALID, "Pcd format incorrect.", File=self._FileWithError, Line=self._LineIndex + 1, ExtraData="%s.%s|%s" % (self._ValueList[0], self._ValueList[1], self._ValueList[2])) PcdValue = ValList[Index] if PcdValue and "." not in self._ValueList[0]: -- 2.6.1.windows.1