]> git.proxmox.com Git - mirror_edk2.git/blobdiff - Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/SetStampTask.java
1) Applied ToolArg and FileArg class to represent tool arguments
[mirror_edk2.git] / Tools / Source / FrameworkTasks / org / tianocore / framework / tasks / SetStampTask.java
index a06d312d06fc80227353307d9431ffe9f96b366c..dc3a96e8e55d86fc3efbf46aa6c7b9ca3a8faa4c 100644 (file)
@@ -22,6 +22,8 @@ import org.apache.tools.ant.taskdefs.Execute;
 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
  Class SetStampTask is a wrap class for setstamp.exe.\r
  **/\r
@@ -32,10 +34,14 @@ public class SetStampTask extends Task implements EfiDefine {
          -peFile  : file of PE\r
          -timeFile: Txt file of time\r
      **/ \r
-    \r
-    private String peFile = "";\r
 \r
-    private String timeFile = "";\r
+    private static String toolName = "SetStamp";\r
+\r
+    private FileArg peFile = new FileArg();\r
+\r
+    private FileArg timeFile = new FileArg();\r
+\r
+    private String outputDir = ".";\r
 \r
     /**\r
      assemble tool command line & execute tool command line\r
@@ -51,14 +57,14 @@ public class SetStampTask extends Task implements EfiDefine {
         String path = project.getProperty("env.FRAMEWORK_TOOLS_PATH");\r
         String command;\r
         if (path == null) {\r
-            command = "SetStamp";\r
+            command = toolName;\r
         } else {\r
-            command = path + "/" + "SetStamp";\r
+            command = path + File.separator + toolName;\r
         }\r
         ///\r
         /// argument of SetStamp tool\r
         ///\r
-        String argument = peFile + timeFile;\r
+        String argument = "" + peFile + timeFile;\r
         ///\r
         /// reture value of SetStamp execution\r
         ///\r
@@ -75,19 +81,20 @@ public class SetStampTask extends Task implements EfiDefine {
             Execute runner = new Execute(streamHandler, null);\r
             runner.setAntRun(project);\r
             runner.setCommandline(commandLine.getCommandline());\r
+            runner.setWorkingDirectory(new File(outputDir));\r
 \r
-            log(Commandline.toString(commandLine.getCommandline()), Project.MSG_VERBOSE);\r
-            log((new File(this.peFile)).getName());\r
+            EdkLog.log(this, EdkLog.EDK_VERBOSE, Commandline.toString(commandLine.getCommandline()));\r
+            EdkLog.log(this, peFile.toFileList() + " < " + timeFile.toFileList());\r
 \r
             returnVal = runner.execute();\r
             if (EFI_SUCCESS == returnVal) {\r
-                log("SetStamp succeeded!", Project.MSG_VERBOSE);\r
+                EdkLog.log(this, EdkLog.EDK_VERBOSE, toolName + " succeeded!");\r
             } else {\r
                 ///\r
                 /// command execution fail\r
                 ///\r
-                log("ERROR = " + Integer.toHexString(returnVal));\r
-                throw new BuildException("SetStamp failed!");\r
+                EdkLog.log(this, "ERROR = " + Integer.toHexString(returnVal));\r
+                throw new BuildException(toolName + " failed!");\r
             }\r
         } catch (Exception e) {\r
             throw new BuildException(e.getMessage());\r
@@ -100,7 +107,7 @@ public class SetStampTask extends Task implements EfiDefine {
      @param     peFile  name of PE File\r
      **/\r
     public void setPeFile(String peFile) {\r
-        this.peFile = " " + peFile;\r
+        this.peFile.setArg(" ", peFile);\r
     }\r
 \r
     /**\r
@@ -109,7 +116,7 @@ public class SetStampTask extends Task implements EfiDefine {
      @return    peFile  name of PE file\r
      **/\r
     public String getPeFile() {\r
-        return this.peFile;\r
+        return this.peFile.getValue();\r
     }\r
 \r
     /**\r
@@ -118,7 +125,7 @@ public class SetStampTask extends Task implements EfiDefine {
      @param     timeFile    name of time file\r
      **/\r
     public void setTimeFile(String timeFile) {\r
-        this.timeFile = " " + timeFile;\r
+        this.timeFile.setArg(" ", timeFile);\r
     }\r
 \r
     /**\r
@@ -127,7 +134,29 @@ public class SetStampTask extends Task implements EfiDefine {
      @returns   name of time file\r
      **/\r
     public String getTimeFile() {\r
-        return this.timeFile;\r
+        return this.timeFile.getValue();\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
+    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
+    public void setOutputDir(String outputDir) {\r
+        this.outputDir = outputDir;\r
+    }\r
 }\r