4 GenFvImageTask is to call GenFvImage.exe to generate FvImage.
6 Copyright (c) 2006, Intel Corporation
7 All rights reserved. This program and the accompanying materials
8 are licensed and made available under the terms and conditions of the BSD License
9 which accompanies this distribution. The full text of the license may be found at
10 http://opensource.org/licenses/bsd-license.php
12 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
13 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
16 package org
.tianocore
.framework
.tasks
;
19 import org
.apache
.tools
.ant
.BuildException
;
20 import org
.apache
.tools
.ant
.Project
;
21 import org
.apache
.tools
.ant
.Task
;
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 GenFvImageTask is to call GenFvImage.exe to generate the FvImage.
32 public class GenFvImageTask
extends Task
implements EfiDefine
{
34 /// The name of input inf file
36 private String infFile
="";
38 /// The target architecture.
40 private String arch
="";
45 GenFvImageTask execute is to assemble tool command line & execute tool
48 public void execute() throws BuildException
{
49 Project project
= this.getOwningTarget().getProject();
50 String path
= project
.getProperty("env.Framework_Tools_Path");
56 path
= path
+ File
.separatorChar
;
59 if (arch
.equalsIgnoreCase("")){
60 command
= path
+ "GenFvImage";
62 if (arch
.equalsIgnoreCase("ia32")){
63 command
= path
+ "GenFvImage_IA32";
65 if (arch
.equalsIgnoreCase("x64")){
66 command
= path
+ "GenFvImage_X64";
68 if (arch
.equalsIgnoreCase("ipf")){
69 command
= path
+ "GenFvImage_IPF";
71 String argument
= infFile
;
75 Commandline commandLine
= new Commandline();
76 commandLine
.setExecutable(command
);
77 commandLine
.createArgument().setLine(argument
);
79 LogStreamHandler streamHandler
= new LogStreamHandler(this,
83 // create a execute object and set it's commandline
85 Execute runner
= new Execute(streamHandler
,null);
86 runner
.setAntRun(project
);
87 runner
.setCommandline(commandLine
.getCommandline());
88 System
.out
.println(Commandline
.toString(commandLine
.getCommandline()));
92 // user execute class call external programs - GenFvImage
94 revl
= runner
.execute();
96 // execute command line success!
98 if (EFI_SUCCESS
== revl
){
99 System
.out
.println("GenFvImage succeeded!");
103 // execute command line failed!
105 throw new BuildException("GenFvImage failed !(error =" +
106 Integer
.toHexString(revl
) + ")");
109 } catch (Exception e
) {
110 System
.out
.println(e
.getMessage());
116 This function is to get class member of infFile
117 @return String name of infFile
119 public String
getInfFile() {
126 This function is to set class member of infFile.
128 @param infFile name of infFile
130 public void setInfFile(String infFile
) {
131 this.infFile
= "-I " + infFile
;
137 This function is to get class member of arch.
138 @return The target architecture.
140 public String
getArch() {
147 This function is to set class member of arch.
149 @param arch The target architecture.
151 public void setArch(String arch
) {