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
;
19 import org
.apache
.tools
.ant
.Task
;
20 import org
.apache
.tools
.ant
.Project
;
21 import org
.apache
.tools
.ant
.BuildException
;
22 import org
.apache
.tools
.ant
.taskdefs
.Execute
;
23 import org
.apache
.tools
.ant
.taskdefs
.LogStreamHandler
;
24 import org
.apache
.tools
.ant
.types
.Commandline
;
29 FwImageTask is used to call FwImage.ext to generate the FwImage.
31 public class FwImageTask
extends Task
implements EfiDefine
{
35 private String time
= "";
39 private String peImage
= "";
43 private String outImage
= "";
47 private String componentType
= "";
50 * assemble tool command line & execute tool command line
52 * @throws BuildException
57 FwimageTask execute function is to assemble tool command line & execute
62 public void execute() throws BuildException
{
64 Project project
= this.getOwningTarget().getProject();
66 // absolute path of efi tools
68 String path
= project
.getProperty("env.Framework_Tools_Path");
73 command
= path
+ "/" + "fwimage";
78 String argument
= time
+ componentType
+ peImage
+ outImage
;
80 // return value of fwimage execution
85 Commandline cmdline
= new Commandline();
86 cmdline
.setExecutable(command
);
87 cmdline
.createArgument().setLine(argument
);
89 LogStreamHandler streamHandler
= new LogStreamHandler(this,
90 Project
.MSG_INFO
, Project
.MSG_WARN
);
91 Execute runner
= new Execute(streamHandler
, null);
93 runner
.setAntRun(project
);
94 runner
.setCommandline(cmdline
.getCommandline());
95 System
.out
.println(Commandline
.toString(cmdline
.getCommandline()));
97 revl
= runner
.execute();
98 if (EFI_SUCCESS
== revl
) {
100 // command execution success
102 System
.out
.println("fwimage succeeded!");
105 // command execution fail
107 System
.out
.println("fwimage failed. (error="
108 + Integer
.toHexString(revl
) + ")");
109 throw new BuildException("fwimage failed. (error="
110 + Integer
.toHexString(revl
) + ")");
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.peImage
= " " + peImage
;
162 This function is to get class member "outImage".
163 @return name of output EFI image
165 public String
getOutImage() {
166 return this.outImage
;
172 This function is to set class member "outImage".
173 @param outImage name of output EFI image
175 public void setOutImage(String outImage
) {
176 this.outImage
= " " + outImage
;
182 This function is to get class member "componentType".
184 @return string of componentType
186 public String
getComponentType() {
187 return this.componentType
;
193 This function is to set class member "componentType".
194 @param componentType string of component type
196 public void setComponentType(String componentType
) {
197 this.componentType
= " " + componentType
;