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.115; helo=mga14.intel.com; envelope-from=liming.gao@intel.com; receiver=edk2-devel@lists.01.org Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) (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 19BB421106FC4 for ; Wed, 29 Aug 2018 23:48:34 -0700 (PDT) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 29 Aug 2018 23:48:34 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.53,306,1531810800"; d="scan'208";a="86150411" Received: from fmsmsx107.amr.corp.intel.com ([10.18.124.205]) by orsmga001.jf.intel.com with ESMTP; 29 Aug 2018 23:48:23 -0700 Received: from fmsmsx152.amr.corp.intel.com (10.18.125.5) by fmsmsx107.amr.corp.intel.com (10.18.124.205) with Microsoft SMTP Server (TLS) id 14.3.319.2; Wed, 29 Aug 2018 23:48:23 -0700 Received: from shsmsx152.ccr.corp.intel.com (10.239.6.52) by FMSMSX152.amr.corp.intel.com (10.18.125.5) with Microsoft SMTP Server (TLS) id 14.3.319.2; Wed, 29 Aug 2018 23:48:22 -0700 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.143]) by SHSMSX152.ccr.corp.intel.com ([169.254.6.150]) with mapi id 14.03.0319.002; Thu, 30 Aug 2018 14:48:21 +0800 From: "Gao, Liming" To: "Feng, Bob C" , "edk2-devel@lists.01.org" CC: "Zhao, ZhiqiangX" , "Zhu, Yonghong" Thread-Topic: [PATCH] BaseTools: Check pcd DefaultValue and SkuId EBNF. Thread-Index: AQHUPaVyZx/SEJ5pO0qfWLKLrQZVXaTX35Jw Date: Thu, 30 Aug 2018 06:48:20 +0000 Message-ID: <4A89E2EF3DFEDB4C8BFDE51014F606A14E2EB455@SHSMSX104.ccr.corp.intel.com> References: <20180827012937.7400-1-bob.c.feng@intel.com> In-Reply-To: <20180827012937.7400-1-bob.c.feng@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [PATCH] BaseTools: Check pcd DefaultValue and SkuId EBNF. 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: Thu, 30 Aug 2018 06:48:35 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Liming Gao >-----Original Message----- >From: Feng, Bob C >Sent: Monday, August 27, 2018 9:30 AM >To: edk2-devel@lists.01.org >Cc: Zhao, ZhiqiangX ; Gao, Liming >; Zhu, Yonghong ; Feng, >Bob C >Subject: [PATCH] BaseTools: Check pcd DefaultValue and SkuId EBNF. > >From: Zhaozh1x > >1. When assign dynamic hii pcd value in dsc file, >missed the DefaultValue, build should be fail. >2. Check the EBNF of SkuId. > >Contributed-under: TianoCore Contribution Agreement 1.1 >Signed-off-by: ZhiqiangX Zhao >Cc: Liming Gao >Cc: Yonghong Zhu >Cc: Bob Feng >--- > BaseTools/Source/Python/Common/Misc.py | 4 +++- > BaseTools/Source/Python/Workspace/DscBuildData.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 74a5f0bca5..8debb0fdf8 100644 >--- a/BaseTools/Source/Python/Common/Misc.py >+++ b/BaseTools/Source/Python/Common/Misc.py >@@ -1525,6 +1525,7 @@ def AnalyzeDscPcd(Setting, PcdType, DataType=3D''): > Size =3D -1 > return [VpdOffset, str(Size), Value], IsValid, 2 > elif PcdType in (MODEL_PCD_DYNAMIC_HII, >MODEL_PCD_DYNAMIC_EX_HII): >+ IsValid =3D (3 <=3D len(FieldList) <=3D 5) > HiiString =3D FieldList[0] > Guid =3D Offset =3D Value =3D Attribute =3D '' > if len(FieldList) > 1: >@@ -1533,9 +1534,10 @@ def AnalyzeDscPcd(Setting, PcdType, DataType=3D''): > Offset =3D FieldList[2] > if len(FieldList) > 3: > Value =3D FieldList[3] >+ if not Value: >+ IsValid =3D False > if len(FieldList) > 4: > Attribute =3D FieldList[4] >- IsValid =3D (3 <=3D len(FieldList) <=3D 5) > return [HiiString, Guid, Offset, Value, Attribute], IsValid, 3 > return [], False, 0 > >diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py >b/BaseTools/Source/Python/Workspace/DscBuildData.py >index e8b36a3868..dd30067491 100644 >--- a/BaseTools/Source/Python/Workspace/DscBuildData.py >+++ b/BaseTools/Source/Python/Workspace/DscBuildData.py >@@ -92,7 +92,7 @@ LIBS =3D -lCommon > ''' > > variablePattern =3D re.compile(r'[\t\s]*0[xX][a-fA-F0-9]+$') >- >+SkuIdPattern =3D re.compile(r'^[a-zA-Z_][a-zA-Z0-9_]*$') > ## regular expressions for finding decimal and hex numbers > Pattern =3D re.compile('^[1-9]\d*|0$') > HexPattern =3D re.compile(r'0[xX][0-9a-fA-F]+$') >@@ -646,8 +646,8 @@ class DscBuildData(PlatformBuildClassObject): > if not Pattern.match(Record[0]) and not >HexPattern.match(Record[0]): > EdkLogger.error('build', FORMAT_INVALID, "The format = of the Sku >ID number is invalid. It only support Integer and HexNumber", > File=3Dself.MetaFile, Line=3DRecord[-= 1]) >- if not IsValidWord(Record[1]): >- EdkLogger.error('build', FORMAT_INVALID, "The format = of the Sku >ID name is invalid. The correct format is '(a-zA-Z0-9_)(a-zA-Z0-9_-.)*'", >+ if not SkuIdPattern.match(Record[1]) or (Record[2] and no= t >SkuIdPattern.match(Record[2])): >+ EdkLogger.error('build', FORMAT_INVALID, "The format = of the Sku >ID name is invalid. The correct format is '(a-zA-Z_)(a-zA-Z0-9_)*'", > File=3Dself.MetaFile, Line=3DRecord[-= 1]) > self._SkuIds[Record[1].upper()] =3D (str(DscBuildData.ToI= nt(Record[0])), >Record[1].upper(), Record[2].upper()) > if TAB_DEFAULT not in self._SkuIds: >-- >2.14.1.windows.1