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
;
34 FwImageTask is used to call FwImage.ext to generate the FwImage.
36 public class FwImageTask
extends Task
implements EfiDefine
{
40 private String time
= "";
44 private String peImage
= "";
45 private String peImageName
= "";
49 private String outImage
= "";
53 private String componentType
= "";
56 * assemble tool command line & execute tool command line
58 * @throws BuildException
63 FwimageTask execute function is to assemble tool command line & execute
68 public void execute() throws BuildException
{
70 Project project
= this.getOwningTarget().getProject();
72 // absolute path of efi tools
74 String path
= project
.getProperty("env.FRAMEWORK_TOOLS_PATH");
79 command
= path
+ "/" + "FwImage";
84 String argument
= time
+ componentType
+ peImage
+ outImage
;
86 // return value of fwimage execution
91 Commandline cmdline
= new Commandline();
92 cmdline
.setExecutable(command
);
93 cmdline
.createArgument().setLine(argument
);
95 LogStreamHandler streamHandler
= new LogStreamHandler(this,
96 Project
.MSG_INFO
, Project
.MSG_WARN
);
97 Execute runner
= new Execute(streamHandler
, null);
99 runner
.setAntRun(project
);
100 runner
.setCommandline(cmdline
.getCommandline());
102 log(Commandline
.toString(cmdline
.getCommandline()), Project
.MSG_VERBOSE
);
103 log(this.peImageName
);
104 revl
= runner
.execute();
105 if (EFI_SUCCESS
== revl
) {
106 log("FwImage succeeded!", Project
.MSG_VERBOSE
);
109 // command execution fail
111 log("ERROR = " + Integer
.toHexString(revl
));
112 throw new BuildException("FwImage failed!");
114 } catch (Exception e
) {
115 throw new BuildException(e
.getMessage());
122 This function is to set operation of class member "time".
124 @param time string of time
126 public void setTime(String time
) {
127 this.time
= " -t " + time
;
133 This function is to get class member "time"
134 @return time string of time
136 public String
getTime() {
143 This function is to get class member "peImage".
144 @return name of PE image
146 public String
getPeImage() {
153 This function is to set class member "peImage"
154 @param peImage name of PE image
156 public void setPeImage(String peImage
) {
157 this.peImageName
= (new File(peImage
)).getName();
158 this.peImage
= " " + peImage
;
164 This function is to get class member "outImage".
165 @return name of output EFI image
167 public String
getOutImage() {
168 return this.outImage
;
174 This function is to set class member "outImage".
175 @param outImage name of output EFI image
177 public void setOutImage(String outImage
) {
178 this.outImage
= " " + outImage
;
184 This function is to get class member "componentType".
186 @return string of componentType
188 public String
getComponentType() {
189 return this.componentType
;
195 This function is to set class member "componentType".
196 @param componentType string of component type
198 public void setComponentType(String componentType
) {
199 this.componentType
= " " + componentType
;