]> git.proxmox.com Git - mirror_edk2.git/blob - Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/GenTeImageTask.java
Remove dependence check of FD upon FlashMap.fdf
[mirror_edk2.git] / Tools / Source / FrameworkTasks / org / tianocore / framework / tasks / GenTeImageTask.java
1 /** @file
2 GenTeImageTask class.
3
4 GenTeImageTask is used to call GenTEImage.exe to generate TE image .
5
6
7 Copyright (c) 2006, Intel Corporation
8 All rights reserved. This program and the accompanying materials
9 are licensed and made available under the terms and conditions of the BSD License
10 which accompanies this distribution. The full text of the license may be found at
11 http://opensource.org/licenses/bsd-license.php
12
13 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
14 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
15
16 **/
17 package org.tianocore.framework.tasks;
18
19 import java.io.File;
20
21 import org.apache.tools.ant.Task;
22 import org.apache.tools.ant.Project;
23 import org.apache.tools.ant.BuildException;
24 import org.apache.tools.ant.taskdefs.Execute;
25 import org.apache.tools.ant.taskdefs.LogStreamHandler;
26 import org.apache.tools.ant.types.Commandline;
27
28 import org.tianocore.common.logger.EdkLog;
29
30 /**
31 * GenTeImageTask class.
32 *
33 * GenTeImageTask is used to call GenAcpiTable.exe to generate ACPI Table image .
34 */
35 public class GenTeImageTask extends Task implements EfiDefine {
36 //
37 // tool name
38 //
39 private String toolName = "GenTeImage";
40 //
41 // input file
42 //
43 private FileArg inputFile = new FileArg();
44
45 //
46 // output file
47 //
48 private FileArg outputFile = new FileArg();
49
50 //
51 // output directory, this variable is added by jave wrap
52 //
53 private String outputDir = "";
54
55 //
56 // Verbose flag
57 //
58 private ToolArg verbose = new ToolArg();
59
60 //
61 // Dump flag
62 //
63 private ToolArg dump = new ToolArg();
64
65 /**
66 execute
67
68 GenTeImgaeTask execute function is to assemble tool command line & execute
69 tool command line
70
71 @throws BuidException
72 **/
73 public void execute() throws BuildException {
74
75 Project project = this.getOwningTarget().getProject();
76 //
77 // absolute path of efi tools
78 //
79 String path = project.getProperty("env.FRAMEWORK_TOOLS_PATH");
80 String command;
81 String argument;
82 if (path == null) {
83 command = toolName;
84 } else {
85 command = path + File.separator + toolName;
86 }
87 //
88 // argument of tools
89 //
90 argument = "" + this.verbose + this.dump + this.outputFile + this.inputFile;
91 //
92 // return value of fwimage execution
93 //
94 int revl = -1;
95
96 try {
97 Commandline cmdline = new Commandline();
98 cmdline.setExecutable(command);
99 cmdline.createArgument().setLine(argument);
100
101 LogStreamHandler streamHandler = new LogStreamHandler(this,
102 Project.MSG_INFO, Project.MSG_WARN);
103 Execute runner = new Execute(streamHandler, null);
104
105 runner.setAntRun(project);
106 runner.setCommandline(cmdline.getCommandline());
107 runner.setWorkingDirectory(new File(outputDir));
108
109 //
110 // Set debug log information.
111 //
112 EdkLog.log(this, EdkLog.EDK_VERBOSE, Commandline.toString(cmdline.getCommandline()));
113 EdkLog.log(this, EdkLog.EDK_INFO, this.inputFile.toFileList()
114 + " => " + this.outputFile.toFileList());
115
116 revl = runner.execute();
117
118 if (EFI_SUCCESS == revl) {
119 //
120 // command execution success
121 //
122 EdkLog.log(this, EdkLog.EDK_VERBOSE, toolName + " succeeded!");
123 } else {
124 //
125 // command execution fail
126 //
127 EdkLog.log(this, EdkLog.EDK_INFO, "ERROR = "+ Integer.toHexString(revl));
128 throw new BuildException(toolName + " failed!");
129 }
130 } catch (Exception e) {
131 throw new BuildException(e.getMessage());
132 }
133 }
134
135 /**
136 getInputFile
137
138 This function is to get class member "inputFile".
139
140 @return string of input file name.
141 **/
142 public String getInputFile() {
143 return inputFile.getValue();
144 }
145
146 /**
147 setComponentType
148
149 This function is to set class member "inputFile".
150
151 @param inputFile
152 string of input file name.
153 **/
154 public void setInputFile(String inputFile) {
155 this.inputFile.setArg(" ", inputFile);
156 }
157
158 /**
159 getOutputFile
160
161 This function is to get class member "outputFile"
162
163 @return outputFile string of output file name.
164 **/
165 public String getOutputFile() {
166 return outputFile.getValue();
167 }
168
169 /**
170 setOutputFile
171
172 This function is to set class member "outputFile"
173
174 @param outputFile
175 string of output file name.
176 **/
177 public void setOutputFile(String outputFile) {
178 this.outputFile.setArg(" -o ", outputFile);
179 }
180
181 /**
182 getOutputDir
183
184 This function is to get class member "outputDir"
185
186 @return outputDir string of output directory.
187 **/
188 public String getOutputDir() {
189 return outputDir;
190 }
191
192 /**
193 setOutputDir
194
195 This function is to set class member "outputDir"
196
197 @param outputDir
198 string of output directory.
199 **/
200 public void setOutputDir(String outputDir) {
201 this.outputDir = outputDir;
202 }
203
204 /**
205 getVerbose
206
207 This function is to get class member "verbose"
208
209 @return verbose the flag of verbose.
210 **/
211 public String getVerbose() {
212 return this.verbose.getValue();
213 }
214
215 /**
216 setVerbose
217
218 This function is to set class member "verbose"
219
220 @param verbose
221 True or False.
222 **/
223 public void setVerbose(boolean verbose) {
224 if (verbose) {
225 this.verbose.setArg(" -", "v");
226 }
227 }
228
229 /**
230 getDump
231
232 This function is to get class member "dump"
233
234 @return verbose the flag of dump.
235 **/
236 public String getDump() {
237 return dump.getValue();
238 }
239
240 /**
241 setDump
242
243 This function is to set class member "dump"
244
245 @param dump
246 True or False.
247 **/
248 public void setDump(boolean dump) {
249 if (dump) {
250 this.dump.setArg(" -", "dump");
251 }
252 }
253 }