From nobody Fri Nov 1 03:31:45 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 1522794853962459.3976771573963; Tue, 3 Apr 2018 15:34:13 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id B639A225501EA; Tue, 3 Apr 2018 15:34:12 -0700 (PDT) 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 13A9D2035BA1F for ; Tue, 3 Apr 2018 15:34:11 -0700 (PDT) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 03 Apr 2018 15:34:09 -0700 Received: from jcarsey-desk1.amr.corp.intel.com ([10.7.159.144]) by orsmga001.jf.intel.com with ESMTP; 03 Apr 2018 15:34:09 -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=192.55.52.120; helo=mga04.intel.com; envelope-from=jaben.carsey@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,403,1517904000"; d="scan'208";a="44656101" From: Jaben Carsey To: edk2-devel@lists.01.org Date: Tue, 3 Apr 2018 15:34:02 -0700 Message-Id: X-Mailer: git-send-email 2.16.2.windows.1 In-Reply-To: References: In-Reply-To: References: Subject: [edk2] [PATCH v1 1/5] BaseTools: Autogen - move RegEx compile 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: , 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" compile each RegEx once not in loops/functions Cc: Liming Gao Cc: Yonghong Zhu Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Jaben Carsey --- BaseTools/Source/Python/AutoGen/AutoGen.py | 22 +++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py b/BaseTools/Source/= Python/AutoGen/AutoGen.py index 3384fdb70b7e..7dd7c35e6685 100644 --- a/BaseTools/Source/Python/AutoGen/AutoGen.py +++ b/BaseTools/Source/Python/AutoGen/AutoGen.py @@ -49,6 +49,16 @@ from GenVar import VariableMgr,var_info ## Regular expression for splitting Dependency Expression string into toke= ns gDepexTokenPattern =3D re.compile("(\(|\)|\w+| \S+\.inf)") =20 +## Regular expression for match: PCD(xxxx.yyy) +gPCDAsGuidPattern =3D re.compile(r"^PCD\(.+\..+\)$") + +# +# Regular expression for finding Include Directories, the difference betwe= en MSFT and INTEL/GCC/RVCT +# is the former use /I , the Latter used -I to specify include directories +# +gBuildOptIncludePatternMsft =3D re.compile(r"(?:.*?)/I[ \t]*([^ ]*)", re.M= ULTILINE | re.DOTALL) +gBuildOptIncludePatternOther =3D re.compile(r"(?:.*?)-I[ \t]*([^ ]*)", re.= MULTILINE | re.DOTALL) + # # Match name =3D variable # @@ -818,13 +828,11 @@ class WorkspaceAutoGen(AutoGen): InfFoundFlag =3D False =20 if FfsFile.NameGuid is not None: - _CheckPCDAsGuidPattern =3D re.compile("^PCD\(.+\..+\)$= ") - # # If the NameGuid reference a PCD name.=20 # The style must match: PCD(xxxx.yyy) # - if _CheckPCDAsGuidPattern.match(FfsFile.NameGuid): + if gPCDAsGuidPattern.match(FfsFile.NameGuid): # # Replace the PCD value. # @@ -3315,9 +3323,9 @@ class ModuleAutoGen(AutoGen): # is the former use /I , the Latter used -I to specify include= directories # if self.PlatformInfo.ToolChainFamily in ('MSFT'): - gBuildOptIncludePattern =3D re.compile(r"(?:.*?)/I[ \t]*([= ^ ]*)", re.MULTILINE | re.DOTALL) + BuildOptIncludeRegEx =3D gBuildOptIncludePatternMsft elif self.PlatformInfo.ToolChainFamily in ('INTEL', 'GCC', 'RV= CT'): - gBuildOptIncludePattern =3D re.compile(r"(?:.*?)-I[ \t]*([= ^ ]*)", re.MULTILINE | re.DOTALL) + BuildOptIncludeRegEx =3D gBuildOptIncludePatternOther else: # # New ToolChainFamily, don't known whether there is option= to specify include directories @@ -3334,13 +3342,13 @@ class ModuleAutoGen(AutoGen): FlagOption =3D '' =20 if self.PlatformInfo.ToolChainFamily !=3D 'RVCT': - IncPathList =3D [NormPath(Path, self.Macros) for Path = in gBuildOptIncludePattern.findall(FlagOption)] + IncPathList =3D [NormPath(Path, self.Macros) for Path = in BuildOptIncludeRegEx.findall(FlagOption)] else: # # RVCT may specify a list of directory seperated by co= mmas # IncPathList =3D [] - for Path in gBuildOptIncludePattern.findall(FlagOption= ): + for Path in BuildOptIncludeRegEx.findall(FlagOption): PathList =3D GetSplitList(Path, TAB_COMMA_SPLIT) IncPathList +=3D [NormPath(PathEntry, self.Macros)= for PathEntry in PathList] =20 --=20 2.16.2.windows.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel