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>
## @file\r
# This file is for installed package information database operations\r
#\r
## @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
#\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
# Import Modules\r
#\r
from os.path import dirname\r
# Import Modules\r
#\r
from os.path import dirname\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
\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 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
from Logger.ToolError import FatalError\r
from Logger.ToolError import EDK1_INF_ERROR\r
from Logger.ToolError import UNKNOWN_ERROR\r
# True: module doesn't depend on package in DpPackagePathList\r
#\r
def VerifyRemoveModuleDep(Path, DpPackagePathList):\r
# True: module doesn't depend on package in DpPackagePathList\r
#\r
def VerifyRemoveModuleDep(Path, DpPackagePathList):\r
- WorkSP = GlobalData.gWORKSPACE\r
- \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
return False\r
else:\r
return True\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
## check whether module depends on packages in DpPackagePathList and can not be satisfied by OtherPkgList\r
#\r
# @param Path: a module path\r
# but can be satisfied by OtherPkgList\r
#\r
def VerifyReplaceModuleDep(Path, DpPackagePathList, OtherPkgList):\r
# but can be satisfied by OtherPkgList\r
#\r
def VerifyReplaceModuleDep(Path, DpPackagePathList, OtherPkgList):\r
- WorkSP = GlobalData.gWORKSPACE\r
- \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
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
return False\r
else:\r
return True\r
return True\r
else:\r
return True\r
return True\r
else:\r
return True\r