+++ /dev/null
-/** @file\r
-This file is to define an ANT task to wrap setstamp.exe tool\r
-\r
-Copyright (c) 2006, Intel Corporation\r
-All rights reserved. This program and the accompanying materials\r
-are licensed and made available under the terms and conditions of the BSD License\r
-which accompanies this distribution. The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\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
-package org.tianocore.framework.tasks;\r
-\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.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
- Class SetStampTask is a wrap class for setstamp.exe.\r
- **/\r
-public class SetStampTask extends Task implements EfiDefine {\r
- /**\r
- SetStamp Task Class\r
- class member\r
- -peFile : file of PE\r
- -timeFile: Txt file of time\r
- **/ \r
-\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
- \r
- @throws BuildException\r
- **/\r
- public void execute() throws BuildException {\r
-\r
- Project project = this.getOwningTarget().getProject();\r
- ///\r
- /// absolute path of edk tools\r
- ///\r
- String path = project.getProperty("env.FRAMEWORK_TOOLS_PATH");\r
- String command;\r
- if (path == null) {\r
- command = toolName;\r
- } else {\r
- command = path + File.separator + toolName;\r
- }\r
- ///\r
- /// argument of SetStamp tool\r
- ///\r
- String argument = "" + peFile + timeFile;\r
- ///\r
- /// reture value of SetStamp execution\r
- ///\r
- int returnVal = -1;\r
-\r
- try {\r
- Commandline commandLine = new Commandline();\r
- commandLine.setExecutable(command);\r
- commandLine.createArgument().setLine(argument);\r
-\r
- LogStreamHandler streamHandler = new LogStreamHandler(this,\r
- Project.MSG_INFO, Project.MSG_WARN);\r
-\r
- Execute runner = new Execute(streamHandler, null);\r
- runner.setAntRun(project);\r
- runner.setCommandline(commandLine.getCommandline());\r
- runner.setWorkingDirectory(new File(outputDir));\r
-\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
- EdkLog.log(this, EdkLog.EDK_VERBOSE, toolName + " succeeded!");\r
- } else {\r
- ///\r
- /// command execution fail\r
- ///\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
- }\r
- }\r
-\r
- /**\r
- set operation of class member "peFile"\r
- \r
- @param peFile name of PE File\r
- **/\r
- public void setPeFile(String peFile) {\r
- this.peFile.setArg(" ", peFile);\r
- }\r
-\r
- /**\r
- get operation of class member "peFile"\r
- \r
- @return peFile name of PE file\r
- **/\r
- public String getPeFile() {\r
- return this.peFile.getValue();\r
- }\r
-\r
- /**\r
- set operation of class member "timeFile"\r
- \r
- @param timeFile name of time file\r
- **/\r
- public void setTimeFile(String timeFile) {\r
- this.timeFile.setArg(" ", timeFile);\r
- }\r
-\r
- /**\r
- get class member "timeFile"\r
- \r
- @returns name of time file\r
- **/\r
- public String getTimeFile() {\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