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 C39FA226847A5 for ; Wed, 25 Apr 2018 01:50:06 -0700 (PDT) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 25 Apr 2018 01:50:06 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,325,1520924400"; d="scan'208";a="49772965" Received: from fmsmsx108.amr.corp.intel.com ([10.18.124.206]) by fmsmga001.fm.intel.com with ESMTP; 25 Apr 2018 01:50:06 -0700 Received: from shsmsx152.ccr.corp.intel.com (10.239.6.52) by FMSMSX108.amr.corp.intel.com (10.18.124.206) with Microsoft SMTP Server (TLS) id 14.3.319.2; Wed, 25 Apr 2018 01:50:05 -0700 Received: from shsmsx103.ccr.corp.intel.com ([169.254.4.210]) by SHSMSX152.ccr.corp.intel.com ([169.254.6.6]) with mapi id 14.03.0319.002; Wed, 25 Apr 2018 16:50:03 +0800 From: "Zhu, Yonghong" To: "Carsey, Jaben" , "edk2-devel@lists.01.org" CC: "Gao, Liming" , "Zhu, Yonghong" Thread-Topic: [PATCH v1 04/27] BaseTools: Workspace - refactor RegEx to minimize multiple compiling Thread-Index: AQHT2L+FbFY39IRnvUi0NJvfS5NXIqQRM0lw Date: Wed, 25 Apr 2018 08:50:03 +0000 Message-ID: References: <7f83d6722511aa3833f7c339e86e80d9afb3ca14.1524239027.git.jaben.carsey@intel.com> In-Reply-To: <7f83d6722511aa3833f7c339e86e80d9afb3ca14.1524239027.git.jaben.carsey@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 v1 04/27] BaseTools: Workspace - refactor RegEx to minimize multiple compiling X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 25 Apr 2018 08:50:07 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Yonghong Zhu =20 Best Regards, Zhu Yonghong -----Original Message----- From: Carsey, Jaben=20 Sent: Friday, April 20, 2018 11:51 PM To: edk2-devel@lists.01.org Cc: Gao, Liming ; Zhu, Yonghong Subject: [PATCH v1 04/27] BaseTools: Workspace - refactor RegEx to minimize= multiple compiling Cc: Liming Gao Cc: Yonghong Zhu Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Jaben Carsey --- BaseTools/Source/Python/Workspace/DscBuildData.py | 4 +++- BaseTools/Source/Python/Workspace/MetaFileParser.py | 8 ++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py b/BaseTools/= Source/Python/Workspace/DscBuildData.py index d6b8b761d607..be3f7b6881e8 100644 --- a/BaseTools/Source/Python/Workspace/DscBuildData.py +++ b/BaseTools/Source/Python/Workspace/DscBuildData.py @@ -41,6 +41,8 @@ from Common.Misc import SaveFileOnChange from Workspace.= BuildClassObject import PlatformBuildClassObject, StructurePcd, PcdClassObj= ect, ModuleBuildClassObject from collections import OrderedDict =20 +variablePattern =3D re.compile(r'[\t\s]*0[xX][a-fA-F0-9]+$') + # # Treat CHAR16 as a synonym for UINT16. CHAR16 support is required for VF= R C structs # @@ -2421,7 +2423,7 @@ class DscBuildData(PlatformBuildClassO= bject): if VariableOffset.isdigit(): if int(VariableOffset, 10) > 0xFFFF: ExceedMax =3D True - elif re.match(r'[\t\s]*0[xX][a-fA-F0-9]+$', VariableOffset): + elif variablePattern.match(VariableOffset): if int(VariableOffset, 16) > 0xFFFF: ExceedMax =3D True # For Offset written in "A.B" diff --git a/BaseTools/Source/Python/Workspace/MetaFileParser.py b/BaseTool= s/Source/Python/Workspace/MetaFileParser.py index 322ed3844966..550359f9abb2 100644 --- a/BaseTools/Source/Python/Workspace/MetaFileParser.py +++ b/BaseTools/Source/Python/Workspace/MetaFileParser.py @@ -35,6 +35,10 @@ from Common.LongFilePathSupport import OpenLongFilePath = as open from MetaFileTable import MetaFileStorage from MetaFileCommentPar= ser import CheckInfComment =20 +## RegEx for finding file versions +hexVersionPattern =3D re.compile(r'0[xX][\da-f-A-F]{5,8}') +decVersionPattern =3D re.compile(r'\d+\.\d+') + ## A decorator used to parse macro definition def ParseMacro(Parser): def MacroParser(self): @@ -366,9 +370,9 @@ class MetaFileParser(object): EdkLogger.error("Parser", FORMAT_INVALID, "%s not defined"= % (Macro), ExtraData=3Dself._CurrentLine, File=3Dself.MetaFile, Line=3Dsel= f._LineIndex + 1) # Sometimes, we need to make differences between EDK and EDK2 modu= les=20 if Name =3D=3D 'INF_VERSION': - if re.match(r'0[xX][\da-f-A-F]{5,8}', Value): + if hexVersionPattern.match(Value): self._Version =3D int(Value, 0) =20 - elif re.match(r'\d+\.\d+', Value): + elif decVersionPattern.match(Value): ValueList =3D Value.split('.') Major =3D '%04o' % int(ValueList[0], 0) Minor =3D '%04o' % int(ValueList[1], 0) -- 2.16.2.windows.1