]> git.proxmox.com Git - mirror_edk2.git/blame - Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/GenTeImageTask.java
Add follows warpped tianotools to frameworktask:
[mirror_edk2.git] / Tools / Source / FrameworkTasks / org / tianocore / framework / tasks / GenTeImageTask.java
CommitLineData
a15bb0d3 1/** @file\r
2 GenTeImageTask class.\r
3\r
4 GenTeImageTask is used to call GenTEImage.exe to generate TE image .\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
27import org.tianocore.logger.EdkLog;\r
28\r
29/**\r
30 * GenTeImageTask class.\r
31 * \r
32 * GenTeImageTask is used to call GenAcpiTable.exe to generate ACPI Table image .\r
33 */\r
34public class GenTeImageTask extends Task implements EfiDefine {\r
35 ///\r
36 /// tool name\r
37 ///\r
38 private String toolName = "GenTeImage";\r
39 ///\r
40 /// input file\r
41 ///\r
42 private String inputFile = "";\r
43\r
44 ///\r
45 /// output file\r
46 ///\r
47 private String outputFile = "";\r
48\r
49 ///\r
50 /// output directory, this variable is added by jave wrap\r
51 ///\r
52 private String outputDir = "";\r
53\r
54 ///\r
55 /// Verbose flag\r
56 ///\r
57 private String verbose = "";\r
58\r
59 ///\r
60 /// Dump flag\r
61 ///\r
62 private String dump = "";\r
63\r
64 /**\r
65 * assemble tool command line & execute tool command line\r
66 * \r
67 * @throws BuildException\r
68 */\r
69 /**\r
70 * execute\r
71 * \r
72 * GenTeImgaeTask execute function is to assemble tool command line & execute\r
73 * tool command line\r
74 * \r
75 * @throws BuidException\r
76 */\r
77 public void execute() throws BuildException {\r
78\r
79 Project project = this.getOwningTarget().getProject();\r
80 //\r
81 // set Logger\r
82 //\r
83 FrameworkLogger logger = new FrameworkLogger(project, toolName.toLowerCase());\r
84 EdkLog.setLogLevel(project.getProperty("env.LOGLEVEL"));\r
85 EdkLog.setLogger(logger);\r
86 //\r
87 // absolute path of efi tools\r
88 //\r
89 String path = project.getProperty("env.FRAMEWORK_TOOLS_PATH");\r
90 String command;\r
91 String argument;\r
92 if (path == null) {\r
93 command = toolName;\r
94 } else {\r
95 command = path + File.separatorChar + toolName;\r
96 }\r
97 //\r
98 // argument of tools\r
99 //\r
100 File file = new File(outputFile);\r
101 if (!file.isAbsolute() && (!this.outputDir.equalsIgnoreCase(""))) {\r
102 argument = this.verbose + this.dump + "-o " +this.outputDir\r
103 + File.separatorChar + this.outputFile + " "\r
104 + this.inputFile;\r
105 } else {\r
106 argument = this.verbose + this.dump + "-o " + this.outputFile\r
107 + " " + this.inputFile;\r
108 }\r
109 //\r
110 // return value of fwimage execution\r
111 //\r
112 int revl = -1;\r
113\r
114 try {\r
115 Commandline cmdline = new Commandline();\r
116 cmdline.setExecutable(command);\r
117 cmdline.createArgument().setLine(argument);\r
118\r
119 LogStreamHandler streamHandler = new LogStreamHandler(this,\r
120 Project.MSG_INFO, Project.MSG_WARN);\r
121 Execute runner = new Execute(streamHandler, null);\r
122\r
123 runner.setAntRun(project);\r
124 runner.setCommandline(cmdline.getCommandline());\r
125 //\r
126 // Set debug log information.\r
127 //\r
128 EdkLog.log(EdkLog.EDK_INFO, Commandline.toString(cmdline\r
129 .getCommandline()));\r
130\r
131 revl = runner.execute();\r
132\r
133 if (EFI_SUCCESS == revl) {\r
134 //\r
135 // command execution success\r
136 //\r
137 EdkLog.log(EdkLog.EDK_INFO, "GenTeImage succeeded!");\r
138 } else {\r
139 //\r
140 // command execution fail\r
141 //\r
142 EdkLog.log(EdkLog.EDK_ERROR, "GenTeImage failed. (error="\r
143 + Integer.toHexString(revl) + ")");\r
144 throw new BuildException("GenTeImage failed. (error="\r
145 + Integer.toHexString(revl) + ")");\r
146\r
147 }\r
148 } catch (Exception e) {\r
149 throw new BuildException(e.getMessage());\r
150 }\r
151 }\r
152\r
153 /**\r
154 * getInputFile\r
155 * \r
156 * This function is to get class member "inputFile".\r
157 * \r
158 * @return string of input file name.\r
159 */\r
160 public String getInputFile() {\r
161 return inputFile;\r
162 }\r
163\r
164 /**\r
165 * setComponentType\r
166 * \r
167 * This function is to set class member "inputFile".\r
168 * \r
169 * @param inputFile\r
170 * string of input file name.\r
171 */\r
172 public void setInputFile(String inputFile) {\r
173 this.inputFile = inputFile;\r
174 }\r
175\r
176 /**\r
177 * getOutputFile\r
178 * \r
179 * This function is to get class member "outputFile"\r
180 * \r
181 * @return outputFile string of output file name.\r
182 */\r
183 public String getOutputFile() {\r
184 return outputFile;\r
185 }\r
186\r
187 /**\r
188 * setOutputFile\r
189 * \r
190 * This function is to set class member "outputFile"\r
191 * \r
192 * @param outputFile\r
193 * string of output file name.\r
194 */\r
195 public void setOutputFile(String outputFile) {\r
196 this.outputFile = outputFile + " ";\r
197 }\r
198\r
199 /**\r
200 * getOutputDir\r
201 * \r
202 * This function is to get class member "outputDir"\r
203 * \r
204 * @return outputDir string of output directory.\r
205 */\r
206 public String getOutputDir() {\r
207 return outputDir;\r
208 }\r
209\r
210 /**\r
211 * setOutputDir\r
212 * \r
213 * This function is to set class member "outputDir"\r
214 * \r
215 * @param outputDir\r
216 * string of output directory.\r
217 */\r
218 public void setOutputDir(String outputDir) {\r
219 this.outputDir = outputDir;\r
220 }\r
221\r
222 /**\r
223 * getVerbose\r
224 * \r
225 * This function is to get class member "verbose"\r
226 * \r
227 * @return verbose the flag of verbose.\r
228 */\r
229 public String getVerbose() {\r
230 return this.verbose;\r
231 }\r
232\r
233 /**\r
234 * setVerbose\r
235 * \r
236 * This function is to set class member "verbose"\r
237 * \r
238 * @param verbose\r
239 * True or False.\r
240 */\r
241 public void setVerbose(boolean verbose) {\r
242 if (verbose) {\r
243 this.verbose = "-v ";\r
244 }\r
245 }\r
246\r
247 /**\r
248 * getDump\r
249 * \r
250 * This function is to get class member "dump"\r
251 * \r
252 * @return verbose the flag of dump.\r
253 */\r
254 public String getDump() {\r
255 return dump;\r
256 }\r
257\r
258 /**\r
259 * setDump\r
260 * \r
261 * This function is to set class member "dump"\r
262 * \r
263 * @param dump\r
264 * True or False.\r
265 */\r
266 public void setDump(boolean dump) {\r
267 if (dump) {\r
268 this.dump = "-dump ";\r
269 }\r
270 }\r
271}\r