]> git.proxmox.com Git - mirror_edk2.git/commitdiff
BaseTools/UPT: Use a simple way to get package path
authorHess Chen <hesheng.chen@intel.com>
Sat, 1 Apr 2017 05:33:03 +0000 (13:33 +0800)
committerYonghong Zhu <yonghong.zhu@intel.com>
Wed, 5 Apr 2017 02:45:04 +0000 (10:45 +0800)
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: Hess Chen <hesheng.chen@intel.com>
Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
BaseTools/Source/Python/UPT/Core/DependencyRules.py

index 7039a7d6262b957cec8572735210c7dcd9eee44e..57f7b40da553ee95927080ed3122de288d6e4560 100644 (file)
@@ -1,7 +1,7 @@
 ## @file\r
 # This file is for installed package information database operations\r
 #\r
-# Copyright (c) 2011 - 2016, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2011 - 2017, Intel Corporation. All rights reserved.<BR>\r
 #\r
 # This program and the accompanying materials are licensed and made available \r
 # under the terms and conditions of the BSD License which accompanies this \r
@@ -21,14 +21,15 @@ Dependency
 # Import Modules\r
 #\r
 from os.path import dirname\r
+import os\r
 \r
 import Logger.Log as Logger\r
 from Logger import StringTable as ST\r
 from Library.Parsing import GetWorkspacePackage\r
 from Library.Parsing import GetWorkspaceModule\r
+from Library.Parsing import GetPkgInfoFromDec\r
 from Library.Misc import GetRelativePath\r
 from Library import GlobalData\r
-from PomAdapter.InfPomAlignment import InfPomAlignment\r
 from Logger.ToolError import FatalError\r
 from Logger.ToolError import EDK1_INF_ERROR\r
 from Logger.ToolError import UNKNOWN_ERROR\r
@@ -373,14 +374,11 @@ class DependencyRules(object):
 #           True:  module doesn't depend on package in DpPackagePathList\r
 #\r
 def VerifyRemoveModuleDep(Path, DpPackagePathList):\r
-    WorkSP = GlobalData.gWORKSPACE\r
-    \r
     try:\r
-        PomAli = InfPomAlignment(Path, WorkSP, Skip=True)\r
-\r
-        for Item in PomAli.GetPackageDependencyList():\r
-            if Item.GetPackageFilePath() in DpPackagePathList:\r
-                Logger.Info(ST.MSG_MODULE_DEPEND_ON % (Path, Item.GetPackageFilePath()))\r
+        for Item in GetPackagePath(Path):\r
+            if Item in DpPackagePathList:\r
+                DecPath = os.path.normpath(os.path.join(GlobalData.gWORKSPACE, Item))\r
+                Logger.Info(ST.MSG_MODULE_DEPEND_ON % (Path, DecPath))\r
                 return False\r
         else:\r
             return True\r
@@ -392,6 +390,30 @@ def VerifyRemoveModuleDep(Path, DpPackagePathList):
         else:\r
             return True\r
 \r
+# # GetPackagePath\r
+#\r
+# Get Dependency package path from an Inf file path\r
+#\r
+def GetPackagePath(InfPath):\r
+    PackagePath = []\r
+    if os.path.exists(InfPath):\r
+        FindSection = False\r
+        for Line in open(InfPath).readlines():\r
+            Line = Line.strip()\r
+            if not Line:\r
+                continue\r
+            if Line.startswith('#'):\r
+                continue\r
+            if Line.startswith('[Packages') and Line.endswith(']'):\r
+                FindSection = True\r
+                continue\r
+            if Line.startswith('[') and Line.endswith(']') and FindSection:\r
+                break\r
+            if FindSection:\r
+                PackagePath.append(os.path.normpath(Line))\r
+\r
+    return PackagePath\r
+\r
 ## check whether module depends on packages in DpPackagePathList and can not be satisfied by OtherPkgList\r
 #\r
 # @param Path: a module path\r
@@ -402,16 +424,13 @@ def VerifyRemoveModuleDep(Path, DpPackagePathList):
 #                 but can be satisfied by OtherPkgList\r
 #\r
 def VerifyReplaceModuleDep(Path, DpPackagePathList, OtherPkgList):\r
-    WorkSP = GlobalData.gWORKSPACE\r
-    \r
     try:\r
-        PomAli = InfPomAlignment(Path, WorkSP, Skip=True)\r
-\r
-        for Item in PomAli.GetPackageDependencyList():\r
-            if Item.GetPackageFilePath() in DpPackagePathList:\r
-                Guid, Version = Item.GetGuid(), Item.GetVersion()\r
+        for Item in GetPackagePath(Path):\r
+            if Item in DpPackagePathList:\r
+                DecPath = os.path.normpath(os.path.join(GlobalData.gWORKSPACE, Item))\r
+                Name, Guid, Version = GetPkgInfoFromDec(DecPath)\r
                 if (Guid, Version) not in OtherPkgList:\r
-                    Logger.Info(ST.MSG_MODULE_DEPEND_ON % (Path, Item.GetPackageFilePath()))\r
+                    Logger.Info(ST.MSG_MODULE_DEPEND_ON % (Path, DecPath))\r
                     return False\r
         else:\r
             return True\r
@@ -422,6 +441,3 @@ def VerifyReplaceModuleDep(Path, DpPackagePathList, OtherPkgList):
             return True\r
         else:\r
             return True\r
-   \r
-\r
-\r