]> git.proxmox.com Git - mirror_edk2.git/blobdiff - Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/GenCRC32SectionTask.java
1) Applied ToolArg and FileArg class to represent tool arguments
[mirror_edk2.git] / Tools / Source / FrameworkTasks / org / tianocore / framework / tasks / GenCRC32SectionTask.java
index d7184cd5d37691a0678dec8d23afe35c6a256c8f..d9273acf7b7f40b23536bbf7a0065d25b7c4e657 100644 (file)
 \r
 package org.tianocore.framework.tasks;\r
 \r
-import java.util.*;\r
+import java.io.File;\r
+\r
+import org.apache.tools.ant.BuildException;\r
 import org.apache.tools.ant.Project;\r
 import org.apache.tools.ant.Task;\r
-import org.apache.tools.ant.BuildException;\r
 import org.apache.tools.ant.taskdefs.Execute;\r
 import org.apache.tools.ant.taskdefs.LogStreamHandler;\r
 import org.apache.tools.ant.types.Commandline;\r
 \r
+import org.tianocore.common.logger.EdkLog;\r
+\r
 /**\r
   GenCRC32SectionTask\r
   \r
@@ -31,18 +34,22 @@ import org.apache.tools.ant.types.Commandline;
   \r
 **/\r
 public class GenCRC32SectionTask extends Task implements EfiDefine {\r
-    ///\r
-    /// output file\r
-    ///\r
-    private String outputFile;\r
-    ///\r
-    /// inputFile list\r
-    ///\r
-    private List<NestElement> inputFileList = new ArrayList<NestElement>();\r
+    //\r
+    // Tool name\r
+    //\r
+    private static String toolName = "GenCRC32Section";\r
+    //\r
+    // output file\r
+    //\r
+    private FileArg outputFile = new FileArg();\r
+    //\r
+    // inputFile list\r
+    //\r
+    private InputFile inputFileList = new InputFile();\r
     \r
-    ///\r
-    /// Project\r
-    ///\r
+    //\r
+    // Project\r
+    //\r
     static private Project project;\r
     \r
     /**\r
@@ -62,22 +69,14 @@ public class GenCRC32SectionTask extends Task implements EfiDefine {
         String path = project.getProperty("env.FRAMEWORK_TOOLS_PATH"); \r
         String command;\r
         if (path == null) {\r
-            command = "GenCRC32Section";\r
+            command = toolName;\r
         } else {\r
-            command = path + "/" + "GenCRC32Section" ;\r
-        }\r
-        // \r
-        // string line of input files \r
-        // \r
-        String inputFiles = " -i "; \r
-        for (int i = 0; i < inputFileList.size(); ++i) {\r
-            inputFiles += inputFileList.get(i).toString(" ");\r
+            command = path + File.separator + toolName ;\r
         }\r
-\r
         // \r
         // assemble argument \r
         //\r
-        String argument =  inputFiles + outputFile; \r
+        String argument =  "" + inputFileList.toStringWithSinglepPrefix(" -i ") + outputFile; \r
         // \r
         // return value of fwimage execution \r
         //\r
@@ -93,21 +92,23 @@ public class GenCRC32SectionTask extends Task implements EfiDefine {
             \r
             runner.setAntRun(project);\r
             runner.setCommandline(cmdline.getCommandline());\r
-            log(Commandline.toString(cmdline.getCommandline()), Project.MSG_VERBOSE);\r
-            log(" ");\r
+\r
+            EdkLog.log(this, EdkLog.EDK_VERBOSE, Commandline.toString(cmdline.getCommandline()));\r
+            EdkLog.log(this, inputFileList.toFileList() + " => " + outputFile.toFileList());\r
+\r
             revl = runner.execute();\r
             if (EFI_SUCCESS == revl){\r
                 //\r
                 //  command execution success \r
                 //\r
-                log("GenCRC32Section succeeded!", Project.MSG_VERBOSE);\r
+                EdkLog.log(this, toolName + " succeeded!");\r
             } else {\r
                 // \r
                 // command execution fail\r
                 //\r
-                log("ERROR = " + Integer.toHexString(revl));\r
+                EdkLog.log(this, "ERROR = " + Integer.toHexString(revl));\r
                 // LAH Added This Line\r
-                throw new BuildException("GenCRC32Section failed!");\r
+                throw new BuildException(toolName + " failed!");\r
             }\r
         } catch (Exception e) {\r
             throw new BuildException(e.getMessage());\r
@@ -120,22 +121,22 @@ public class GenCRC32SectionTask extends Task implements EfiDefine {
       This function is to add a inputFile element into list\r
       @param inputFile : inputFile element\r
     **/\r
-    public void addInputfile(InputFile inputFile) {\r
-        inputFileList.add(inputFile);\r
+    public void addConfiguredInputfile(InputFile inputFile) {\r
+        inputFileList.insert(inputFile);\r
     }\r
     \r
     /**\r
-     get class member "outputFile"\r
-     * @return name of output file\r
-     */\r
+      get class member "outputFile"\r
+      @return name of output file\r
+     **/\r
     public String getOutputFile() {\r
-        return this.outputFile;\r
+        return this.outputFile.getValue();\r
     }\r
     /**\r
-     * set class member "outputFile"\r
-     * @param outputFile : outputFile parameter \r
-     */\r
+      set class member "outputFile"\r
+      @param outputFile : outputFile parameter \r
+     **/\r
     public void setOutputFile(String outputFile) {\r
-        this.outputFile = " -o " + outputFile;\r
+        this.outputFile.setArg(" -o ", outputFile);\r
     }\r
 }\r