]> git.proxmox.com Git - mirror_edk2.git/blobdiff - Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/CreateMtFileTask.java
1) Applied ToolArg and FileArg class to represent tool arguments
[mirror_edk2.git] / Tools / Source / FrameworkTasks / org / tianocore / framework / tasks / CreateMtFileTask.java
index 672e712b3e91d43d1001a9466d6e4f826888f476..bdc492c0dc7d54d92f8cbc7809bfd121752516fc 100644 (file)
@@ -33,33 +33,33 @@ import org.tianocore.common.logger.EdkLog;
   CreateMtFileTask is used to call CreateMtFile.exe to create MT file.\r
 **/\r
 public class CreateMtFileTask extends Task implements EfiDefine {\r
-    ///\r
-    /// Tool name\r
-    ///\r
-    private String toolName="CreateMtFile";\r
-    ///\r
-    /// file size\r
-    ///\r
-    private String fileSize = "";\r
-\r
-    ///\r
-    /// output file\r
-    ///\r
-    private String outputFile = "";\r
-\r
-    ///\r
-    /// output directory, this variable is added by jave wrap\r
-    ///\r
-    private String outputDir = "";\r
+    //\r
+    // Tool name\r
+    //\r
+    private String toolName = "CreateMtFile";\r
+    //\r
+    // file size\r
+    //\r
+    private ToolArg fileSize = new ToolArg();\r
+\r
+    //\r
+    // output file\r
+    //\r
+    private FileArg outputFile = new FileArg();\r
+\r
+    //\r
+    // output directory, this variable is added by jave wrap\r
+    //\r
+    private String outputDir = ".";\r
 \r
     /**\r
-     * execute\r
-     *\r
-     * StripTask execute function is to assemble tool command line & execute\r
-     * tool command line\r
-     *\r
-     * @throws BuidException\r
-     */\r
+      execute\r
+     \r
+      StripTask execute function is to assemble tool command line & execute\r
+      tool command line\r
+     \r
+      @throws BuidException\r
+     **/\r
     public void execute() throws BuildException {\r
 \r
         Project project = this.getOwningTarget().getProject();\r
@@ -73,18 +73,12 @@ public class CreateMtFileTask extends Task implements EfiDefine {
         if (path == null) {\r
             command = toolName;\r
         } else {\r
-            command = path + File.separatorChar + toolName;\r
+            command = path + File.separator + toolName;\r
         }\r
         //\r
         // argument of tools\r
         //\r
-        File file = new File(outputFile);\r
-        if (!file.isAbsolute() && (!this.outputDir.equalsIgnoreCase(""))) {\r
-            argument = outputDir + File.separatorChar +  outputFile + " " + this.fileSize;\r
-\r
-        } else {\r
-            argument = outputFile  + " " + this.fileSize;\r
-        }\r
+        argument = "" + outputFile + fileSize;\r
         //\r
         // return value of fwimage execution\r
         //\r
@@ -101,24 +95,26 @@ public class CreateMtFileTask extends Task implements EfiDefine {
 \r
             runner.setAntRun(project);\r
             runner.setCommandline(cmdline.getCommandline());\r
+            runner.setWorkingDirectory(new File(outputDir));\r
+\r
             //\r
             // Set debug log information.\r
             //\r
             EdkLog.log(this, EdkLog.EDK_VERBOSE, Commandline.toString(cmdline.getCommandline()));\r
-            EdkLog.log(this, EdkLog.EDK_INFO, (new File(this.outputFile)).getName());\r
-            revl = runner.execute();\r
+            EdkLog.log(this, EdkLog.EDK_INFO, this.outputFile.toFileList());\r
 \r
+            revl = runner.execute();\r
             if (EFI_SUCCESS == revl) {\r
                 //\r
                 // command execution success\r
                 //\r
-                EdkLog.log(this, EdkLog.EDK_VERBOSE, "CreateMtFile succeeded!");\r
+                EdkLog.log(this, EdkLog.EDK_VERBOSE, toolName + " succeeded!");\r
             } else {\r
                 //\r
                 // command execution fail\r
                 //\r
                 EdkLog.log(this, EdkLog.EDK_INFO, "ERROR = " + Integer.toHexString(revl));\r
-                throw new BuildException("CreateMtFile failed!");\r
+                throw new BuildException(toolName + " failed!");\r
             }\r
         } catch (Exception e) {\r
             throw new BuildException(e.getMessage());\r
@@ -126,70 +122,70 @@ public class CreateMtFileTask extends Task implements EfiDefine {
     }\r
 \r
     /**\r
-     * getFileSize\r
-     *\r
-     * This function is to get class member "fileSize".\r
-     *\r
-     * @return fileSize       string of file size.\r
-     */\r
+      getFileSize\r
+     \r
+      This function is to get class member "fileSize".\r
+     \r
+      @return fileSize       string of file size.\r
+     **/\r
     public String getFileSize() {\r
-        return this.fileSize;\r
+        return this.fileSize.getValue();\r
     }\r
 \r
     /**\r
-     * setFileSize\r
-     *\r
-     * This function is to set class member "fileSize".\r
-     *\r
-     * @param fileSize\r
-     *            string of file size value.\r
-     */\r
+      setFileSize\r
+     \r
+      This function is to set class member "fileSize".\r
+     \r
+      @param fileSize\r
+                 string of file size value.\r
+     **/\r
     public void setFileSize(String fileSize) {\r
-        this.fileSize = fileSize;\r
+        this.fileSize.setArg(" ", fileSize);\r
     }\r
 \r
     /**\r
-     * getOutputFile\r
-     *\r
-     * This function is to get class member "outputFile"\r
-     *\r
-     * @return outputFile string of output file name.\r
-     */\r
+      getOutputFile\r
+     \r
+      This function is to get class member "outputFile"\r
+     \r
+      @return outputFile string of output file name.\r
+     **/\r
     public String getOutputFile() {\r
-        return outputFile;\r
+        return outputFile.getValue();\r
     }\r
 \r
     /**\r
-     * setOutputFile\r
-     *\r
-     * This function is to set class member "outputFile"\r
-     *\r
-     * @param outputFile\r
-     *            string of output file name.\r
-     */\r
+      setOutputFile\r
+     \r
+      This function is to set class member "outputFile"\r
+     \r
+      @param outputFile\r
+                 string of output file name.\r
+     **/\r
     public void setOutputFile(String outputFile) {\r
-        this.outputFile = outputFile;\r
+        this.outputFile.setArg(" ", outputFile);\r
     }\r
 \r
     /**\r
-     * getOutputDir\r
-     *\r
-     * This function is to get class member "outputDir"\r
-     *\r
-     * @return outputDir string of output directory.\r
-     */\r
+      getOutputDir\r
+     \r
+      This function is to get class member "outputDir"\r
+     \r
+      @return outputDir string of output directory.\r
+     **/\r
     public String getOutputDir() {\r
         return outputDir;\r
     }\r
 \r
     /**\r
-     * setOutputDir\r
-     *\r
-     * This function is to set class member "outputDir"\r
-     *\r
-     * @param outputDir\r
-     *            string of output directory.\r
-     */\r
+      setOutputDir\r
+     \r
+      This function is to set class member "outputDir"\r
+     \r
+      @param outputDir\r
+                 string of output directory.\r
+     **/\r
     public void setOutputDir(String outputDir) {\r
         this.outputDir = outputDir;\r
     }\r