]> git.proxmox.com Git - mirror_edk2.git/blame - Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/GenTeImageTask.java
Changed spelling to manifest
[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
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
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
ff225cbb 27\r
28import 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
35public class GenTeImageTask extends Task implements EfiDefine {\r
0fdb42ac 36 //\r
37 // tool name\r
38 //\r
a15bb0d3 39 private String toolName = "GenTeImage";\r
0fdb42ac 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
a15bb0d3 53 private String outputDir = "";\r
54\r
0fdb42ac 55 //\r
56 // Verbose flag\r
57 //\r
58 private ToolArg verbose = new ToolArg();\r
a15bb0d3 59\r
0fdb42ac 60 //\r
61 // Dump flag\r
62 //\r
63 private ToolArg dump = new ToolArg();\r
a15bb0d3 64\r
65 /**\r
0fdb42ac 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
a15bb0d3 73 public void execute() throws BuildException {\r
74\r
75 Project project = this.getOwningTarget().getProject();\r
76 //\r
a15bb0d3 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
0fdb42ac 85 command = path + File.separator + toolName;\r
a15bb0d3 86 }\r
87 //\r
88 // argument of tools\r
89 //\r
0fdb42ac 90 argument = "" + this.verbose + this.dump + this.outputFile + this.inputFile;\r
a15bb0d3 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
0fdb42ac 107 runner.setWorkingDirectory(new File(outputDir));\r
108\r
a15bb0d3 109 //\r
110 // Set debug log information.\r
111 //\r
91f7d582 112 EdkLog.log(this, EdkLog.EDK_VERBOSE, Commandline.toString(cmdline.getCommandline()));\r
0fdb42ac 113 EdkLog.log(this, EdkLog.EDK_INFO, this.inputFile.toFileList()\r
114 + " => " + this.outputFile.toFileList());\r
a15bb0d3 115\r
116 revl = runner.execute();\r
117\r
118 if (EFI_SUCCESS == revl) {\r
119 //\r
120 // command execution success\r
121 //\r
0fdb42ac 122 EdkLog.log(this, EdkLog.EDK_VERBOSE, toolName + " succeeded!");\r
a15bb0d3 123 } else {\r
124 //\r
125 // command execution fail\r
126 //\r
91f7d582 127 EdkLog.log(this, EdkLog.EDK_INFO, "ERROR = "+ Integer.toHexString(revl));\r
0fdb42ac 128 throw new BuildException(toolName + " failed!");\r
a15bb0d3 129 }\r
130 } catch (Exception e) {\r
131 throw new BuildException(e.getMessage());\r
132 }\r
133 }\r
134\r
135 /**\r
0fdb42ac 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
a15bb0d3 142 public String getInputFile() {\r
0fdb42ac 143 return inputFile.getValue();\r
a15bb0d3 144 }\r
145\r
146 /**\r
0fdb42ac 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
a15bb0d3 154 public void setInputFile(String inputFile) {\r
0fdb42ac 155 this.inputFile.setArg(" ", inputFile);\r
a15bb0d3 156 }\r
157\r
158 /**\r
0fdb42ac 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
a15bb0d3 165 public String getOutputFile() {\r
0fdb42ac 166 return outputFile.getValue();\r
a15bb0d3 167 }\r
168\r
169 /**\r
0fdb42ac 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
a15bb0d3 177 public void setOutputFile(String outputFile) {\r
0fdb42ac 178 this.outputFile.setArg(" -o ", outputFile);\r
a15bb0d3 179 }\r
180\r
181 /**\r
0fdb42ac 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
a15bb0d3 188 public String getOutputDir() {\r
189 return outputDir;\r
190 }\r
191\r
192 /**\r
0fdb42ac 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
a15bb0d3 200 public void setOutputDir(String outputDir) {\r
201 this.outputDir = outputDir;\r
202 }\r
203\r
204 /**\r
0fdb42ac 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
a15bb0d3 211 public String getVerbose() {\r
0fdb42ac 212 return this.verbose.getValue();\r
a15bb0d3 213 }\r
214\r
215 /**\r
0fdb42ac 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
a15bb0d3 223 public void setVerbose(boolean verbose) {\r
224 if (verbose) {\r
0fdb42ac 225 this.verbose.setArg(" -", "v");\r
a15bb0d3 226 }\r
227 }\r
228\r
229 /**\r
0fdb42ac 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
a15bb0d3 236 public String getDump() {\r
0fdb42ac 237 return dump.getValue();\r
a15bb0d3 238 }\r
239\r
240 /**\r
0fdb42ac 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
a15bb0d3 248 public void setDump(boolean dump) {\r
249 if (dump) {\r
0fdb42ac 250 this.dump.setArg(" -", "dump");\r
a15bb0d3 251 }\r
252 }\r
253}\r