]> git.proxmox.com Git - mirror_edk2.git/blob - Tools/Java/Source/FrameworkTasks/org/tianocore/framework/tasks/ZeroDebugDataTask.java
Restructuring for better separation of Tool packages.
[mirror_edk2.git] / Tools / Java / 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
28 import org.tianocore.common.logger.EdkLog;
29
30 /**
31 ZeroDebugDataTask class.
32
33 ZeroDebugDataTask is used to call ZeroDebugData.exe to remove debug data.
34 **/
35 public class ZeroDebugDataTask extends Task implements EfiDefine {
36 //
37 // Tool name
38 //
39 private static String toolName = "ZeroDebugData";
40 //
41 // input PE file
42 //
43 private FileArg peFile = new FileArg();
44
45 //
46 // output file
47 //
48 private FileArg outputFile = new FileArg(" ", "DebugData.dat");
49
50 //
51 // output directory, this variable is added by jave wrap
52 //
53 private String outputDir = ".";
54
55
56 /**
57 execute
58
59 ZeroDebugDataTask execute function is to assemble tool command line & execute
60 tool command line
61
62 @throws BuidException
63 **/
64 public void execute() throws BuildException {
65
66 Project project = this.getOwningTarget().getProject();
67
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 = toolName;
76 } else {
77 command = path + File.separatorChar + toolName;
78 }
79
80 //
81 // argument of tools
82 //
83 argument = "" + peFile + outputFile;
84
85 //
86 // return value of fwimage execution
87 //
88 int revl = -1;
89
90 try {
91 Commandline cmdline = new Commandline();
92 cmdline.setExecutable(command);
93 cmdline.createArgument().setLine(argument);
94
95 LogStreamHandler streamHandler = new LogStreamHandler(this,
96 Project.MSG_INFO, Project.MSG_WARN);
97 Execute runner = new Execute(streamHandler, null);
98
99 runner.setAntRun(project);
100 runner.setCommandline(cmdline.getCommandline());
101 runner.setWorkingDirectory(new File(outputDir));
102 //
103 // Set debug log information.
104 //
105 EdkLog.log(this, EdkLog.EDK_VERBOSE, Commandline.toString(cmdline.getCommandline()));
106 EdkLog.log(this, EdkLog.EDK_INFO, peFile.toFileList() + " => " + outputFile.toFileList());
107
108 revl = runner.execute();
109
110 if (EFI_SUCCESS == revl) {
111 //
112 // command execution success
113 //
114 EdkLog.log(this, EdkLog.EDK_VERBOSE, "ZeroDebugData succeeded!");
115 } else {
116 //
117 // command execution fail
118 //
119 EdkLog.log(this, EdkLog.EDK_INFO, "ERROR = " + Integer.toHexString(revl));
120 throw new BuildException("ZeroDebugData failed!");
121 }
122 } catch (Exception e) {
123 throw new BuildException(e.getMessage());
124 }
125 }
126
127 /**
128 getPeFile
129
130 This function is to get class member "inputFile".
131
132 @return string of input file name.
133 **/
134 public String getPeFile() {
135 return this.peFile.getValue();
136 }
137
138 /**
139 setPeFile
140
141 This function is to set class member "peFile".
142
143 @param peFile
144 string of input file name.
145 **/
146 public void setPeFile(String peFile) {
147 this.peFile.setArg(" ", peFile);
148 }
149
150 /**
151 getOutputFile
152
153 This function is to get class member "outputFile"
154
155 @return outputFile string of output file name.
156 **/
157 public String getOutputFile() {
158 return this.outputFile.getValue();
159 }
160
161 /**
162 setOutputFile
163
164 This function is to set class member "outputFile"
165
166 @param outputFile
167 string of output file name.
168 **/
169 public void setOutputFile(String outputFile) {
170 this.outputFile.setArg(" ", outputFile);
171 }
172
173 /**
174 getOutputDir
175
176 This function is to get class member "outputDir"
177
178 @return outputDir string of output directory.
179 **/
180 public String getOutputDir() {
181 return outputDir;
182 }
183
184 /**
185 setOutputDir
186
187 This function is to set class member "outputDir"
188
189 @param outputDir
190 string of output directory.
191 **/
192 public void setOutputDir(String outputDir) {
193 this.outputDir = outputDir;
194 }
195 }