]> git.proxmox.com Git - mirror_edk2.git/blobdiff - Tools/Source/GenBuild/org/tianocore/build/FfsProcess.java
Support calling customized compression tool in FrameworkTask.
[mirror_edk2.git] / Tools / Source / GenBuild / org / tianocore / build / FfsProcess.java
index a09871907356a3099e178eb8927eee7c8cc7e42f..3a67e6eb3467ae1ae13b6f017d0ffb212c4db27b 100644 (file)
@@ -238,7 +238,9 @@ public class FfsProcess {
     **/\r
     private void dealSections(int mode, Document doc, Element root, XmlCursor cursor, Vector<String> list) {\r
         String type = cursor.getAttributeText(new QName("EncapsulationType"));\r
-        if (type == null) {\r
+        String toolName = cursor.getAttributeText(new QName("ToolName"));\r
+        String sectType = cursor.getAttributeText(new QName("SectionType"));\r
+        if (type == null && sectType == null) {\r
             if (cursor.toFirstChild()) {\r
                 do {\r
                     if (cursor.getName().getLocalPart().equalsIgnoreCase("Section")) {\r
@@ -255,33 +257,69 @@ public class FfsProcess {
             return;\r
         }\r
         Element ele;\r
-        if (type.equalsIgnoreCase("COMPRESS")) {\r
+        Element toolEle = null;\r
+        if (type.equalsIgnoreCase("COMPRESS") && (toolName == null || toolName.equalsIgnoreCase(""))) {\r
             mode = MODE_COMPRESS;\r
             //\r
-            // <compress compressName = "dummy">\r
-            //\r
-            ele = doc.createElement("compress");\r
-            ele.setAttribute("compressName", "dummy");\r
+            // <gensection sectiontype="EFI_SECTION_COMPRESSION">   \r
+            // \r
+            ele = doc.createElement("gensection");\r
+            ele.setAttribute("sectionType", "EFI_SECTION_COMPRESSION");\r
+            \r
         } else {\r
             mode = MODE_GUID_DEFINED;\r
             //\r
+            // <gensection sectiontype="EFI_SECTION_GUID_DEFINED">\r
+            // \r
+            ele = doc.createElement("gensection");\r
+            if (type != null) {\r
+                ele.setAttribute("sectiontype", "EFI_SECTION_GUID_DEFINED");\r
+            } else {\r
+                ele.setAttribute("sectiontype", sectType);\r
+            }\r
+            //\r
             // <tool toolName="${OEMTOOLPATH}\toolname"\r
             // outputPath = "${DEST_DIR_OUTPUT}">\r
             //\r
-            ele = doc.createElement("tool");\r
-            ele.setAttribute("toolName", "${WORKSPACE_DIR}" + File.separatorChar + "Tools" + File.separatorChar + "bin"\r
+            toolEle = doc.createElement("tool");\r
+            if (toolName == null || toolName.equalsIgnoreCase("")) {\r
+                toolEle.setAttribute("toolName", "${WORKSPACE_DIR}" + File.separatorChar + "Tools" + File.separatorChar + "bin"\r
                                          + File.separatorChar + "GenCRC32Section");\r
-            ele.setAttribute("outputPath", "${DEST_DIR_OUTPUT}");\r
+            }else{\r
+                File toolExe = new File(toolName);\r
+                //\r
+                //  If <Tool> element exist, add sub element under <tool> . \r
+                // \r
+                if (toolExe.isAbsolute()) {\r
+                    toolEle.setAttribute("toolName", toolName);\r
+                } else {\r
+                    toolEle.setAttribute("toolName", "${WORKSPACE_DIR}" + File.separatorChar + "Tools" + File.separatorChar + "bin"\r
+                                         + File.separatorChar + toolName);\r
+                }\r
+            }\r
+            \r
+            toolEle.setAttribute("outputPath", "${DEST_DIR_OUTPUT}");\r
+            ele.appendChild(toolEle);\r
         }\r
         if (cursor.toFirstChild()) {\r
             do {\r
                 if (cursor.getName().getLocalPart().equalsIgnoreCase("Section")) {\r
                     cursor.push();\r
-                    dealSection(mode, doc, ele, cursor, list);\r
+                    if (toolEle == null) {\r
+                        dealSection(mode, doc, ele, cursor, list);\r
+                    } else {\r
+                        dealSection(mode, doc, toolEle, cursor, list);\r
+                    }\r
+                    \r
                     cursor.pop();\r
                 } else if (cursor.getName().getLocalPart().equalsIgnoreCase("Sections")) {\r
                     cursor.push();\r
-                    dealSections(mode, doc, ele, cursor, list);\r
+                    if (toolEle == null) {\r
+                        dealSections(mode, doc, ele, cursor, list);\r
+                    } else {\r
+                        dealSections(mode, doc, toolEle, cursor, list);\r
+                    }\r
+                    \r
                     cursor.pop();\r
                 }\r
             } while (cursor.toNextSibling());\r