4 GenTeImageTask is used to call GenTEImage.exe to generate TE image .
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
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.
17 package org
.tianocore
.framework
.tasks
;
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
;
28 import org
.tianocore
.common
.logger
.EdkLog
;
31 * GenTeImageTask class.
33 * GenTeImageTask is used to call GenAcpiTable.exe to generate ACPI Table image .
35 public class GenTeImageTask
extends Task
implements EfiDefine
{
39 private String toolName
= "GenTeImage";
43 private String inputFile
= "";
48 private String outputFile
= "";
51 /// output directory, this variable is added by jave wrap
53 private String outputDir
= "";
58 private String verbose
= "";
63 private String dump
= "";
66 * assemble tool command line & execute tool command line
68 * @throws BuildException
73 * GenTeImgaeTask execute function is to assemble tool command line & execute
76 * @throws BuidException
78 public void execute() throws BuildException
{
80 Project project
= this.getOwningTarget().getProject();
84 FrameworkLogger logger
= new FrameworkLogger(project
, toolName
.toLowerCase());
85 EdkLog
.setLogLevel(project
.getProperty("env.LOGLEVEL"));
86 EdkLog
.setLogger(logger
);
88 // absolute path of efi tools
90 String path
= project
.getProperty("env.FRAMEWORK_TOOLS_PATH");
96 command
= path
+ File
.separatorChar
+ toolName
;
101 File file
= new File(outputFile
);
102 if (!file
.isAbsolute() && (!this.outputDir
.equalsIgnoreCase(""))) {
103 argument
= this.verbose
+ this.dump
+ "-o " +this.outputDir
104 + File
.separatorChar
+ this.outputFile
+ " "
107 argument
= this.verbose
+ this.dump
+ "-o " + this.outputFile
108 + " " + this.inputFile
;
111 // return value of fwimage execution
116 Commandline cmdline
= new Commandline();
117 cmdline
.setExecutable(command
);
118 cmdline
.createArgument().setLine(argument
);
120 LogStreamHandler streamHandler
= new LogStreamHandler(this,
121 Project
.MSG_INFO
, Project
.MSG_WARN
);
122 Execute runner
= new Execute(streamHandler
, null);
124 runner
.setAntRun(project
);
125 runner
.setCommandline(cmdline
.getCommandline());
127 // Set debug log information.
129 EdkLog
.log(EdkLog
.EDK_VERBOSE
, Commandline
.toString(cmdline
.getCommandline()));
130 EdkLog
.log(EdkLog
.EDK_INFO
, (new File(this.inputFile
)).getName());
132 revl
= runner
.execute();
134 if (EFI_SUCCESS
== revl
) {
136 // command execution success
138 EdkLog
.log(EdkLog
.EDK_VERBOSE
, "GenTeImage succeeded!");
141 // command execution fail
143 EdkLog
.log(EdkLog
.EDK_INFO
, "ERROR = "+ Integer
.toHexString(revl
));
144 throw new BuildException("GenTeImage failed!");
146 } catch (Exception e
) {
147 throw new BuildException(e
.getMessage());
154 * This function is to get class member "inputFile".
156 * @return string of input file name.
158 public String
getInputFile() {
165 * This function is to set class member "inputFile".
168 * string of input file name.
170 public void setInputFile(String inputFile
) {
171 this.inputFile
= inputFile
;
177 * This function is to get class member "outputFile"
179 * @return outputFile string of output file name.
181 public String
getOutputFile() {
188 * This function is to set class member "outputFile"
191 * string of output file name.
193 public void setOutputFile(String outputFile
) {
194 this.outputFile
= outputFile
+ " ";
200 * This function is to get class member "outputDir"
202 * @return outputDir string of output directory.
204 public String
getOutputDir() {
211 * This function is to set class member "outputDir"
214 * string of output directory.
216 public void setOutputDir(String outputDir
) {
217 this.outputDir
= outputDir
;
223 * This function is to get class member "verbose"
225 * @return verbose the flag of verbose.
227 public String
getVerbose() {
234 * This function is to set class member "verbose"
239 public void setVerbose(boolean verbose
) {
241 this.verbose
= "-v ";
248 * This function is to get class member "dump"
250 * @return verbose the flag of dump.
252 public String
getDump() {
259 * This function is to set class member "dump"
264 public void setDump(boolean dump
) {
266 this.dump
= "-dump ";