2 GenCapsuleHdrTask class.
4 GenCapsuleHdrTask is used to call GenCapsuleHdr.exe to generate capsule.
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
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.
17 package org
.tianocore
.framework
.tasks
;
21 import org
.apache
.tools
.ant
.Task
;
22 import org
.apache
.tools
.ant
.Project
;
23 import org
.apache
.tools
.ant
.BuildException
;
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 import org
.tianocore
.logger
.EdkLog
;
30 GenCapsuleHdrTask class.
32 GenCapsuleHdrTask is used to call GenCapsuleHdr.exe to generate capsule.
34 public class GenCapsuleHdrTask
extends Task
implements EfiDefine
{
38 private String toolName
= "GenCapsuleHdr";
43 private String scriptFile
= "";
48 private String outputFile
= "";
51 /// output directory, this variable is added by jave wrap
53 private String outputDir
= "";
58 private String verbose
= "";
63 private String dump
= "";
68 private String size
= "";
71 /// capsule into one image flag
73 private String joinFlag
= "";
78 private String capsuleFile
= "";
84 * GenCapsuleHdrTask execute function is to assemble tool command line & execute
87 * @throws BuidException
89 public void execute() throws BuildException
{
91 Project project
= this.getOwningTarget().getProject();
95 FrameworkLogger logger
= new FrameworkLogger(project
, "gencapsulehdr");
96 EdkLog
.setLogLevel(project
.getProperty("env.LOGLEVEL"));
97 EdkLog
.setLogger(logger
);
99 // absolute path of efi tools
101 String path
= project
.getProperty("env.FRAMEWORK_TOOLS_PATH");
107 command
= path
+ File
.separatorChar
+ toolName
;
112 File file
= new File(outputFile
);
113 if (!file
.isAbsolute() && (!this.outputDir
.equalsIgnoreCase(""))) {
114 argument
= this.verbose
+ this.dump
+ "-o " +this.outputDir
115 + File
.separatorChar
+ this.outputFile
+ " "
116 + this.scriptFile
+ " " + this.size
+ " " + this.joinFlag
+ this.capsuleFile
;
118 argument
= this.verbose
+ this.dump
+ "-o " + this.outputFile
119 + " " + this.scriptFile
+ " " + this.size
+ " " + this.joinFlag
+ this.capsuleFile
;
122 // return value of fwimage execution
127 Commandline cmdline
= new Commandline();
128 cmdline
.setExecutable(command
);
129 cmdline
.createArgument().setLine(argument
);
131 LogStreamHandler streamHandler
= new LogStreamHandler(this,
132 Project
.MSG_INFO
, Project
.MSG_WARN
);
133 Execute runner
= new Execute(streamHandler
, null);
135 runner
.setAntRun(project
);
136 runner
.setCommandline(cmdline
.getCommandline());
138 // Set debug log information.
140 EdkLog
.log(EdkLog
.EDK_INFO
, Commandline
.toString(cmdline
143 revl
= runner
.execute();
145 if (EFI_SUCCESS
== revl
) {
147 // command execution success
149 EdkLog
.log(EdkLog
.EDK_INFO
, "GenCapsuleHdr succeeded!");
152 // command execution fail
154 EdkLog
.log(EdkLog
.EDK_ERROR
, "GenCapsuleHdr failed. (error="
155 + Integer
.toHexString(revl
) + ")");
156 throw new BuildException("GenCapsuleHdr failed. (error="
157 + Integer
.toHexString(revl
) + ")");
160 } catch (Exception e
) {
161 throw new BuildException(e
.getMessage());
168 * This function is to get class member "scriptFile".
170 * @return string of input file name.
172 public String
getScriptFile() {
173 return this.scriptFile
;
179 * This function is to set class member "inputFile".
182 * string of input file name.
184 public void setScriptFile(String scriptFile
) {
185 this.scriptFile
= "-script " + scriptFile
;
191 * This function is to get class member "outputFile"
193 * @return outputFile string of output file name.
195 public String
getOutputFile() {
202 * This function is to set class member "outputFile"
205 * string of output file name.
207 public void setOutputFile(String outputFile
) {
208 this.outputFile
= outputFile
+ " ";
214 * This function is to get class member "outputDir"
216 * @return outputDir string of output directory.
218 public String
getOutputDir() {
225 * This function is to set class member "outputDir"
228 * string of output directory.
230 public void setOutputDir(String outputDir
) {
231 this.outputDir
= outputDir
;
237 * This function is to get class member "verbose"
239 * @return verbose the flag of verbose.
241 public String
getVerbose() {
248 * This function is to set class member "verbose"
253 public void setVerbose(boolean verbose
) {
255 this.verbose
= "-v ";
262 * This function is to get class member "dump"
264 * @return verbose the flag of dump.
266 public String
getDump() {
273 * This function is to set class member "dump".
278 public void setDump(boolean dump
) {
280 this.dump
= "-dump ";
287 * This function is to set class member "size".
289 * @return size string of size value
291 public String
getSize() {
298 * This function is to set class member "size".
300 * @param size string of size value.
302 public void setSize(String size
) {
303 this.size
= "-split " + size
;
309 * This function is to get class member "capsuleFile"
311 * @return capsuleFile capsule file name
313 public String
getCapsuleFile() {
320 * This function is to set class member "capsuleFile"
322 * @param capsuleFile capsule file name
324 public void setCapsuleFile(String capsuleFile
) {
325 this.capsuleFile
= capsuleFile
;
331 * This function is to get class member "joinFlag"
333 * @return joinFlag flag of if need to join split capsule images into
336 public String
getJoinFlag() {
343 * This function is to set class member "joinFlag"
345 * @param joinFlag flag of if need to join split capsule images into
348 public void setJoinFlag(boolean joinFlag
) {
350 this.joinFlag
= "-j ";