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
;
26 Class SetStampTask is a wrap class for setstamp.exe.
28 public class SetStampTask
extends Task
implements EfiDefine
{
33 -timeFile: Txt file of time
36 private String peFile
= "";
38 private String timeFile
= "";
41 assemble tool command line & execute tool command line
43 @throws BuildException
45 public void execute() throws BuildException
{
47 Project project
= this.getOwningTarget().getProject();
49 /// absolute path of edk tools
51 String path
= project
.getProperty("env.FRAMEWORK_TOOLS_PATH");
56 command
= path
+ "/" + "SetStamp";
59 /// argument of SetStamp tool
61 String argument
= peFile
+ timeFile
;
63 /// reture value of SetStamp execution
68 Commandline commandLine
= new Commandline();
69 commandLine
.setExecutable(command
);
70 commandLine
.createArgument().setLine(argument
);
72 LogStreamHandler streamHandler
= new LogStreamHandler(this,
73 Project
.MSG_INFO
, Project
.MSG_WARN
);
75 Execute runner
= new Execute(streamHandler
, null);
76 runner
.setAntRun(project
);
77 runner
.setCommandline(commandLine
.getCommandline());
79 log(Commandline
.toString(commandLine
.getCommandline()), Project
.MSG_VERBOSE
);
80 log((new File(this.peFile
)).getName());
82 returnVal
= runner
.execute();
83 if (EFI_SUCCESS
== returnVal
) {
84 log("SetStamp succeeded!", Project
.MSG_VERBOSE
);
87 /// command execution fail
89 log("ERROR = " + Integer
.toHexString(returnVal
));
90 throw new BuildException("SetStamp failed!");
92 } catch (Exception e
) {
93 throw new BuildException(e
.getMessage());
98 set operation of class member "peFile"
100 @param peFile name of PE File
102 public void setPeFile(String peFile
) {
103 this.peFile
= " " + peFile
;
107 get operation of class member "peFile"
109 @return peFile name of PE file
111 public String
getPeFile() {
116 set operation of class member "timeFile"
118 @param timeFile name of time file
120 public void setTimeFile(String timeFile
) {
121 this.timeFile
= " " + timeFile
;
125 get class member "timeFile"
127 @returns name of time file
129 public String
getTimeFile() {
130 return this.timeFile
;