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();
94 // absolute path of efi tools
96 String path
= project
.getProperty("env.FRAMEWORK_TOOLS_PATH");
102 command
= path
+ File
.separatorChar
+ toolName
;
107 File file
= new File(outputFile
);
108 if (!file
.isAbsolute() && (!this.outputDir
.equalsIgnoreCase(""))) {
109 argument
= this.verbose
+ this.dump
+ "-o " +this.outputDir
110 + File
.separatorChar
+ this.outputFile
+ " "
111 + this.scriptFile
+ " " + this.size
+ " " + this.joinFlag
+ this.capsuleFile
;
113 argument
= this.verbose
+ this.dump
+ "-o " + this.outputFile
114 + " " + this.scriptFile
+ " " + this.size
+ " " + this.joinFlag
+ this.capsuleFile
;
117 // return value of fwimage execution
122 Commandline cmdline
= new Commandline();
123 cmdline
.setExecutable(command
);
124 cmdline
.createArgument().setLine(argument
);
126 LogStreamHandler streamHandler
= new LogStreamHandler(this,
127 Project
.MSG_INFO
, Project
.MSG_WARN
);
128 Execute runner
= new Execute(streamHandler
, null);
130 runner
.setAntRun(project
);
131 runner
.setCommandline(cmdline
.getCommandline());
133 // Set debug log information.
135 EdkLog
.log(this, EdkLog
.EDK_VERBOSE
, Commandline
.toString(cmdline
.getCommandline()));
136 EdkLog
.log(this, EdkLog
.EDK_INFO
, (new File(scriptFile
)).getName());
137 revl
= runner
.execute();
139 if (EFI_SUCCESS
== revl
) {
141 // command execution success
143 EdkLog
.log(this, EdkLog
.EDK_VERBOSE
, "GenCapsuleHdr succeeded!");
146 // command execution fail
148 EdkLog
.log(this, EdkLog
.EDK_ERROR
, "ERROR = " + Integer
.toHexString(revl
));
149 throw new BuildException("GenCapsuleHdr failed!");
151 } catch (Exception e
) {
152 throw new BuildException(e
.getMessage());
159 * This function is to get class member "scriptFile".
161 * @return string of input file name.
163 public String
getScriptFile() {
164 return this.scriptFile
;
170 * This function is to set class member "inputFile".
173 * string of input file name.
175 public void setScriptFile(String scriptFile
) {
176 this.scriptFile
= "-script " + scriptFile
;
182 * This function is to get class member "outputFile"
184 * @return outputFile string of output file name.
186 public String
getOutputFile() {
193 * This function is to set class member "outputFile"
196 * string of output file name.
198 public void setOutputFile(String outputFile
) {
199 this.outputFile
= outputFile
+ " ";
205 * This function is to get class member "outputDir"
207 * @return outputDir string of output directory.
209 public String
getOutputDir() {
216 * This function is to set class member "outputDir"
219 * string of output directory.
221 public void setOutputDir(String outputDir
) {
222 this.outputDir
= outputDir
;
228 * This function is to get class member "verbose"
230 * @return verbose the flag of verbose.
232 public String
getVerbose() {
239 * This function is to set class member "verbose"
244 public void setVerbose(boolean verbose
) {
246 this.verbose
= "-v ";
253 * This function is to get class member "dump"
255 * @return verbose the flag of dump.
257 public String
getDump() {
264 * This function is to set class member "dump".
269 public void setDump(boolean dump
) {
271 this.dump
= "-dump ";
278 * This function is to set class member "size".
280 * @return size string of size value
282 public String
getSize() {
289 * This function is to set class member "size".
291 * @param size string of size value.
293 public void setSize(String size
) {
294 this.size
= "-split " + size
;
300 * This function is to get class member "capsuleFile"
302 * @return capsuleFile capsule file name
304 public String
getCapsuleFile() {
311 * This function is to set class member "capsuleFile"
313 * @param capsuleFile capsule file name
315 public void setCapsuleFile(String capsuleFile
) {
316 this.capsuleFile
= capsuleFile
;
322 * This function is to get class member "joinFlag"
324 * @return joinFlag flag of if need to join split capsule images into
327 public String
getJoinFlag() {
334 * This function is to set class member "joinFlag"
336 * @param joinFlag flag of if need to join split capsule images into
339 public void setJoinFlag(boolean joinFlag
) {
341 this.joinFlag
= "-j ";