From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by mx.groups.io with SMTP id smtpd.web08.4149.1617260776542366404 for ; Thu, 01 Apr 2021 00:06:16 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@intel.onmicrosoft.com header.s=selector2-intel-onmicrosoft-com header.b=xJDy+IJ3; spf=pass (domain: intel.com, ip: 134.134.136.24, mailfrom: yuwei.chen@intel.com) IronPort-SDR: cv42OH4dPpKUp37I1VcPCyuoUYmBhjelWxqFjwNsHf0+EutheAhJ/veUBpfSJPCTqg4alwoh+w XGXTs8b9aogQ== X-IronPort-AV: E=McAfee;i="6000,8403,9940"; a="192271851" X-IronPort-AV: E=Sophos;i="5.81,296,1610438400"; d="scan'208";a="192271851" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Apr 2021 00:06:15 -0700 IronPort-SDR: FY7npHCYkayd07iDi0zIzd98YjHeE6G7aNlM/FBpWjeABptpCVfEcpUHAxqedHKAZEDbYteshS kn+PaePs2fEA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.81,296,1610438400"; d="scan'208";a="446110327" Received: from orsmsx602.amr.corp.intel.com ([10.22.229.15]) by fmsmga002.fm.intel.com with ESMTP; 01 Apr 2021 00:06:13 -0700 Received: from orsmsx604.amr.corp.intel.com (10.22.229.17) by ORSMSX602.amr.corp.intel.com (10.22.229.15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2106.2; Thu, 1 Apr 2021 00:06:12 -0700 Received: from ORSEDG601.ED.cps.intel.com (10.7.248.6) by orsmsx604.amr.corp.intel.com (10.22.229.17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2106.2 via Frontend Transport; Thu, 1 Apr 2021 00:06:12 -0700 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (104.47.58.170) by edgegateway.intel.com (134.134.137.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2106.2; Thu, 1 Apr 2021 00:06:12 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KG85PGW//7G4ifoq+ZoErkPSGkRlevCySBxxPWKYBVQBHskiTZG2sePKGJ+j0xlj5DT9urGVqfbKFPj+5YlShklQ1KXiMN4sJC8kcX10eU7H3Hs9EZZfLa29xQlrLKFEgNUeb0qSopUmtasXR/dmOwyD9cjKkuPe3Ixu006gxtgvgfol1Ey/BUJybo4TQq6yqAgFvtLybMWCYcBfRHlD/1JgnaTuHqoqaHKBzl7FXbu5Myuio1HHCLm7WXfdcU+Ti5lGzobBVsafgBm0Jq/QkA3sE782BaCL9jcTbH6lg12nRrGkOc12DJ5IUA100SW7wVvDBiPimvoMzQR95vY5dg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=xAQVKWfkuqofFEDSJ7FvfwfBzlXGTbLkY/axsTVIsaU=; b=UzP3uUUskJ7dcklfcv1iHsL6fy5x0hQZa0Fu9YNq20CFlGjuJP+sQTdeE2hNgq14kt/34lMqc2fCTeM1GASmseKIaW6lri4KyDtTXb3ySj+fwp8YR27rhYVw6+IzRZjSpNsR3d0qT31IZwTMBX8mu+psl9/1jpXloqkGumJDNUjDPZCjuAJv2fbfpADZ9kpxlLRpTv3SSVZYc+fzszJR8ZbpZvso02T5Xa0A4RKqcMAR2bpXZkWqS6pxDpMdB9EwD9HqDoZXy+x7NeQintRtCXvmZDhWmLOqf6Ep5uRyIwEimjcoVbPygry/r/pYZMA/Rsq7bXKp2SsHkzLaiPbJuQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.onmicrosoft.com; s=selector2-intel-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=xAQVKWfkuqofFEDSJ7FvfwfBzlXGTbLkY/axsTVIsaU=; b=xJDy+IJ3aPNcUveQDAq+PR3Jjy5dDrOam/jVup7nf9FXnD+BVdXY9tJ/VeWIpahQjbunrrmdJW0fFOzHUHaNzIzuPPeN9bwNgQr5YqtR9wWkodUvCVlsI79FHINOcmkuMniUmflYXx6hwATWQTopxCBe/VbLgnv/YcZpmMhWPb4= Received: from DM5PR11MB1594.namprd11.prod.outlook.com (2603:10b6:4:5::16) by DM5PR11MB1658.namprd11.prod.outlook.com (2603:10b6:4:8::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3977.24; Thu, 1 Apr 2021 07:06:10 +0000 Received: from DM5PR11MB1594.namprd11.prod.outlook.com ([fe80::8d2a:f371:783f:3a55]) by DM5PR11MB1594.namprd11.prod.outlook.com ([fe80::8d2a:f371:783f:3a55%7]) with mapi id 15.20.3999.027; Thu, 1 Apr 2021 07:06:10 +0000 From: "Yuwei Chen" To: "devel@edk2.groups.io" , "Chen, Christine" CC: "Liang, MingyueX" , "Feng, Bob C" , Liming Gao Subject: Re: [edk2-devel] [PATCH 1/1] BaseTools/Ecc: Update structpcd parsing method. Thread-Topic: [edk2-devel] [PATCH 1/1] BaseTools/Ecc: Update structpcd parsing method. Thread-Index: AQHXJsU5XNuXBxgZ30miOF/Y0l0cNaqfPThg Date: Thu, 1 Apr 2021 07:06:10 +0000 Message-ID: References: <1671A9FBA7001DE0.30755@groups.io> In-Reply-To: <1671A9FBA7001DE0.30755@groups.io> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-version: 11.5.1.3 dlp-reaction: no-action dlp-product: dlpe-windows authentication-results: edk2.groups.io; dkim=none (message not signed) header.d=none;edk2.groups.io; dmarc=none action=none header.from=intel.com; x-originating-ip: [192.55.46.56] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 31e2d42a-1982-4866-e9ab-08d8f4dca139 x-ms-traffictypediagnostic: DM5PR11MB1658: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:2803; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: hAQkkKuajQnskGcuuCHKa7W4cm1FUAKnUxBlt2ravgEbMQYNF4cl8r3liDesySYuZxHxhmSttLxX6YCHR+2/6JuZzGTgtk2mapMngtCxgAWp1RX8B83KiyNttz8cVdv35NT+RyLw76zPHQzyyjJ8CJ+COaEaW7EUBkRjXrFjB37gCB8p9PbztdgIzF+Kg1mGpxHoOJl49EvzQoznHWLAmbA4Ac+mMdS7Tj8mVzoM8eCwqDDsGVVNXehA7jONhTjP5otF/kpRaJJK7Oj4IigeQu5RXpH1iVBJaaGUt8f1T3VvRdeOQ72Bsfte9fbCmfdOYVn/ETdKybGVY6H2Lcz3XVx+Ch9WQH6yIMqFpa4i1jYgS1KZvwfsmuUqhlSXTXNGIXMgAocFc4oOZt6+CIqipXT0ZQ4SJuPfaBZ8EiCEQjxZVLRJ89+56qa5CVM1blunccpWAFgfg2jdDcBPTyfo4NTRU5NZV6/SnMOUai66ROwZYBoyqMD3Z3YyhCowdMYFosQrXaVGdEX1Lw6DOr7d0JLpOVG3Nm8w7+n4Ltwkx9itOe+kZKM3QQJQSAYlVfzfUW14gInKhOwHrwjQO7zUTG+s9LW1l5IPReSiI5mH1k8Hxq45O/VrrmiLMPcxzJ4ijOoIP75vP2RYDSNJiRekqBZzWbVfX0tAWZ/xGZ5Fiw0yYUnguRWZcSHTZZjBaBGHLElaekShqShPqeyI4S58z9G1vB8vCphoOCO8XCD5xMs= x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM5PR11MB1594.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(346002)(396003)(376002)(366004)(39860400002)(136003)(6506007)(8676002)(966005)(478600001)(5660300002)(55016002)(2906002)(186003)(26005)(71200400001)(83380400001)(110136005)(54906003)(4326008)(66446008)(64756008)(15650500001)(33656002)(66556008)(52536014)(66476007)(66946007)(7696005)(53546011)(38100700001)(316002)(30864003)(8936002)(86362001)(76116006)(9686003)(559001)(579004);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata: =?us-ascii?Q?rsST1sZLJHsV3UhbwW7H7jKAb9M4WrvsXpL+zpoztF7yPbiAawCI3eWZIFDo?= =?us-ascii?Q?9ZStaZv3xj2dOCnJRzL0KyzCKN2flDuWR+NgYWzMx4pGIs7tuZ504u14afRQ?= =?us-ascii?Q?S2rL0icbmepBtrxKFYlpxKQTSdybmqGT5MlnwVfkjpaxwLAo0zVCfZLbx406?= =?us-ascii?Q?OH4SRBnEXQIo3TgNHJOvnZ9GnHLQP2VQ5L8v6HrhPleH78dgmvQlIDyAdXYE?= =?us-ascii?Q?M25Lp2sA6uAZJ0EwFphmPCmnIhXzkQCswX4/mDknSWlRWRhZWxi9G+XgyjCN?= =?us-ascii?Q?H25hHoJ+hZWAAxdOl29KHZX/TVRZI9B3M9RhJYwks5j5QhfCKXQbeL3auqJk?= =?us-ascii?Q?Hb++RfzM0X3/onKs1jpYBHMDbAxOOzRYeqpu1OJmB+ZIy70yqUDyVuQTtIdF?= =?us-ascii?Q?qgSwwZwdPqw1fEd5KzfFt7jHQliq2gSImCGifrUniF40WjqI+cxiRtG7Q0Fw?= =?us-ascii?Q?SusstPWx6zj3jQbE+vfZa86u+3yp9US8jOr/Fz6yOnqvRCXF7yftMgkLPtfB?= =?us-ascii?Q?Unu8FJFvY9hpH49cywLQOk8IZxBVHSvNYMcbCoEPwk+UmvOzsV6r9aJLxOMS?= =?us-ascii?Q?QQCqVoK7LVQR7O9mXWwhlu5IfJo1CWrK+/dR+SMwYHRus1dN3hkV8vBD7wse?= =?us-ascii?Q?/Askg4Vf2Bjv/ABaR+wTAJpQAcr1jIqI3mnO9DNEoS3yUDT2rzC3jMBdEOO5?= =?us-ascii?Q?0K13nk/U+nQHvR5JDY1x0xv0xCxZYowBtLqZGlPcXZAYb8b3fak2tIAq4msx?= =?us-ascii?Q?MaN3CY3IUQ3e+YCieruNd4riV2Kn+rmSZIKDwhuzUbu3iVWys9Eo+eNTlX8m?= =?us-ascii?Q?Ptb0GOiRCVy/mR4Io7Zede6vTvf8R31HMc6ccoC6Ik3Q6OFVw0rlZYG1gbI0?= =?us-ascii?Q?2jNj0Ln8deyRRZJK4RsHxJwJbh3FD7H6t0HVSH25s+G14od+YUMsA9wqiqE0?= =?us-ascii?Q?nfZwG/+3XNoHhJDQKIZWG2u2LsHKmr2N3NucFJ+nRu8mlMJgqeFg5qb/Wr9+?= =?us-ascii?Q?hbo0Z6sAYTcLIo9EaG+z32dihOmScEnyT4ykWZzMcHmEYn5JVvweoDkrVdbd?= =?us-ascii?Q?R8m2RXvmfeLvNAIqltrkOvUvL9VV9vhFNr2CsXPwph7i6rryIQb0v+uhJx1Y?= =?us-ascii?Q?YlhLi6PDOge8X9ieMD6ZxjymUDiPmgxjq0m9QIMAeh2GGVj1iia5IaHHvSs+?= =?us-ascii?Q?JaA1Bar3nX/U1+sdzOBoM3S9tbf0sO3hN216ru7b9CVdaY6/rhbA8t2nAXfD?= =?us-ascii?Q?OrjGARbCjHjV4O8/srjbsF6ITUbOXWGHUUIML0ZKazGs1+hILJ3UeZFZrGpG?= =?us-ascii?Q?AsM=3D?= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: DM5PR11MB1594.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 31e2d42a-1982-4866-e9ab-08d8f4dca139 X-MS-Exchange-CrossTenant-originalarrivaltime: 01 Apr 2021 07:06:10.7095 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: PGp5CxOICVGjuyDUlYfyYbOEmIvJ7bg3zorXAAQK5i2P6b+R4mQrKQvZB8Gt643mcGJ13wvf2L2vL+0UlAUCoQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR11MB1658 Return-Path: yuwei.chen@intel.com X-OriginatorOrg: intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Please ignore this patch, sorry for wrong sending. Thanks, Yuwei > -----Original Message----- > From: devel@edk2.groups.io On Behalf Of Yuwei > Chen > Sent: Thursday, April 1, 2021 3:04 PM > To: devel@edk2.groups.io > Cc: Liang, MingyueX ; Feng, Bob C > ; Liming Gao > Subject: [edk2-devel] [PATCH 1/1] BaseTools/Ecc: Update structpcd parsin= g > method. >=20 > From: mliang2x >=20 > Update the pcdparser method in Dec and DSC files. >=20 > Signed-off-by: Mingyue Liang > Cc: Bob Feng > Cc: Liming Gao > Cc: Yuwei Chen > --- > .../Ecc/MetaFileWorkspace/MetaFileParser.py | 464 ++++++++++-------- > 1 file changed, 265 insertions(+), 199 deletions(-) >=20 > diff --git > a/BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileParser.py > b/BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileParser.py > index 9c27c8e16a05..588d3dbe6ed5 100644 > --- a/BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileParser.py > +++ > b/BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileParser.py > @@ -22,7 +22,7 @@ import Ecc.EccToolError as EccToolError from > CommonDataClass.DataClass import * from Common.DataType import * > from Common.StringUtils import * -from Common.Misc import > GuidStructureStringToGuidString, CheckPcdDatum, PathClass, > AnalyzePcdData > +from Common.Misc import GuidStructureStringToGuidString, > CheckPcdDatum, > +PathClass, AnalyzePcdData, AnalyzeDscPcd, AnalyzePcdExpression, > +ParseFieldValue, StructPattern > from Common.Expression import * > from CommonDataClass.Exceptions import * >=20 > @@ -31,6 +31,8 @@ from GenFds.FdfParser import FdfParser from > Common.LongFilePathSupport import OpenLongFilePath as open from > Common.LongFilePathSupport import CodecOpenLongFilePath >=20 > +CODEPattern =3D re.compile(r"{CODE\([a-fA-F0-9Xx\{\},\s]*\)}") > + > ## A decorator used to parse macro definition def ParseMacro(Parser): > def MacroParser(self): > @@ -174,6 +176,11 @@ class MetaFileParser(object): > # UNI object and extra UNI object > self._UniObj =3D None > self._UniExtraObj =3D None > + # StructPcd var > + self._PcdCodeValue =3D "" > + self._PcdDataTypeCODE =3D False > + self._CurrentPcdName =3D "" > + self._GuidDict =3D {} # for Parser PCD value > + {GUID(gTokeSpaceGuidName)} >=20 > ## Store the parsed data in table > def _Store(self, *Args): > @@ -395,6 +402,40 @@ class MetaFileParser(object): > Macros.update(self._SectionsMacroDict[(self._SectionTyp= e, Scope1, > Scope2)]) > return Macros >=20 > + def ProcessMultipleLineCODEValue(self, Content): > + CODEBegin =3D False > + CODELine =3D "" > + continuelinecount =3D 0 > + newContent =3D [] > + for Index in range(0, len(Content)): > + Line =3D Content[Index] > + if CODEBegin: > + CODELine =3D CODELine + Line > + continuelinecount +=3D1 > + if ")}" in Line: > + newContent.append(CODELine) > + for _ in range(continuelinecount): > + newContent.append("") > + CODEBegin =3D False > + CODELine =3D "" > + continuelinecount =3D 0 > + else: > + if not Line: > + newContent.append(Line) > + continue > + if "{CODE(" not in Line: > + newContent.append(Line) > + continue > + elif CODEPattern.findall(Line): > + newContent.append(Line) > + continue > + else: > + CODEBegin =3D True > + CODELine =3D Line > + > + return newContent > + > + > _SectionParser =3D {} > Finished =3D property(_GetFinished, _SetFinished) > _Macros =3D property(_GetMacros) > @@ -812,6 +853,8 @@ class DscParser(MetaFileParser): > Content =3D open(str(self.MetaFile.Path), 'r').readlines() > except: > EdkLogger.error("Parser", FILE_READ_FAILURE, > ExtraData=3Dself.MetaFile) > + > + Content =3D self.ProcessMultipleLineCODEValue(Content) > # > # Insert a record for file > # > @@ -1018,24 +1061,71 @@ class DscParser(MetaFileParser): > # > @ParseMacro > def _PcdParser(self): > + if self._PcdDataTypeCODE: > + self._PcdCodeValue =3D self._PcdCodeValue + "\n " + self._C= urrentLine > + if self._CurrentLine.endswith(")}"): > + self._CurrentLine =3D "|".join((self._CurrentPcdName, > self._PcdCodeValue)) > + self._PcdDataTypeCODE =3D False > + self._PcdCodeValue =3D "" > + else: > + self._ValueList =3D None > + return > TokenList =3D GetSplitValueList(self._CurrentLine, TAB_VALUE_SP= LIT, 1) > + self._CurrentPcdName =3D TokenList[0] > + if len(TokenList) =3D=3D 2 and TokenList[1].strip().startswith(= "{CODE"): > + self._PcdDataTypeCODE =3D True > + self._PcdCodeValue =3D TokenList[1].strip() > + > + if self._PcdDataTypeCODE: > + if self._CurrentLine.endswith(")}"): > + self._PcdDataTypeCODE =3D False > + self._PcdCodeValue =3D "" > + else: > + self._ValueList =3D None > + return > self._ValueList[0:1] =3D GetSplitValueList(TokenList[0], TAB_SP= LIT) > + PcdNameTockens =3D GetSplitValueList(TokenList[0], TAB_SPLIT) > + if len(PcdNameTockens) =3D=3D 2: > + self._ValueList[0], self._ValueList[1] =3D PcdNameTockens[0= ], > PcdNameTockens[1] > + elif len(PcdNameTockens) =3D=3D 3: > + self._ValueList[0], self._ValueList[1] =3D ".".join((PcdNam= eTockens[0], > PcdNameTockens[1])), PcdNameTockens[2] > + elif len(PcdNameTockens) > 3: > + self._ValueList[0], self._ValueList[1] =3D > + ".".join((PcdNameTockens[0], PcdNameTockens[1])), > + ".".join(PcdNameTockens[2:]) > if len(TokenList) =3D=3D 2: > self._ValueList[2] =3D TokenList[1] > if self._ValueList[0] =3D=3D '' or self._ValueList[1] =3D=3D ''= : > EdkLogger.error('Parser', FORMAT_INVALID, "No token space G= UID or > PCD name specified", > ExtraData=3Dself._CurrentLine + " > (.|)", > - File=3Dself.MetaFile, Line=3Dself._LineInde= x+1) > + File=3Dself.MetaFile, Line=3Dself._LineInde= x + > + 1) > if self._ValueList[2] =3D=3D '': > + # > + # The PCD values are optional for FIXEDATBUILD, > PATCHABLEINMODULE, Dynamic/DynamicEx default > + # > + if self._SectionType in (MODEL_PCD_FIXED_AT_BUILD, > MODEL_PCD_PATCHABLE_IN_MODULE, MODEL_PCD_DYNAMIC_DEFAULT, > MODEL_PCD_DYNAMIC_EX_DEFAULT): > + return > EdkLogger.error('Parser', FORMAT_INVALID, "No PCD value giv= en", > ExtraData=3Dself._CurrentLine + " > (.|)", > - File=3Dself.MetaFile, Line=3Dself._LineInde= x+1) > + File=3Dself.MetaFile, Line=3Dself._LineInde= x + > + 1) > + > + # Validate the datum type of Dynamic Defaul PCD and DynamicEx > Default PCD > + ValueList =3D GetSplitValueList(self._ValueList[2]) > + if len(ValueList) > 1 and ValueList[1] in [TAB_UINT8, TAB_UINT1= 6, > TAB_UINT32, TAB_UINT64] \ > + and self._ItemType in [MODEL_PCD_DYNAMIC_= DEFAULT, > MODEL_PCD_DYNAMIC_EX_DEFAULT]: > + EdkLogger.error('Parser', FORMAT_INVALID, "The datum type '= %s' of > PCD is wrong" % ValueList[1], > + ExtraData=3Dself._CurrentLine, > + File=3Dself.MetaFile, Line=3Dself._LineIndex + 1) > + > + # Validate the VariableName of DynamicHii and DynamicExHii for = PCD > Entry must not be an empty string > + if self._ItemType in [MODEL_PCD_DYNAMIC_HII, > MODEL_PCD_DYNAMIC_EX_HII]: > + DscPcdValueList =3D GetSplitValueList(TokenList[1], TAB_VAL= UE_SPLIT, > 1) > + if len(DscPcdValueList[0].replace('L', '').replace('"', '')= .strip()) =3D=3D 0: > + EdkLogger.error('Parser', FORMAT_INVALID, "The Variable= Name > field in the HII format PCD entry must not be an empty string", > + ExtraData=3Dself._CurrentLine, > + File=3Dself.MetaFile, Line=3Dself._LineIndex + 1) > # if value are 'True', 'true', 'TRUE' or 'False', 'false', 'FAL= SE', replace with > integer 1 or 0. > DscPcdValueList =3D GetSplitValueList(TokenList[1], TAB_VALUE_S= PLIT, 1) > if DscPcdValueList[0] in ['True', 'true', 'TRUE']: > - self._ValueList[2] =3D TokenList[1].replace(DscPcdValueList= [0], '1', 1); > + self._ValueList[2] =3D > + TokenList[1].replace(DscPcdValueList[0], '1', 1) > elif DscPcdValueList[0] in ['False', 'false', 'FALSE']: > - self._ValueList[2] =3D TokenList[1].replace(DscPcdValueList= [0], '0', 1); > + self._ValueList[2] =3D > + TokenList[1].replace(DscPcdValueList[0], '0', 1) >=20 > ## [components] section parser > @ParseMacro > @@ -1502,6 +1592,10 @@ class DecParser(MetaFileParser): > self._include_flag =3D False > self._package_flag =3D False >=20 > + self._AllPCDs =3D [] # Only for check duplicate PCD > + self._AllPcdDict =3D {} > + > + > ## Parser starter > def Start(self): > Content =3D '' > @@ -1510,6 +1604,7 @@ class DecParser(MetaFileParser): > except: > EdkLogger.error("Parser", FILE_READ_FAILURE, > ExtraData=3Dself.MetaFile) >=20 > + Content =3D self.ProcessMultipleLineCODEValue(Content) > # > # Insert a record for file > # > @@ -1707,51 +1802,6 @@ class DecParser(MetaFileParser): > namelist[2] =3D ".".join((arrayindex,namelist[2])) > return namelist >=20 > - def StructPcdParser(self): > - self._ValueList[0] =3D self._CurrentStructurePcdName > - > - if "|" not in self._CurrentLine: > - if "" =3D=3D self._CurrentLine: > - self._include_flag =3D True > - self._package_flag =3D False > - self._ValueList =3D None > - return > - if "" =3D=3D self._CurrentLine: > - self._package_flag =3D True > - self._ValueList =3D None > - self._include_flag =3D False > - return > - > - if self._include_flag: > - self._ValueList[1] =3D "_" + > md5(self._CurrentLine.encode('utf-8')).hexdigest() > - self._ValueList[2] =3D self._CurrentLine > - if self._package_flag and "}" !=3D self._CurrentLine: > - self._ValueList[1] =3D "_" + > md5(self._CurrentLine.encode('utf-8')).hexdigest() > - self._ValueList[2] =3D self._CurrentLine > - if self._CurrentLine =3D=3D "}": > - self._package_flag =3D False > - self._include_flag =3D False > - self._ValueList =3D None > - else: > - PcdTockens =3D self._CurrentLine.split(TAB_VALUE_SPLIT) > - PcdNames =3D self.ParsePcdName(PcdTockens[0].split(TAB_SPLI= T)) > - if len(PcdNames) =3D=3D 2: > - if PcdNames[1].strip().endswith("]"): > - PcdName =3D PcdNames[1][:PcdNames[1].index('[')] > - Index =3D PcdNames[1][PcdNames[1].index('['):] > - self._ValueList[0] =3D TAB_SPLIT.join((PcdNames[0],= PcdName)) > - self._ValueList[1] =3D Index > - self._ValueList[2] =3D PcdTockens[1] > - else: > - self._CurrentStructurePcdName =3D "" > - else: > - if self._CurrentStructurePcdName !=3D TAB_SPLIT.join(Pc= dNames[:2]): > - EdkLogger.error('Parser', FORMAT_INVALID, "Pcd Name= does not > match: %s and %s " % ( > - self._CurrentStructurePcdName, TAB_SPLIT.join(PcdNa= mes[:2])), > - File=3Dself.MetaFile, Line=3Dself._= LineIndex + 1) > - self._ValueList[1] =3D TAB_SPLIT.join(PcdNames[2:]) > - self._ValueList[2] =3D PcdTockens[1] > - > ## PCD sections parser > # > # [PcdsFixedAtBuild] > @@ -1763,159 +1813,175 @@ class DecParser(MetaFileParser): > @ParseMacro > def _PcdParser(self): > if self._CurrentStructurePcdName: > - self.StructPcdParser() > - return > - TokenList =3D GetSplitValueList(self._CurrentLine, TAB_VALUE_SP= LIT, 1) > - self._ValueList[0:1] =3D GetSplitValueList(TokenList[0], TAB_SP= LIT) > - # check PCD information > - if self._ValueList[0] =3D=3D '' or self._ValueList[1] =3D=3D ''= : > - EdkLogger.error('Parser', FORMAT_INVALID, "No token space G= UID or > PCD name specified", > - ExtraData=3Dself._CurrentLine + \ > - " > (.|||< > Token>)", > - File=3Dself.MetaFile, Line=3Dself._LineInde= x+1) > - # check PCD datum information > - if len(TokenList) < 2 or TokenList[1] =3D=3D '': > - EdkLogger.error('Parser', FORMAT_INVALID, "No PCD Datum > information given", > - ExtraData=3Dself._CurrentLine + \ > - " > (.|||< > Token>)", > - File=3Dself.MetaFile, Line=3Dself._LineInde= x+1) > - > - > - ValueRe =3D re.compile(r'^\s*L?\".*\|.*\"') > - PtrValue =3D ValueRe.findall(TokenList[1]) > - > - # Has VOID* type string, may contain "|" character in the strin= g. > - if len(PtrValue) !=3D 0: > - ptrValueList =3D re.sub(ValueRe, '', TokenList[1]) > - ValueList =3D GetSplitValueList(ptrValueList) > - ValueList[0] =3D PtrValue[0] > - else: > - ValueList =3D GetSplitValueList(TokenList[1]) > - > - > - # check if there's enough datum information given > - if len(ValueList) !=3D 3: > - EdkLogger.error('Parser', FORMAT_INVALID, "Invalid PCD Datu= m > information given", > - ExtraData=3Dself._CurrentLine + \ > - " > (.|||< > Token>)", > - File=3Dself.MetaFile, Line=3Dself._LineInde= x+1) > - # check default value > - if ValueList[0] =3D=3D '': > - EdkLogger.error('Parser', FORMAT_INVALID, "Missing DefaultV= alue in > PCD Datum information", > - ExtraData=3Dself._CurrentLine + \ > - " > (.|||< > Token>)", > - File=3Dself.MetaFile, Line=3Dself._LineInde= x+1) > - # check datum type > - if ValueList[1] =3D=3D '': > - EdkLogger.error('Parser', FORMAT_INVALID, "Missing DatumTyp= e in > PCD Datum information", > - ExtraData=3Dself._CurrentLine + \ > - " > (.|||< > Token>)", > - File=3Dself.MetaFile, Line=3Dself._LineInde= x+1) > - # check token of the PCD > - if ValueList[2] =3D=3D '': > - EdkLogger.error('Parser', FORMAT_INVALID, "Missing Token in= PCD > Datum information", > - ExtraData=3Dself._CurrentLine + \ > - " > (.|||< > Token>)", > - File=3Dself.MetaFile, Line=3Dself._LineInde= x+1) > - # check format of default value against the datum type > - IsValid, Cause =3D CheckPcdDatum(ValueList[1], ValueList[0]) > - if not IsValid: > - EdkLogger.error('Parser', FORMAT_INVALID, Cause, > ExtraData=3Dself._CurrentLine, > - File=3Dself.MetaFile, Line=3Dself._LineInde= x+1) > - if Cause =3D=3D "StructurePcd": > - self._CurrentStructurePcdName =3D TAB_SPLIT.join(self._Valu= eList[0:2]) > self._ValueList[0] =3D self._CurrentStructurePcdName > - self._ValueList[1] =3D ValueList[1].strip() >=20 > - if EccGlobalData.gConfig.UniCheckPCDInfo =3D=3D '1' or > EccGlobalData.gConfig.UniCheckAll =3D=3D '1' or EccGlobalData.gConfig.Ch= eckAll > =3D=3D '1': > - # check Description, Prompt information > - PatternDesc =3D re.compile('##\s*([\x21-\x7E\s]*)', re.S) > - PatternPrompt =3D re.compile('#\s+@Prompt\s+([\x21-\x7E\s]*= )', re.S) > - Description =3D None > - Prompt =3D None > - # check @ValidRange, @ValidList and @Expression format vali= d > - ErrorCodeValid =3D '0x0 <=3D %s <=3D 0xFFFFFFFF' > - PatternValidRangeIn =3D '(NOT)?\s*(\d+\s*-\s*\d+|0[xX][a-fA= -F0- > 9]+\s*-\s*0[xX][a-fA-F0-9]+|LT\s*\d+|LT\s*0[xX][a-fA-F0- > 9]+|GT\s*\d+|GT\s*0[xX][a-fA-F0-9]+|LE\s*\d+|LE\s*0[xX][a-fA-F0- > 9]+|GE\s*\d+|GE\s*0[xX][a-fA-F0-9]+|XOR\s*\d+|XOR\s*0[xX][a-fA-F0- > 9]+|EQ\s*\d+|EQ\s*0[xX][a-fA-F0-9]+)' > - PatternValidRng =3D re.compile('^' + '(NOT)?\s*' + PatternV= alidRangeIn > + '$') > - for Comment in self._Comments: > - Comm =3D Comment[0].strip() > - if not Comm: > - continue > - if not Description: > - Description =3D PatternDesc.findall(Comm) > - if not Prompt: > - Prompt =3D PatternPrompt.findall(Comm) > - if Comm[0] =3D=3D '#': > - ValidFormt =3D Comm.lstrip('#') > - ValidFormt =3D ValidFormt.lstrip() > - if ValidFormt[0:11] =3D=3D '@ValidRange': > - ValidFormt =3D ValidFormt[11:] > - ValidFormt =3D ValidFormt.lstrip() > - try: > - ErrorCode, Expression =3D ValidFormt.split(= '|', 1) > - except ValueError: > - ErrorCode =3D '0x0' > - Expression =3D ValidFormt > - ErrorCode, Expression =3D ErrorCode.strip(), Ex= pression.strip() > - try: > - if not eval(ErrorCodeValid % ErrorCode): > - EdkLogger.warn('Parser', '@ValidRange E= rrorCode(%s) of > PCD %s is not valid UINT32 value.' % (ErrorCode, TokenList[0])) > - except: > - EdkLogger.warn('Parser', '@ValidRange Error= Code(%s) of > PCD %s is not valid UINT32 value.' % (ErrorCode, TokenList[0])) > - if not PatternValidRng.search(Expression): > - EdkLogger.warn('Parser', '@ValidRange Expre= ssion(%s) of > PCD %s is incorrect format.' % (Expression, TokenList[0])) > - if ValidFormt[0:10] =3D=3D '@ValidList': > - ValidFormt =3D ValidFormt[10:] > - ValidFormt =3D ValidFormt.lstrip() > - try: > - ErrorCode, Expression =3D ValidFormt.split(= '|', 1) > - except ValueError: > - ErrorCode =3D '0x0' > - Expression =3D ValidFormt > - ErrorCode, Expression =3D ErrorCode.strip(), Ex= pression.strip() > - try: > - if not eval(ErrorCodeValid % ErrorCode): > - EdkLogger.warn('Parser', '@ValidList Er= rorCode(%s) of > PCD %s is not valid UINT32 value.' % (ErrorCode, TokenList[0])) > - except: > - EdkLogger.warn('Parser', '@ValidList ErrorC= ode(%s) of PCD %s > is not valid UINT32 value.' % (ErrorCode, TokenList[0])) > - Values =3D Expression.split(',') > - for Value in Values: > - Value =3D Value.strip() > - try: > - eval(Value) > - except: > - EdkLogger.warn('Parser', '@ValidList Ex= pression of PCD %s > include a invalid value(%s).' % (TokenList[0], Value)) > - break > - if ValidFormt[0:11] =3D=3D '@Expression': > - ValidFormt =3D ValidFormt[11:] > - ValidFormt =3D ValidFormt.lstrip() > - try: > - ErrorCode, Expression =3D ValidFormt.split(= '|', 1) > - except ValueError: > - ErrorCode =3D '0x0' > - Expression =3D ValidFormt > - ErrorCode, Expression =3D ErrorCode.strip(), Ex= pression.strip() > - try: > - if not eval(ErrorCodeValid % ErrorCode): > - EdkLogger.warn('Parser', '@Expression E= rrorCode(%s) of > PCD %s is not valid UINT32 value.' % (ErrorCode, TokenList[0])) > - except: > - EdkLogger.warn('Parser', '@Expression Error= Code(%s) of > PCD %s is not valid UINT32 value.' % (ErrorCode, TokenList[0])) > - if not Expression: > - EdkLogger.warn('Parser', '@Expression Expre= ssion of PCD %s > is incorrect format.' % TokenList[0]) > - if not Description: > - EdkLogger.warn('Parser', 'PCD %s Description informatio= n is not > provided.' % TokenList[0]) > - if not Prompt: > - EdkLogger.warn('Parser', 'PCD %s Prompt information is = not > provided.' % TokenList[0]) > - # check Description, Prompt localization information > - if self._UniObj: > - self._UniObj.CheckPcdInfo(TokenList[0]) > + if "|" not in self._CurrentLine: > + if "" =3D=3D self._CurrentLine: > + self._include_flag =3D True > + self._package_flag =3D False > + self._ValueList =3D None > + return > + if "" =3D=3D self._CurrentLine: > + self._package_flag =3D True > + self._ValueList =3D None > + self._include_flag =3D False > + return >=20 > - if ValueList[0] in ['True', 'true', 'TRUE']: > - ValueList[0] =3D '1' > - elif ValueList[0] in ['False', 'false', 'FALSE']: > - ValueList[0] =3D '0' > + if self._include_flag: > + self._ValueList[1] =3D "_" + > md5(self._CurrentLine.encode('utf-8')).hexdigest() > + self._ValueList[2] =3D self._CurrentLine > + if self._package_flag and "}" !=3D self._CurrentLine: > + self._ValueList[1] =3D "_" + > md5(self._CurrentLine.encode('utf-8')).hexdigest() > + self._ValueList[2] =3D self._CurrentLine > + if self._CurrentLine =3D=3D "}": > + self._package_flag =3D False > + self._include_flag =3D False > + self._ValueList =3D None > + return > + else: > + PcdTockens =3D self._CurrentLine.split(TAB_VALUE_SPLIT) > + PcdNames =3D self.ParsePcdName(PcdTockens[0].split(TAB_= SPLIT)) > + if len(PcdNames) =3D=3D 2: > + if PcdNames[1].strip().endswith("]"): > + PcdName =3D PcdNames[1][:PcdNames[1].index('[')= ] > + Index =3D PcdNames[1][PcdNames[1].index('['):] > + self._ValueList[0] =3D TAB_SPLIT.join((PcdNames= [0],PcdName)) > + self._ValueList[1] =3D Index > + self._ValueList[2] =3D PcdTockens[1] > + else: > + self._CurrentStructurePcdName =3D "" > + else: > + if self._CurrentStructurePcdName !=3D > TAB_SPLIT.join(PcdNames[:2]): > + EdkLogger.error('Parser', FORMAT_INVALID, "Pcd = Name does > not match: %s and %s " % (self._CurrentStructurePcdName, > TAB_SPLIT.join(PcdNames[:2])), > + File=3Dself.MetaFile, Line=3Dself._Line= Index + 1) > + self._ValueList[1] =3D TAB_SPLIT.join(PcdNames[2:]) > + self._ValueList[2] =3D PcdTockens[1] >=20 > - self._ValueList[2] =3D ValueList[0].strip() + '|' + ValueList[1= ].strip() + '|' + > ValueList[2].strip() > + if not self._CurrentStructurePcdName: > + if self._PcdDataTypeCODE: > + if ")}" in self._CurrentLine: > + ValuePart, RestofValue =3D self._CurrentLine.split(= ")}") > + self._PcdCodeValue =3D self._PcdCodeValue + "\n " += ValuePart > + self._CurrentLine =3D "|".join((self._CurrentPcdNam= e, > self._PcdCodeValue, RestofValue)) > + self._PcdDataTypeCODE =3D False > + self._PcdCodeValue =3D "" > + else: > + self._PcdCodeValue =3D self._PcdCodeValue + "\n " + > self._CurrentLine > + self._ValueList =3D None > + return > + TokenList =3D GetSplitValueList(self._CurrentLine, TAB_VALU= E_SPLIT, 1) > + self._CurrentPcdName =3D TokenList[0] > + if len(TokenList) =3D=3D 2 and TokenList[1].strip().startsw= ith("{CODE"): > + if ")}" in self._CurrentLine: > + self._PcdDataTypeCODE =3D False > + self._PcdCodeValue =3D "" > + else: > + self._PcdDataTypeCODE =3D True > + self._PcdCodeValue =3D TokenList[1].strip() > + self._ValueList =3D None > + return > + > + self._ValueList[0:1] =3D GetSplitValueList(TokenList[0], TA= B_SPLIT) > + ValueRe =3D re.compile(r'^[a-zA-Z_][a-zA-Z0-9_]*') > + # check PCD information > + if self._ValueList[0] =3D=3D '' or self._ValueList[1] =3D= =3D '': > + EdkLogger.error('Parser', FORMAT_INVALID, "No token spa= ce GUID > or PCD name specified", > + ExtraData=3Dself._CurrentLine + \ > + " > (.|||< > Token>)", > + File=3Dself.MetaFile, Line=3Dself._Line= Index+1) > + # check format of token space GUID CName > + if not ValueRe.match(self._ValueList[0]): > + EdkLogger.error('Parser', FORMAT_INVALID, > + "The format of the token space GUID CNa= me is invalid. The > correct format is '(a-zA-Z_)[a-zA-Z0-9_]*'", > + ExtraData=3Dself._CurrentLine + \ > + " > (.|||< > Token>)", > + File=3Dself.MetaFile, Line=3Dself._Line= Index + 1) > + # check format of PCD CName > + if not ValueRe.match(self._ValueList[1]): > + EdkLogger.error('Parser', FORMAT_INVALID, > + "The format of the PCD CName is invalid= . The correct format > is '(a-zA-Z_)[a-zA-Z0-9_]*'", > + ExtraData=3Dself._CurrentLine + \ > + " > (.|||< > Token>)", > + File=3Dself.MetaFile, > + Line=3Dself._LineIndex + 1) > + > + # check PCD datum information > + if len(TokenList) < 2 or TokenList[1] =3D=3D '': > + EdkLogger.error('Parser', FORMAT_INVALID, "No PCD Datum > information given", > + ExtraData=3Dself._CurrentLine + \ > + " > (.|||< > Token>)", > + File=3Dself.MetaFile, > + Line=3Dself._LineIndex+1) > + > + > + ValueRe =3D re.compile(r'^\s*L?\".*\|.*\"') > + PtrValue =3D ValueRe.findall(TokenList[1]) > + > + # Has VOID* type string, may contain "|" character in the s= tring. > + if len(PtrValue) !=3D 0: > + ptrValueList =3D re.sub(ValueRe, '', TokenList[1]) > + ValueList =3D AnalyzePcdExpression(ptrValueList) > + ValueList[0] =3D PtrValue[0] > + else: > + ValueList =3D AnalyzePcdExpression(TokenList[1]) > + > + > + # check if there's enough datum information given > + if len(ValueList) !=3D 3: > + EdkLogger.error('Parser', FORMAT_INVALID, "Invalid PCD = Datum > information given", > + ExtraData=3Dself._CurrentLine + \ > + " > (.|||< > Token>)", > + File=3Dself.MetaFile, Line=3Dself._Line= Index + 1) > + # check default value > + if ValueList[0] =3D=3D '': > + EdkLogger.error('Parser', FORMAT_INVALID, "Missing Defa= ultValue > in PCD Datum information", > + ExtraData=3Dself._CurrentLine + \ > + " > (.|||< > Token>)", > + File=3Dself.MetaFile, Line=3Dself._Line= Index + 1) > + # check datum type > + if ValueList[1] =3D=3D '': > + EdkLogger.error('Parser', FORMAT_INVALID, "Missing Datu= mType > in PCD Datum information", > + ExtraData=3Dself._CurrentLine + \ > + " > (.|||< > Token>)", > + File=3Dself.MetaFile, Line=3Dself._Line= Index + 1) > + # check token of the PCD > + if ValueList[2] =3D=3D '': > + EdkLogger.error('Parser', FORMAT_INVALID, "Missing Toke= n in PCD > Datum information", > + ExtraData=3Dself._CurrentLine + \ > + " > (.|||< > Token>)", > + File=3Dself.MetaFile, > + Line=3Dself._LineIndex + 1) > + > + PcdValue =3D ValueList[0] > + if PcdValue: > + try: > + self._GuidDict.update(self._AllPcdDict) > + ValueList[0] =3D ValueExpressionEx(ValueList[0], Va= lueList[1], > self._GuidDict)(True) > + except BadExpression as Value: > + EdkLogger.error('Parser', FORMAT_INVALID, Value, > ExtraData=3Dself._CurrentLine, File=3Dself.MetaFile, Line=3Dself._LineIn= dex + 1) > + # check format of default value against the datum type > + IsValid, Cause =3D CheckPcdDatum(ValueList[1], ValueList[0]= ) > + if not IsValid: > + EdkLogger.error('Parser', FORMAT_INVALID, Cause, > ExtraData=3Dself._CurrentLine, > + File=3Dself.MetaFile, > + Line=3Dself._LineIndex + 1) > + > + if Cause =3D=3D "StructurePcd": > + self._CurrentStructurePcdName =3D > TAB_SPLIT.join(self._ValueList[0:2]) > + self._ValueList[0] =3D self._CurrentStructurePcdName > + self._ValueList[1] =3D ValueList[1].strip() > + > + if ValueList[0] in ['True', 'true', 'TRUE']: > + ValueList[0] =3D '1' > + elif ValueList[0] in ['False', 'false', 'FALSE']: > + ValueList[0] =3D '0' > + > + # check for duplicate PCD definition > + if (self._Scope[0], self._ValueList[0], self._ValueList[1])= in > self._AllPCDs: > + EdkLogger.error('Parser', FORMAT_INVALID, > + "The same PCD name and GUID have been a= lready defined", > + ExtraData=3Dself._CurrentLine, File=3Ds= elf.MetaFile, > Line=3Dself._LineIndex + 1) > + else: > + self._AllPCDs.append((self._Scope[0], self._ValueList[0= ], > self._ValueList[1])) > + self._AllPcdDict[TAB_SPLIT.join(self._ValueList[0:2])] > + =3D ValueList[0] > + > + self._ValueList[2] =3D ValueList[0].strip() + '|' + > + ValueList[1].strip() + '|' + ValueList[2].strip() >=20 > _SectionParser =3D { > MODEL_META_DATA_HEADER : MetaFileParser._DefineParse= r, > -- > 2.26.2.windows.1 >=20 >=20 >=20 >=20 >=20