public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [Patch V2][edk2-stable201908] BaseTools: Incorrect error message for library instance not found
@ 2019-08-22  4:00 Bob Feng
  2019-08-22 14:32 ` Liming Gao
  0 siblings, 1 reply; 3+ messages in thread
From: Bob Feng @ 2019-08-22  4:00 UTC (permalink / raw)
  To: devel; +Cc: Bob Feng, Liming Gao

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>
---
V2: We need to check if a inf is a Library or a Module.
 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
@@ -87,11 +87,11 @@ class MemoryDataPipe(DataPipe):
         #Module's Library Instance
         ModuleLibs = {}
         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))
                 except:
                     libModules[(lib.MetaFile.File,lib.MetaFile.Root,lib.Arch,lib.MetaFile.Path)] = [(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
@@ -1087,11 +1087,11 @@ class PlatformAutoGen(AutoGen):
     def GetAllModuleInfo(self,WithoutPcd=True):
         ModuleLibs = set()
         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]))
             if WithoutPcd and module_obj.PcdIsDriver:
                 continue
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
@@ -246,11 +246,13 @@ class WorkspaceAutoGen(AutoGen):
                 if BuildData.MetaFile.Ext == '.inf' and str(BuildData) in Platform.Modules :
                     Libs.extend(GetModuleLibInstances(BuildData, Platform,
                                      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:
                     continue
                 if BuildData.MetaFile.Ext == '.inf':
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
@@ -13,10 +13,11 @@ from .BuildClassObject import LibraryClassObject
 import Common.GlobalData as GlobalData
 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):
         super(OrderedListDict, self).__init__(*args, **kwargs)
         self.default_factory = list
@@ -83,11 +84,11 @@ def GetDeclaredPcd(Platform, BuildDatabase, Arch, Target, Toolchain, additionalP
 #  @param Target: Current target
 #  @param Toolchain: Current toolchain
 #  @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:
         return Module.LibInstances
     ModuleType = Module.ModuleType
@@ -111,11 +112,11 @@ def GetModuleLibInstances(Module, Platform, BuildDatabase, Arch, Target, Toolcha
     LibraryConsumerList = [Module]
     Constructor = []
     ConsumedByList = OrderedListDict()
     LibraryInstance = OrderedDict()
 
-    if FileName:
+    if not Module.LibraryClass:
         EdkLogger.verbose("")
         EdkLogger.verbose("Library instances of module [%s] [%s]:" % (str(Module), Arch))
 
     while len(LibraryConsumerList) > 0:
         M = LibraryConsumerList.pop()
@@ -124,11 +125,11 @@ def GetModuleLibInstances(Module, Platform, BuildDatabase, Arch, Target, Toolcha
                 # override library instance for this module
                 LibraryPath = Platform.Modules[str(Module)].LibraryClasses.get(LibraryClassName,Platform.LibraryClasses[LibraryClassName, ModuleType])
                 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,
                                             ExtraData="in [%s] [%s]\n\tconsumed by module [%s]" % (str(M), Arch, str(Module)))
                         else:
@@ -141,21 +142,21 @@ def GetModuleLibInstances(Module, Platform, BuildDatabase, Arch, Target, Toolcha
                 elif LibraryModule.LibraryClass is None \
                      or len(LibraryModule.LibraryClass) == 0 \
                      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,
                                         ExtraData="consumed by [%s]" % str(Module))
                     else:
                         return []
 
                 LibraryInstance[LibraryClassName] = LibraryModule
                 LibraryConsumerList.append(LibraryModule)
-                if FileName:
+                if not Module.LibraryClass:
                     EdkLogger.verbose("\t" + str(LibraryClassName) + " : " + str(LibraryModule))
             else:
                 LibraryModule = LibraryInstance[LibraryClassName]
 
             if LibraryModule is None:
@@ -232,11 +233,11 @@ def GetModuleLibInstances(Module, Platform, BuildDatabase, Arch, Target, Toolcha
     #
     # if any remaining node Item in the graph has a constructor and an incoming edge, then the graph has a cycle
     #
     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)
             else:
                 return []
-- 
2.20.1.windows.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [Patch V2][edk2-stable201908] BaseTools: Incorrect error message for library instance not found
  2019-08-22  4:00 [Patch V2][edk2-stable201908] BaseTools: Incorrect error message for library instance not found Bob Feng
@ 2019-08-22 14:32 ` Liming Gao
  2019-08-23  6:20   ` Bob Feng
  0 siblings, 1 reply; 3+ messages in thread
From: Liming Gao @ 2019-08-22 14:32 UTC (permalink / raw)
  To: Feng, Bob C, devel@edk2.groups.io

Reviewed-by: Liming Gao <liming.gao@intel.com>

> -----Original Message-----
> From: Feng, Bob C
> Sent: Thursday, August 22, 2019 12:01 PM
> To: devel@edk2.groups.io
> Cc: Feng, Bob C <bob.c.feng@intel.com>; Gao, Liming <liming.gao@intel.com>
> Subject: [Patch V2][edk2-stable201908] 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>
> ---
> V2: We need to check if a inf is a Library or a Module.
>  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
> @@ -87,11 +87,11 @@ class MemoryDataPipe(DataPipe):
>          #Module's Library Instance
>          ModuleLibs = {}
>          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))
>                  except:
>                      libModules[(lib.MetaFile.File,lib.MetaFile.Root,lib.Arch,lib.MetaFile.Path)] =
> [(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
> @@ -1087,11 +1087,11 @@ class PlatformAutoGen(AutoGen):
>      def GetAllModuleInfo(self,WithoutPcd=True):
>          ModuleLibs = set()
>          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]))
>              if WithoutPcd and module_obj.PcdIsDriver:
>                  continue
> 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
> @@ -246,11 +246,13 @@ class WorkspaceAutoGen(AutoGen):
>                  if BuildData.MetaFile.Ext == '.inf' and str(BuildData) in Platform.Modules :
>                      Libs.extend(GetModuleLibInstances(BuildData, Platform,
>                                       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:
>                      continue
>                  if BuildData.MetaFile.Ext == '.inf':
> 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
> @@ -13,10 +13,11 @@ from .BuildClassObject import LibraryClassObject
>  import Common.GlobalData as GlobalData
>  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):
>          super(OrderedListDict, self).__init__(*args, **kwargs)
>          self.default_factory = list
> @@ -83,11 +84,11 @@ def GetDeclaredPcd(Platform, BuildDatabase, Arch, Target, Toolchain, additionalP
>  #  @param Target: Current target
>  #  @param Toolchain: Current toolchain
>  #  @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:
>          return Module.LibInstances
>      ModuleType = Module.ModuleType
> @@ -111,11 +112,11 @@ def GetModuleLibInstances(Module, Platform, BuildDatabase, Arch, Target, Toolcha
>      LibraryConsumerList = [Module]
>      Constructor = []
>      ConsumedByList = OrderedListDict()
>      LibraryInstance = OrderedDict()
> 
> -    if FileName:
> +    if not Module.LibraryClass:
>          EdkLogger.verbose("")
>          EdkLogger.verbose("Library instances of module [%s] [%s]:" % (str(Module), Arch))
> 
>      while len(LibraryConsumerList) > 0:
>          M = LibraryConsumerList.pop()
> @@ -124,11 +125,11 @@ def GetModuleLibInstances(Module, Platform, BuildDatabase, Arch, Target, Toolcha
>                  # override library instance for this module
>                  LibraryPath =
> Platform.Modules[str(Module)].LibraryClasses.get(LibraryClassName,Platform.LibraryClasses[LibraryClassName, ModuleType])
>                  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,
>                                              ExtraData="in [%s] [%s]\n\tconsumed by module [%s]" % (str(M), Arch, str(Module)))
>                          else:
> @@ -141,21 +142,21 @@ def GetModuleLibInstances(Module, Platform, BuildDatabase, Arch, Target, Toolcha
>                  elif LibraryModule.LibraryClass is None \
>                       or len(LibraryModule.LibraryClass) == 0 \
>                       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,
>                                          ExtraData="consumed by [%s]" % str(Module))
>                      else:
>                          return []
> 
>                  LibraryInstance[LibraryClassName] = LibraryModule
>                  LibraryConsumerList.append(LibraryModule)
> -                if FileName:
> +                if not Module.LibraryClass:
>                      EdkLogger.verbose("\t" + str(LibraryClassName) + " : " + str(LibraryModule))
>              else:
>                  LibraryModule = LibraryInstance[LibraryClassName]
> 
>              if LibraryModule is None:
> @@ -232,11 +233,11 @@ def GetModuleLibInstances(Module, Platform, BuildDatabase, Arch, Target, Toolcha
>      #
>      # if any remaining node Item in the graph has a constructor and an incoming edge, then the graph has a cycle
>      #
>      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)
>              else:
>                  return []
> --
> 2.20.1.windows.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Patch V2][edk2-stable201908] BaseTools: Incorrect error message for library instance not found
  2019-08-22 14:32 ` Liming Gao
@ 2019-08-23  6:20   ` Bob Feng
  0 siblings, 0 replies; 3+ messages in thread
From: Bob Feng @ 2019-08-23  6:20 UTC (permalink / raw)
  To: Gao, Liming, devel@edk2.groups.io

Pushed @abc0155b034230128ad4aaa51ac05a315acfa7c1

-----Original Message-----
From: Gao, Liming 
Sent: Thursday, August 22, 2019 10:32 PM
To: Feng, Bob C <bob.c.feng@intel.com>; devel@edk2.groups.io
Subject: RE: [Patch V2][edk2-stable201908] BaseTools: Incorrect error message for library instance not found

Reviewed-by: Liming Gao <liming.gao@intel.com>

> -----Original Message-----
> From: Feng, Bob C
> Sent: Thursday, August 22, 2019 12:01 PM
> To: devel@edk2.groups.io
> Cc: Feng, Bob C <bob.c.feng@intel.com>; Gao, Liming 
> <liming.gao@intel.com>
> Subject: [Patch V2][edk2-stable201908] 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>
> ---
> V2: We need to check if a inf is a Library or a Module.
>  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
> @@ -87,11 +87,11 @@ class MemoryDataPipe(DataPipe):
>          #Module's Library Instance
>          ModuleLibs = {}
>          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))
>                  except:
>                      
> libModules[(lib.MetaFile.File,lib.MetaFile.Root,lib.Arch,lib.MetaFile.
> Path)] = [(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
> @@ -1087,11 +1087,11 @@ class PlatformAutoGen(AutoGen):
>      def GetAllModuleInfo(self,WithoutPcd=True):
>          ModuleLibs = set()
>          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.BaseN
> ame,l.MetaFile.OriginalPath,l.Arch,True) for l in
> Libs]))
>              if WithoutPcd and module_obj.PcdIsDriver:
>                  continue
> 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
> @@ -246,11 +246,13 @@ class WorkspaceAutoGen(AutoGen):
>                  if BuildData.MetaFile.Ext == '.inf' and str(BuildData) in Platform.Modules :
>                      Libs.extend(GetModuleLibInstances(BuildData, Platform,
>                                       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:
>                      continue
>                  if BuildData.MetaFile.Ext == '.inf':
> 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
> @@ -13,10 +13,11 @@ from .BuildClassObject import LibraryClassObject  
> import Common.GlobalData as GlobalData  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):
>          super(OrderedListDict, self).__init__(*args, **kwargs)
>          self.default_factory = list
> @@ -83,11 +84,11 @@ def GetDeclaredPcd(Platform, BuildDatabase, Arch, 
> Target, Toolchain, additionalP  #  @param Target: Current target  #  
> @param Toolchain: Current toolchain  #  @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:
>          return Module.LibInstances
>      ModuleType = Module.ModuleType
> @@ -111,11 +112,11 @@ def GetModuleLibInstances(Module, Platform, BuildDatabase, Arch, Target, Toolcha
>      LibraryConsumerList = [Module]
>      Constructor = []
>      ConsumedByList = OrderedListDict()
>      LibraryInstance = OrderedDict()
> 
> -    if FileName:
> +    if not Module.LibraryClass:
>          EdkLogger.verbose("")
>          EdkLogger.verbose("Library instances of module [%s] [%s]:" % 
> (str(Module), Arch))
> 
>      while len(LibraryConsumerList) > 0:
>          M = LibraryConsumerList.pop() @@ -124,11 +125,11 @@ def 
> GetModuleLibInstances(Module, Platform, BuildDatabase, Arch, Target, Toolcha
>                  # override library instance for this module
>                  LibraryPath =
> Platform.Modules[str(Module)].LibraryClasses.get(LibraryClassName,Platform.LibraryClasses[LibraryClassName, ModuleType])
>                  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,
>                                              ExtraData="in [%s] [%s]\n\tconsumed by module [%s]" % (str(M), Arch, str(Module)))
>                          else:
> @@ -141,21 +142,21 @@ def GetModuleLibInstances(Module, Platform, BuildDatabase, Arch, Target, Toolcha
>                  elif LibraryModule.LibraryClass is None \
>                       or len(LibraryModule.LibraryClass) == 0 \
>                       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,
>                                          ExtraData="consumed by [%s]" % str(Module))
>                      else:
>                          return []
> 
>                  LibraryInstance[LibraryClassName] = LibraryModule
>                  LibraryConsumerList.append(LibraryModule)
> -                if FileName:
> +                if not Module.LibraryClass:
>                      EdkLogger.verbose("\t" + str(LibraryClassName) + " : " + str(LibraryModule))
>              else:
>                  LibraryModule = LibraryInstance[LibraryClassName]
> 
>              if LibraryModule is None:
> @@ -232,11 +233,11 @@ def GetModuleLibInstances(Module, Platform, BuildDatabase, Arch, Target, Toolcha
>      #
>      # if any remaining node Item in the graph has a constructor and an incoming edge, then the graph has a cycle
>      #
>      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)
>              else:
>                  return []
> --
> 2.20.1.windows.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-08-23  6:20 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-08-22  4:00 [Patch V2][edk2-stable201908] BaseTools: Incorrect error message for library instance not found Bob Feng
2019-08-22 14:32 ` Liming Gao
2019-08-23  6:20   ` Bob Feng

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox