]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Support "Defining Module Sequence in FV.inf". Since modules sequences in Fv.inf can...
authorwuyizhong <wuyizhong@6f19259b-4bc3-4df7-8a09-765794883524>
Mon, 25 Sep 2006 08:17:50 +0000 (08:17 +0000)
committerwuyizhong <wuyizhong@6f19259b-4bc3-4df7-8a09-765794883524>
Mon, 25 Sep 2006 08:17:50 +0000 (08:17 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@1605 6f19259b-4bc3-4df7-8a09-765794883524

Tools/Source/GenBuild/org/tianocore/build/fpd/FpdParserForThread.java
Tools/Source/GenBuild/org/tianocore/build/fpd/FpdParserTask.java
Tools/Source/GenBuild/org/tianocore/build/global/OnDependency.java
Tools/Source/GenBuild/org/tianocore/build/global/SurfaceAreaQuery.java

index de9a28c7d5abf5f84a1e75c2269c8ed26d059553..aa0ebe51b64f5553a8240d8505b3e62c87348f7b 100644 (file)
@@ -205,7 +205,7 @@ public class FpdParserForThread extends FpdParserTask {
                     //\r
                     // Exist ready thread\r
                     //\r
                     //\r
                     // Exist ready thread\r
                     //\r
-//                    EdkLog.log(this, EdkLog.EDK_ALWAYS, "Exist ready thread");\r
+                    EdkLog.log(this, EdkLog.EDK_DEBUG, "Exist ready thread");\r
 \r
                 } else if (existNoneReady && currentRunNumber == 0) {\r
                     //\r
 \r
                 } else if (existNoneReady && currentRunNumber == 0) {\r
                     //\r
@@ -216,21 +216,21 @@ public class FpdParserForThread extends FpdParserTask {
                     //\r
                     // Current queue build finish, move to next\r
                     //\r
                     //\r
                     // Current queue build finish, move to next\r
                     //\r
-                    EdkLog.log(this, EdkLog.EDK_ALWAYS, "Current queue build finish, move to next");\r
+                    EdkLog.log(this, EdkLog.EDK_DEBUG, "Current queue build finish, move to next");\r
                     ++currentQueueCode;\r
                     continue ;\r
                 } else {\r
                     //\r
                     // active thread exist, but no ready thread\r
                     //\r
                     ++currentQueueCode;\r
                     continue ;\r
                 } else {\r
                     //\r
                     // active thread exist, but no ready thread\r
                     //\r
-                    EdkLog.log(this, EdkLog.EDK_ALWAYS, "Active thread exist, but no ready thread. Current running number is " + currentRunNumber);\r
+                    EdkLog.log(this, EdkLog.EDK_DEBUG, "Active thread exist, but no ready thread. Current running number is " + currentRunNumber);\r
                 }\r
 \r
                 try {\r
                     deamonSemaphore.wait();\r
                     \r
                     //\r
                 }\r
 \r
                 try {\r
                     deamonSemaphore.wait();\r
                     \r
                     //\r
-                    // if find error. Let other threads to finish\r
+                    // if find error. Waiting running threads to finish\r
                     //\r
                     if (errorModule != null) {\r
                         while (currentRunNumber > 0) {\r
                     //\r
                     if (errorModule != null) {\r
                         while (currentRunNumber > 0) {\r
index addb43a6cf637dd917c56e74126370179c3a0123..106e6d6a072eec091ac5c0f94d7fb7869d773994 100644 (file)
@@ -36,6 +36,7 @@ import org.apache.xmlbeans.XmlObject;
 \r
 import org.tianocore.common.definitions.EdkDefinitions;\r
 import org.tianocore.common.exception.EdkException;\r
 \r
 import org.tianocore.common.definitions.EdkDefinitions;\r
 import org.tianocore.common.exception.EdkException;\r
+import org.tianocore.common.logger.EdkLog;\r
 import org.tianocore.pcd.action.ActionMessage;\r
 import org.tianocore.build.FrameworkBuildTask;\r
 import org.tianocore.build.global.GlobalData;\r
 import org.tianocore.pcd.action.ActionMessage;\r
 import org.tianocore.build.FrameworkBuildTask;\r
 import org.tianocore.build.global.GlobalData;\r
@@ -43,11 +44,15 @@ import org.tianocore.build.global.OutputManager;
 import org.tianocore.build.global.SurfaceAreaQuery;\r
 import org.tianocore.build.id.FpdModuleIdentification;\r
 import org.tianocore.build.id.ModuleIdentification;\r
 import org.tianocore.build.global.SurfaceAreaQuery;\r
 import org.tianocore.build.id.FpdModuleIdentification;\r
 import org.tianocore.build.id.ModuleIdentification;\r
+import org.tianocore.build.id.PackageIdentification;\r
 import org.tianocore.build.id.PlatformIdentification;\r
 import org.tianocore.build.pcd.action.PlatformPcdPreprocessActionForBuilding;\r
 import org.tianocore.build.toolchain.ToolChainAttribute;\r
 import org.tianocore.build.toolchain.ToolChainElement;\r
 import org.tianocore.build.toolchain.ToolChainMap;\r
 import org.tianocore.build.id.PlatformIdentification;\r
 import org.tianocore.build.pcd.action.PlatformPcdPreprocessActionForBuilding;\r
 import org.tianocore.build.toolchain.ToolChainAttribute;\r
 import org.tianocore.build.toolchain.ToolChainElement;\r
 import org.tianocore.build.toolchain.ToolChainMap;\r
+import org.w3c.dom.NamedNodeMap;\r
+import org.w3c.dom.Node;\r
+import org.w3c.dom.NodeList;\r
 \r
 /**\r
   <code>FpdParserTask</code> is an ANT task. The main function is parsing Framework\r
 \r
 /**\r
   <code>FpdParserTask</code> is an ANT task. The main function is parsing Framework\r
@@ -117,6 +122,8 @@ public class FpdParserTask extends Task {
      Surface area is not valid.\r
     **/\r
     public void execute() throws BuildException {\r
      Surface area is not valid.\r
     **/\r
     public void execute() throws BuildException {\r
+        this.setTaskName("FpdParser");\r
+        \r
         //\r
         // Parse FPD file\r
         //\r
         //\r
         // Parse FPD file\r
         //\r
@@ -267,13 +274,45 @@ public class FpdParserTask extends Task {
                     }\r
                     bw.newLine();\r
                 }\r
                     }\r
                     bw.newLine();\r
                 }\r
-\r
+                \r
                 //\r
                 // Files\r
                 //\r
                 //\r
                 // Files\r
                 //\r
+                Set<FpdModuleIdentification> moduleSeqSet = getModuleSequenceForFv(validFv[i]);\r
+                \r
                 Set<FpdModuleIdentification> filesSet = fvs.get(validFv[i]);\r
                 Set<FpdModuleIdentification> filesSet = fvs.get(validFv[i]);\r
-                if (filesSet != null) {\r
-                    FpdModuleIdentification[] files = filesSet.toArray(new FpdModuleIdentification[filesSet.size()]);\r
+                \r
+                FpdModuleIdentification[] files = null;\r
+                if (moduleSeqSet == null) {\r
+                    if (filesSet != null) {\r
+                        files = filesSet.toArray(new FpdModuleIdentification[filesSet.size()]);\r
+                    }\r
+                } else {\r
+                    //\r
+                    // if moduleSeqSet and filesSet is inconsistent, report error\r
+                    //\r
+                    if (filesSet == null && moduleSeqSet.size() != 0) {\r
+                        throw new BuildException("Can not find any modules belongs to FV[" + validFv[i] + "], but listed some in BuildOptions.UserExtensions[@UserID='IMAGES' @Identifier='1']");\r
+                    } else if(moduleSeqSet.size() != filesSet.size()){\r
+                        throw new BuildException("Modules for FV[" + validFv[i] + "] defined in FrameworkModules and in BuildOptions.UserExtensions[@UserID='IMAGES' @Identifier='1'] are inconsistent. ");\r
+                    } else {\r
+                        //\r
+                        // whether all modules in moduleSeqSet listed in filesSet\r
+                        //\r
+                        Iterator<FpdModuleIdentification> iter = moduleSeqSet.iterator();\r
+                        while (iter.hasNext()) {\r
+                            FpdModuleIdentification item = iter.next();\r
+                            if (!filesSet.contains(item)) {\r
+                                throw new BuildException("Can not find " + item + " belongs to FV[" + validFv[i] + "]");\r
+                            }\r
+                        }\r
+                    }\r
+                    \r
+                    files = moduleSeqSet.toArray(new FpdModuleIdentification[moduleSeqSet.size()]);\r
+                }\r
+                \r
+                \r
+                if (files != null) {\r
                     bw.write("[files]");\r
                     bw.newLine();\r
                     for (int j = 0; j < files.length; j++) {\r
                     bw.write("[files]");\r
                     bw.newLine();\r
                     for (int j = 0; j < files.length; j++) {\r
@@ -289,6 +328,10 @@ public class FpdParserTask extends Task {
                 BuildException buildException = new BuildException("Generation of the FV file [" + fvFile.getPath() + "] failed!\n" + ex.getMessage());\r
                 buildException.setStackTrace(ex.getStackTrace());\r
                 throw buildException;\r
                 BuildException buildException = new BuildException("Generation of the FV file [" + fvFile.getPath() + "] failed!\n" + ex.getMessage());\r
                 buildException.setStackTrace(ex.getStackTrace());\r
                 throw buildException;\r
+            } catch (EdkException ex) {\r
+                BuildException buildException = new BuildException("Generation of the FV file [" + fvFile.getPath() + "] failed!\n" + ex.getMessage());\r
+                buildException.setStackTrace(ex.getStackTrace());\r
+                throw buildException;\r
             }\r
         }\r
     }\r
             }\r
         }\r
     }\r
@@ -613,4 +656,99 @@ public class FpdParserTask extends Task {
         \r
         return archs;\r
     }\r
         \r
         return archs;\r
     }\r
+    \r
+    private Set<FpdModuleIdentification> getModuleSequenceForFv(String fvName) throws EdkException {\r
+        Node node = saq.getFpdModuleSequence(fvName);\r
+        Set<FpdModuleIdentification> result = new LinkedHashSet<FpdModuleIdentification>();\r
+        \r
+        if ( node == null) {\r
+            EdkLog.log(this, EdkLog.EDK_WARNING, "FV[" + fvName + "] does not specify module sequence in FPD. Assuming present sequence as default sequence in FV. ");\r
+            return null;\r
+        } else {\r
+            NodeList childNodes = node.getChildNodes();\r
+            for (int i = 0; i < childNodes.getLength(); i++) {\r
+                Node childItem = childNodes.item(i);\r
+                if (childItem.getNodeType() == Node.ELEMENT_NODE) {\r
+                    //\r
+                    // Find child elements "IncludeModules"\r
+                    //\r
+                    if (childItem.getNodeName().compareTo("IncludeModules") == 0) {\r
+                        //\r
+                        // result will be updated\r
+                        //\r
+                        processNodes(childItem, result);\r
+                    } else if (childItem.getNodeName().compareTo("FvName") == 0) {\r
+                        \r
+                    } else if (childItem.getNodeName().compareTo("InfFileName") == 0) {\r
+                        \r
+                    } else {\r
+                        //\r
+                        // Report Warning\r
+                        //\r
+                        EdkLog.log(this, EdkLog.EDK_WARNING, "Unrecognised element " + childItem.getNodeName() + " under FPD.BuildOptions.UserExtensions[UserID='IMAGES' Identifier='1']");\r
+                    }\r
+                }\r
+            }\r
+        }\r
+        \r
+        return result;\r
+    }\r
+    \r
+    private void processNodes(Node node, Set<FpdModuleIdentification> result) throws EdkException {\r
+        //\r
+        // Found out all elements "Module"\r
+        //\r
+        NodeList childNodes = node.getChildNodes();\r
+        for (int j = 0; j < childNodes.getLength(); j++) {\r
+            Node childItem = childNodes.item(j);\r
+            if (childItem.getNodeType() == Node.ELEMENT_NODE) {\r
+                if (childItem.getNodeName().compareTo("Module") == 0) {\r
+                    String moduleGuid = null;\r
+                    String moduleVersion = null;\r
+                    String packageGuid = null;\r
+                    String packageVersion = null;\r
+                    String arch = null;\r
+                    \r
+                    NamedNodeMap attr = childItem.getAttributes();\r
+                    for (int i = 0; i < attr.getLength(); i++) {\r
+                        Node attrItem = attr.item(i);\r
+                        if (attrItem.getNodeName().compareTo("ModuleGuid") == 0) {\r
+                            moduleGuid = attrItem.getNodeValue();\r
+                        } else if (attrItem.getNodeName().compareTo("ModuleVersion") == 0) {\r
+                            moduleVersion = attrItem.getNodeValue();\r
+                        } else if (attrItem.getNodeName().compareTo("PackageGuid") == 0) {\r
+                            packageGuid = attrItem.getNodeValue();\r
+                        } else if (attrItem.getNodeName().compareTo("PackageVersion") == 0) {\r
+                            packageVersion = attrItem.getNodeValue();\r
+                        } else if (attrItem.getNodeName().compareTo("Arch") == 0) {\r
+                            arch = attrItem.getNodeValue();\r
+                        } else {\r
+                            //\r
+                            // Report warning\r
+                            //\r
+                            EdkLog.log(this, EdkLog.EDK_WARNING, "Unrecognised attribute " + attrItem.getNodeName() + " under FPD.BuildOptions.UserExtensions[UserID='IMAGES' Identifier='1'].IncludeModules.Module");\r
+                        }\r
+                    }\r
+                    \r
+                    PackageIdentification packageId = new PackageIdentification(packageGuid, packageVersion);\r
+                    GlobalData.refreshPackageIdentification(packageId);\r
+                    \r
+                    ModuleIdentification moduleId = new ModuleIdentification(moduleGuid, moduleVersion);\r
+                    moduleId.setPackage(packageId);\r
+                    GlobalData.refreshModuleIdentification(moduleId);\r
+                    \r
+                    if (arch == null) {\r
+                        throw new EdkException("Attribute [Arch] is required for element FPD.BuildOptions.UserExtensions[UserID='IMAGES' Identifier='1'].IncludeModules.Module. ");\r
+                    }\r
+                    \r
+                    result.add(new FpdModuleIdentification(moduleId, arch));\r
+                } else {\r
+                    //\r
+                    // Report Warning\r
+                    //\r
+                    EdkLog.log(this, EdkLog.EDK_WARNING, "Unrecognised element " + childItem.getNodeName() + " under FPD.BuildOptions.UserExtensions[UserID='IMAGES' Identifier='1'].IncludeModules");\r
+                }\r
+            }\r
+        }\r
+    }\r
 }\r
 }\r
index fbffb3bcb77490e55b1fe4c029339029c42e46aa..678bfb869bf63cb111f1d46482a89c30f2cc6272 100644 (file)
@@ -14,9 +14,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 package org.tianocore.build.global;\r
 \r
 import java.io.File;\r
 package org.tianocore.build.global;\r
 \r
 import java.io.File;\r
-import java.util.HashMap;\r
 import java.util.Iterator;\r
 import java.util.Iterator;\r
-import java.util.Map;\r
 \r
 import org.apache.tools.ant.BuildException;\r
 import org.apache.tools.ant.Task;\r
 \r
 import org.apache.tools.ant.BuildException;\r
 import org.apache.tools.ant.Task;\r
index 9a1ca98d189bc175e9d6d5e3f011f6e56aa71781..0140e8b704614bee058546f39c659935760ae256 100644 (file)
@@ -27,9 +27,7 @@ import org.tianocore.ExternsDocument.Externs.Extern;
 import org.apache.xmlbeans.XmlObject;\r
 import org.apache.xmlbeans.XmlString;\r
 import org.tianocore.*;\r
 import org.apache.xmlbeans.XmlObject;\r
 import org.apache.xmlbeans.XmlString;\r
 import org.tianocore.*;\r
-import org.tianocore.ExternsDocument.Externs;\r
 import org.tianocore.FilenameDocument.Filename;\r
 import org.tianocore.FilenameDocument.Filename;\r
-import org.tianocore.ModuleSurfaceAreaDocument.ModuleSurfaceArea;\r
 import org.tianocore.MsaHeaderDocument.MsaHeader;\r
 import org.tianocore.ProtocolsDocument.Protocols.Protocol;\r
 import org.tianocore.ProtocolsDocument.Protocols.ProtocolNotify;\r
 import org.tianocore.MsaHeaderDocument.MsaHeader;\r
 import org.tianocore.ProtocolsDocument.Protocols.Protocol;\r
 import org.tianocore.ProtocolsDocument.Protocols.ProtocolNotify;\r
@@ -1993,4 +1991,17 @@ public class SurfaceAreaQuery {
                        return false;\r
                }\r
        }\r
                        return false;\r
                }\r
        }\r
+    \r
+    public Node getFpdModuleSequence(String fvName) {\r
+        String[] xPath = new String[] { "/BuildOptions/UserExtensions[@UserID='IMAGES' and @Identifier='1' and ./FvName='" + fvName + "']" };\r
+        Object[] result = get("PlatformSurfaceArea", xPath);\r
+        \r
+        if (result == null || result.length == 0) {\r
+            return null;\r
+        }\r
+        \r
+        UserExtensionsDocument.UserExtensions a =  (UserExtensionsDocument.UserExtensions)result[0];\r
+        \r
+        return a.getDomNode();\r
+    }\r
 }\r
 }\r