]> git.proxmox.com Git - mirror_edk2.git/blob - Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/SetStampTask.java
Updated PeiRebase to produce a map file of the relocations done by this tool. This...
[mirror_edk2.git] / Tools / Source / FrameworkTasks / org / tianocore / framework / tasks / SetStampTask.java
1 /** @file
2 This file is to define an ANT task to wrap setstamp.exe tool
3
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
9
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.
12
13 **/
14 package org.tianocore.framework.tasks;
15
16 import java.io.File;
17
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;
24
25 /**
26 Class SetStampTask is a wrap class for setstamp.exe.
27 **/
28 public class SetStampTask extends Task implements EfiDefine {
29 /**
30 SetStamp Task Class
31 class member
32 -peFile : file of PE
33 -timeFile: Txt file of time
34 **/
35
36 private String peFile = "";
37
38 private String timeFile = "";
39
40 /**
41 assemble tool command line & execute tool command line
42
43 @throws BuildException
44 **/
45 public void execute() throws BuildException {
46
47 Project project = this.getOwningTarget().getProject();
48 ///
49 /// absolute path of edk tools
50 ///
51 String path = project.getProperty("env.FRAMEWORK_TOOLS_PATH");
52 String command;
53 if (path == null) {
54 command = "SetStamp";
55 } else {
56 command = path + "/" + "SetStamp";
57 }
58 ///
59 /// argument of SetStamp tool
60 ///
61 String argument = peFile + timeFile;
62 ///
63 /// reture value of SetStamp execution
64 ///
65 int returnVal = -1;
66
67 try {
68 Commandline commandLine = new Commandline();
69 commandLine.setExecutable(command);
70 commandLine.createArgument().setLine(argument);
71
72 LogStreamHandler streamHandler = new LogStreamHandler(this,
73 Project.MSG_INFO, Project.MSG_WARN);
74
75 Execute runner = new Execute(streamHandler, null);
76 runner.setAntRun(project);
77 runner.setCommandline(commandLine.getCommandline());
78
79 log(Commandline.toString(commandLine.getCommandline()), Project.MSG_VERBOSE);
80 log((new File(this.peFile)).getName());
81
82 returnVal = runner.execute();
83 if (EFI_SUCCESS == returnVal) {
84 log("SetStamp succeeded!", Project.MSG_VERBOSE);
85 } else {
86 ///
87 /// command execution fail
88 ///
89 log("ERROR = " + Integer.toHexString(returnVal));
90 throw new BuildException("SetStamp failed!");
91 }
92 } catch (Exception e) {
93 throw new BuildException(e.getMessage());
94 }
95 }
96
97 /**
98 set operation of class member "peFile"
99
100 @param peFile name of PE File
101 **/
102 public void setPeFile(String peFile) {
103 this.peFile = " " + peFile;
104 }
105
106 /**
107 get operation of class member "peFile"
108
109 @return peFile name of PE file
110 **/
111 public String getPeFile() {
112 return this.peFile;
113 }
114
115 /**
116 set operation of class member "timeFile"
117
118 @param timeFile name of time file
119 **/
120 public void setTimeFile(String timeFile) {
121 this.timeFile = " " + timeFile;
122 }
123
124 /**
125 get class member "timeFile"
126
127 @returns name of time file
128 **/
129 public String getTimeFile() {
130 return this.timeFile;
131 }
132
133 }