]> git.proxmox.com Git - mirror_edk2.git/blob - Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/FwImageTask.java
Modify GenFfsTask to make it don't create ORG file.
[mirror_edk2.git] / Tools / Source / FrameworkTasks / org / tianocore / framework / tasks / FwImageTask.java
1 /** @file
2 FwImageTask class.
3
4 FwImageTask is used to call FwImage.ext to generate the FwImage.
5
6
7 Copyright (c) 2006, Intel Corporation
8 All rights reserved. This program and the accompanying materials
9 are licensed and made available under the terms and conditions of the BSD License
10 which accompanies this distribution. The full text of the license may be found at
11 http://opensource.org/licenses/bsd-license.php
12
13 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
14 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
15
16 **/
17 package org.tianocore.framework.tasks;
18
19 import java.io.File;
20
21 import org.apache.tools.ant.BuildException;
22 import org.apache.tools.ant.Project;
23 import org.apache.tools.ant.Task;
24 import org.apache.tools.ant.taskdefs.Execute;
25 import org.apache.tools.ant.taskdefs.LogStreamHandler;
26 import org.apache.tools.ant.types.Commandline;
27
28 import org.tianocore.common.logger.EdkLog;
29
30
31 /**
32 FwImageTask class.
33
34 FwImageTask is used to call FwImage.ext to generate the FwImage.
35 **/
36 public class FwImageTask extends Task implements EfiDefine{
37 ///
38 /// time&data
39 ///
40 private String time = "";
41 ///
42 /// input PE image
43 ///
44 private String peImage = "";
45 private String peImageName = "";
46 ///
47 /// output EFI image
48 ///
49 private String outImage = "";
50 ///
51 /// component type
52 ///
53 private String componentType = "";
54
55 /**
56 * assemble tool command line & execute tool command line
57 *
58 * @throws BuildException
59 */
60 /**
61 execute
62
63 FwimageTask execute function is to assemble tool command line & execute
64 tool command line
65
66 @throws BuidException
67 **/
68 public void execute() throws BuildException {
69
70 Project project = this.getOwningTarget().getProject();
71 //
72 // absolute path of efi tools
73 //
74 String path = project.getProperty("env.FRAMEWORK_TOOLS_PATH");
75 String command;
76 if (path == null) {
77 command = "FwImage";
78 } else {
79 command = path + "/" + "FwImage";
80 }
81 //
82 // argument of tools
83 //
84 String argument = time + componentType + peImage + outImage;
85 //
86 // return value of fwimage execution
87 //
88 int revl = -1;
89
90 try {
91 Commandline cmdline = new Commandline();
92 cmdline.setExecutable(command);
93 cmdline.createArgument().setLine(argument);
94
95 LogStreamHandler streamHandler = new LogStreamHandler(this,
96 Project.MSG_INFO, Project.MSG_WARN);
97 Execute runner = new Execute(streamHandler, null);
98
99 runner.setAntRun(project);
100 runner.setCommandline(cmdline.getCommandline());
101
102 log(Commandline.toString(cmdline.getCommandline()), Project.MSG_VERBOSE);
103 log(this.peImageName);
104 revl = runner.execute();
105 if (EFI_SUCCESS == revl) {
106 log("FwImage succeeded!", Project.MSG_VERBOSE);
107 } else {
108 //
109 // command execution fail
110 //
111 log("ERROR = " + Integer.toHexString(revl));
112 throw new BuildException("FwImage failed!");
113 }
114 } catch (Exception e) {
115 throw new BuildException(e.getMessage());
116 }
117 }
118
119 /**
120 setTime
121
122 This function is to set operation of class member "time".
123
124 @param time string of time
125 **/
126 public void setTime(String time) {
127 this.time = " -t " + time;
128 }
129
130 /**
131 getTime
132
133 This function is to get class member "time"
134 @return time string of time
135 **/
136 public String getTime() {
137 return this.time;
138 }
139
140 /**
141 getPeImage
142
143 This function is to get class member "peImage".
144 @return name of PE image
145 **/
146 public String getPeImage() {
147 return this.peImage;
148 }
149
150 /**
151 setPeImage
152
153 This function is to set class member "peImage"
154 @param peImage name of PE image
155 **/
156 public void setPeImage(String peImage) {
157 this.peImageName = (new File(peImage)).getName();
158 this.peImage = " " + peImage;
159 }
160
161 /**
162 getOutImage
163
164 This function is to get class member "outImage".
165 @return name of output EFI image
166 **/
167 public String getOutImage() {
168 return this.outImage;
169 }
170
171 /**
172 setOutImage
173
174 This function is to set class member "outImage".
175 @param outImage name of output EFI image
176 **/
177 public void setOutImage(String outImage) {
178 this.outImage = " " + outImage;
179 }
180
181 /**
182 getComponentType
183
184 This function is to get class member "componentType".
185
186 @return string of componentType
187 **/
188 public String getComponentType() {
189 return this.componentType;
190 }
191
192 /**
193 setComponentType
194
195 This function is to set class member "componentType".
196 @param componentType string of component type
197 **/
198 public void setComponentType(String componentType) {
199 this.componentType = " " + componentType;
200 }
201 }