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
;
27 import org
.tianocore
.logger
.EdkLog
;
30 * GenTeImageTask class.
32 * GenTeImageTask is used to call GenAcpiTable.exe to generate ACPI Table image .
34 public class GenTeImageTask
extends Task
implements EfiDefine
{
38 private String toolName
= "GenTeImage";
42 private String inputFile
= "";
47 private String outputFile
= "";
50 /// output directory, this variable is added by jave wrap
52 private String outputDir
= "";
57 private String verbose
= "";
62 private String dump
= "";
65 * assemble tool command line & execute tool command line
67 * @throws BuildException
72 * GenTeImgaeTask execute function is to assemble tool command line & execute
75 * @throws BuidException
77 public void execute() throws BuildException
{
79 Project project
= this.getOwningTarget().getProject();
83 FrameworkLogger logger
= new FrameworkLogger(project
, toolName
.toLowerCase());
84 EdkLog
.setLogLevel(project
.getProperty("env.LOGLEVEL"));
85 EdkLog
.setLogger(logger
);
87 // absolute path of efi tools
89 String path
= project
.getProperty("env.FRAMEWORK_TOOLS_PATH");
95 command
= path
+ File
.separatorChar
+ toolName
;
100 File file
= new File(outputFile
);
101 if (!file
.isAbsolute() && (!this.outputDir
.equalsIgnoreCase(""))) {
102 argument
= this.verbose
+ this.dump
+ "-o " +this.outputDir
103 + File
.separatorChar
+ this.outputFile
+ " "
106 argument
= this.verbose
+ this.dump
+ "-o " + this.outputFile
107 + " " + this.inputFile
;
110 // return value of fwimage execution
115 Commandline cmdline
= new Commandline();
116 cmdline
.setExecutable(command
);
117 cmdline
.createArgument().setLine(argument
);
119 LogStreamHandler streamHandler
= new LogStreamHandler(this,
120 Project
.MSG_INFO
, Project
.MSG_WARN
);
121 Execute runner
= new Execute(streamHandler
, null);
123 runner
.setAntRun(project
);
124 runner
.setCommandline(cmdline
.getCommandline());
126 // Set debug log information.
128 EdkLog
.log(EdkLog
.EDK_INFO
, Commandline
.toString(cmdline
131 revl
= runner
.execute();
133 if (EFI_SUCCESS
== revl
) {
135 // command execution success
137 EdkLog
.log(EdkLog
.EDK_INFO
, "GenTeImage succeeded!");
140 // command execution fail
142 EdkLog
.log(EdkLog
.EDK_ERROR
, "GenTeImage failed. (error="
143 + Integer
.toHexString(revl
) + ")");
144 throw new BuildException("GenTeImage failed. (error="
145 + Integer
.toHexString(revl
) + ")");
148 } catch (Exception e
) {
149 throw new BuildException(e
.getMessage());
156 * This function is to get class member "inputFile".
158 * @return string of input file name.
160 public String
getInputFile() {
167 * This function is to set class member "inputFile".
170 * string of input file name.
172 public void setInputFile(String inputFile
) {
173 this.inputFile
= inputFile
;
179 * This function is to get class member "outputFile"
181 * @return outputFile string of output file name.
183 public String
getOutputFile() {
190 * This function is to set class member "outputFile"
193 * string of output file name.
195 public void setOutputFile(String outputFile
) {
196 this.outputFile
= outputFile
+ " ";
202 * This function is to get class member "outputDir"
204 * @return outputDir string of output directory.
206 public String
getOutputDir() {
213 * This function is to set class member "outputDir"
216 * string of output directory.
218 public void setOutputDir(String outputDir
) {
219 this.outputDir
= outputDir
;
225 * This function is to get class member "verbose"
227 * @return verbose the flag of verbose.
229 public String
getVerbose() {
236 * This function is to set class member "verbose"
241 public void setVerbose(boolean verbose
) {
243 this.verbose
= "-v ";
250 * This function is to get class member "dump"
252 * @return verbose the flag of dump.
254 public String
getDump() {
261 * This function is to set class member "dump"
266 public void setDump(boolean dump
) {
268 this.dump
= "-dump ";