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 ToolArg fileSize
= new ToolArg();
48 private FileArg outputFile
= new FileArg();
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
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
.separator
+ toolName
;
81 argument
= "" + outputFile
+ fileSize
;
83 // return value of fwimage execution
88 Commandline cmdline
= new Commandline();
89 cmdline
.setExecutable(command
);
90 cmdline
.createArgument().setLine(argument
);
92 LogStreamHandler streamHandler
= new LogStreamHandler(this,
93 Project
.MSG_INFO
, Project
.MSG_WARN
);
94 Execute runner
= new Execute(streamHandler
, null);
96 runner
.setAntRun(project
);
97 runner
.setCommandline(cmdline
.getCommandline());
98 runner
.setWorkingDirectory(new File(outputDir
));
101 // Set debug log information.
103 EdkLog
.log(this, EdkLog
.EDK_VERBOSE
, Commandline
.toString(cmdline
.getCommandline()));
104 EdkLog
.log(this, EdkLog
.EDK_INFO
, this.outputFile
.toFileList());
106 revl
= runner
.execute();
107 if (EFI_SUCCESS
== revl
) {
109 // command execution success
111 EdkLog
.log(this, EdkLog
.EDK_VERBOSE
, toolName
+ " succeeded!");
114 // command execution fail
116 EdkLog
.log(this, EdkLog
.EDK_INFO
, "ERROR = " + Integer
.toHexString(revl
));
117 throw new BuildException(toolName
+ " failed!");
119 } catch (Exception e
) {
120 throw new BuildException(e
.getMessage());
127 This function is to get class member "fileSize".
129 @return fileSize string of file size.
131 public String
getFileSize() {
132 return this.fileSize
.getValue();
138 This function is to set class member "fileSize".
141 string of file size value.
143 public void setFileSize(String fileSize
) {
144 this.fileSize
.setArg(" ", fileSize
);
150 This function is to get class member "outputFile"
152 @return outputFile string of output file name.
154 public String
getOutputFile() {
155 return outputFile
.getValue();
161 This function is to set class member "outputFile"
164 string of output file name.
166 public void setOutputFile(String outputFile
) {
167 this.outputFile
.setArg(" ", outputFile
);
173 This function is to get class member "outputDir"
175 @return outputDir string of output directory.
177 public String
getOutputDir() {
184 This function is to set class member "outputDir"
187 string of output directory.
189 public void setOutputDir(String outputDir
) {
190 this.outputDir
= outputDir
;