]> git.proxmox.com Git - mirror_edk2.git/blob - Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/FwImageTask.java
Changed Error message from successed to succeeded.
[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 org.apache.tools.ant.Task;
20 import org.apache.tools.ant.Project;
21 import org.apache.tools.ant.BuildException;
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 FwImageTask class.
28
29 FwImageTask is used to call FwImage.ext to generate the FwImage.
30 **/
31 public class FwImageTask extends Task implements EfiDefine{
32 ///
33 /// time&data
34 ///
35 private String time = "";
36 ///
37 /// input PE image
38 ///
39 private String peImage = "";
40 ///
41 /// output EFI image
42 ///
43 private String outImage = "";
44 ///
45 /// component type
46 ///
47 private String componentType = "";
48
49 /**
50 * assemble tool command line & execute tool command line
51 *
52 * @throws BuildException
53 */
54 /**
55 execute
56
57 FwimageTask execute function is to assemble tool command line & execute
58 tool command line
59
60 @throws BuidException
61 **/
62 public void execute() throws BuildException {
63
64 Project project = this.getOwningTarget().getProject();
65 //
66 // absolute path of efi tools
67 //
68 String path = project.getProperty("env.Framework_Tools_Path");
69 String command;
70 if (path == null) {
71 command = "fwimage";
72 } else {
73 command = path + "/" + "fwimage";
74 }
75 //
76 // argument of tools
77 //
78 String argument = time + componentType + peImage + outImage;
79 //
80 // return value of fwimage execution
81 //
82 int revl = -1;
83
84 try {
85 Commandline cmdline = new Commandline();
86 cmdline.setExecutable(command);
87 cmdline.createArgument().setLine(argument);
88
89 LogStreamHandler streamHandler = new LogStreamHandler(this,
90 Project.MSG_INFO, Project.MSG_WARN);
91 Execute runner = new Execute(streamHandler, null);
92
93 runner.setAntRun(project);
94 runner.setCommandline(cmdline.getCommandline());
95 System.out.println(Commandline.toString(cmdline.getCommandline()));
96
97 revl = runner.execute();
98 if (EFI_SUCCESS == revl) {
99 //
100 // command execution success
101 //
102 System.out.println("fwimage succeeded!");
103 } else {
104 //
105 // command execution fail
106 //
107 System.out.println("fwimage failed. (error="
108 + Integer.toHexString(revl) + ")");
109 throw new BuildException("fwimage failed. (error="
110 + Integer.toHexString(revl) + ")");
111
112 }
113 } catch (Exception e) {
114 throw new BuildException(e.getMessage());
115 }
116 }
117
118 /**
119 setTime
120
121 This function is to set operation of class member "time".
122
123 @param time string of time
124 **/
125 public void setTime(String time) {
126 this.time = " -t " + time;
127 }
128
129 /**
130 getTime
131
132 This function is to get class member "time"
133 @return time string of time
134 **/
135 public String getTime() {
136 return this.time;
137 }
138
139 /**
140 getPeImage
141
142 This function is to get class member "peImage".
143 @return name of PE image
144 **/
145 public String getPeImage() {
146 return this.peImage;
147 }
148
149 /**
150 setPeImage
151
152 This function is to set class member "peImage"
153 @param peImage name of PE image
154 **/
155 public void setPeImage(String peImage) {
156 this.peImage = " " + peImage;
157 }
158
159 /**
160 getOutImage
161
162 This function is to get class member "outImage".
163 @return name of output EFI image
164 **/
165 public String getOutImage() {
166 return this.outImage;
167 }
168
169 /**
170 setOutImage
171
172 This function is to set class member "outImage".
173 @param outImage name of output EFI image
174 **/
175 public void setOutImage(String outImage) {
176 this.outImage = " " + outImage;
177 }
178
179 /**
180 getComponentType
181
182 This function is to get class member "componentType".
183
184 @return string of componentType
185 **/
186 public String getComponentType() {
187 return this.componentType;
188 }
189
190 /**
191 setComponentType
192
193 This function is to set class member "componentType".
194 @param componentType string of component type
195 **/
196 public void setComponentType(String componentType) {
197 this.componentType = " " + componentType;
198 }
199 }