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
;
25 import org
.tianocore
.build
.*;
30 FwImageTask is used to call FwImage.ext to generate the FwImage.
32 public class FwImageTask
extends Task
implements EfiDefine
{
36 private String time
= "";
40 private String peImage
= "";
44 private String outImage
= "";
48 private String componentType
= "";
51 * assemble tool command line & execute tool command line
53 * @throws BuildException
58 FwimageTask execute function is to assemble tool command line & execute
63 public void execute() throws BuildException
{
65 Project project
= this.getOwningTarget().getProject();
67 // absolute path of efi tools
69 String path
= project
.getProperty("env.FRAMEWORK_TOOLS_PATH");
74 command
= path
+ "/" + "fwimage";
79 String argument
= time
+ componentType
+ peImage
+ outImage
;
81 // return value of fwimage execution
86 Commandline cmdline
= new Commandline();
87 cmdline
.setExecutable(command
);
88 cmdline
.createArgument().setLine(argument
);
90 LogStreamHandler streamHandler
= new LogStreamHandler(this,
91 Project
.MSG_INFO
, Project
.MSG_WARN
);
92 Execute runner
= new Execute(streamHandler
, null);
94 runner
.setAntRun(project
);
95 runner
.setCommandline(cmdline
.getCommandline());
96 //System.out.println(Commandline.toString(cmdline.getCommandline()));
97 //GenBuildTask.myLogger.log(Commandline.toString(cmdline.getCommandline()),0);
98 //getProject().log(Commandline.toString(cmdline.getCommandline()));
99 revl
= runner
.execute();
100 if (EFI_SUCCESS
== revl
) {
102 // command execution success
104 System
.out
.println("fwimage successed!");
107 // command execution fail
109 System
.out
.println("fwimage failed. (error="
110 + Integer
.toHexString(revl
) + ")");
111 throw new BuildException("fwimage failed. (error="
112 + Integer
.toHexString(revl
) + ")");
115 } catch (Exception e
) {
116 throw new BuildException(e
.getMessage());
123 This function is to set operation of class member "time".
125 @param time string of time
127 public void setTime(String time
) {
128 this.time
= " -t " + time
;
134 This function is to get class member "time"
135 @return time string of time
137 public String
getTime() {
144 This function is to get class member "peImage".
145 @return name of PE image
147 public String
getPeImage() {
154 This function is to set class member "peImage"
155 @param peImage name of PE image
157 public void setPeImage(String peImage
) {
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
;