]>
git.proxmox.com Git - mirror_edk2.git/blob - Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/GenFvImageTask.java
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
.IOException
;
27 import java
.io
.InputStream
;
28 import java
.io
.InputStreamReader
;
29 import java
.lang
.ProcessBuilder
;
30 import java
.util
.ArrayList
;
31 import java
.util
.LinkedList
;
32 import java
.util
.List
;
38 GenFvImageTask is to call GenFvImage.exe to generate the FvImage.
41 public class GenFvImageTask
extends Task
implements EfiDefine
{
45 static final private String toolName
= "GenFvImage";
47 /// The name of input inf file
49 private String infFile
="";
53 private String outputDir
= ".";
57 LinkedList
<String
> argList
= new LinkedList
<String
>();
62 GenFvImageTask execute is to assemble tool command line & execute tool
65 public void execute() throws BuildException
{
66 Project project
= this.getOwningTarget().getProject();
67 String path
= project
.getProperty("env.FRAMEWORK_TOOLS_PATH");
72 path
+= File
.separatorChar
;
74 argList
.addFirst(path
+ toolName
);
78 ProcessBuilder pb
= new ProcessBuilder(argList
);
79 pb
.directory(new File(outputDir
));
82 Process cmdProc
= pb
.start();
83 InputStreamReader cmdOut
= new InputStreamReader(cmdProc
.getInputStream());
84 char[] buf
= new char[1024];
86 exitCode
= cmdProc
.waitFor();
88 int len
= cmdOut
.read(buf
, 0, 1024);
89 log(new String(buf
, 0, len
), Project
.MSG_ERR
);
91 log("GenFvImage - DONE!", Project
.MSG_VERBOSE
);
93 } catch (Exception e
) {
94 throw new BuildException(e
.getMessage());
97 throw new BuildException("GenFvImage: failed to generate FV file!");
105 This function is to get class member of infFile
106 @return String name of infFile
108 public String
getInfFile() {
115 This function is to set class member of infFile.
117 @param infFile name of infFile
119 public void setInfFile(String infFile
) {
120 this.infFile
= infFile
;
122 argList
.add(infFile
);
128 This function is to get output directory.
130 @return Path of output directory.
132 public String
getOutputDir() {
139 This function is to set output directory.
141 @param outputDir The output direcotry.
143 public void setOutputDir(String outputDir
) {
144 this.outputDir
= outputDir
;