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