]> git.proxmox.com Git - mirror_edk2.git/blobdiff - Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/GenSectionTask.java
1) Changed ToolArg class to abstract generic arguments of a tool
[mirror_edk2.git] / Tools / Source / FrameworkTasks / org / tianocore / framework / tasks / GenSectionTask.java
index fc5ebbf3dc740048fac917081217ae8108c6a3f9..4d335e0ba6c706144cfdfd87c7e2f5c63adb4de0 100644 (file)
@@ -31,34 +31,30 @@ import org.apache.tools.ant.taskdefs.LogStreamHandler;
 import org.apache.tools.ant.types.Commandline;\r
 import org.tianocore.common.logger.EdkLog;\r
 \r
-public class GenSectionTask extends Task implements EfiDefine, Section,FfsTypes {\r
-    ///\r
-    /// inputfile name\r
-    ///\r
-    private String inputFile = "";\r
-    ///\r
-    /// \r
-    /// \r
-    private String inputFileName = "";\r
-    ///\r
-    /// outputfile name\r
-    ///\r
-    private String outputFile = "";\r
-    ///\r
-    /// section type\r
-    ///\r
-    private String sectionType = "";\r
-    ///\r
-    /// version number\r
-    ///\r
-    private String versionNum = "";\r
-    ///\r
-    /// interface string\r
-    ///\r
-    private String interfaceString = "";\r
-    ///\r
-    /// Section file list\r
-    ///\r
+public class GenSectionTask extends Task implements EfiDefine, Section, FfsTypes {\r
+    //\r
+    // inputfile name\r
+    //\r
+    private FileArg inputFile = new FileArg();\r
+    //\r
+    // outputfile name\r
+    //\r
+    private FileArg outputFile = new FileArg();\r
+    //\r
+    // section type\r
+    //\r
+    private ToolArg sectionType = new ToolArg();\r
+    //\r
+    // version number\r
+    //\r
+    private ToolArg versionNum = new ToolArg();\r
+    //\r
+    // interface string\r
+    //\r
+    private ToolArg interfaceString = new ToolArg();\r
+    //\r
+    // Section file list\r
+    //\r
     private List<Section> sectFileList = new ArrayList<Section>();\r
    \r
     /**\r
@@ -84,8 +80,7 @@ public class GenSectionTask extends Task implements EfiDefine, Section,FfsTypes
         //\r
         // argument of tools\r
         //\r
-        String argument = inputFile + outputFile + " -s "+ sectionType + versionNum\r
-                + interfaceString;\r
+        String argument = "" + inputFile + outputFile + sectionType + versionNum + interfaceString;\r
         //\r
         // return value of gensection execution\r
         //\r
@@ -103,16 +98,17 @@ public class GenSectionTask extends Task implements EfiDefine, Section,FfsTypes
             runner.setAntRun(project);\r
             runner.setCommandline(cmdline.getCommandline());\r
 \r
-            EdkLog.log(this, EdkLog.EDK_INFO, inputFileName);\r
-            EdkLog.log(this, EdkLog.EDK_DEBUG, Commandline.toString(cmdline.getCommandline()));\r
+            EdkLog.log(this, inputFile.toFileList() + " => " + outputFile.toFileList());\r
+            EdkLog.log(this, EdkLog.EDK_VERBOSE, Commandline.toString(cmdline.getCommandline()));\r
+\r
             revl = runner.execute();\r
             if (EFI_SUCCESS == revl) {\r
-                log("GenSection succeeded!", Project.MSG_VERBOSE);\r
+                EdkLog.log(this, EdkLog.EDK_VERBOSE, "GenSection succeeded!");\r
             } else {\r
                 //\r
                 // command execution fail\r
                 //\r
-                log("ERROR = " + Integer.toHexString(revl));\r
+                EdkLog.log(this, EdkLog.EDK_INFO, "ERROR = " + Integer.toHexString(revl));\r
                 throw new BuildException("GenSection failed!");\r
             }\r
         } catch (Exception e) {\r
@@ -128,7 +124,7 @@ public class GenSectionTask extends Task implements EfiDefine, Section,FfsTypes
       @return                    name of input file\r
     **/\r
     public String getInputFile() {\r
-        return this.inputFile;\r
+        return this.inputFile.getValue();\r
     }\r
 \r
     /**\r
@@ -139,8 +135,7 @@ public class GenSectionTask extends Task implements EfiDefine, Section,FfsTypes
       @param inputFile            name of input file\r
     **/\r
     public void setInputFile(String inputFile) {\r
-        this.inputFileName = (new File(inputFile)).getName();\r
-        this.inputFile = " -i " + inputFile;\r
+        this.inputFile.setArg(" -i ", inputFile);\r
     }\r
 \r
     /**\r
@@ -151,7 +146,7 @@ public class GenSectionTask extends Task implements EfiDefine, Section,FfsTypes
       @return                      name of output file\r
     **/\r
     public String getOutputFile() {\r
-        return this.outputFile;\r
+        return this.outputFile.getValue();\r
     }\r
 \r
     /**\r
@@ -161,7 +156,7 @@ public class GenSectionTask extends Task implements EfiDefine, Section,FfsTypes
       @param  outputFile            name of output file\r
     **/\r
     public void setOutputfile(String outputFile) {\r
-        this.outputFile = " -o " + outputFile;\r
+        this.outputFile.setArg(" -o ", outputFile);\r
     }\r
 \r
     /**\r
@@ -172,7 +167,7 @@ public class GenSectionTask extends Task implements EfiDefine, Section,FfsTypes
       @return                        sectoin type\r
     **/\r
     public String getSectionType() {\r
-        return this.sectionType;\r
+        return this.sectionType.getValue();\r
     }\r
 \r
     /**\r
@@ -183,7 +178,7 @@ public class GenSectionTask extends Task implements EfiDefine, Section,FfsTypes
       @param sectionType              section type\r
     **/\r
     public void setSectionType(String sectionType) {\r
-        this.sectionType = sectionType;\r
+        this.sectionType.setArg(" -s ", sectionType);\r
     }\r
 \r
     /**\r
@@ -193,7 +188,7 @@ public class GenSectionTask extends Task implements EfiDefine, Section,FfsTypes
       @return                         version number\r
     **/\r
     public String getVersionNum() {\r
-        return this.versionNum;\r
+        return this.versionNum.getValue();\r
     }\r
 \r
     /**\r
@@ -203,7 +198,7 @@ public class GenSectionTask extends Task implements EfiDefine, Section,FfsTypes
       @param versionNum               version number\r
     **/\r
     public void setVersionNum(String versionNum) {\r
-        this.versionNum = " -v " + versionNum;\r
+        this.versionNum.setArg(" -v ", versionNum);\r
     }\r
 \r
     /**\r
@@ -213,7 +208,7 @@ public class GenSectionTask extends Task implements EfiDefine, Section,FfsTypes
       @return                         interface string\r
     **/\r
     public String getInterfaceString() {\r
-        return this.interfaceString;\r
+        return this.interfaceString.getValue();\r
     }\r
 \r
     /**\r
@@ -223,7 +218,7 @@ public class GenSectionTask extends Task implements EfiDefine, Section,FfsTypes
       @param interfaceString            interface string\r
     **/\r
     public void setInterfaceString(String interfaceString) {\r
-        this.interfaceString = " -a " + "\"" + interfaceString + "\"";\r
+        this.interfaceString.setArg(" -a ", "\"" + interfaceString + "\"");\r
     }\r
     \r
     /**\r
@@ -263,7 +258,7 @@ public class GenSectionTask extends Task implements EfiDefine, Section,FfsTypes
         //  Search SectionList find earch section and call it's \r
         //  ToBuffer function.\r
         //\r
-        if (this.sectionType.equalsIgnoreCase("EFI_SECTION_COMPRESSION")){\r
+        if (this.sectionType.getValue().equalsIgnoreCase("EFI_SECTION_COMPRESSION")){\r
             Section    sect;\r
             \r
             //\r