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
;
26 import java
.io
.InputStreamReader
;
27 import java
.lang
.ProcessBuilder
;
28 import java
.util
.LinkedList
;
30 import org
.tianocore
.common
.logger
.EdkLog
;
35 GenFvImageTask is to call GenFvImage.exe to generate the FvImage.
38 public class GenFvImageTask
extends Task
implements EfiDefine
{
42 static final private String toolName
= "GenFvImage";
44 // The name of input inf file
46 private FileArg infFile
= new FileArg();
50 private String outputDir
= ".";
55 GenFvImageTask execute is to assemble tool command line & execute tool
58 public void execute() throws BuildException
{
59 Project project
= this.getOwningTarget().getProject();
60 String path
= project
.getProperty("env.FRAMEWORK_TOOLS_PATH");
66 command
= path
+ File
.separator
+ toolName
;
69 String argument
= "" + infFile
;
75 Commandline cmdline
= new Commandline();
76 cmdline
.setExecutable(command
);
77 cmdline
.createArgument().setLine(argument
);
79 LogStreamHandler streamHandler
= new LogStreamHandler(this,
80 Project
.MSG_INFO
, Project
.MSG_WARN
);
81 Execute runner
= new Execute(streamHandler
, null);
83 runner
.setAntRun(project
);
84 runner
.setCommandline(cmdline
.getCommandline());
85 runner
.setWorkingDirectory(new File(outputDir
));
87 // log command line string.
89 EdkLog
.log(this, EdkLog
.EDK_VERBOSE
, Commandline
.toString(cmdline
.getCommandline()));
90 EdkLog
.log(this, infFile
.toFileList());
92 exitCode
= runner
.execute();
94 EdkLog
.log(this, "ERROR = " + Integer
.toHexString(exitCode
));
96 EdkLog
.log(this, EdkLog
.EDK_VERBOSE
, "GenFvImage succeeded!");
98 } catch (Exception e
) {
99 throw new BuildException(e
.getMessage());
102 throw new BuildException("GenFvImage: failed to generate FV file!");
109 This function is to get class member of infFile
110 @return String name of infFile
112 public String
getInfFile() {
113 return infFile
.getValue();
119 This function is to set class member of infFile.
121 @param infFile name of infFile
123 public void setInfFile(String infFile
) {
124 this.infFile
.setArg(" -I ", infFile
);
130 This function is to get output directory.
132 @return Path of output directory.
134 public String
getOutputDir() {
141 This function is to set output directory.
143 @param outputDir The output direcotry.
145 public void setOutputDir(String outputDir
) {
146 this.outputDir
= outputDir
;