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: Hess Chen <hesheng.chen@intel.com> Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
This commit is contained in:
@ -1,7 +1,7 @@
|
|||||||
## @file
|
## @file
|
||||||
# This file is for installed package information database operations
|
# This file is for installed package information database operations
|
||||||
#
|
#
|
||||||
# Copyright (c) 2011 - 2016, Intel Corporation. All rights reserved.<BR>
|
# Copyright (c) 2011 - 2017, Intel Corporation. All rights reserved.<BR>
|
||||||
#
|
#
|
||||||
# This program and the accompanying materials are licensed and made available
|
# This program and the accompanying materials are licensed and made available
|
||||||
# under the terms and conditions of the BSD License which accompanies this
|
# under the terms and conditions of the BSD License which accompanies this
|
||||||
@ -21,14 +21,15 @@ Dependency
|
|||||||
# Import Modules
|
# Import Modules
|
||||||
#
|
#
|
||||||
from os.path import dirname
|
from os.path import dirname
|
||||||
|
import os
|
||||||
|
|
||||||
import Logger.Log as Logger
|
import Logger.Log as Logger
|
||||||
from Logger import StringTable as ST
|
from Logger import StringTable as ST
|
||||||
from Library.Parsing import GetWorkspacePackage
|
from Library.Parsing import GetWorkspacePackage
|
||||||
from Library.Parsing import GetWorkspaceModule
|
from Library.Parsing import GetWorkspaceModule
|
||||||
|
from Library.Parsing import GetPkgInfoFromDec
|
||||||
from Library.Misc import GetRelativePath
|
from Library.Misc import GetRelativePath
|
||||||
from Library import GlobalData
|
from Library import GlobalData
|
||||||
from PomAdapter.InfPomAlignment import InfPomAlignment
|
|
||||||
from Logger.ToolError import FatalError
|
from Logger.ToolError import FatalError
|
||||||
from Logger.ToolError import EDK1_INF_ERROR
|
from Logger.ToolError import EDK1_INF_ERROR
|
||||||
from Logger.ToolError import UNKNOWN_ERROR
|
from Logger.ToolError import UNKNOWN_ERROR
|
||||||
@ -373,14 +374,11 @@ class DependencyRules(object):
|
|||||||
# True: module doesn't depend on package in DpPackagePathList
|
# True: module doesn't depend on package in DpPackagePathList
|
||||||
#
|
#
|
||||||
def VerifyRemoveModuleDep(Path, DpPackagePathList):
|
def VerifyRemoveModuleDep(Path, DpPackagePathList):
|
||||||
WorkSP = GlobalData.gWORKSPACE
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
PomAli = InfPomAlignment(Path, WorkSP, Skip=True)
|
for Item in GetPackagePath(Path):
|
||||||
|
if Item in DpPackagePathList:
|
||||||
for Item in PomAli.GetPackageDependencyList():
|
DecPath = os.path.normpath(os.path.join(GlobalData.gWORKSPACE, Item))
|
||||||
if Item.GetPackageFilePath() in DpPackagePathList:
|
Logger.Info(ST.MSG_MODULE_DEPEND_ON % (Path, DecPath))
|
||||||
Logger.Info(ST.MSG_MODULE_DEPEND_ON % (Path, Item.GetPackageFilePath()))
|
|
||||||
return False
|
return False
|
||||||
else:
|
else:
|
||||||
return True
|
return True
|
||||||
@ -392,6 +390,30 @@ def VerifyRemoveModuleDep(Path, DpPackagePathList):
|
|||||||
else:
|
else:
|
||||||
return True
|
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
|
## check whether module depends on packages in DpPackagePathList and can not be satisfied by OtherPkgList
|
||||||
#
|
#
|
||||||
# @param Path: a module path
|
# @param Path: a module path
|
||||||
@ -402,16 +424,13 @@ def VerifyRemoveModuleDep(Path, DpPackagePathList):
|
|||||||
# but can be satisfied by OtherPkgList
|
# but can be satisfied by OtherPkgList
|
||||||
#
|
#
|
||||||
def VerifyReplaceModuleDep(Path, DpPackagePathList, OtherPkgList):
|
def VerifyReplaceModuleDep(Path, DpPackagePathList, OtherPkgList):
|
||||||
WorkSP = GlobalData.gWORKSPACE
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
PomAli = InfPomAlignment(Path, WorkSP, Skip=True)
|
for Item in GetPackagePath(Path):
|
||||||
|
if Item in DpPackagePathList:
|
||||||
for Item in PomAli.GetPackageDependencyList():
|
DecPath = os.path.normpath(os.path.join(GlobalData.gWORKSPACE, Item))
|
||||||
if Item.GetPackageFilePath() in DpPackagePathList:
|
Name, Guid, Version = GetPkgInfoFromDec(DecPath)
|
||||||
Guid, Version = Item.GetGuid(), Item.GetVersion()
|
|
||||||
if (Guid, Version) not in OtherPkgList:
|
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
|
return False
|
||||||
else:
|
else:
|
||||||
return True
|
return True
|
||||||
@ -422,6 +441,3 @@ def VerifyReplaceModuleDep(Path, DpPackagePathList, OtherPkgList):
|
|||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user