From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) (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 04D93219392ED for ; Tue, 4 Apr 2017 19:23:19 -0700 (PDT) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga105.fm.intel.com with ESMTP; 04 Apr 2017 19:23:19 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.36,276,1486454400"; d="scan'208";a="842019372" Received: from fmsmsx103.amr.corp.intel.com ([10.18.124.201]) by FMSMGA003.fm.intel.com with ESMTP; 04 Apr 2017 19:23:19 -0700 Received: from shsmsx151.ccr.corp.intel.com (10.239.6.50) by FMSMSX103.amr.corp.intel.com (10.18.124.201) with Microsoft SMTP Server (TLS) id 14.3.319.2; Tue, 4 Apr 2017 19:23:19 -0700 Received: from shsmsx103.ccr.corp.intel.com ([169.254.4.117]) by SHSMSX151.ccr.corp.intel.com ([169.254.3.224]) with mapi id 14.03.0319.002; Wed, 5 Apr 2017 10:23:15 +0800 From: "Zhu, Yonghong" To: "Chen, Hesheng" , "edk2-devel@lists.01.org" Thread-Topic: [patch 1/3] BaseTools/UPT: Use a simple way to get package path Thread-Index: AQHSqql67v+WInM5OE2nF5v7heOpHaG2EYBQ Date: Wed, 5 Apr 2017 02:23:15 +0000 Message-ID: References: <1491024785-9388-1-git-send-email-hesheng.chen@intel.com> In-Reply-To: <1491024785-9388-1-git-send-email-hesheng.chen@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiYzljNjdlYzgtMDQxZC00NmFmLThkOWMtZmJkMTgwOGFlNzJiIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX0lDIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE1LjkuNi42IiwiVHJ1c3RlZExhYmVsSGFzaCI6IkxSSzhBd01cL0VGdzdMSkVxWDVNZ0QwRUd2TFwvMW5aTlhtRVdGRkRRWFRqbz0ifQ== x-ctpclassification: CTP_IC x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [patch 1/3] BaseTools/UPT: Use a simple way to get package path X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 05 Apr 2017 02:23:20 -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: Chen, Hesheng=20 Sent: Saturday, April 1, 2017 1:33 PM To: edk2-devel@lists.01.org Cc: Zhu, Yonghong Subject: [patch 1/3] BaseTools/UPT: Use a simple way to get package path Instead of parsing all content of DEC file, just get the package path only = to save time. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: hesschen --- .../Source/Python/UPT/Core/DependencyRules.py | 56 ++++++++++++++----= ---- 1 file changed, 36 insertions(+), 20 deletions(-) diff --git a/BaseTools/Source/Python/UPT/Core/DependencyRules.py b/BaseTool= s/Source/Python/UPT/Core/DependencyRules.py index 7039a7d..57f7b40 100644 --- a/BaseTools/Source/Python/UPT/Core/DependencyRules.py +++ b/BaseTools/Source/Python/UPT/Core/DependencyRules.py @@ -1,7 +1,7 @@ ## @file # This file is for installed package information database operations # -#= Copyright (c) 2011 - 2016, Intel Corporation. All rights reserved.
+# Copyright (c) 2011 - 2017, Intel Corporation. All rights=20 +reserved.
# # This program and the accompanying materials are licensed and made availa= ble # under the terms and conditions of the BSD License which accompanies = this @@ -21,14 +21,15 @@ Dependency # Import Modules # from os.path impo= rt dirname +import os =20 import Logger.Log as Logger from Logger import StringTable as ST from Library.Parsing import GetWorkspacePackage from Library.Parsing import GetWorkspaceModule +from Library.Parsing import GetPkgInfoFromDec from Library.Misc import GetRelativePath from Library import GlobalData -from PomAdapter.InfPomAlignment import InfPomAlignment from Logger.ToolError import FatalError from Logger.ToolError import EDK1_INF_ERROR from Logger.ToolError import UNKNOWN_ERROR @@ -373,14 +374,11 @@ class DependencyRules(object): # True: module doesn't depend on package in DpPackagePathList # def VerifyRemoveModuleDep(Path, DpPackagePathList): - WorkSP =3D GlobalData.gWORKSPACE - =20 try: - PomAli =3D InfPomAlignment(Path, WorkSP, Skip=3DTrue) - - for Item in PomAli.GetPackageDependencyList(): - if Item.GetPackageFilePath() in DpPackagePathList: - Logger.Info(ST.MSG_MODULE_DEPEND_ON % (Path, Item.GetPacka= geFilePath())) + for Item in GetPackagePath(Path): + if Item in DpPackagePathList: + DecPath =3D os.path.normpath(os.path.join(GlobalData.gWORK= SPACE, Item)) + Logger.Info(ST.MSG_MODULE_DEPEND_ON % (Path, DecPath)) return False else: return True @@ -392,6 +390,30 @@ def VerifyRemoveModuleDep(Path, DpPackagePathList): else: return True =20 +# # GetPackagePath +# +# Get Dependency package path from an Inf file path +# +def GetPackagePath(InfPath): + PackagePath =3D [] + if os.path.exists(InfPath): + FindSection =3D False + for Line in open(InfPath).readlines(): + Line =3D Line.strip() + if not Line: + continue + if Line.startswith('#'): + continue + if Line.startswith('[Packages') and Line.endswith(']'): + FindSection =3D True + continue + if Line.startswith('[') and Line.endswith(']') and FindSection= : + break + if FindSection: + PackagePath.append(os.path.normpath(Line)) + + return PackagePath + ## check whether module depends on packages in DpPackagePathList and can n= ot be satisfied by OtherPkgList # # @param Path: a module path @@ -402,16 +424,13 @@ def VerifyRemoveModuleDep(Path, DpPackagePathList): # but can be satisfied by OtherPkgList # def VerifyReplaceModuleDep(Path, DpPackagePathList, OtherPkgList): - WorkSP =3D GlobalData.gWORKSPACE - =20 try: - PomAli =3D InfPomAlignment(Path, WorkSP, Skip=3DTrue) - - for Item in PomAli.GetPackageDependencyList(): - if Item.GetPackageFilePath() in DpPackagePathList: - Guid, Version =3D Item.GetGuid(), Item.GetVersion() + for Item in GetPackagePath(Path): + if Item in DpPackagePathList: + DecPath =3D os.path.normpath(os.path.join(GlobalData.gWORK= SPACE, Item)) + Name, Guid, Version =3D GetPkgInfoFromDec(DecPath) if (Guid, Version) not in OtherPkgList: - Logger.Info(ST.MSG_MODULE_DEPEND_ON % (Path, Item.GetP= ackageFilePath())) + Logger.Info(ST.MSG_MODULE_DEPEND_ON % (Path, DecPath)) return False else: return True @@ -422,6 +441,3 @@ def VerifyReplaceModuleDep(Path, DpPackagePathList, Oth= erPkgList): return True else: return True - =20 - - --=20 2.7.2.windows.1