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
;
16 import org
.apache
.tools
.ant
.BuildException
;
17 import org
.apache
.tools
.ant
.Project
;
18 import org
.apache
.tools
.ant
.Task
;
19 import org
.apache
.tools
.ant
.taskdefs
.Execute
;
20 import org
.apache
.tools
.ant
.taskdefs
.LogStreamHandler
;
21 import org
.apache
.tools
.ant
.types
.Commandline
;
24 Class SetStampTask is a wrap class for setstamp.exe.
26 public class SetStampTask
extends Task
implements EfiDefine
{
31 -timeFile: Txt file of time
34 private String peFile
= "";
36 private String timeFile
= "";
39 assemble tool command line & execute tool command line
41 @throws BuildException
43 public void execute() throws BuildException
{
45 Project project
= this.getOwningTarget().getProject();
47 /// absolute path of edk tools
49 String path
= project
.getProperty("env.FRAMEWORK_TOOLS_PATH");
54 command
= path
+ "/" + "SetStamp";
57 /// argument of SetStamp tool
59 String argument
= peFile
+ timeFile
;
61 /// reture value of SetStamp execution
66 Commandline commandLine
= new Commandline();
67 commandLine
.setExecutable(command
);
68 commandLine
.createArgument().setLine(argument
);
70 LogStreamHandler streamHandler
= new LogStreamHandler(this,
71 Project
.MSG_INFO
, Project
.MSG_WARN
);
73 Execute runner
= new Execute(streamHandler
, null);
74 runner
.setAntRun(project
);
75 runner
.setCommandline(commandLine
.getCommandline());
77 System
.out
.println(Commandline
.toString(commandLine
80 returnVal
= runner
.execute();
81 if (EFI_SUCCESS
== returnVal
) {
83 /// command execution success
85 System
.out
.println("SetStamp execute succeeded!");
88 /// command execution fail
90 System
.out
.println("SetStamp failed. (error="
91 + Integer
.toHexString(returnVal
) + ")");
92 throw new BuildException("SetStamp failed. (error="
93 + Integer
.toHexString(returnVal
) + ")");
95 } catch (Exception e
) {
96 throw new BuildException(e
.getMessage());
101 set operation of class member "peFile"
103 @param peFile name of PE File
105 public void setPeFile(String peFile
) {
106 this.peFile
= " " + peFile
;
110 get operation of class member "peFile"
112 @return peFile name of PE file
114 public String
getPeFile() {
119 set operation of class member "timeFile"
121 @param timeFile name of time file
123 public void setTimeFile(String timeFile
) {
124 this.timeFile
= " " + timeFile
;
128 get class member "timeFile"
130 @returns name of time file
132 public String
getTimeFile() {
133 return this.timeFile
;