]> git.proxmox.com Git - mirror_edk2.git/blame_incremental - 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
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 // 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
54\r
55\r
56 /**\r
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
64 public void execute() throws BuildException {\r
65\r
66 Project project = this.getOwningTarget().getProject();\r
67\r
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
75 command = toolName;\r
76 } else {\r
77 command = path + File.separatorChar + toolName;\r
78 }\r
79\r
80 //\r
81 // argument of tools\r
82 //\r
83 argument = "" + peFile + outputFile;\r
84\r
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
101 runner.setWorkingDirectory(new File(outputDir)); \r
102 //\r
103 // Set debug log information.\r
104 //\r
105 EdkLog.log(this, EdkLog.EDK_VERBOSE, Commandline.toString(cmdline.getCommandline()));\r
106 EdkLog.log(this, EdkLog.EDK_INFO, peFile.toFileList() + " => " + outputFile.toFileList());\r
107\r
108 revl = runner.execute();\r
109\r
110 if (EFI_SUCCESS == revl) {\r
111 //\r
112 // command execution success\r
113 //\r
114 EdkLog.log(this, EdkLog.EDK_VERBOSE, "ZeroDebugData succeeded!");\r
115 } else {\r
116 //\r
117 // command execution fail\r
118 //\r
119 EdkLog.log(this, EdkLog.EDK_INFO, "ERROR = " + Integer.toHexString(revl));\r
120 throw new BuildException("ZeroDebugData failed!");\r
121 }\r
122 } catch (Exception e) {\r
123 throw new BuildException(e.getMessage());\r
124 }\r
125 }\r
126\r
127 /**\r
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
134 public String getPeFile() {\r
135 return this.peFile.getValue();\r
136 }\r
137\r
138 /**\r
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
146 public void setPeFile(String peFile) {\r
147 this.peFile.setArg(" ", peFile);\r
148 }\r
149\r
150 /**\r
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
157 public String getOutputFile() {\r
158 return this.outputFile.getValue();\r
159 }\r
160\r
161 /**\r
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
169 public void setOutputFile(String outputFile) {\r
170 this.outputFile.setArg(" ", outputFile);\r
171 }\r
172\r
173 /**\r
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
180 public String getOutputDir() {\r
181 return outputDir;\r
182 }\r
183\r
184 /**\r
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
192 public void setOutputDir(String outputDir) {\r
193 this.outputDir = outputDir;\r
194 }\r
195}\r