]>
Commit | Line | Data |
---|---|---|
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 | |
17 | package org.tianocore.framework.tasks;\r | |
18 | \r | |
19 | import java.io.File;\r | |
20 | \r | |
21 | import org.apache.tools.ant.Task;\r | |
22 | import org.apache.tools.ant.Project;\r | |
23 | import org.apache.tools.ant.BuildException;\r | |
24 | import org.apache.tools.ant.taskdefs.Execute;\r | |
25 | import org.apache.tools.ant.taskdefs.LogStreamHandler;\r | |
26 | import org.apache.tools.ant.types.Commandline;\r | |
ff225cbb | 27 | \r |
28 | import 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 | |
35 | public 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 | |
ff225cbb | 54 | *\r |
a15bb0d3 | 55 | * ZeroDebugDataTask execute function is to assemble tool command line & execute\r |
56 | * tool command line\r | |
ff225cbb | 57 | *\r |
a15bb0d3 | 58 | * @throws BuidException\r |
59 | */\r | |
60 | public void execute() throws BuildException {\r | |
61 | \r | |
62 | Project project = this.getOwningTarget().getProject();\r | |
91f7d582 | 63 | \r |
a15bb0d3 | 64 | //\r |
65 | // absolute path of efi tools\r | |
66 | //\r | |
67 | String path = project.getProperty("env.FRAMEWORK_TOOLS_PATH");\r | |
68 | String command;\r | |
69 | String argument;\r | |
70 | if (path == null) {\r | |
71 | command = "ZeroDebugData";\r | |
72 | } else {\r | |
73 | command = path + File.separatorChar + "ZeroDebugData";\r | |
74 | }\r | |
75 | //\r | |
76 | // argument of tools\r | |
77 | //\r | |
78 | File file = new File(outputFile);\r | |
79 | if (!file.isAbsolute() && (!this.outputDir.equalsIgnoreCase(""))) {\r | |
80 | argument = this.peFile + " " + outputDir + File.separatorChar\r | |
81 | + outputFile;\r | |
82 | } else {\r | |
83 | argument = this.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 | //\r | |
102 | // Set debug log information.\r | |
103 | //\r | |
91f7d582 | 104 | EdkLog.log(this, EdkLog.EDK_VERBOSE, Commandline.toString(cmdline.getCommandline()));\r |
105 | EdkLog.log(this, EdkLog.EDK_INFO, (new File(this.peFile)).getName());\r | |
219e2247 | 106 | \r |
a15bb0d3 | 107 | revl = runner.execute();\r |
ff225cbb | 108 | \r |
a15bb0d3 | 109 | if (EFI_SUCCESS == revl) {\r |
110 | //\r | |
111 | // command execution success\r | |
112 | //\r | |
91f7d582 | 113 | EdkLog.log(this, EdkLog.EDK_VERBOSE, "ZeroDebugData succeeded!");\r |
a15bb0d3 | 114 | } else {\r |
115 | //\r | |
116 | // command execution fail\r | |
117 | //\r | |
91f7d582 | 118 | EdkLog.log(this, EdkLog.EDK_INFO, "ERROR = " + Integer.toHexString(revl));\r |
219e2247 | 119 | throw new BuildException("ZeroDebugData failed!");\r |
a15bb0d3 | 120 | \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 | |
ff225cbb | 129 | *\r |
a15bb0d3 | 130 | * This function is to get class member "inputFile".\r |
ff225cbb | 131 | *\r |
a15bb0d3 | 132 | * @return string of input file name.\r |
133 | */\r | |
134 | public String getPeFile() {\r | |
135 | return this.peFile;\r | |
136 | }\r | |
137 | \r | |
138 | /**\r | |
139 | * setPeFile\r | |
ff225cbb | 140 | *\r |
a15bb0d3 | 141 | * This function is to set class member "peFile".\r |
ff225cbb | 142 | *\r |
a15bb0d3 | 143 | * @param peFile\r |
144 | * string of input file name.\r | |
145 | */\r | |
146 | public void setPeFile(String peFile) {\r | |
147 | this.peFile = peFile;\r | |
148 | }\r | |
149 | \r | |
150 | /**\r | |
151 | * getOutputFile\r | |
ff225cbb | 152 | *\r |
a15bb0d3 | 153 | * This function is to get class member "outputFile"\r |
ff225cbb | 154 | *\r |
a15bb0d3 | 155 | * @return outputFile string of output file name.\r |
156 | */\r | |
157 | public String getOutputFile() {\r | |
158 | return outputFile;\r | |
159 | }\r | |
160 | \r | |
161 | /**\r | |
162 | * setOutputFile\r | |
ff225cbb | 163 | *\r |
a15bb0d3 | 164 | * This function is to set class member "outputFile"\r |
ff225cbb | 165 | *\r |
a15bb0d3 | 166 | * @param outputFile\r |
167 | * string of output file name.\r | |
168 | */\r | |
169 | public void setOutputFile(String outputFile) {\r | |
170 | this.outputFile = outputFile;\r | |
171 | }\r | |
172 | \r | |
173 | /**\r | |
174 | * getOutputDir\r | |
ff225cbb | 175 | *\r |
a15bb0d3 | 176 | * This function is to get class member "outputDir"\r |
ff225cbb | 177 | *\r |
a15bb0d3 | 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 | |
ff225cbb | 186 | *\r |
a15bb0d3 | 187 | * This function is to set class member "outputDir"\r |
ff225cbb | 188 | *\r |
a15bb0d3 | 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 |