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
;
28 import org
.tianocore
.common
.logger
.EdkLog
;
31 GenCapsuleHdrTask class.
33 GenCapsuleHdrTask is used to call GenCapsuleHdr.exe to generate capsule.
35 public class GenCapsuleHdrTask
extends Task
implements EfiDefine
{
39 private String toolName
= "GenCapsuleHdr";
44 private String scriptFile
= "";
49 private String outputFile
= "";
52 /// output directory, this variable is added by jave wrap
54 private String outputDir
= "";
59 private String verbose
= "";
64 private String dump
= "";
69 private String size
= "";
72 /// capsule into one image flag
74 private String joinFlag
= "";
79 private String capsuleFile
= "";
85 * GenCapsuleHdrTask execute function is to assemble tool command line & execute
88 * @throws BuidException
90 public void execute() throws BuildException
{
92 Project project
= this.getOwningTarget().getProject();
96 FrameworkLogger logger
= new FrameworkLogger(project
, "gencapsulehdr");
97 EdkLog
.setLogLevel(project
.getProperty("env.LOGLEVEL"));
98 EdkLog
.setLogger(logger
);
100 // absolute path of efi tools
102 String path
= project
.getProperty("env.FRAMEWORK_TOOLS_PATH");
108 command
= path
+ File
.separatorChar
+ toolName
;
113 File file
= new File(outputFile
);
114 if (!file
.isAbsolute() && (!this.outputDir
.equalsIgnoreCase(""))) {
115 argument
= this.verbose
+ this.dump
+ "-o " +this.outputDir
116 + File
.separatorChar
+ this.outputFile
+ " "
117 + this.scriptFile
+ " " + this.size
+ " " + this.joinFlag
+ this.capsuleFile
;
119 argument
= this.verbose
+ this.dump
+ "-o " + this.outputFile
120 + " " + this.scriptFile
+ " " + this.size
+ " " + this.joinFlag
+ this.capsuleFile
;
123 // return value of fwimage execution
128 Commandline cmdline
= new Commandline();
129 cmdline
.setExecutable(command
);
130 cmdline
.createArgument().setLine(argument
);
132 LogStreamHandler streamHandler
= new LogStreamHandler(this,
133 Project
.MSG_INFO
, Project
.MSG_WARN
);
134 Execute runner
= new Execute(streamHandler
, null);
136 runner
.setAntRun(project
);
137 runner
.setCommandline(cmdline
.getCommandline());
139 // Set debug log information.
141 EdkLog
.log(EdkLog
.EDK_VERBOSE
, Commandline
.toString(cmdline
.getCommandline()));
142 EdkLog
.log(EdkLog
.EDK_INFO
, (new File(scriptFile
)).getName());
143 revl
= runner
.execute();
145 if (EFI_SUCCESS
== revl
) {
147 // command execution success
149 EdkLog
.log(EdkLog
.EDK_VERBOSE
, "GenCapsuleHdr succeeded!");
152 // command execution fail
154 EdkLog
.log(EdkLog
.EDK_ERROR
, "ERROR = " + Integer
.toHexString(revl
));
155 throw new BuildException("GenCapsuleHdr failed!");
157 } catch (Exception e
) {
158 throw new BuildException(e
.getMessage());
165 * This function is to get class member "scriptFile".
167 * @return string of input file name.
169 public String
getScriptFile() {
170 return this.scriptFile
;
176 * This function is to set class member "inputFile".
179 * string of input file name.
181 public void setScriptFile(String scriptFile
) {
182 this.scriptFile
= "-script " + scriptFile
;
188 * This function is to get class member "outputFile"
190 * @return outputFile string of output file name.
192 public String
getOutputFile() {
199 * This function is to set class member "outputFile"
202 * string of output file name.
204 public void setOutputFile(String outputFile
) {
205 this.outputFile
= outputFile
+ " ";
211 * This function is to get class member "outputDir"
213 * @return outputDir string of output directory.
215 public String
getOutputDir() {
222 * This function is to set class member "outputDir"
225 * string of output directory.
227 public void setOutputDir(String outputDir
) {
228 this.outputDir
= outputDir
;
234 * This function is to get class member "verbose"
236 * @return verbose the flag of verbose.
238 public String
getVerbose() {
245 * This function is to set class member "verbose"
250 public void setVerbose(boolean verbose
) {
252 this.verbose
= "-v ";
259 * This function is to get class member "dump"
261 * @return verbose the flag of dump.
263 public String
getDump() {
270 * This function is to set class member "dump".
275 public void setDump(boolean dump
) {
277 this.dump
= "-dump ";
284 * This function is to set class member "size".
286 * @return size string of size value
288 public String
getSize() {
295 * This function is to set class member "size".
297 * @param size string of size value.
299 public void setSize(String size
) {
300 this.size
= "-split " + size
;
306 * This function is to get class member "capsuleFile"
308 * @return capsuleFile capsule file name
310 public String
getCapsuleFile() {
317 * This function is to set class member "capsuleFile"
319 * @param capsuleFile capsule file name
321 public void setCapsuleFile(String capsuleFile
) {
322 this.capsuleFile
= capsuleFile
;
328 * This function is to get class member "joinFlag"
330 * @return joinFlag flag of if need to join split capsule images into
333 public String
getJoinFlag() {
340 * This function is to set class member "joinFlag"
342 * @param joinFlag flag of if need to join split capsule images into
345 public void setJoinFlag(boolean joinFlag
) {
347 this.joinFlag
= "-j ";