From abc0155b034230128ad4aaa51ac05a315acfa7c1 Mon Sep 17 00:00:00 2001 From: "Feng, Bob C" Date: Wed, 21 Aug 2019 12:03:05 +0800 Subject: [PATCH] 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 Cc: Liming Gao Reviewed-by: Liming Gao --- BaseTools/Source/Python/AutoGen/DataPipe.py | 2 +- BaseTools/Source/Python/AutoGen/PlatformAutoGen.py | 2 +- BaseTools/Source/Python/AutoGen/WorkspaceAutoGen.py | 4 +++- .../Source/Python/Workspace/WorkspaceCommon.py | 13 +++++++------ 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/BaseTools/Source/Python/AutoGen/DataPipe.py b/BaseTools/Source/Python/AutoGen/DataPipe.py index 2ca4f9ff4a..8b8cfd1c51 100755 --- a/BaseTools/Source/Python/AutoGen/DataPipe.py +++ b/BaseTools/Source/Python/AutoGen/DataPipe.py @@ -89,7 +89,7 @@ class MemoryDataPipe(DataPipe): libModules = {} for m in PlatformInfo.Platform.Modules: 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: try: libModules[(lib.MetaFile.File,lib.MetaFile.Root,lib.Arch,lib.MetaFile.Path)].append((m.File,m.Root,module_obj.Arch,m.Path)) diff --git a/BaseTools/Source/Python/AutoGen/PlatformAutoGen.py b/BaseTools/Source/Python/AutoGen/PlatformAutoGen.py index dd629ba2fa..565424a95e 100644 --- a/BaseTools/Source/Python/AutoGen/PlatformAutoGen.py +++ b/BaseTools/Source/Python/AutoGen/PlatformAutoGen.py @@ -1089,7 +1089,7 @@ class PlatformAutoGen(AutoGen): for m in self.Platform.Modules: module_obj = self.BuildDatabase[m,self.Arch,self.BuildTarget,self.ToolChain] 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: 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])) diff --git a/BaseTools/Source/Python/AutoGen/WorkspaceAutoGen.py b/BaseTools/Source/Python/AutoGen/WorkspaceAutoGen.py index ea0d8f8bfb..2494267472 100644 --- a/BaseTools/Source/Python/AutoGen/WorkspaceAutoGen.py +++ b/BaseTools/Source/Python/AutoGen/WorkspaceAutoGen.py @@ -248,7 +248,9 @@ class WorkspaceAutoGen(AutoGen): self.BuildDatabase, Arch, self.BuildTarget, - self.ToolChain + self.ToolChain, + self.Platform.MetaFile, + EdkLogger )) for BuildData in list(self.BuildDatabase._CACHE_.values()): if BuildData.Arch != Arch: diff --git a/BaseTools/Source/Python/Workspace/WorkspaceCommon.py b/BaseTools/Source/Python/Workspace/WorkspaceCommon.py index 76583f46e5..0b11ec2d59 100644 --- a/BaseTools/Source/Python/Workspace/WorkspaceCommon.py +++ b/BaseTools/Source/Python/Workspace/WorkspaceCommon.py @@ -15,6 +15,7 @@ from Workspace.BuildClassObject import StructurePcd from Common.BuildToolError import RESOURCE_NOT_AVAILABLE from Common.BuildToolError import OPTION_MISSING from Common.BuildToolError import BUILD_ERROR +import Common.EdkLogger as EdkLogger class OrderedListDict(OrderedDict): 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 # 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): if Module.LibInstances: @@ -113,7 +114,7 @@ def GetModuleLibInstances(Module, Platform, BuildDatabase, Arch, Target, Toolcha ConsumedByList = OrderedListDict() LibraryInstance = OrderedDict() - if FileName: + if not Module.LibraryClass: EdkLogger.verbose("") 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: LibraryPath = M.LibraryClasses.get(LibraryClassName) if LibraryPath is None: - if FileName: + if not Module.LibraryClass: EdkLogger.error("build", RESOURCE_NOT_AVAILABLE, "Instance of library class [%s] is not found" % LibraryClassName, 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 and ModuleType not in LibraryModule.LibraryClass[0].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, "Module type [%s] is not supported by library instance [%s]" \ % (ModuleType, LibraryPath), File=FileName, @@ -153,7 +154,7 @@ def GetModuleLibInstances(Module, Platform, BuildDatabase, Arch, Target, Toolcha LibraryInstance[LibraryClassName] = LibraryModule LibraryConsumerList.append(LibraryModule) - if FileName: + if not Module.LibraryClass: EdkLogger.verbose("\t" + str(LibraryClassName) + " : " + str(LibraryModule)) else: LibraryModule = LibraryInstance[LibraryClassName] @@ -234,7 +235,7 @@ def GetModuleLibInstances(Module, Platform, BuildDatabase, Arch, Target, Toolcha # for Item in LibraryList: 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]) EdkLogger.error("build", BUILD_ERROR, 'Library [%s] with constructors has a cycle' % str(Item), ExtraData=ErrorMessage, File=FileName)