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