]> git.proxmox.com Git - mirror_edk2.git/blobdiff - Tools/Source/GenBuild/org/tianocore/build/FfsProcess.java
Change to new XML Schema.
[mirror_edk2.git] / Tools / Source / GenBuild / org / tianocore / build / FfsProcess.java
index 267a50e4e36bd9c1c2490ecafe8d115790f0d116..02eca2abef22f0b333ac1ca6e8c21cce88334d5a 100644 (file)
@@ -26,6 +26,10 @@ import org.apache.tools.ant.BuildException;
 import org.apache.tools.ant.Project;\r
 import org.apache.xmlbeans.XmlCursor;\r
 import org.apache.xmlbeans.XmlObject;\r
+import org.tianocore.BuildOptionsDocument;\r
+import org.tianocore.build.global.GlobalData;\r
+import org.tianocore.build.global.SurfaceAreaQuery;\r
+import org.tianocore.build.id.FpdModuleIdentification;\r
 import org.w3c.dom.Document;\r
 import org.w3c.dom.Element;\r
 import org.w3c.dom.NamedNodeMap;\r
@@ -60,6 +64,8 @@ public class FfsProcess {
     /// Xml Document Node for corresponding FFS layout\r
     ///\r
     private Node ffs;\r
+    \r
+    private BuildOptionsDocument.BuildOptions.Ffs ffsXmlObject;\r
 \r
     ///\r
     /// ANT script to call GenFfs\r
@@ -131,11 +137,31 @@ public class FfsProcess {
       @throws BuildException\r
               If specified COMMON_FILE XML file is not valide.\r
     **/\r
-    public boolean initSections(String buildType, Project project) throws BuildException {\r
+    public boolean initSections(String buildType, Project project, FpdModuleIdentification fpdModuleId) throws BuildException {\r
         //\r
-        // first try to sections defined in PLATFORM level\r
+        // Firstly, try to find in ModuleSA\r
         //\r
-\r
+//        BuildOptionsDocument.BuildOptions.Ffs[] ffsArray = SurfaceAreaQuery.getModuleFfs();\r
+//        for (int i = 0; i < ffsArray.length; i++) {\r
+//            if (isMatch(ffsArray[i].getFfsKey(), buildType)) {\r
+//                ffsXmlObject = ffsArray[i];\r
+//                return true;\r
+//            }\r
+//        }\r
+        \r
+        //\r
+        // secondly, try to sections defined in PLATFORM level\r
+        //\r
+        SurfaceAreaQuery.push(GlobalData.getFpdBuildOptions());\r
+        BuildOptionsDocument.BuildOptions.Ffs[] ffsArray = SurfaceAreaQuery.getFpdFfs();\r
+        SurfaceAreaQuery.pop();\r
+        for (int i = 0; i < ffsArray.length; i++) {\r
+            if (isMatch(ffsArray[i].getFfsKey(), buildType)) {\r
+                ffsXmlObject = ffsArray[i];\r
+                return true;\r
+            }\r
+        }\r
+        \r
         //\r
         // if module specify sections itself, it's okay\r
         // otherwise find sections from WORKSPACE default setting with\r
@@ -194,22 +220,30 @@ public class FfsProcess {
     **/\r
     public String[] getGenSectionElements(Document document, String basename, String guid, String targetFilename) {\r
         this.basename = basename;\r
-        if (ffs == null) {\r
+        if (ffs == null && ffsXmlObject == null) {\r
             return new String[0];\r
         }\r
         Vector<String> sectionList = new Vector<String>();\r
         XmlCursor cursor = null;\r
         try {\r
-            cursor = XmlObject.Factory.parse(ffs).newCursor();\r
+            if (ffsXmlObject == null) {\r
+                cursor = XmlObject.Factory.parse(ffs).newCursor();\r
+            }\r
+            else {\r
+                cursor = ffsXmlObject.newCursor();\r
+            }\r
         } catch (Exception e) {\r
             return null;\r
         }\r
         int mode = MODE_NONE;\r
         Element root = document.createElement("genffsfile");\r
         root.setAttribute("outputDir", "${BIN_DIR}");\r
+        root.setAttribute("moduleType", "${MODULE_TYPE}");\r
         root.setAttribute("BaseName", basename);\r
         root.setAttribute("fileGuid", guid);\r
-        cursor.toFirstChild();\r
+        if (ffsXmlObject == null) {\r
+            cursor.toFirstChild();\r
+        }\r
         if (cursor.toFirstChild()) {\r
             do {\r
                 if (cursor.getName().getLocalPart().equalsIgnoreCase("Attribute")) {\r
@@ -315,7 +349,7 @@ public class FfsProcess {
             // outputPath = "${DEST_DIR_OUTPUT}">\r
             //\r
             ele = doc.createElement("tool");\r
-            ele.setAttribute("toolName", "${WORKSPACE_DIR}" + File.separatorChar + "Tools" + File.separatorChar + "bin"\r
+            ele.setAttribute("toolName", "${WORKSPACE_DIR}" + File.separatorChar + "Tools" + File.separatorChar + "Bin"\r
                                          + File.separatorChar + "GenCRC32Section");\r
             ele.setAttribute("outputPath", "${DEST_DIR_OUTPUT}");\r
         }\r
@@ -365,7 +399,7 @@ public class FfsProcess {
     }\r
 \r
     /**\r
-       Get the corresponding section file suffix.\r
+      Get the corresponding section file suffix.\r
        \r
       @param type Section type\r
       @return Corresponding section file extension\r