2 This file is to define an ANT task to wrap setstamp.exe tool
4 Copyright (c) 2006, Intel Corporation
5 All rights reserved. This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
14 package org
.tianocore
.framework
.tasks
;
18 import org
.apache
.tools
.ant
.BuildException
;
19 import org
.apache
.tools
.ant
.Project
;
20 import org
.apache
.tools
.ant
.Task
;
21 import org
.apache
.tools
.ant
.taskdefs
.Execute
;
22 import org
.apache
.tools
.ant
.taskdefs
.LogStreamHandler
;
23 import org
.apache
.tools
.ant
.types
.Commandline
;
25 import org
.tianocore
.common
.logger
.EdkLog
;
28 Class SetStampTask is a wrap class for setstamp.exe.
30 public class SetStampTask
extends Task
implements EfiDefine
{
35 -timeFile: Txt file of time
38 private static String toolName
= "SetStamp";
40 private FileArg peFile
= new FileArg();
42 private FileArg timeFile
= new FileArg();
44 private String outputDir
= ".";
47 assemble tool command line & execute tool command line
49 @throws BuildException
51 public void execute() throws BuildException
{
53 Project project
= this.getOwningTarget().getProject();
55 /// absolute path of edk tools
57 String path
= project
.getProperty("env.FRAMEWORK_TOOLS_PATH");
62 command
= path
+ File
.separator
+ toolName
;
65 /// argument of SetStamp tool
67 String argument
= "" + peFile
+ timeFile
;
69 /// reture value of SetStamp execution
74 Commandline commandLine
= new Commandline();
75 commandLine
.setExecutable(command
);
76 commandLine
.createArgument().setLine(argument
);
78 LogStreamHandler streamHandler
= new LogStreamHandler(this,
79 Project
.MSG_INFO
, Project
.MSG_WARN
);
81 Execute runner
= new Execute(streamHandler
, null);
82 runner
.setAntRun(project
);
83 runner
.setCommandline(commandLine
.getCommandline());
84 runner
.setWorkingDirectory(new File(outputDir
));
86 EdkLog
.log(this, EdkLog
.EDK_VERBOSE
, Commandline
.toString(commandLine
.getCommandline()));
87 EdkLog
.log(this, peFile
.toFileList() + " < " + timeFile
.toFileList());
89 returnVal
= runner
.execute();
90 if (EFI_SUCCESS
== returnVal
) {
91 EdkLog
.log(this, EdkLog
.EDK_VERBOSE
, toolName
+ " succeeded!");
94 /// command execution fail
96 EdkLog
.log(this, "ERROR = " + Integer
.toHexString(returnVal
));
97 throw new BuildException(toolName
+ " failed!");
99 } catch (Exception e
) {
100 throw new BuildException(e
.getMessage());
105 set operation of class member "peFile"
107 @param peFile name of PE File
109 public void setPeFile(String peFile
) {
110 this.peFile
.setArg(" ", peFile
);
114 get operation of class member "peFile"
116 @return peFile name of PE file
118 public String
getPeFile() {
119 return this.peFile
.getValue();
123 set operation of class member "timeFile"
125 @param timeFile name of time file
127 public void setTimeFile(String timeFile
) {
128 this.timeFile
.setArg(" ", timeFile
);
132 get class member "timeFile"
134 @returns name of time file
136 public String
getTimeFile() {
137 return this.timeFile
.getValue();
143 This function is to get class member "outputDir"
145 @return outputDir string of output directory.
147 public String
getOutputDir() {
154 This function is to set class member "outputDir"
157 string of output directory.
159 public void setOutputDir(String outputDir
) {
160 this.outputDir
= outputDir
;