- Remove the TOOL without NAME defined and its definition in ARCH_build.opt
[mirror_edk2.git] / Tools / Python / buildgen / SurfaceAreaElement.py
index 2f022c7..ae1938f 100644 (file)
@@ -284,9 +284,6 @@ class LibraryClass(FrameworkElement.LibraryClass, SurfaceAreaElement):
                 self.FavoriteIntance = FrameworkElement.Module()\r
             self.FavoriteIntance.Version = attribute\r
 \r
-    def Postprocess(self):\r
-        self.Interface = self._Workspace.GetLibraryInterface(self.Name)\r
-\r
 class SourceFile(FrameworkElement.SourceFile, SurfaceAreaElement):\r
     def __init__(self, workspace, module, dom):\r
         FrameworkElement.SourceFile.__init__(self)\r
@@ -758,7 +755,7 @@ class ModuleSurfaceArea(FrameworkElement.Module, SurfaceAreaElement):
         # resolve library class\r
         if self._Elements.has_key("LibraryClassDefinitions"):\r
             for lc in self._Elements["LibraryClassDefinitions"]:\r
-                lc.Interface = self._Workspace.GetLibraryInterface(lc.Name)\r
+                lc.Interface = self.GetLibraryInterface(lc.Name)\r
                 if "ALWAYS_PRODUCED" in lc.Usage:\r
                     self.IsLibrary = True\r
                     lc.Interface.Instances.append(self)\r
@@ -811,6 +808,14 @@ class ModuleSurfaceArea(FrameworkElement.Module, SurfaceAreaElement):
                     if arch not in self.Externs:\r
                         self.Externs[arch] = []\r
                     self.Externs[arch].append(extern)\r
+                    \r
+    def GetLibraryInterface(self, name):\r
+        if name in self.Package.LibraryInterfaces:\r
+            return self.Package.LibraryInterfaces[name]\r
+        for pd in self._Elements["PackageDependencies"]:\r
+            if name in pd.Package.LibraryInterfaces:\r
+                return pd.Package.LibraryInterfaces[name]\r
+        return ""\r
 ##    def SetupEnvironment(self):\r
 ##        self.Environment["MODULE"] = self.Name\r
 ##        self.Environment["MODULE_GUID"] = self.GuidValue\r
@@ -1027,10 +1032,14 @@ class Workspace(FrameworkElement.Workspace, SurfaceAreaElement):
                 return platform\r
         return ""\r
 \r
-    def GetLibraryInterface(self, name):\r
+    def GetLibraryInterface(self, name, package):\r
         if name not in self.LibraryInterfaceXref["NAME"]:\r
             return ""\r
-        return self.LibraryInterfaceXref["NAME"][name]\r
+        liList = self.LibraryInterfaceXref["NAME"][name]\r
+        for li in liList:\r
+            if li.Package == package:\r
+                return li\r
+        return ""\r
     \r
     def SubPath(self, *relativePathList):\r
         return os.path.normpath(os.path.join(self.Path, *relativePathList))\r
@@ -1084,14 +1093,17 @@ class Workspace(FrameworkElement.Workspace, SurfaceAreaElement):
             ##      library class name -> library class object\r
             ##\r
             for lcname in p.LibraryInterfaces:\r
-                if lcname in self.LibraryInterfaceXref["NAME"]:\r
-                    raise Exception("Duplicate library class: %s in package %s" % (lcname, name))\r
+                if lcname not in self.LibraryInterfaceXref["NAME"]:\r
+                    # raise Exception("Duplicate library class: %s in package %s" % (lcname, name))\r
+                    self.LibraryInterfaceXref["NAME"][lcname] = []\r
                 lcInterface = p.LibraryInterfaces[lcname]\r
-                self.LibraryInterfaceXref["NAME"][lcname] = lcInterface\r
+                self.LibraryInterfaceXref["NAME"][lcname].append(lcInterface)\r
                 \r
-                if lcInterface not in self.LibraryInterfaceXref["PATH"]:\r
-                    self.LibraryInterfaceXref["PATH"][lcInterface] = []\r
-                self.LibraryInterfaceXref["PATH"][lcInterface].append(lcname)\r
+                lcHeader = p.SubPath(lcInterface.Path)\r
+                if lcHeader not in self.LibraryInterfaceXref["PATH"]:\r
+                    # raise Exception("Duplicate library class interface: %s in package %s" % (lcInterface, name))\r
+                    self.LibraryInterfaceXref["PATH"][lcHeader] = []\r
+                self.LibraryInterfaceXref["PATH"][lcHeader].append(lcInterface)\r
 \r
         ##\r
         ## setup package cross reference as nest-dict\r
@@ -1111,7 +1123,10 @@ class Workspace(FrameworkElement.Workspace, SurfaceAreaElement):
                 if guid not in moduleGuidIndex:\r
                     moduleGuidIndex[guid] = {}\r
                 else:\r
-                    print "! Duplicate module GUID found:", guid, path\r
+                    print "! Duplicate module GUID found:", guid, p.SubPath(path)\r
+                    dm = moduleGuidIndex[guid].values()[0][0]\r
+                    print "                              ", dm.GuidValue,\\r
+                                                    dm.Package.SubPath(dm.Path)\r
 \r
                 if version not in moduleGuidIndex[guid]:\r
                     moduleGuidIndex[guid][version] = []\r
@@ -1483,17 +1498,18 @@ def PrintWorkspace(ws):
                 print "\n"\r
     print "\nLibrary Classes:"\r
     for name in ws.LibraryInterfaceXref["NAME"]:\r
-        lc = ws.LibraryInterfaceXref["NAME"][name]\r
-        pkgPath = os.path.dirname(lc.Package.Path)\r
-        print "\n  [%s] <%s>" % (lc.Name, pkgPath + os.path.sep + lc.Path)\r
-\r
-        print "    Produced By:"\r
-        for li in lc.Instances:\r
-            print "      %-40s <%s>" % (li.Name+"-"+li.Version, li.Package.SubPath(li.Path))\r
-\r
-        print "    Consumed By:"\r
-        for li in lc.Consumers:\r
-            print "      %-40s <%s>" % (li.Name+"-"+li.Version, li.Package.SubPath(li.Path))\r
+        lcList = ws.LibraryInterfaceXref["NAME"][name]\r
+        for lc in lcList:\r
+            pkgPath = os.path.dirname(lc.Package.Path)\r
+            print "\n  [%s] <%s>" % (lc.Name, pkgPath + os.path.sep + lc.Path)\r
+\r
+            print "    Produced By:"\r
+            for li in lc.Instances:\r
+                print "      %-40s <%s>" % (li.Name+"-"+li.Version, li.Package.SubPath(li.Path))\r
+\r
+            print "    Consumed By:"\r
+            for li in lc.Consumers:\r
+                print "      %-40s <%s>" % (li.Name+"-"+li.Version, li.Package.SubPath(li.Path))\r
 \r
     print "\nActive Platform:"\r
     for arch in ws.ActivePlatform.Libraries:\r