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 // FIXME arch should be passed via schema attributes.
60 arch
=System
.getenv("ARCH");
66 if (arch
.equalsIgnoreCase("IA32")){
67 command
= path
+ "GenFvImage_Ia32";
69 else if (arch
.equalsIgnoreCase("X64")){
70 command
= path
+ "GenFvImage_X64";
72 else if (arch
.equalsIgnoreCase("IPF")){
73 command
= path
+ "GenFvImage_Ipf";
76 command
= path
+ "GenFvImage";
78 String argument
= infFile
;
82 Commandline commandLine
= new Commandline();
83 commandLine
.setExecutable(command
);
84 commandLine
.createArgument().setLine(argument
);
86 LogStreamHandler streamHandler
= new LogStreamHandler(this,
90 // create a execute object and set it's commandline
92 Execute runner
= new Execute(streamHandler
,null);
93 runner
.setAntRun(project
);
94 runner
.setCommandline(commandLine
.getCommandline());
95 System
.out
.println(Commandline
.toString(commandLine
.getCommandline()));
99 // user execute class call external programs - GenFvImage
101 revl
= runner
.execute();
103 // execute command line success!
105 if (EFI_SUCCESS
== revl
){
106 System
.out
.println("GenFvImage succeeded!");
110 // execute command line failed!
112 throw new BuildException("GenFvImage failed !(error =" +
113 Integer
.toHexString(revl
) + ")");
116 } catch (Exception e
) {
117 System
.out
.println(e
.getMessage());
123 This function is to get class member of infFile
124 @return String name of infFile
126 public String
getInfFile() {
133 This function is to set class member of infFile.
135 @param infFile name of infFile
137 public void setInfFile(String infFile
) {
138 this.infFile
= "-I " + infFile
;
144 This function is to get class member of arch.
145 @return The target architecture.
147 public String
getArch() {
154 This function is to set class member of arch.
156 @param arch The target architecture.
158 public void setArch(String arch
) {