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();
60 FwimageTask execute function is to assemble tool command line & execute
65 public void execute() throws BuildException
{
67 Project project
= this.getOwningTarget().getProject();
69 // absolute path of efi tools
71 String path
= project
.getProperty("env.FRAMEWORK_TOOLS_PATH");
76 command
= path
+ File
.separator
+ toolName
;
81 String argument
= "" + time
+ componentType
+ peImage
+ outImage
;
83 // return value of fwimage execution
88 Commandline cmdline
= new Commandline();
89 cmdline
.setExecutable(command
);
90 cmdline
.createArgument().setLine(argument
);
92 LogStreamHandler streamHandler
= new LogStreamHandler(this,
93 Project
.MSG_INFO
, Project
.MSG_WARN
);
94 Execute runner
= new Execute(streamHandler
, null);
96 runner
.setAntRun(project
);
97 runner
.setCommandline(cmdline
.getCommandline());
99 EdkLog
.log(this, EdkLog
.EDK_VERBOSE
, Commandline
.toString(cmdline
.getCommandline()));
100 EdkLog
.log(this, peImage
.toFileList() + " => " + outImage
.toFileList());
102 revl
= runner
.execute();
103 if (EFI_SUCCESS
== revl
) {
104 EdkLog
.log(this, EdkLog
.EDK_VERBOSE
, "FwImage succeeded!");
107 // command execution fail
109 EdkLog
.log(this, "ERROR = " + Integer
.toHexString(revl
));
110 throw new BuildException("FwImage failed!");
112 } catch (Exception e
) {
113 throw new BuildException(e
.getMessage());
120 This function is to set operation of class member "time".
122 @param time string of time
124 public void setTime(String time
) {
125 this.time
.setArg(" -t ", time
);
131 This function is to get class member "time"
132 @return time string of time
134 public String
getTime() {
135 return this.time
.getValue();
141 This function is to get class member "peImage".
142 @return name of PE image
144 public String
getPeImage() {
145 return this.peImage
.getValue();
151 This function is to set class member "peImage"
152 @param peImage name of PE image
154 public void setPeImage(String peImage
) {
155 this.peImage
.setArg(" ", peImage
);
161 This function is to get class member "outImage".
162 @return name of output EFI image
164 public String
getOutImage() {
165 return this.outImage
.getValue();
171 This function is to set class member "outImage".
172 @param outImage name of output EFI image
174 public void setOutImage(String outImage
) {
175 this.outImage
.setArg(" ", outImage
);
181 This function is to get class member "componentType".
183 @return string of componentType
185 public String
getComponentType() {
186 return this.componentType
.getValue();
192 This function is to set class member "componentType".
193 @param componentType string of component type
195 public void setComponentType(String componentType
) {
196 this.componentType
.setArg(" ", componentType
);