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_VERBOSE
, Commandline
.toString(cmdline
.getCommandline()));
141 EdkLog
.log(EdkLog
.EDK_INFO
, (new File(scriptFile
)).getName());
142 revl
= runner
.execute();
144 if (EFI_SUCCESS
== revl
) {
146 // command execution success
148 EdkLog
.log(EdkLog
.EDK_VERBOSE
, "GenCapsuleHdr succeeded!");
151 // command execution fail
153 EdkLog
.log(EdkLog
.EDK_ERROR
, "ERROR = " + Integer
.toHexString(revl
));
154 throw new BuildException("GenCapsuleHdr failed!");
156 } catch (Exception e
) {
157 throw new BuildException(e
.getMessage());
164 * This function is to get class member "scriptFile".
166 * @return string of input file name.
168 public String
getScriptFile() {
169 return this.scriptFile
;
175 * This function is to set class member "inputFile".
178 * string of input file name.
180 public void setScriptFile(String scriptFile
) {
181 this.scriptFile
= "-script " + scriptFile
;
187 * This function is to get class member "outputFile"
189 * @return outputFile string of output file name.
191 public String
getOutputFile() {
198 * This function is to set class member "outputFile"
201 * string of output file name.
203 public void setOutputFile(String outputFile
) {
204 this.outputFile
= outputFile
+ " ";
210 * This function is to get class member "outputDir"
212 * @return outputDir string of output directory.
214 public String
getOutputDir() {
221 * This function is to set class member "outputDir"
224 * string of output directory.
226 public void setOutputDir(String outputDir
) {
227 this.outputDir
= outputDir
;
233 * This function is to get class member "verbose"
235 * @return verbose the flag of verbose.
237 public String
getVerbose() {
244 * This function is to set class member "verbose"
249 public void setVerbose(boolean verbose
) {
251 this.verbose
= "-v ";
258 * This function is to get class member "dump"
260 * @return verbose the flag of dump.
262 public String
getDump() {
269 * This function is to set class member "dump".
274 public void setDump(boolean dump
) {
276 this.dump
= "-dump ";
283 * This function is to set class member "size".
285 * @return size string of size value
287 public String
getSize() {
294 * This function is to set class member "size".
296 * @param size string of size value.
298 public void setSize(String size
) {
299 this.size
= "-split " + size
;
305 * This function is to get class member "capsuleFile"
307 * @return capsuleFile capsule file name
309 public String
getCapsuleFile() {
316 * This function is to set class member "capsuleFile"
318 * @param capsuleFile capsule file name
320 public void setCapsuleFile(String capsuleFile
) {
321 this.capsuleFile
= capsuleFile
;
327 * This function is to get class member "joinFlag"
329 * @return joinFlag flag of if need to join split capsule images into
332 public String
getJoinFlag() {
339 * This function is to set class member "joinFlag"
341 * @param joinFlag flag of if need to join split capsule images into
344 public void setJoinFlag(boolean joinFlag
) {
346 this.joinFlag
= "-j ";