]> git.proxmox.com Git - mirror_edk2.git/blobdiff - Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/GenSectionTask.java
1) Applied ToolArg and FileArg class to represent tool arguments
[mirror_edk2.git] / Tools / Source / FrameworkTasks / org / tianocore / framework / tasks / GenSectionTask.java
index 8396f707ab3bc2772007b17c9b6e75e0ae4e9f3f..b1bf83c2a786accd6833a641054016aff642c5d7 100644 (file)
  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
  \r
  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
  \r
- **/\r
+**/\r
 \r
 package org.tianocore.framework.tasks;\r
 \r
 import java.io.ByteArrayOutputStream;\r
 import java.io.DataOutputStream;\r
 \r
 package org.tianocore.framework.tasks;\r
 \r
 import java.io.ByteArrayOutputStream;\r
 import java.io.DataOutputStream;\r
+import java.io.File;\r
+import java.io.file;\r
 import java.util.ArrayList;\r
 import java.util.Iterator;\r
 import java.util.List;\r
 import java.util.ArrayList;\r
 import java.util.Iterator;\r
 import java.util.List;\r
@@ -30,8 +32,11 @@ import org.apache.tools.ant.taskdefs.LogStreamHandler;
 import org.apache.tools.ant.types.Commandline;\r
 import org.tianocore.common.logger.EdkLog;\r
 \r
 import org.apache.tools.ant.types.Commandline;\r
 import org.tianocore.common.logger.EdkLog;\r
 \r
-public class GenSectionTask extends Task implements EfiDefine, Section,\r
-        FfsTypes {\r
+public class GenSectionTask extends Task implements EfiDefine, Section, FfsTypes {\r
+    //\r
+    // Tool name\r
+    // \r
+    private final static String toolName = "GenSection";\r
     //\r
     // inputfile name\r
     //\r
     //\r
     // inputfile name\r
     //\r
@@ -68,13 +73,13 @@ public class GenSectionTask extends Task implements EfiDefine, Section,
     private boolean haveTool = false;\r
 \r
     /**\r
     private boolean haveTool = false;\r
 \r
     /**\r
-     * execute\r
-     * \r
-     * GenSectionTaks execute is to assemble tool command line & execute tool\r
-     * command line.\r
-     * \r
-     * @throws BuildException\r
-     */\r
+      execute\r
+      \r
+      GenSectionTaks execute is to assemble tool command line & execute tool\r
+      command line.\r
+      \r
+      @throws BuildException\r
+    **/\r
     public void execute() throws BuildException {\r
         String command;\r
         Project project = this.getOwningTarget().getProject();\r
     public void execute() throws BuildException {\r
         String command;\r
         Project project = this.getOwningTarget().getProject();\r
@@ -83,15 +88,14 @@ public class GenSectionTask extends Task implements EfiDefine, Section,
         //\r
         String path = project.getProperty("env.FRAMEWORK_TOOLS_PATH");\r
         if (path == null) {\r
         //\r
         String path = project.getProperty("env.FRAMEWORK_TOOLS_PATH");\r
         if (path == null) {\r
-            command = "GenSection";\r
+            command = toolName;\r
         } else {\r
         } else {\r
-            command = path + "/" + "GenSection";\r
+            command = path + File.separator + toolName;\r
         }\r
         //\r
         // argument of tools\r
         //\r
         }\r
         //\r
         // argument of tools\r
         //\r
-        String argument = "" + inputFile + outputFile + sectionType\r
-                + versionNum + interfaceString;\r
+        String argument = "" + inputFile + outputFile + sectionType + versionNum + interfaceString;\r
         //\r
         // return value of gensection execution\r
         //\r
         //\r
         // return value of gensection execution\r
         //\r
@@ -109,21 +113,19 @@ public class GenSectionTask extends Task implements EfiDefine, Section,
             runner.setAntRun(project);\r
             runner.setCommandline(cmdline.getCommandline());\r
 \r
             runner.setAntRun(project);\r
             runner.setCommandline(cmdline.getCommandline());\r
 \r
-            EdkLog.log(this, inputFile.toFileList() + " => "\r
-                    + outputFile.toFileList());\r
-            EdkLog.log(this, EdkLog.EDK_VERBOSE, Commandline.toString(cmdline\r
-                    .getCommandline()));\r
+            EdkLog.log(this, inputFile.toFileList() + versionNum.getValue() \r
+                + interfaceString.getValue() + " => " + outputFile.toFileList());\r
+            EdkLog.log(this, EdkLog.EDK_VERBOSE, Commandline.toString(cmdline.getCommandline()));\r
 \r
             revl = runner.execute();\r
             if (EFI_SUCCESS == revl) {\r
 \r
             revl = runner.execute();\r
             if (EFI_SUCCESS == revl) {\r
-                EdkLog.log(this, EdkLog.EDK_VERBOSE, "GenSection succeeded!");\r
+                EdkLog.log(this, EdkLog.EDK_VERBOSE, toolName + " succeeded!");\r
             } else {\r
                 //\r
                 // command execution fail\r
                 //\r
             } else {\r
                 //\r
                 // command execution fail\r
                 //\r
-                EdkLog.log(this, EdkLog.EDK_INFO, "ERROR = "\r
-                        + Integer.toHexString(revl));\r
-                throw new BuildException("GenSection failed!");\r
+                EdkLog.log(this, EdkLog.EDK_INFO, "ERROR = " + Integer.toHexString(revl));\r
+                throw new BuildException(toolName + " failed!");\r
             }\r
         } catch (Exception e) {\r
             throw new BuildException(e.getMessage());\r
             }\r
         } catch (Exception e) {\r
             throw new BuildException(e.getMessage());\r
@@ -131,157 +133,144 @@ public class GenSectionTask extends Task implements EfiDefine, Section,
     }\r
 \r
     /**\r
     }\r
 \r
     /**\r
-     * getInputFile\r
-     * \r
-     * This function is to get class member "inputFile".\r
-     * \r
-     * @return name of input file\r
-     */\r
+      getInputFile\r
+      \r
+      This function is to get class member "inputFile".\r
+      \r
+      @return                    name of input file\r
+    **/\r
     public String getInputFile() {\r
         return this.inputFile.getValue();\r
     }\r
 \r
     /**\r
     public String getInputFile() {\r
         return this.inputFile.getValue();\r
     }\r
 \r
     /**\r
-     * setInputFile\r
-     * \r
-     * This function is to set class member "inputFile".\r
-     * \r
-     * @param inputFile\r
-     *            name of input file\r
-     */\r
+      setInputFile\r
+      \r
+      This function is to set class member "inputFile".\r
+      \r
+      @param inputFile            name of input file\r
+    **/\r
     public void setInputFile(String inputFile) {\r
         this.inputFile.setArg(" -i ", inputFile);\r
     }\r
 \r
     /**\r
     public void setInputFile(String inputFile) {\r
         this.inputFile.setArg(" -i ", inputFile);\r
     }\r
 \r
     /**\r
-     * getOutputFile\r
-     * \r
-     * This function is to get class member "outputFile".\r
-     * \r
-     * @return name of output file\r
-     */\r
+      getOutputFile\r
+      \r
+      This function is to get class member "outputFile".\r
+      \r
+      @return                      name of output file\r
+    **/\r
     public String getOutputFile() {\r
         return this.outputFile.getValue();\r
     }\r
 \r
     /**\r
     public String getOutputFile() {\r
         return this.outputFile.getValue();\r
     }\r
 \r
     /**\r
-     * setOutputfile\r
-     * \r
-     * This function is to set class member "outputFile".\r
-     * \r
-     * @param outputFile\r
-     *            name of output file\r
-     */\r
+      setOutputfile\r
+      \r
+      This function is to set class member "outputFile".\r
+      @param  outputFile            name of output file\r
+    **/\r
     public void setOutputfile(String outputFile) {\r
         this.outputFile.setArg(" -o ", outputFile);\r
     }\r
 \r
     /**\r
     public void setOutputfile(String outputFile) {\r
         this.outputFile.setArg(" -o ", outputFile);\r
     }\r
 \r
     /**\r
-     * getSectionType\r
-     * \r
-     * This function is to get class member "sectionType".\r
-     * \r
-     * @return sectoin type\r
-     */\r
+      getSectionType\r
+      \r
+      This function is to get class member "sectionType".\r
+      \r
+      @return                        sectoin type\r
+    **/\r
     public String getSectionType() {\r
         return this.sectionType.getValue();\r
     }\r
 \r
     /**\r
     public String getSectionType() {\r
         return this.sectionType.getValue();\r
     }\r
 \r
     /**\r
-     * setSectionType\r
-     * \r
-     * This function is to set class member "sectionType".\r
-     * \r
-     * @param sectionType\r
-     *            section type\r
-     */\r
+      setSectionType\r
+      \r
+      This function is to set class member "sectionType".\r
+      \r
+      @param sectionType              section type\r
+    **/\r
     public void setSectionType(String sectionType) {\r
         this.sectionType.setArg(" -s ", sectionType);\r
     }\r
 \r
     /**\r
     public void setSectionType(String sectionType) {\r
         this.sectionType.setArg(" -s ", sectionType);\r
     }\r
 \r
     /**\r
-     * getVersionNum\r
-     * \r
-     * This function is to get class member "versionNum".\r
-     * \r
-     * @return version number\r
-     */\r
+      getVersionNum\r
+      \r
+      This function is to get class member "versionNum".\r
+      @return                         version number\r
+    **/\r
     public String getVersionNum() {\r
         return this.versionNum.getValue();\r
     }\r
 \r
     /**\r
     public String getVersionNum() {\r
         return this.versionNum.getValue();\r
     }\r
 \r
     /**\r
-     * setVersionNume\r
-     * \r
-     * This function is to set class member "versionNum".\r
-     * \r
-     * @param versionNum\r
-     *            version number\r
-     */\r
+      setVersionNume\r
+      \r
+      This function is to set class member "versionNum".\r
+      @param versionNum               version number\r
+    **/\r
     public void setVersionNum(String versionNum) {\r
         this.versionNum.setArg(" -v ", versionNum);\r
     }\r
 \r
     /**\r
     public void setVersionNum(String versionNum) {\r
         this.versionNum.setArg(" -v ", versionNum);\r
     }\r
 \r
     /**\r
-     * getInterfaceString\r
-     * \r
-     * This function is to get class member "interfaceString".\r
-     * \r
-     * @return interface string\r
-     */\r
+      getInterfaceString\r
+      \r
+      This function is to get class member "interfaceString".\r
+      @return                         interface string\r
+    **/\r
     public String getInterfaceString() {\r
         return this.interfaceString.getValue();\r
     }\r
 \r
     /**\r
     public String getInterfaceString() {\r
         return this.interfaceString.getValue();\r
     }\r
 \r
     /**\r
-     * setInterfaceString\r
-     * \r
-     * This funcion is to set class member "interfaceString".\r
-     * \r
-     * @param interfaceString\r
-     *            interface string\r
-     */\r
+      setInterfaceString\r
+      \r
+      This funcion is to set class member "interfaceString".\r
+      @param interfaceString            interface string\r
+    **/\r
     public void setInterfaceString(String interfaceString) {\r
         this.interfaceString.setArg(" -a ", "\"" + interfaceString + "\"");\r
     }\r
     public void setInterfaceString(String interfaceString) {\r
         this.interfaceString.setArg(" -a ", "\"" + interfaceString + "\"");\r
     }\r
-\r
+    \r
     /**\r
     /**\r
-     * addSectFile\r
-     * \r
-     * This function is to add sectFile to list.\r
-     * \r
-     * @param sectFile\r
-     *            instance of sectFile.\r
-     */\r
-    public void addSectFile(SectFile sectFile) {\r
+      addSectFile\r
+      \r
+      This function is to add sectFile to list.\r
+      \r
+      @param sectFile     instance of sectFile.\r
+    **/\r
+    public void addSectFile(SectFile sectFile){\r
         this.sectFileList.add(sectFile);\r
     }\r
 \r
     /**\r
         this.sectFileList.add(sectFile);\r
     }\r
 \r
     /**\r
-     * setTool\r
-     * \r
-     * This function is to set the class member "Tool";\r
-     * \r
-     * @param tool\r
-     */\r
+      setTool\r
+      \r
+      This function is to set the class member "Tool";\r
+      \r
+      @param tool \r
+    **/\r
     public void addTool(Tool tool) {\r
         this.sectFileList.add(tool);\r
         this.haveTool = true;\r
     }\r
     public void addTool(Tool tool) {\r
         this.sectFileList.add(tool);\r
         this.haveTool = true;\r
     }\r
-\r
+    \r
     /**\r
     /**\r
-     * addGenSection\r
-     * \r
-     * This function is to add GenSectin element to list\r
-     * \r
-     * @param task\r
-     *            Instance of genSection\r
-     */\r
-    public void addGenSection(GenSectionTask task) {\r
+      addGenSection\r
+      \r
+      This function is to add GenSectin element to list\r
+      @param task         Instance of genSection\r
+    **/\r
+    public void addGenSection(GenSectionTask task){\r
         this.sectFileList.add(task);\r
     }\r
         this.sectFileList.add(task);\r
     }\r
-\r
-    public void toBuffer(DataOutputStream buffer) {\r
+    \r
+    public void toBuffer(DataOutputStream buffer){\r
         //\r
         // Search SectionList find earch section and call it's\r
         // ToBuffer function.\r
         //\r
         // Search SectionList find earch section and call it's\r
         // ToBuffer function.\r