Fixed EDKT493. Added support to "SupModuleList" for checking if a library instance...
authorjwang36 <jwang36@de2fecce-e211-0410-80a6-f3fac2684e05>
Tue, 23 Jan 2007 08:51:06 +0000 (08:51 +0000)
committerjwang36 <jwang36@de2fecce-e211-0410-80a6-f3fac2684e05>
Tue, 23 Jan 2007 08:51:06 +0000 (08:51 +0000)
git-svn-id: https://edk2.tianocore.org/svn/edk2/trunk@2282 de2fecce-e211-0410-80a6-f3fac2684e05

edk2/Tools/Java/Source/GenBuild/org/tianocore/build/GenBuildTask.java
edk2/Tools/Java/Source/GenBuild/org/tianocore/build/autogen/AutoGen.java
edk2/Tools/Java/Source/GenBuild/org/tianocore/build/autogen/AutogenLibOrder.java
edk2/Tools/Java/Source/GenBuild/org/tianocore/build/global/SurfaceAreaQuery.java

index 9d7eb6d..8be1d62 100644 (file)
@@ -26,14 +26,11 @@ import java.util.Vector;
 \r
 import org.apache.tools.ant.BuildException;\r
 import org.apache.tools.ant.BuildListener;\r
+import org.apache.tools.ant.Location;\r
 import org.apache.tools.ant.Project;\r
 import org.apache.tools.ant.taskdefs.Ant;\r
 import org.apache.tools.ant.taskdefs.Property;\r
 import org.apache.xmlbeans.XmlObject;\r
-\r
-import org.tianocore.common.definitions.ToolDefinitions;\r
-import org.tianocore.common.exception.EdkException;\r
-import org.tianocore.common.logger.EdkLog;\r
 import org.tianocore.build.autogen.AutoGen;\r
 import org.tianocore.build.exception.AutoGenException;\r
 import org.tianocore.build.exception.GenBuildException;\r
@@ -48,6 +45,9 @@ import org.tianocore.build.id.ModuleIdentification;
 import org.tianocore.build.id.PackageIdentification;\r
 import org.tianocore.build.id.PlatformIdentification;\r
 import org.tianocore.build.tools.ModuleItem;\r
+import org.tianocore.common.definitions.ToolDefinitions;\r
+import org.tianocore.common.exception.EdkException;\r
+import org.tianocore.common.logger.EdkLog;\r
 \r
 /**\r
   <p>\r
@@ -151,6 +151,10 @@ public class GenBuildTask extends Ant {
             BuildException buildException = new BuildException(e.getMessage());\r
             buildException.setStackTrace(e.getStackTrace());\r
             throw buildException;\r
+        } catch (Exception e) {\r
+            BuildException buildException = new BuildException(e.getMessage());\r
+            buildException.setStackTrace(e.getStackTrace());\r
+            throw buildException;\r
         }\r
     }\r
 \r
@@ -197,7 +201,7 @@ public class GenBuildTask extends Ant {
             moduleId.setMsaFile(msaFile);\r
         }\r
         \r
-        String[] producedLibraryClasses = saq.getLibraryClasses("ALWAYS_PRODUCED",null);\r
+        String[] producedLibraryClasses = saq.getLibraryClasses("ALWAYS_PRODUCED", null, null);\r
         if (producedLibraryClasses.length == 0) {\r
             moduleId.setLibrary(false);\r
         } else {\r
index 5925e50..ce6ff61 100644 (file)
@@ -347,8 +347,8 @@ public class AutoGen {
         //\r
         // Write library class's related *.h file to autogen.h.\r
         //\r
-        String[] libClassList = saq.getLibraryClasses(CommonDefinition.ALWAYSCONSUMED,this.arch);\r
-        if (libClassList != null) {\r
+        String[] libClassList = saq.getLibraryClasses(CommonDefinition.ALWAYSCONSUMED, this.arch, null);\r
+        if (libClassList.length > 0) {\r
             libClassIncludeH = LibraryClassToAutogenH(libClassList);\r
             item = libClassIncludeH.iterator();\r
             while (item.hasNext()) {\r
@@ -356,8 +356,8 @@ public class AutoGen {
             }\r
         }\r
 \r
-        libClassList = saq.getLibraryClasses(CommonDefinition.ALWAYSPRODUCED, this.arch);\r
-        if (libClassList != null) {\r
+        libClassList = saq.getLibraryClasses(CommonDefinition.ALWAYSPRODUCED, this.arch, null);\r
+        if (libClassList.length > 0) {\r
             libClassIncludeH = LibraryClassToAutogenH(libClassList);\r
             item = libClassIncludeH.iterator();\r
             while (item.hasNext()) {\r
@@ -584,7 +584,7 @@ public class AutoGen {
         //\r
         // Write library class's related *.h file to autogen.h\r
         //\r
-        String[] libClassList = saq.getLibraryClasses(CommonDefinition.ALWAYSCONSUMED, this.arch);\r
+        String[] libClassList = saq.getLibraryClasses(CommonDefinition.ALWAYSCONSUMED, this.arch, null);\r
         if (libClassList != null) {\r
             libClassIncludeH = LibraryClassToAutogenH(libClassList);\r
             item = libClassIncludeH.iterator();\r
@@ -593,7 +593,7 @@ public class AutoGen {
             }\r
         }\r
 \r
-        libClassList = saq.getLibraryClasses(CommonDefinition.ALWAYSPRODUCED, this.arch);\r
+        libClassList = saq.getLibraryClasses(CommonDefinition.ALWAYSPRODUCED, this.arch, null);\r
         if (libClassList != null) {\r
             libClassIncludeH = LibraryClassToAutogenH(libClassList);\r
             item = libClassIncludeH.iterator();\r
@@ -1354,12 +1354,11 @@ public class AutoGen {
         //\r
         // Add library constructor to AutoGen.c\r
         //\r
-        LibConstructorToAutogenC(libConstructList, moduleType,\r
-                                 fileBuffer/* autogenC */);\r
+        LibConstructorToAutogenC(libConstructList, moduleType, fileBuffer);\r
         //\r
         // Add library destructor to AutoGen.c\r
         //\r
-        LibDestructorToAutogenC(libDestructList, moduleType, fileBuffer/* autogenC */);\r
+        LibDestructorToAutogenC(libDestructList, moduleType, fileBuffer);\r
     }\r
 \r
     /**\r
@@ -2106,6 +2105,7 @@ public class AutoGen {
     private void collectLibInstanceInfo() throws EdkException{\r
         int index;\r
 \r
+        String moduleType = moduleId.getModuleType();\r
         String libConstructName = null;\r
         String libDestructName = null;\r
         String libModuleType   = null;\r
@@ -2113,112 +2113,118 @@ public class AutoGen {
         String[] exitBoots = null;\r
 \r
         ModuleIdentification[] libraryIdList = saq.getLibraryInstance(this.arch);\r
+        if (libraryIdList.length <= 0) {\r
+            return;\r
+        }\r
+        //\r
+        // Reorder library instance sequence.\r
+        //\r
+        AutogenLibOrder libOrder = new AutogenLibOrder(libraryIdList, this.arch);\r
+        List<ModuleIdentification> orderList = libOrder.orderLibInstance();\r
+        //\r
+        // Process library instance one by one.\r
+        //\r
+        for (int i = 0; i < orderList.size(); i++) {\r
+            //\r
+            // Get library instance basename.\r
+            //\r
+            ModuleIdentification libInstanceId = orderList.get(i);\r
 \r
-        if (libraryIdList != null) {\r
             //\r
-            // Reorder library instance sequence.\r
+            // Get override map\r
             //\r
-            AutogenLibOrder libOrder = new AutogenLibOrder(libraryIdList,\r
-                                                           this.arch);\r
-            List<ModuleIdentification> orderList = libOrder\r
-                                                   .orderLibInstance();\r
 \r
-            if (orderList != null) {\r
-                //\r
-                // Process library instance one by one.\r
-                //\r
-                for (int i = 0; i < orderList.size(); i++) {\r
-                    //\r
-                    // Get library instance basename.\r
-                    //\r
-                    ModuleIdentification libInstanceId = orderList.get(i);\r
-\r
-                    //\r
-                    // Get override map\r
-                    //\r
-\r
-                    Map<String, XmlObject> libDoc = GlobalData.getDoc(libInstanceId, this.arch);\r
-                    saq.push(libDoc);\r
-                    //\r
-                    // Get <PPis>, <Protocols>, <Guids> list of this library\r
-                    // instance.\r
-                    //\r
-                    String[] ppiList = saq.getPpiArray(this.arch);\r
-                    String[] ppiNotifyList = saq.getPpiNotifyArray(this.arch);\r
-                    String[] protocolList = saq.getProtocolArray(this.arch);\r
-                    String[] protocolNotifyList = saq.getProtocolNotifyArray(this.arch);\r
-                    String[] guidList = saq.getGuidEntryArray(this.arch);\r
-                    PackageIdentification[] pkgList = saq.getDependencePkg(this.arch);\r
-\r
-                    //\r
-                    // Add those ppi, protocol, guid in global ppi,\r
-                    // protocol, guid\r
-                    // list.\r
-                    //\r
-                    for (index = 0; index < ppiList.length; index++) {\r
-                        this.mPpiList.add(ppiList[index]);\r
-                    }\r
+            Map<String, XmlObject> libDoc = GlobalData.getDoc(libInstanceId, this.arch);\r
+            saq.push(libDoc);\r
+            //\r
+            // check if the library instance support current module\r
+            // \r
+            String[] libraryClassList = saq.getLibraryClasses(CommonDefinition.ALWAYSPRODUCED,\r
+                                                              this.arch,\r
+                                                              moduleType\r
+                                                             );\r
+            if (libraryClassList.length <= 0) {\r
+                throw new EdkException("Library instance " + libInstanceId.getName() \r
+                                       + " doesn't support module type " + moduleType);\r
+            }\r
+            //\r
+            // Get <PPis>, <Protocols>, <Guids> list of this library\r
+            // instance.\r
+            //\r
+            String[] ppiList = saq.getPpiArray(this.arch);\r
+            String[] ppiNotifyList = saq.getPpiNotifyArray(this.arch);\r
+            String[] protocolList = saq.getProtocolArray(this.arch);\r
+            String[] protocolNotifyList = saq.getProtocolNotifyArray(this.arch);\r
+            String[] guidList = saq.getGuidEntryArray(this.arch);\r
+            PackageIdentification[] pkgList = saq.getDependencePkg(this.arch);\r
 \r
-                    for (index = 0; index < ppiNotifyList.length; index++) {\r
-                        this.mPpiList.add(ppiNotifyList[index]);\r
-                    }\r
+            //\r
+            // Add those ppi, protocol, guid in global ppi,\r
+            // protocol, guid\r
+            // list.\r
+            //\r
+            for (index = 0; index < ppiList.length; index++) {\r
+                this.mPpiList.add(ppiList[index]);\r
+            }\r
 \r
-                    for (index = 0; index < protocolList.length; index++) {\r
-                        this.mProtocolList.add(protocolList[index]);\r
-                    }\r
+            for (index = 0; index < ppiNotifyList.length; index++) {\r
+                this.mPpiList.add(ppiNotifyList[index]);\r
+            }\r
 \r
-                    for (index = 0; index < protocolNotifyList.length; index++) {\r
-                        this.mProtocolList.add(protocolNotifyList[index]);\r
-                    }\r
+            for (index = 0; index < protocolList.length; index++) {\r
+                this.mProtocolList.add(protocolList[index]);\r
+            }\r
 \r
-                    for (index = 0; index < guidList.length; index++) {\r
-                        this.mGuidList.add(guidList[index]);\r
-                    }\r
-                    for (index = 0; index < pkgList.length; index++) {\r
-                        if (!this.mDepPkgList.contains(pkgList[index])) {\r
-                            this.mDepPkgList.add(pkgList[index]);\r
-                        }\r
-                    }\r
+            for (index = 0; index < protocolNotifyList.length; index++) {\r
+                this.mProtocolList.add(protocolNotifyList[index]);\r
+            }\r
 \r
-                    //\r
-                    // If not yet parse this library instance's constructor\r
-                    // element,parse it.\r
-                    //\r
-                    libConstructName = saq.getLibConstructorName();\r
-                    libDestructName = saq.getLibDestructorName();\r
-                    libModuleType = saq.getModuleType();\r
-\r
-                    //\r
-                    // Collect SetVirtualAddressMapCallBack and\r
-                    // ExitBootServiceCallBack.\r
-                    //\r
-                    setVirtuals = saq.getSetVirtualAddressMapCallBackArray();\r
-                    exitBoots = saq.getExitBootServicesCallBackArray();\r
-                    if (setVirtuals != null) {\r
-                        for (int j = 0; j < setVirtuals.length; j++) {\r
-                            this.setVirtalAddList.add(setVirtuals[j]);\r
-                        }\r
-                    }\r
-                    if (exitBoots != null) {\r
-                        for (int k = 0; k < exitBoots.length; k++) {\r
-                            this.exitBootServiceList.add(exitBoots[k]);\r
-                        }\r
-                    }\r
-                    saq.pop();\r
-                    //\r
-                    // Add dependent library instance constructor function.\r
-                    //\r
-                    if (libConstructName != null) {\r
-                        this.libConstructList.add(new String[] {libConstructName, libModuleType});\r
-                    }\r
-                    //\r
-                    // Add dependent library instance destructor fuction.\r
-                    //\r
-                    if (libDestructName != null) {\r
-                        this.libDestructList.add(new String[] {libDestructName, libModuleType});\r
-                    }\r
+            for (index = 0; index < guidList.length; index++) {\r
+                this.mGuidList.add(guidList[index]);\r
+            }\r
+            for (index = 0; index < pkgList.length; index++) {\r
+                if (!this.mDepPkgList.contains(pkgList[index])) {\r
+                    this.mDepPkgList.add(pkgList[index]);\r
+                }\r
+            }\r
+\r
+            //\r
+            // If not yet parse this library instance's constructor\r
+            // element,parse it.\r
+            //\r
+            libConstructName = saq.getLibConstructorName();\r
+            libDestructName = saq.getLibDestructorName();\r
+            libModuleType = saq.getModuleType();\r
+\r
+            //\r
+            // Collect SetVirtualAddressMapCallBack and\r
+            // ExitBootServiceCallBack.\r
+            //\r
+            setVirtuals = saq.getSetVirtualAddressMapCallBackArray();\r
+            exitBoots = saq.getExitBootServicesCallBackArray();\r
+            if (setVirtuals != null) {\r
+                for (int j = 0; j < setVirtuals.length; j++) {\r
+                    this.setVirtalAddList.add(setVirtuals[j]);\r
+                }\r
+            }\r
+            if (exitBoots != null) {\r
+                for (int k = 0; k < exitBoots.length; k++) {\r
+                    this.exitBootServiceList.add(exitBoots[k]);\r
                 }\r
             }\r
+            saq.pop();\r
+            //\r
+            // Add dependent library instance constructor function.\r
+            //\r
+            if (libConstructName != null) {\r
+                this.libConstructList.add(new String[] {libConstructName, libModuleType});\r
+            }\r
+            //\r
+            // Add dependent library instance destructor fuction.\r
+            //\r
+            if (libDestructName != null) {\r
+                this.libDestructList.add(new String[] {libDestructName, libModuleType});\r
+            }\r
         }\r
     }\r
 \r
index 042f044..ca415da 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
index 17f7541..78bea2a 100644 (file)
@@ -38,6 +38,7 @@ import org.tianocore.build.id.PackageIdentification;
 import org.tianocore.build.id.PlatformIdentification;\r
 import org.tianocore.build.toolchain.ToolChainInfo;\r
 import org.tianocore.common.exception.EdkException;\r
+import org.tianocore.common.definitions.EdkDefinitions;\r
 import org.w3c.dom.Node;\r
 \r
 /**\r
@@ -593,7 +594,7 @@ public class SurfaceAreaQuery {
      *          xpath\r
      * @returns null if nothing is there\r
      */\r
-    public String[] getLibraryClasses(String usage, String arch) {\r
+    public String[] getLibraryClasses(String usage, String arch, String moduleType) {\r
         String[] xPath;\r
         if (usage == null || usage.equals("")) {\r
             xPath = new String[] { "/LibraryClass" };\r
@@ -610,8 +611,10 @@ public class SurfaceAreaQuery {
         List<String> libraryClassName = new ArrayList<String>();\r
         for (int i = 0; i < libraryClassList.length; i++) {\r
                        List archList = libraryClassList[i].getSupArchList();\r
-\r
-                       if (arch == null || contains(archList, arch)) {\r
+            List moduleTypeList = libraryClassList[i].getSupModuleList();\r
+                       if ((arch == null || contains(archList, arch))\r
+                && (moduleType == null || contains(moduleTypeList, moduleType)\r
+                    || contains(moduleTypeList, EdkDefinitions.MODULE_TYPE_BASE))) {\r
                 libraryClassName.add(libraryClassList[i].getKeyword());\r
                        }\r
         }\r
@@ -2008,15 +2011,8 @@ public class SurfaceAreaQuery {
                if (list == null || list.size()== 0) {\r
                        return true;\r
                }\r
-        Iterator it = list.iterator();\r
-        while (it.hasNext()) {\r
-            String s = (String)it.next();\r
-            if (s.equalsIgnoreCase(str)) {\r
-                return true;\r
-            }\r
-        }\r
 \r
-        return false;\r
+        return list.contains(str);\r
     }\r
 \r
        public boolean isHaveTianoR8FlashMap(){\r