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 FileArg scriptFile
= new FileArg();
49 private FileArg outputFile
= new FileArg();
52 // output directory, this variable is added by jave wrap
54 private String outputDir
= ".";
59 private ToolArg verbose
= new ToolArg();
64 private ToolArg dump
= new ToolArg();
69 private ToolArg size
= new ToolArg();
72 // capsule into one image flag
74 private ToolArg joinFlag
= new ToolArg();
79 private FileArg capsuleFile
= new FileArg();
85 GenCapsuleHdrTask execute function is to assemble tool command line & execute
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
.separator
+ toolName
;
107 argument
= "" + this.verbose
+ this.dump
+ this.outputFile
108 + this.scriptFile
+ this.size
+ this.joinFlag
+ this.capsuleFile
;
111 // return value of fwimage execution
116 Commandline cmdline
= new Commandline();
117 cmdline
.setExecutable(command
);
118 cmdline
.createArgument().setLine(argument
);
120 LogStreamHandler streamHandler
= new LogStreamHandler(this,
121 Project
.MSG_INFO
, Project
.MSG_WARN
);
122 Execute runner
= new Execute(streamHandler
, null);
124 runner
.setAntRun(project
);
125 runner
.setCommandline(cmdline
.getCommandline());
126 runner
.setWorkingDirectory(new File(outputDir
));
129 // Set debug log information.
131 EdkLog
.log(this, EdkLog
.EDK_VERBOSE
, Commandline
.toString(cmdline
.getCommandline()));
132 EdkLog
.log(this, EdkLog
.EDK_INFO
, scriptFile
.toFileList() + " => " +
133 outputFile
.toFileList() + capsuleFile
.toFileList());
135 revl
= runner
.execute();
136 if (EFI_SUCCESS
== revl
) {
138 // command execution success
140 EdkLog
.log(this, EdkLog
.EDK_VERBOSE
, toolName
+ " succeeded!");
143 // command execution fail
145 EdkLog
.log(this, EdkLog
.EDK_ERROR
, "ERROR = " + Integer
.toHexString(revl
));
146 throw new BuildException(toolName
+ " failed!");
148 } catch (Exception e
) {
149 throw new BuildException(e
.getMessage());
156 This function is to get class member "scriptFile".
158 @return string of input file name.
160 public String
getScriptFile() {
161 return this.scriptFile
.getValue();
167 This function is to set class member "inputFile".
170 string of input file name.
172 public void setScriptFile(String scriptFile
) {
173 this.scriptFile
.setArg(" -script ", scriptFile
);
179 This function is to get class member "outputFile"
181 @return outputFile string of output file name.
183 public String
getOutputFile() {
184 return outputFile
.getValue();
190 This function is to set class member "outputFile"
193 string of output file name.
195 public void setOutputFile(String outputFile
) {
196 this.outputFile
.setArg(" -o ", outputFile
);
202 This function is to get class member "outputDir"
204 @return outputDir string of output directory.
206 public String
getOutputDir() {
213 This function is to set class member "outputDir"
216 string of output directory.
218 public void setOutputDir(String outputDir
) {
219 this.outputDir
= outputDir
;
225 This function is to get class member "verbose"
227 @return verbose the flag of verbose.
229 public String
getVerbose() {
230 return this.verbose
.getValue();
236 This function is to set class member "verbose"
241 public void setVerbose(boolean verbose
) {
243 this.verbose
.setArg(" -", "v");
250 This function is to get class member "dump"
252 @return verbose the flag of dump.
254 public String
getDump() {
255 return dump
.getValue();
261 This function is to set class member "dump".
266 public void setDump(boolean dump
) {
268 this.dump
.setArg(" -", "dump");
275 This function is to set class member "size".
277 @return size string of size value
279 public String
getSize() {
280 return size
.getValue();
286 This function is to set class member "size".
288 @param size string of size value.
290 public void setSize(String size
) {
291 this.size
.setArg(" -split ", size
);
297 This function is to get class member "capsuleFile"
299 @return capsuleFile capsule file name
301 public String
getCapsuleFile() {
302 return capsuleFile
.getValue();
308 This function is to set class member "capsuleFile"
310 @param capsuleFile capsule file name
312 public void setCapsuleFile(String capsuleFile
) {
313 this.capsuleFile
.setArg(" ", capsuleFile
);
319 This function is to get class member "joinFlag"
321 @return joinFlag flag of if need to join split capsule images into
324 public String
getJoinFlag() {
325 return joinFlag
.getValue();
331 This function is to set class member "joinFlag"
333 @param joinFlag flag of if need to join split capsule images into
336 public void setJoinFlag(boolean joinFlag
) {
338 this.joinFlag
.setArg(" -", "j");