From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) (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 37DE321A04820 for ; Fri, 31 Mar 2017 22:33:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=intel.com; i=@intel.com; q=dns/txt; s=intel; t=1491024789; x=1522560789; h=from:to:cc:subject:date:message-id; bh=WPz0vaLlnro6a+MOd8N6eBZSD5ErWiuAtfeUyVvvB7M=; b=HvNm/r+1HHNmRmYyifO09EXLqtayjphl98wJwGYglIPZudKuMT8y14lQ qBg8MexKRL8eTaHDRRDCSJGXeHhMPA==; Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 31 Mar 2017 22:33:08 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.36,255,1486454400"; d="scan'208";a="1114236482" Received: from tiano01.ccr.corp.intel.com ([10.239.9.111]) by orsmga001.jf.intel.com with ESMTP; 31 Mar 2017 22:33:08 -0700 From: hesschen To: edk2-devel@lists.01.org Date: Sat, 1 Apr 2017 13:33:03 +0800 Message-Id: <1491024785-9388-1-git-send-email-hesheng.chen@intel.com> X-Mailer: git-send-email 2.7.2.windows.1 Subject: [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: Sat, 01 Apr 2017 05:33:09 -0000 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/BaseTools/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 reserved.
# # This program and the accompanying materials are licensed and made available # under the terms and conditions of the BSD License which accompanies this @@ -21,14 +21,15 @@ Dependency # Import Modules # from os.path import dirname +import os 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 = GlobalData.gWORKSPACE - try: - PomAli = InfPomAlignment(Path, WorkSP, Skip=True) - - for Item in PomAli.GetPackageDependencyList(): - if Item.GetPackageFilePath() in DpPackagePathList: - Logger.Info(ST.MSG_MODULE_DEPEND_ON % (Path, Item.GetPackageFilePath())) + for Item in GetPackagePath(Path): + if Item in DpPackagePathList: + DecPath = os.path.normpath(os.path.join(GlobalData.gWORKSPACE, 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 +# # GetPackagePath +# +# Get Dependency package path from an Inf file path +# +def GetPackagePath(InfPath): + PackagePath = [] + if os.path.exists(InfPath): + FindSection = False + for Line in open(InfPath).readlines(): + Line = Line.strip() + if not Line: + continue + if Line.startswith('#'): + continue + if Line.startswith('[Packages') and Line.endswith(']'): + FindSection = 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 not 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 = GlobalData.gWORKSPACE - try: - PomAli = InfPomAlignment(Path, WorkSP, Skip=True) - - for Item in PomAli.GetPackageDependencyList(): - if Item.GetPackageFilePath() in DpPackagePathList: - Guid, Version = Item.GetGuid(), Item.GetVersion() + for Item in GetPackagePath(Path): + if Item in DpPackagePathList: + DecPath = os.path.normpath(os.path.join(GlobalData.gWORKSPACE, Item)) + Name, Guid, Version = GetPkgInfoFromDec(DecPath) if (Guid, Version) not in OtherPkgList: - Logger.Info(ST.MSG_MODULE_DEPEND_ON % (Path, Item.GetPackageFilePath())) + Logger.Info(ST.MSG_MODULE_DEPEND_ON % (Path, DecPath)) return False else: return True @@ -422,6 +441,3 @@ def VerifyReplaceModuleDep(Path, DpPackagePathList, OtherPkgList): return True else: return True - - - -- 2.7.2.windows.1