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