From nobody Mon Dec 23 01:07:14 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1521432344142312.13748186193266; Sun, 18 Mar 2018 21:05:44 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 63CD82257C2B9; Sun, 18 Mar 2018 20:59:13 -0700 (PDT) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) (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 DE39E22571B4B for ; Sun, 18 Mar 2018 20:59:11 -0700 (PDT) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 18 Mar 2018 21:05:39 -0700 Received: from shwdeopenpsi105.ccr.corp.intel.com ([10.239.9.129]) by fmsmga002.fm.intel.com with ESMTP; 18 Mar 2018 21:05:38 -0700 X-Original-To: edk2-devel@lists.01.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.20; helo=mga02.intel.com; envelope-from=bob.c.feng@intel.com; receiver=edk2-devel@lists.01.org X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.48,328,1517904000"; d="scan'208";a="29134704" From: BobCF To: edk2-devel@lists.01.org Date: Mon, 19 Mar 2018 12:05:19 +0800 Message-Id: <20180319040519.19352-1-bob.c.feng@intel.com> X-Mailer: git-send-email 2.14.3.windows.1 Subject: [edk2] [Patch] BaseTool: Error handling for PCD datumtype. X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Liming Gao MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Report error if the Pcd DatumType is wrong. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Bob Feng Cc: Liming Gao Reviewed-by: Liming Gao --- BaseTools/Source/Python/Workspace/BuildClassObject.py | 2 ++ BaseTools/Source/Python/Workspace/DecBuildData.py | 13 +++++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/BaseTools/Source/Python/Workspace/BuildClassObject.py b/BaseTo= ols/Source/Python/Workspace/BuildClassObject.py index 1352fa21c8..a306dc0b23 100644 --- a/BaseTools/Source/Python/Workspace/BuildClassObject.py +++ b/BaseTools/Source/Python/Workspace/BuildClassObject.py @@ -67,10 +67,11 @@ class PcdClassObject(object): self.DscDefaultValue =3D None self.DscRawValue =3D None if IsDsc: self.DscDefaultValue =3D Value self.PcdValueFromComm =3D "" + self.DefinitionPosition =3D ("","") =20 ## Convert the class to a string # # Convert each member of the class to string # Organize to a signle line format string @@ -176,10 +177,11 @@ class StructurePcd(PcdClassObject): self.validateranges =3D PcdObject.validateranges if PcdObject.vali= dateranges else self.validateranges self.validlists =3D PcdObject.validlists if PcdObject.validlists e= lse self.validlists self.expressions =3D PcdObject.expressions if PcdObject.expression= s else self.expressions self.DscRawValue =3D PcdObject.DscRawValue if PcdObject.DscRawValu= e else self.DscRawValue self.PcdValueFromComm =3D PcdObject.PcdValueFromComm if PcdObject.= PcdValueFromComm else self.PcdValueFromComm + self.DefinitionPosition =3D PcdObject.DefinitionPosition if PcdObj= ect.DefinitionPosition else self.DefinitionPosition if type(PcdObject) is StructurePcd: self.StructuredPcdIncludeFile =3D PcdObject.StructuredPcdInclu= deFile if PcdObject.StructuredPcdIncludeFile else self.StructuredPcdInclude= File self.PackageDecs =3D PcdObject.PackageDecs if PcdObject.Packag= eDecs else self.PackageDecs self.DefaultValues =3D PcdObject.DefaultValues if PcdObject.De= faultValues else self.DefaultValues self.PcdMode =3D PcdObject.PcdMode if PcdObject.PcdMode else s= elf.PcdMode diff --git a/BaseTools/Source/Python/Workspace/DecBuildData.py b/BaseTools/= Source/Python/Workspace/DecBuildData.py index ee00ec0719..4d6edadc8f 100644 --- a/BaseTools/Source/Python/Workspace/DecBuildData.py +++ b/BaseTools/Source/Python/Workspace/DecBuildData.py @@ -392,15 +392,11 @@ class DecBuildData(PackageBuildClassObject): struct_pcd.SetDecDefaultValue(item.DefaultValue) else: struct_pcd.AddDefaultValue(item.TokenCName, item.Defau= ltValue,self.MetaFile.File,LineNo) =20 struct_pcd.PackageDecs =3D dep_pkgs - if not struct_pcd.StructuredPcdIncludeFile: - EdkLogger.error("build", PCD_STRUCTURE_PCD_ERROR, "The str= ucture Pcd %s.%s header file is not found in %s line %s \n" % (struct_pcd.T= okenSpaceGuidCName, struct_pcd.TokenCName,self.MetaFile.File,LineNo )) - str_pcd_set.append(struct_pcd) - return str_pcd_set =20 ## Retrieve PCD declarations for given type def _GetPcd(self, Type): Pcds =3D sdict() @@ -444,18 +440,27 @@ class DecBuildData(PackageBuildClassObject): None, list(validateranges), list(validlists), list(expressions) ) + PcdObj.DefinitionPosition =3D (self.MetaFile.File,LineNo) if "." in TokenSpaceGuid: StrPcdSet.append((PcdObj,LineNo)) else: Pcds[PcdCName, TokenSpaceGuid, self._PCD_TYPE_STRING_[Type= ]] =3D PcdObj =20 StructurePcds =3D self.ProcessStructurePcd(StrPcdSet) for pcd in StructurePcds: Pcds[pcd.TokenCName, pcd.TokenSpaceGuidCName, self._PCD_TYPE_S= TRING_[Type]] =3D pcd + StructPattern =3D re.compile(r'[_a-zA-Z][0-9A-Za-z_]*$') + for pcd in Pcds.values(): + if pcd.DatumType not in [TAB_UINT8, TAB_UINT16, TAB_UINT32, TA= B_UINT64, TAB_VOID, "BOOLEAN"]: + if StructPattern.match(pcd.DatumType) =3D=3D None: + EdkLogger.error('build', FORMAT_INVALID, "DatumType on= ly support BOOLEAN, UINT8, UINT16, UINT32, UINT64, VOID* or a valid struct = name.", pcd.DefinitionPosition[0],pcd.DefinitionPosition[1]) + for struct_pcd in Pcds.values(): + if isinstance(struct_pcd,StructurePcd) and not struct_pcd.Stru= cturedPcdIncludeFile: + EdkLogger.error("build", PCD_STRUCTURE_PCD_ERROR, "The str= ucture Pcd %s.%s header file is not found in %s line %s \n" % (struct_pcd.T= okenSpaceGuidCName, struct_pcd.TokenCName,struct_pcd.DefinitionPosition[0],= struct_pcd.DefinitionPosition[1] )) =20 return Pcds @property def CommonIncludes(self): if self._CommonIncludes is None: --=20 2.14.3.windows.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel