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