Fixed EDKT493. Added support to "SupModuleList" for checking if a library instance...
[mirror_edk2.git] / Tools / Java / Source / GenBuild / org / tianocore / build / autogen / AutogenLibOrder.java
index 042f0447ef9552ec55c77e45c0330925fe4e470f..ca415daf9094fb2a48222cd5a4101942a35c070e 100644 (file)
@@ -90,8 +90,8 @@ public class AutogenLibOrder {
             //\r
             // Create library class consume database.\r
             //\r
-            libClassConsmList = saq.getLibraryClasses(CommonDefinition.ALWAYSCONSUMED, arch);\r
-            if (libClassConsmList != null) {\r
+            libClassConsmList = saq.getLibraryClasses(CommonDefinition.ALWAYSCONSUMED, arch, null);\r
+            if (libClassConsmList.length > 0) {\r
                 if (this.libInstanceConsumes.containsKey(libInstance)) {\r
                     throw new AutoGenException(\r
                             libraryList[i].getName()\r
@@ -104,8 +104,8 @@ public class AutogenLibOrder {
             //\r
             // Create library class implementer database\r
             //\r
-            libClassDeclList = saq.getLibraryClasses(CommonDefinition.ALWAYSPRODUCED, arch);\r
-            if (libClassDeclList != null) {\r
+            libClassDeclList = saq.getLibraryClasses(CommonDefinition.ALWAYSPRODUCED, arch, null);\r
+            if (libClassDeclList.length > 0) {\r
                 this.libInstanceProduces.put(libInstance, libClassDeclList);\r
                 for (int j = 0; j < libClassDeclList.length; j++) {\r
                     if (this.libClassProducer.containsKey(libClassDeclList[j])) {\r
@@ -132,6 +132,9 @@ public class AutogenLibOrder {
             for (int k = 0; k < libraryList.length; ++k) {\r
                 ModuleIdentification consumer = libraryList[k];\r
                 String[] consumedClassList = libInstanceConsumes.get(consumer);\r
+                if (consumedClassList == null) {\r
+                    continue;\r
+                }\r
 \r
                 for (int l = 0; l < consumedClassList.length; ++l) {\r
                     if (consumedClassList[l].equals(className)) {\r
@@ -168,6 +171,9 @@ public class AutogenLibOrder {
             orderList.addFirst(n);\r
 \r
             String[] consumedClassList = libInstanceConsumes.get(n);\r
+            if (consumedClassList == null) {\r
+                continue;\r
+            }\r
             for (int i = 0; i < consumedClassList.length; ++i) {\r
                 ModuleIdentification m = libClassProducer.get(consumedClassList[i]);\r
                 if (m == null) {\r
@@ -231,27 +237,26 @@ public class AutogenLibOrder {
         //\r
         // Append the remaining library instance to the end of sorted list\r
         //\r
-       boolean HasError = false;\r
+        boolean HasError = false;\r
         for (int i = 0; i < libInstanceList.length; ++i) {\r
-           HashSet<ModuleIdentification> consumedBy = libInstanceConsumedBy.get(libInstanceList[i]);\r
+            HashSet<ModuleIdentification> consumedBy = libInstanceConsumedBy.get(libInstanceList[i]);\r
             if (consumedBy.size() > 0 && libInstanceList[i].hasConstructor()) {\r
                 EdkLog.log(EdkLog.EDK_ERROR, libInstanceList[i].getName()\r
                            + " with constructor has a circular dependency!");\r
-               ModuleIdentification[] consumedByList = consumedBy.toArray(new ModuleIdentification[consumedBy.size()]);\r
-               for (int j = 0; j < consumedByList.length; ++j) {\r
-                   EdkLog.log(EdkLog.EDK_ERROR,\r
-                              " consumed by " + consumedByList[j].getName());\r
-               }\r
-               HasError = true;\r
+                ModuleIdentification[] consumedByList = consumedBy.toArray(new ModuleIdentification[consumedBy.size()]);\r
+                for (int j = 0; j < consumedByList.length; ++j) {\r
+                    EdkLog.log(EdkLog.EDK_ERROR, " consumed by " + consumedByList[j].getName());\r
+                }\r
+                HasError = true;\r
             }\r
 \r
             if (!orderList.contains(libInstanceList[i])) {\r
                 orderList.add(libInstanceList[i]);\r
             }\r
         }\r
-       if (HasError) {\r
-           throw new AutoGenException("Circular dependency in library instances is found!");\r
-       }\r
+        if (HasError) {\r
+            throw new AutoGenException("Circular dependency in library instances is found!");\r
+        }\r
 \r
         return orderList;\r
     }\r