]> git.proxmox.com Git - mirror_edk2.git/blob - Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/GenFvImageTask.java
One GenFvImage can handle all archs now.
[mirror_edk2.git] / Tools / Source / FrameworkTasks / org / tianocore / framework / tasks / GenFvImageTask.java
1 /** @file
2 GenFvImageTask class.
3
4 GenFvImageTask is to call GenFvImage.exe to generate FvImage.
5
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
11
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.
14
15 **/
16 package org.tianocore.framework.tasks;
17 import java.io.File;
18
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;
25
26 /**
27 GenFvImageTask
28
29 GenFvImageTask is to call GenFvImage.exe to generate the FvImage.
30
31 **/
32 public class GenFvImageTask extends Task implements EfiDefine{
33 ///
34 /// The name of input inf file
35 ///
36 private String infFile="";
37
38 /**
39 execute
40
41 GenFvImageTask execute is to assemble tool command line & execute tool
42 command line.
43 **/
44 public void execute() throws BuildException {
45 Project project = this.getOwningTarget().getProject();
46 String path = project.getProperty("env.FRAMEWORK_TOOLS_PATH");
47 String command = "";
48
49 if (path == null){
50 path = "";
51 }else {
52 path = path + File.separatorChar;
53 }
54
55 command = path + "GenFvImage";
56
57 String argument = infFile;
58
59 try {
60
61 Commandline commandLine = new Commandline();
62 commandLine.setExecutable(command);
63 commandLine.createArgument().setLine(argument);
64
65 LogStreamHandler streamHandler = new LogStreamHandler(this,
66 Project.MSG_INFO,
67 Project.MSG_WARN);
68 //
69 // create a execute object and set it's commandline
70 //
71 Execute runner = new Execute(streamHandler,null);
72 runner.setAntRun(project);
73 runner.setCommandline(commandLine.getCommandline());
74 System.out.println(Commandline.toString(commandLine.getCommandline()));
75
76 int revl = -1;
77 //
78 // user execute class call external programs - GenFvImage
79 //
80 revl = runner.execute();
81 //
82 // execute command line success!
83 //
84 if (EFI_SUCCESS == revl){
85 System.out.println("GenFvImage succeeded!");
86 } else {
87
88 //
89 // execute command line failed!
90 //
91 throw new BuildException("GenFvImage failed !(error =" +
92 Integer.toHexString(revl) + ")");
93 }
94
95 } catch (Exception e) {
96 System.out.println(e.getMessage());
97 }
98 }
99 /**
100 getInfFile
101
102 This function is to get class member of infFile
103 @return String name of infFile
104 **/
105 public String getInfFile() {
106 return infFile;
107 }
108
109 /**
110 setInfFile
111
112 This function is to set class member of infFile.
113
114 @param infFile name of infFile
115 **/
116 public void setInfFile(String infFile) {
117 this.infFile = "-I " + infFile;
118 }
119
120 }