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
;
27 import org
.tianocore
.logger
.EdkLog
;
33 FwImageTask is used to call FwImage.ext to generate the FwImage.
35 public class FwImageTask
extends Task
implements EfiDefine
{
39 private String time
= "";
43 private String peImage
= "";
44 private String peImageName
= "";
48 private String outImage
= "";
52 private String componentType
= "";
55 * assemble tool command line & execute tool command line
57 * @throws BuildException
62 FwimageTask execute function is to assemble tool command line & execute
67 public void execute() throws BuildException
{
69 Project project
= this.getOwningTarget().getProject();
71 // absolute path of efi tools
73 String path
= project
.getProperty("env.FRAMEWORK_TOOLS_PATH");
78 command
= path
+ "/" + "FwImage";
83 String argument
= time
+ componentType
+ peImage
+ outImage
;
85 // return value of fwimage execution
90 Commandline cmdline
= new Commandline();
91 cmdline
.setExecutable(command
);
92 cmdline
.createArgument().setLine(argument
);
94 LogStreamHandler streamHandler
= new LogStreamHandler(this,
95 Project
.MSG_INFO
, Project
.MSG_WARN
);
96 Execute runner
= new Execute(streamHandler
, null);
98 runner
.setAntRun(project
);
99 runner
.setCommandline(cmdline
.getCommandline());
101 log(Commandline
.toString(cmdline
.getCommandline()), Project
.MSG_VERBOSE
);
102 log(this.peImageName
);
103 revl
= runner
.execute();
104 if (EFI_SUCCESS
== revl
) {
105 log("fwimage succeeded!", Project
.MSG_VERBOSE
);
108 // command execution fail
110 log("ERROR = " + Integer
.toHexString(revl
));
111 throw new BuildException("fwimage failed!");
113 } catch (Exception e
) {
114 throw new BuildException(e
.getMessage());
121 This function is to set operation of class member "time".
123 @param time string of time
125 public void setTime(String time
) {
126 this.time
= " -t " + time
;
132 This function is to get class member "time"
133 @return time string of time
135 public String
getTime() {
142 This function is to get class member "peImage".
143 @return name of PE image
145 public String
getPeImage() {
152 This function is to set class member "peImage"
153 @param peImage name of PE image
155 public void setPeImage(String peImage
) {
156 this.peImageName
= (new File(peImage
)).getName();
157 this.peImage
= " " + peImage
;
163 This function is to get class member "outImage".
164 @return name of output EFI image
166 public String
getOutImage() {
167 return this.outImage
;
173 This function is to set class member "outImage".
174 @param outImage name of output EFI image
176 public void setOutImage(String outImage
) {
177 this.outImage
= " " + outImage
;
183 This function is to get class member "componentType".
185 @return string of componentType
187 public String
getComponentType() {
188 return this.componentType
;
194 This function is to set class member "componentType".
195 @param componentType string of component type
197 public void setComponentType(String componentType
) {
198 this.componentType
= " " + componentType
;