BaseTools: Incorrect error message for library instance not found

BZ:https://bugzilla.tianocore.org/show_bug.cgi?id=2099
This is a regression issue introduced by commit e8449e.

This patch is to fix this issue.

Signed-off-by: Bob Feng <bob.c.feng@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
This commit is contained in:
Feng, Bob C 2019-08-21 12:03:05 +08:00
parent 5f7bb39117
commit abc0155b03
4 changed files with 12 additions and 9 deletions

View File

@ -89,7 +89,7 @@ class MemoryDataPipe(DataPipe):
libModules = {} libModules = {}
for m in PlatformInfo.Platform.Modules: for m in PlatformInfo.Platform.Modules:
module_obj = BuildDB.BuildObject[m,PlatformInfo.Arch,PlatformInfo.BuildTarget,PlatformInfo.ToolChain] module_obj = BuildDB.BuildObject[m,PlatformInfo.Arch,PlatformInfo.BuildTarget,PlatformInfo.ToolChain]
Libs = GetModuleLibInstances(module_obj, PlatformInfo.Platform, BuildDB.BuildObject, PlatformInfo.Arch,PlatformInfo.BuildTarget,PlatformInfo.ToolChain) Libs = GetModuleLibInstances(module_obj, PlatformInfo.Platform, BuildDB.BuildObject, PlatformInfo.Arch,PlatformInfo.BuildTarget,PlatformInfo.ToolChain,PlatformInfo.MetaFile,EdkLogger)
for lib in Libs: for lib in Libs:
try: try:
libModules[(lib.MetaFile.File,lib.MetaFile.Root,lib.Arch,lib.MetaFile.Path)].append((m.File,m.Root,module_obj.Arch,m.Path)) libModules[(lib.MetaFile.File,lib.MetaFile.Root,lib.Arch,lib.MetaFile.Path)].append((m.File,m.Root,module_obj.Arch,m.Path))

View File

@ -1089,7 +1089,7 @@ class PlatformAutoGen(AutoGen):
for m in self.Platform.Modules: for m in self.Platform.Modules:
module_obj = self.BuildDatabase[m,self.Arch,self.BuildTarget,self.ToolChain] module_obj = self.BuildDatabase[m,self.Arch,self.BuildTarget,self.ToolChain]
if not bool(module_obj.LibraryClass): if not bool(module_obj.LibraryClass):
Libs = GetModuleLibInstances(module_obj, self.Platform, self.BuildDatabase, self.Arch,self.BuildTarget,self.ToolChain) Libs = GetModuleLibInstances(module_obj, self.Platform, self.BuildDatabase, self.Arch,self.BuildTarget,self.ToolChain,self.MetaFile,EdkLogger)
else: else:
Libs = [] Libs = []
ModuleLibs.update( set([(l.MetaFile.File,l.MetaFile.Root,l.MetaFile.Path,l.MetaFile.BaseName,l.MetaFile.OriginalPath,l.Arch,True) for l in Libs])) ModuleLibs.update( set([(l.MetaFile.File,l.MetaFile.Root,l.MetaFile.Path,l.MetaFile.BaseName,l.MetaFile.OriginalPath,l.Arch,True) for l in Libs]))

View File

@ -248,7 +248,9 @@ class WorkspaceAutoGen(AutoGen):
self.BuildDatabase, self.BuildDatabase,
Arch, Arch,
self.BuildTarget, self.BuildTarget,
self.ToolChain self.ToolChain,
self.Platform.MetaFile,
EdkLogger
)) ))
for BuildData in list(self.BuildDatabase._CACHE_.values()): for BuildData in list(self.BuildDatabase._CACHE_.values()):
if BuildData.Arch != Arch: if BuildData.Arch != Arch:

View File

@ -15,6 +15,7 @@ from Workspace.BuildClassObject import StructurePcd
from Common.BuildToolError import RESOURCE_NOT_AVAILABLE from Common.BuildToolError import RESOURCE_NOT_AVAILABLE
from Common.BuildToolError import OPTION_MISSING from Common.BuildToolError import OPTION_MISSING
from Common.BuildToolError import BUILD_ERROR from Common.BuildToolError import BUILD_ERROR
import Common.EdkLogger as EdkLogger
class OrderedListDict(OrderedDict): class OrderedListDict(OrderedDict):
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
@ -85,7 +86,7 @@ def GetDeclaredPcd(Platform, BuildDatabase, Arch, Target, Toolchain, additionalP
# @retval: List of dependent libraries which are InfBuildData instances # @retval: List of dependent libraries which are InfBuildData instances
# #
def GetLiabraryInstances(Module, Platform, BuildDatabase, Arch, Target, Toolchain): def GetLiabraryInstances(Module, Platform, BuildDatabase, Arch, Target, Toolchain):
return GetModuleLibInstances(Module, Platform, BuildDatabase, Arch, Target, Toolchain) return GetModuleLibInstances(Module, Platform, BuildDatabase, Arch, Target, Toolchain,Platform.MetaFile,EdkLogger)
def GetModuleLibInstances(Module, Platform, BuildDatabase, Arch, Target, Toolchain, FileName = '', EdkLogger = None): def GetModuleLibInstances(Module, Platform, BuildDatabase, Arch, Target, Toolchain, FileName = '', EdkLogger = None):
if Module.LibInstances: if Module.LibInstances:
@ -113,7 +114,7 @@ def GetModuleLibInstances(Module, Platform, BuildDatabase, Arch, Target, Toolcha
ConsumedByList = OrderedListDict() ConsumedByList = OrderedListDict()
LibraryInstance = OrderedDict() LibraryInstance = OrderedDict()
if FileName: if not Module.LibraryClass:
EdkLogger.verbose("") EdkLogger.verbose("")
EdkLogger.verbose("Library instances of module [%s] [%s]:" % (str(Module), Arch)) EdkLogger.verbose("Library instances of module [%s] [%s]:" % (str(Module), Arch))
@ -126,7 +127,7 @@ def GetModuleLibInstances(Module, Platform, BuildDatabase, Arch, Target, Toolcha
if LibraryPath is None: if LibraryPath is None:
LibraryPath = M.LibraryClasses.get(LibraryClassName) LibraryPath = M.LibraryClasses.get(LibraryClassName)
if LibraryPath is None: if LibraryPath is None:
if FileName: if not Module.LibraryClass:
EdkLogger.error("build", RESOURCE_NOT_AVAILABLE, EdkLogger.error("build", RESOURCE_NOT_AVAILABLE,
"Instance of library class [%s] is not found" % LibraryClassName, "Instance of library class [%s] is not found" % LibraryClassName,
File=FileName, File=FileName,
@ -143,7 +144,7 @@ def GetModuleLibInstances(Module, Platform, BuildDatabase, Arch, Target, Toolcha
or (ModuleType != SUP_MODULE_USER_DEFINED and ModuleType != SUP_MODULE_HOST_APPLICATION or (ModuleType != SUP_MODULE_USER_DEFINED and ModuleType != SUP_MODULE_HOST_APPLICATION
and ModuleType not in LibraryModule.LibraryClass[0].SupModList): and ModuleType not in LibraryModule.LibraryClass[0].SupModList):
# only USER_DEFINED can link against any library instance despite of its SupModList # only USER_DEFINED can link against any library instance despite of its SupModList
if FileName: if not Module.LibraryClass:
EdkLogger.error("build", OPTION_MISSING, EdkLogger.error("build", OPTION_MISSING,
"Module type [%s] is not supported by library instance [%s]" \ "Module type [%s] is not supported by library instance [%s]" \
% (ModuleType, LibraryPath), File=FileName, % (ModuleType, LibraryPath), File=FileName,
@ -153,7 +154,7 @@ def GetModuleLibInstances(Module, Platform, BuildDatabase, Arch, Target, Toolcha
LibraryInstance[LibraryClassName] = LibraryModule LibraryInstance[LibraryClassName] = LibraryModule
LibraryConsumerList.append(LibraryModule) LibraryConsumerList.append(LibraryModule)
if FileName: if not Module.LibraryClass:
EdkLogger.verbose("\t" + str(LibraryClassName) + " : " + str(LibraryModule)) EdkLogger.verbose("\t" + str(LibraryClassName) + " : " + str(LibraryModule))
else: else:
LibraryModule = LibraryInstance[LibraryClassName] LibraryModule = LibraryInstance[LibraryClassName]
@ -234,7 +235,7 @@ def GetModuleLibInstances(Module, Platform, BuildDatabase, Arch, Target, Toolcha
# #
for Item in LibraryList: for Item in LibraryList:
if ConsumedByList[Item] and Item in Constructor and len(Constructor) > 1: if ConsumedByList[Item] and Item in Constructor and len(Constructor) > 1:
if FileName: if not Module.LibraryClass:
ErrorMessage = "\tconsumed by " + "\n\tconsumed by ".join(str(L) for L in ConsumedByList[Item]) ErrorMessage = "\tconsumed by " + "\n\tconsumed by ".join(str(L) for L in ConsumedByList[Item])
EdkLogger.error("build", BUILD_ERROR, 'Library [%s] with constructors has a cycle' % str(Item), EdkLogger.error("build", BUILD_ERROR, 'Library [%s] with constructors has a cycle' % str(Item),
ExtraData=ErrorMessage, File=FileName) ExtraData=ErrorMessage, File=FileName)