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
;
27 import org
.tianocore
.logger
.EdkLog
;
30 CreateMtFileTask class.
32 CreateMtFileTask is used to call CreateMtFile.exe to create MT file.
34 public class CreateMtFileTask
extends Task
implements EfiDefine
{
38 private String toolName
="CreateMtFile";
42 private String fileSize
= "";
47 private String outputFile
= "";
50 /// output directory, this variable is added by jave wrap
52 private String outputDir
= "";
57 * StripTask execute function is to assemble tool command line & execute
60 * @throws BuidException
62 public void execute() throws BuildException
{
64 Project project
= this.getOwningTarget().getProject();
68 FrameworkLogger logger
= new FrameworkLogger(project
, "createmtfile");
69 EdkLog
.setLogLevel(project
.getProperty("env.LOGLEVEL"));
70 EdkLog
.setLogger(logger
);
72 // absolute path of efi tools
74 String path
= project
.getProperty("env.FRAMEWORK_TOOLS_PATH");
80 command
= path
+ File
.separatorChar
+ toolName
;
85 File file
= new File(outputFile
);
86 if (!file
.isAbsolute() && (!this.outputDir
.equalsIgnoreCase(""))) {
87 argument
= outputDir
+ File
.separatorChar
+ outputFile
+ " " + this.fileSize
;
90 argument
= outputFile
+ " " + this.fileSize
;
93 // return value of fwimage execution
98 Commandline cmdline
= new Commandline();
99 cmdline
.setExecutable(command
);
100 cmdline
.createArgument().setLine(argument
);
102 LogStreamHandler streamHandler
= new LogStreamHandler(this,
103 Project
.MSG_INFO
, Project
.MSG_WARN
);
104 Execute runner
= new Execute(streamHandler
, null);
106 runner
.setAntRun(project
);
107 runner
.setCommandline(cmdline
.getCommandline());
109 // Set debug log information.
111 EdkLog
.log(EdkLog
.EDK_INFO
, Commandline
.toString(cmdline
.getCommandline()));
113 revl
= runner
.execute();
115 if (EFI_SUCCESS
== revl
) {
117 // command execution success
119 EdkLog
.log(EdkLog
.EDK_INFO
,"CreateMtFile succeeded!");
122 // command execution fail
124 EdkLog
.log(EdkLog
.EDK_ERROR
, "CreateMtFile failed. (error="
125 + Integer
.toHexString(revl
) + ")");
126 throw new BuildException("CreateMtFile failed. (error="
127 + Integer
.toHexString(revl
) + ")");
130 } catch (Exception e
) {
131 throw new BuildException(e
.getMessage());
138 * This function is to get class member "fileSize".
140 * @return fileSize string of file size.
142 public String
getFileSize() {
143 return this.fileSize
;
149 * This function is to set class member "fileSize".
152 * string of file size value.
154 public void setFileSize(String fileSize
) {
155 this.fileSize
= fileSize
;
161 * This function is to get class member "outputFile"
163 * @return outputFile string of output file name.
165 public String
getOutputFile() {
172 * This function is to set class member "outputFile"
175 * string of output file name.
177 public void setOutputFile(String outputFile
) {
178 this.outputFile
= outputFile
;
184 * This function is to get class member "outputDir"
186 * @return outputDir string of output directory.
188 public String
getOutputDir() {
195 * This function is to set class member "outputDir"
198 * string of output directory.
200 public void setOutputDir(String outputDir
) {
201 this.outputDir
= outputDir
;