4 FwImageTask is used to call FwImage.ext to generate the FwImage.
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
.BuildException
;
22 import org
.apache
.tools
.ant
.Project
;
23 import org
.apache
.tools
.ant
.Task
;
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
;
33 FwImageTask is used to call FwImage.ext to generate the FwImage.
35 public class FwImageTask
extends Task
implements EfiDefine
{
39 private static String toolName
= "FwImage";
43 private ToolArg time
= new ToolArg();
47 private FileArg peImage
= new FileArg();
51 private FileArg outImage
= new FileArg();
55 private ToolArg componentType
= new ToolArg();
58 * assemble tool command line & execute tool command line
60 * @throws BuildException
65 FwimageTask execute function is to assemble tool command line & execute
70 public void execute() throws BuildException
{
72 Project project
= this.getOwningTarget().getProject();
74 // absolute path of efi tools
76 String path
= project
.getProperty("env.FRAMEWORK_TOOLS_PATH");
81 command
= path
+ "/" + toolName
;
86 String argument
= "" + time
+ componentType
+ peImage
+ outImage
;
88 // return value of fwimage execution
93 Commandline cmdline
= new Commandline();
94 cmdline
.setExecutable(command
);
95 cmdline
.createArgument().setLine(argument
);
97 LogStreamHandler streamHandler
= new LogStreamHandler(this,
98 Project
.MSG_INFO
, Project
.MSG_WARN
);
99 Execute runner
= new Execute(streamHandler
, null);
101 runner
.setAntRun(project
);
102 runner
.setCommandline(cmdline
.getCommandline());
104 EdkLog
.log(this, EdkLog
.EDK_VERBOSE
, Commandline
.toString(cmdline
.getCommandline()));
105 EdkLog
.log(this, peImage
.toFileList() + " => " + outImage
.toFileList());
107 revl
= runner
.execute();
108 if (EFI_SUCCESS
== revl
) {
109 EdkLog
.log(this, EdkLog
.EDK_VERBOSE
, "FwImage succeeded!");
112 // command execution fail
114 EdkLog
.log(this, "ERROR = " + Integer
.toHexString(revl
));
115 throw new BuildException("FwImage failed!");
117 } catch (Exception e
) {
118 throw new BuildException(e
.getMessage());
125 This function is to set operation of class member "time".
127 @param time string of time
129 public void setTime(String time
) {
130 this.time
.setArg(" -t ", time
);
136 This function is to get class member "time"
137 @return time string of time
139 public String
getTime() {
140 return this.time
.getValue();
146 This function is to get class member "peImage".
147 @return name of PE image
149 public String
getPeImage() {
150 return this.peImage
.getValue();
156 This function is to set class member "peImage"
157 @param peImage name of PE image
159 public void setPeImage(String peImage
) {
160 this.peImage
.setArg(" ", peImage
);
166 This function is to get class member "outImage".
167 @return name of output EFI image
169 public String
getOutImage() {
170 return this.outImage
.getValue();
176 This function is to set class member "outImage".
177 @param outImage name of output EFI image
179 public void setOutImage(String outImage
) {
180 this.outImage
.setArg(" ", outImage
);
186 This function is to get class member "componentType".
188 @return string of componentType
190 public String
getComponentType() {
191 return this.componentType
.getValue();
197 This function is to set class member "componentType".
198 @param componentType string of component type
200 public void setComponentType(String componentType
) {
201 this.componentType
.setArg(" ", componentType
);