2 CreateMtFileTask class.
4 CreateMtFileTask is used to call CreateMtFile.exe to create MT file.
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 CreateMtFileTask class.
33 CreateMtFileTask is used to call CreateMtFile.exe to create MT file.
35 public class CreateMtFileTask
extends Task
implements EfiDefine
{
39 private String toolName
="CreateMtFile";
43 private String fileSize
= "";
48 private String outputFile
= "";
51 /// output directory, this variable is added by jave wrap
53 private String outputDir
= "";
58 * StripTask execute function is to assemble tool command line & execute
61 * @throws BuidException
63 public void execute() throws BuildException
{
65 Project project
= this.getOwningTarget().getProject();
68 // absolute path of efi tools
70 String path
= project
.getProperty("env.FRAMEWORK_TOOLS_PATH");
76 command
= path
+ File
.separatorChar
+ toolName
;
81 File file
= new File(outputFile
);
82 if (!file
.isAbsolute() && (!this.outputDir
.equalsIgnoreCase(""))) {
83 argument
= outputDir
+ File
.separatorChar
+ outputFile
+ " " + this.fileSize
;
86 argument
= outputFile
+ " " + this.fileSize
;
89 // return value of fwimage execution
94 Commandline cmdline
= new Commandline();
95 cmdline
.setExecutable(command
);
96 cmdline
.createArgument().setLine(argument
);
98 LogStreamHandler streamHandler
= new LogStreamHandler(this,
99 Project
.MSG_INFO
, Project
.MSG_WARN
);
100 Execute runner
= new Execute(streamHandler
, null);
102 runner
.setAntRun(project
);
103 runner
.setCommandline(cmdline
.getCommandline());
105 // Set debug log information.
107 EdkLog
.log(this, EdkLog
.EDK_VERBOSE
, Commandline
.toString(cmdline
.getCommandline()));
108 EdkLog
.log(this, EdkLog
.EDK_INFO
, (new File(this.outputFile
)).getName());
109 revl
= runner
.execute();
111 if (EFI_SUCCESS
== revl
) {
113 // command execution success
115 EdkLog
.log(this, EdkLog
.EDK_VERBOSE
, "CreateMtFile succeeded!");
118 // command execution fail
120 EdkLog
.log(this, EdkLog
.EDK_INFO
, "ERROR = " + Integer
.toHexString(revl
));
121 throw new BuildException("CreateMtFile failed!");
123 } catch (Exception e
) {
124 throw new BuildException(e
.getMessage());
131 * This function is to get class member "fileSize".
133 * @return fileSize string of file size.
135 public String
getFileSize() {
136 return this.fileSize
;
142 * This function is to set class member "fileSize".
145 * string of file size value.
147 public void setFileSize(String fileSize
) {
148 this.fileSize
= fileSize
;
154 * This function is to get class member "outputFile"
156 * @return outputFile string of output file name.
158 public String
getOutputFile() {
165 * This function is to set class member "outputFile"
168 * string of output file name.
170 public void setOutputFile(String outputFile
) {
171 this.outputFile
= outputFile
;
177 * This function is to get class member "outputDir"
179 * @return outputDir string of output directory.
181 public String
getOutputDir() {
188 * This function is to set class member "outputDir"
191 * string of output directory.
193 public void setOutputDir(String outputDir
) {
194 this.outputDir
= outputDir
;