]> git.proxmox.com Git - mirror_edk2.git/blob - Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/ZeroDebugDataTask.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 / ZeroDebugDataTask.java
1 /** @file
2 ZeroDebugDataTask class.
3
4 ZeroDebugDataTask is used to call ZeroDebugData.exe to remove debug data.
5
6
7 Copyright (c) 2006, Intel Corporation
8 All rights reserved. This program and the accompanying materials
9 are licensed and made available under the terms and conditions of the BSD License
10 which accompanies this distribution. The full text of the license may be found at
11 http://opensource.org/licenses/bsd-license.php
12
13 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
14 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
15
16 **/
17 package org.tianocore.framework.tasks;
18
19 import java.io.File;
20
21 import org.apache.tools.ant.Task;
22 import org.apache.tools.ant.Project;
23 import org.apache.tools.ant.BuildException;
24 import org.apache.tools.ant.taskdefs.Execute;
25 import org.apache.tools.ant.taskdefs.LogStreamHandler;
26 import org.apache.tools.ant.types.Commandline;
27 import org.tianocore.logger.EdkLog;
28
29 /**
30 ZeroDebugDataTask class.
31
32 ZeroDebugDataTask is used to call ZeroDebugData.exe to remove debug data.
33 **/
34 public class ZeroDebugDataTask extends Task implements EfiDefine {
35 // /
36 // / input PE file
37 // /
38 private String peFile = "";
39
40 // /
41 // / output file
42 // /
43 private String outputFile = "DebugData.dat";
44
45 // /
46 // / output directory, this variable is added by jave wrap
47 // /
48 private String outputDir = "";
49
50
51 /**
52 * execute
53 *
54 * ZeroDebugDataTask execute function is to assemble tool command line & execute
55 * tool command line
56 *
57 * @throws BuidException
58 */
59 public void execute() throws BuildException {
60
61 Project project = this.getOwningTarget().getProject();
62 //
63 // set Logger
64 //
65 FrameworkLogger logger = new FrameworkLogger(project, "zerodebugdata");
66 EdkLog.setLogLevel(project.getProperty("env.LOGLEVEL"));
67 EdkLog.setLogger(logger);
68 //
69 // absolute path of efi tools
70 //
71 String path = project.getProperty("env.FRAMEWORK_TOOLS_PATH");
72 String command;
73 String argument;
74 if (path == null) {
75 command = "ZeroDebugData";
76 } else {
77 command = path + File.separatorChar + "ZeroDebugData";
78 }
79 //
80 // argument of tools
81 //
82 File file = new File(outputFile);
83 if (!file.isAbsolute() && (!this.outputDir.equalsIgnoreCase(""))) {
84 argument = this.peFile + " " + outputDir + File.separatorChar
85 + outputFile;
86 } else {
87 argument = this.peFile + " " + outputFile;
88 }
89 //
90 // return value of fwimage execution
91 //
92 int revl = -1;
93
94 try {
95 Commandline cmdline = new Commandline();
96 cmdline.setExecutable(command);
97 cmdline.createArgument().setLine(argument);
98
99 LogStreamHandler streamHandler = new LogStreamHandler(this,
100 Project.MSG_INFO, Project.MSG_WARN);
101 Execute runner = new Execute(streamHandler, null);
102
103 runner.setAntRun(project);
104 runner.setCommandline(cmdline.getCommandline());
105 //
106 // Set debug log information.
107 //
108 EdkLog.log(EdkLog.EDK_VERBOSE, Commandline.toString(cmdline.getCommandline()));
109 EdkLog.log(EdkLog.EDK_INFO, (new File(this.peFile)).getName());
110
111 revl = runner.execute();
112
113 if (EFI_SUCCESS == revl) {
114 //
115 // command execution success
116 //
117 EdkLog.log(EdkLog.EDK_VERBOSE, "ZeroDebugData succeeded!");
118 } else {
119 //
120 // command execution fail
121 //
122 EdkLog.log(EdkLog.EDK_INFO, "ERROR = " + Integer.toHexString(revl));
123 throw new BuildException("ZeroDebugData failed!");
124
125 }
126 } catch (Exception e) {
127 throw new BuildException(e.getMessage());
128 }
129 }
130
131 /**
132 * getPeFile
133 *
134 * This function is to get class member "inputFile".
135 *
136 * @return string of input file name.
137 */
138 public String getPeFile() {
139 return this.peFile;
140 }
141
142 /**
143 * setPeFile
144 *
145 * This function is to set class member "peFile".
146 *
147 * @param peFile
148 * string of input file name.
149 */
150 public void setPeFile(String peFile) {
151 this.peFile = peFile;
152 }
153
154 /**
155 * getOutputFile
156 *
157 * This function is to get class member "outputFile"
158 *
159 * @return outputFile string of output file name.
160 */
161 public String getOutputFile() {
162 return outputFile;
163 }
164
165 /**
166 * setOutputFile
167 *
168 * This function is to set class member "outputFile"
169 *
170 * @param outputFile
171 * string of output file name.
172 */
173 public void setOutputFile(String outputFile) {
174 this.outputFile = outputFile;
175 }
176
177 /**
178 * getOutputDir
179 *
180 * This function is to get class member "outputDir"
181 *
182 * @return outputDir string of output directory.
183 */
184 public String getOutputDir() {
185 return outputDir;
186 }
187
188 /**
189 * setOutputDir
190 *
191 * This function is to set class member "outputDir"
192 *
193 * @param outputDir
194 * string of output directory.
195 */
196 public void setOutputDir(String outputDir) {
197 this.outputDir = outputDir;
198 }
199 }