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();
82 // absolute path of efi tools
84 String path
= project
.getProperty("env.FRAMEWORK_TOOLS_PATH");
90 command
= path
+ File
.separatorChar
+ toolName
;
95 File file
= new File(outputFile
);
96 if (!file
.isAbsolute() && (!this.outputDir
.equalsIgnoreCase(""))) {
97 argument
= this.verbose
+ this.dump
+ "-o " +this.outputDir
98 + File
.separatorChar
+ this.outputFile
+ " "
101 argument
= this.verbose
+ this.dump
+ "-o " + this.outputFile
102 + " " + this.inputFile
;
105 // return value of fwimage execution
110 Commandline cmdline
= new Commandline();
111 cmdline
.setExecutable(command
);
112 cmdline
.createArgument().setLine(argument
);
114 LogStreamHandler streamHandler
= new LogStreamHandler(this,
115 Project
.MSG_INFO
, Project
.MSG_WARN
);
116 Execute runner
= new Execute(streamHandler
, null);
118 runner
.setAntRun(project
);
119 runner
.setCommandline(cmdline
.getCommandline());
121 // Set debug log information.
123 EdkLog
.log(this, EdkLog
.EDK_VERBOSE
, Commandline
.toString(cmdline
.getCommandline()));
124 EdkLog
.log(this, EdkLog
.EDK_INFO
, (new File(this.inputFile
)).getName());
126 revl
= runner
.execute();
128 if (EFI_SUCCESS
== revl
) {
130 // command execution success
132 EdkLog
.log(this, EdkLog
.EDK_VERBOSE
, "GenTeImage succeeded!");
135 // command execution fail
137 EdkLog
.log(this, EdkLog
.EDK_INFO
, "ERROR = "+ Integer
.toHexString(revl
));
138 throw new BuildException("GenTeImage failed!");
140 } catch (Exception e
) {
141 throw new BuildException(e
.getMessage());
148 * This function is to get class member "inputFile".
150 * @return string of input file name.
152 public String
getInputFile() {
159 * This function is to set class member "inputFile".
162 * string of input file name.
164 public void setInputFile(String inputFile
) {
165 this.inputFile
= inputFile
;
171 * This function is to get class member "outputFile"
173 * @return outputFile string of output file name.
175 public String
getOutputFile() {
182 * This function is to set class member "outputFile"
185 * string of output file name.
187 public void setOutputFile(String outputFile
) {
188 this.outputFile
= outputFile
+ " ";
194 * This function is to get class member "outputDir"
196 * @return outputDir string of output directory.
198 public String
getOutputDir() {
205 * This function is to set class member "outputDir"
208 * string of output directory.
210 public void setOutputDir(String outputDir
) {
211 this.outputDir
= outputDir
;
217 * This function is to get class member "verbose"
219 * @return verbose the flag of verbose.
221 public String
getVerbose() {
228 * This function is to set class member "verbose"
233 public void setVerbose(boolean verbose
) {
235 this.verbose
= "-v ";
242 * This function is to get class member "dump"
244 * @return verbose the flag of dump.
246 public String
getDump() {
253 * This function is to set class member "dump"
258 public void setDump(boolean dump
) {
260 this.dump
= "-dump ";