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
;
18 import org
.apache
.tools
.ant
.BuildException
;
19 import org
.apache
.tools
.ant
.Project
;
20 import org
.apache
.tools
.ant
.Task
;
21 import org
.apache
.tools
.ant
.taskdefs
.Execute
;
22 import org
.apache
.tools
.ant
.taskdefs
.LogStreamHandler
;
23 import org
.apache
.tools
.ant
.types
.Commandline
;
27 import org
.tianocore
.common
.logger
.EdkLog
;
32 GenFvImageTask is to call GenFvImage.exe to generate the FvImage.
35 public class GenFvImageTask
extends Task
implements EfiDefine
{
39 static final private String toolName
= "GenFvImage";
41 // The name of input inf file
43 private FileArg infFile
= new FileArg();
47 private String outputDir
= ".";
52 GenFvImageTask execute is to assemble tool command line & execute tool
55 public void execute() throws BuildException
{
56 Project project
= this.getOwningTarget().getProject();
57 String path
= project
.getProperty("env.FRAMEWORK_TOOLS_PATH");
63 command
= path
+ File
.separator
+ toolName
;
66 String argument
= "" + infFile
;
72 Commandline cmdline
= new Commandline();
73 cmdline
.setExecutable(command
);
74 cmdline
.createArgument().setLine(argument
);
76 LogStreamHandler streamHandler
= new LogStreamHandler(this,
77 Project
.MSG_INFO
, Project
.MSG_WARN
);
78 Execute runner
= new Execute(streamHandler
, null);
80 runner
.setAntRun(project
);
81 runner
.setCommandline(cmdline
.getCommandline());
82 runner
.setWorkingDirectory(new File(outputDir
));
84 // log command line string.
86 EdkLog
.log(this, EdkLog
.EDK_VERBOSE
, Commandline
.toString(cmdline
.getCommandline()));
87 EdkLog
.log(this, infFile
.toFileList());
89 exitCode
= runner
.execute();
91 EdkLog
.log(this, "ERROR = " + Integer
.toHexString(exitCode
));
93 EdkLog
.log(this, EdkLog
.EDK_VERBOSE
, "GenFvImage succeeded!");
95 } catch (Exception e
) {
96 throw new BuildException(e
.getMessage());
99 throw new BuildException("GenFvImage: failed to generate FV file!");
106 This function is to get class member of infFile
107 @return String name of infFile
109 public String
getInfFile() {
110 return infFile
.getValue();
116 This function is to set class member of infFile.
118 @param infFile name of infFile
120 public void setInfFile(String infFile
) {
121 this.infFile
.setArg(" -I ", infFile
);
127 This function is to get output directory.
129 @return Path of output directory.
131 public String
getOutputDir() {
138 This function is to set output directory.
140 @param outputDir The output direcotry.
142 public void setOutputDir(String outputDir
) {
143 this.outputDir
= outputDir
;