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
;
23 import java
.io
.InputStreamReader
;
24 import java
.lang
.ProcessBuilder
;
25 import java
.util
.LinkedList
;
30 GenFvImageTask is to call GenFvImage.exe to generate the FvImage.
33 public class GenFvImageTask
extends Task
implements EfiDefine
{
37 static final private String toolName
= "GenFvImage";
39 /// The name of input inf file
41 private String infFile
="";
45 private String outputDir
= ".";
49 LinkedList
<String
> argList
= new LinkedList
<String
>();
54 GenFvImageTask execute is to assemble tool command line & execute tool
57 public void execute() throws BuildException
{
58 Project project
= this.getOwningTarget().getProject();
59 String path
= project
.getProperty("env.FRAMEWORK_TOOLS_PATH");
64 path
+= File
.separatorChar
;
66 argList
.addFirst(path
+ toolName
);
70 ProcessBuilder pb
= new ProcessBuilder(argList
);
71 pb
.directory(new File(outputDir
));
73 log((new File(this.infFile
)).getName());
75 Process cmdProc
= pb
.start();
76 InputStreamReader cmdOut
= new InputStreamReader(cmdProc
.getInputStream());
77 char[] buf
= new char[1024];
79 exitCode
= cmdProc
.waitFor();
81 int len
= cmdOut
.read(buf
, 0, 1024);
82 log(new String(buf
, 0, len
));
84 log("GenFvImage succeeded!", Project
.MSG_VERBOSE
);
86 } catch (Exception e
) {
87 throw new BuildException(e
.getMessage());
90 //throw new BuildException("GenFvImage: failed to generate FV file!");
98 This function is to get class member of infFile
99 @return String name of infFile
101 public String
getInfFile() {
108 This function is to set class member of infFile.
110 @param infFile name of infFile
112 public void setInfFile(String infFile
) {
113 this.infFile
= infFile
;
115 argList
.add(infFile
);
121 This function is to get output directory.
123 @return Path of output directory.
125 public String
getOutputDir() {
132 This function is to set output directory.
134 @param outputDir The output direcotry.
136 public void setOutputDir(String outputDir
) {
137 this.outputDir
= outputDir
;