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