2 CreateMtFileTask class.
\r
4 CreateMtFileTask is used to call CreateMtFile.exe to create MT file.
\r
7 Copyright (c) 2006, Intel Corporation
\r
8 All rights reserved. This program and the accompanying materials
\r
9 are licensed and made available under the terms and conditions of the BSD License
\r
10 which accompanies this distribution. The full text of the license may be found at
\r
11 http://opensource.org/licenses/bsd-license.php
\r
13 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
\r
14 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
\r
17 package org.tianocore.framework.tasks;
\r
19 import java.io.File;
\r
21 import org.apache.tools.ant.Task;
\r
22 import org.apache.tools.ant.Project;
\r
23 import org.apache.tools.ant.BuildException;
\r
24 import org.apache.tools.ant.taskdefs.Execute;
\r
25 import org.apache.tools.ant.taskdefs.LogStreamHandler;
\r
26 import org.apache.tools.ant.types.Commandline;
\r
28 import org.tianocore.common.logger.EdkLog;
\r
31 CreateMtFileTask class.
\r
33 CreateMtFileTask is used to call CreateMtFile.exe to create MT file.
\r
35 public class CreateMtFileTask extends Task implements EfiDefine {
\r
39 private String toolName = "CreateMtFile";
\r
43 private ToolArg fileSize = new ToolArg();
\r
48 private FileArg outputFile = new FileArg();
\r
51 // output directory, this variable is added by jave wrap
\r
53 private String outputDir = ".";
\r
58 StripTask execute function is to assemble tool command line & execute
\r
61 @throws BuidException
\r
63 public void execute() throws BuildException {
\r
65 Project project = this.getOwningTarget().getProject();
\r
68 // absolute path of efi tools
\r
70 String path = project.getProperty("env.FRAMEWORK_TOOLS_PATH");
\r
76 command = path + File.separator + toolName;
\r
79 // argument of tools
\r
81 argument = "" + outputFile + fileSize;
\r
83 // return value of fwimage execution
\r
88 Commandline cmdline = new Commandline();
\r
89 cmdline.setExecutable(command);
\r
90 cmdline.createArgument().setLine(argument);
\r
92 LogStreamHandler streamHandler = new LogStreamHandler(this,
\r
93 Project.MSG_INFO, Project.MSG_WARN);
\r
94 Execute runner = new Execute(streamHandler, null);
\r
96 runner.setAntRun(project);
\r
97 runner.setCommandline(cmdline.getCommandline());
\r
98 runner.setWorkingDirectory(new File(outputDir));
\r
101 // Set debug log information.
\r
103 EdkLog.log(this, EdkLog.EDK_VERBOSE, Commandline.toString(cmdline.getCommandline()));
\r
104 EdkLog.log(this, EdkLog.EDK_INFO, this.outputFile.toFileList());
\r
106 revl = runner.execute();
\r
107 if (EFI_SUCCESS == revl) {
\r
109 // command execution success
\r
111 EdkLog.log(this, EdkLog.EDK_VERBOSE, toolName + " succeeded!");
\r
114 // command execution fail
\r
116 EdkLog.log(this, EdkLog.EDK_INFO, "ERROR = " + Integer.toHexString(revl));
\r
117 throw new BuildException(toolName + " failed!");
\r
119 } catch (Exception e) {
\r
120 throw new BuildException(e.getMessage());
\r
127 This function is to get class member "fileSize".
\r
129 @return fileSize string of file size.
\r
131 public String getFileSize() {
\r
132 return this.fileSize.getValue();
\r
138 This function is to set class member "fileSize".
\r
141 string of file size value.
\r
143 public void setFileSize(String fileSize) {
\r
144 this.fileSize.setArg(" ", fileSize);
\r
150 This function is to get class member "outputFile"
\r
152 @return outputFile string of output file name.
\r
154 public String getOutputFile() {
\r
155 return outputFile.getValue();
\r
161 This function is to set class member "outputFile"
\r
164 string of output file name.
\r
166 public void setOutputFile(String outputFile) {
\r
167 this.outputFile.setArg(" ", outputFile);
\r
173 This function is to get class member "outputDir"
\r
175 @return outputDir string of output directory.
\r
177 public String getOutputDir() {
\r
184 This function is to set class member "outputDir"
\r
187 string of output directory.
\r
189 public void setOutputDir(String outputDir) {
\r
190 this.outputDir = outputDir;
\r