]> git.proxmox.com Git - mirror_edk2.git/blame - Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/CreateMtFileTask.java
Modify GenFfsTask to make it don't create ORG file.
[mirror_edk2.git] / Tools / Source / FrameworkTasks / org / tianocore / framework / tasks / CreateMtFileTask.java
CommitLineData
a15bb0d3 1/** @file\r
2 CreateMtFileTask class.\r
3\r
4 CreateMtFileTask is used to call CreateMtFile.exe to create MT file.\r
ff225cbb 5\r
6\r
a15bb0d3 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
ff225cbb 12\r
a15bb0d3 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
15\r
16 **/\r
17package org.tianocore.framework.tasks;\r
18\r
19import java.io.File;\r
20\r
21import org.apache.tools.ant.Task;\r
22import org.apache.tools.ant.Project;\r
23import org.apache.tools.ant.BuildException;\r
24import org.apache.tools.ant.taskdefs.Execute;\r
25import org.apache.tools.ant.taskdefs.LogStreamHandler;\r
26import org.apache.tools.ant.types.Commandline;\r
ff225cbb 27\r
28import org.tianocore.common.logger.EdkLog;\r
a15bb0d3 29\r
30/**\r
31 CreateMtFileTask class.\r
32\r
33 CreateMtFileTask is used to call CreateMtFile.exe to create MT file.\r
34**/\r
35public class CreateMtFileTask extends Task implements EfiDefine {\r
36 ///\r
37 /// Tool name\r
38 ///\r
39 private String toolName="CreateMtFile";\r
40 ///\r
41 /// file size\r
42 ///\r
43 private String fileSize = "";\r
44\r
45 ///\r
46 /// output file\r
47 ///\r
48 private String outputFile = "";\r
49\r
50 ///\r
51 /// output directory, this variable is added by jave wrap\r
52 ///\r
53 private String outputDir = "";\r
54\r
55 /**\r
56 * execute\r
ff225cbb 57 *\r
a15bb0d3 58 * StripTask execute function is to assemble tool command line & execute\r
59 * tool command line\r
ff225cbb 60 *\r
a15bb0d3 61 * @throws BuidException\r
62 */\r
63 public void execute() throws BuildException {\r
64\r
65 Project project = this.getOwningTarget().getProject();\r
66 //\r
67 // set Logger\r
68 //\r
69 FrameworkLogger logger = new FrameworkLogger(project, "createmtfile");\r
70 EdkLog.setLogLevel(project.getProperty("env.LOGLEVEL"));\r
71 EdkLog.setLogger(logger);\r
72 //\r
73 // absolute path of efi tools\r
74 //\r
75 String path = project.getProperty("env.FRAMEWORK_TOOLS_PATH");\r
76 String command;\r
77 String argument;\r
78 if (path == null) {\r
79 command = toolName;\r
80 } else {\r
81 command = path + File.separatorChar + toolName;\r
82 }\r
83 //\r
84 // argument of tools\r
85 //\r
86 File file = new File(outputFile);\r
87 if (!file.isAbsolute() && (!this.outputDir.equalsIgnoreCase(""))) {\r
88 argument = outputDir + File.separatorChar + outputFile + " " + this.fileSize;\r
ff225cbb 89\r
a15bb0d3 90 } else {\r
91 argument = outputFile + " " + this.fileSize;\r
92 }\r
93 //\r
94 // return value of fwimage execution\r
95 //\r
96 int revl = -1;\r
97\r
98 try {\r
99 Commandline cmdline = new Commandline();\r
100 cmdline.setExecutable(command);\r
101 cmdline.createArgument().setLine(argument);\r
102\r
103 LogStreamHandler streamHandler = new LogStreamHandler(this,\r
104 Project.MSG_INFO, Project.MSG_WARN);\r
105 Execute runner = new Execute(streamHandler, null);\r
106\r
107 runner.setAntRun(project);\r
108 runner.setCommandline(cmdline.getCommandline());\r
109 //\r
110 // Set debug log information.\r
111 //\r
219e2247 112 EdkLog.log(EdkLog.EDK_VERBOSE, Commandline.toString(cmdline.getCommandline()));\r
113 EdkLog.log(EdkLog.EDK_INFO, (new File(this.outputFile)).getName());\r
a15bb0d3 114 revl = runner.execute();\r
ff225cbb 115\r
a15bb0d3 116 if (EFI_SUCCESS == revl) {\r
117 //\r
118 // command execution success\r
119 //\r
219e2247 120 EdkLog.log(EdkLog.EDK_VERBOSE, "CreateMtFile succeeded!");\r
a15bb0d3 121 } else {\r
122 //\r
123 // command execution fail\r
124 //\r
3f7b510e 125 EdkLog.log(EdkLog.EDK_INFO, "ERROR = " + Integer.toHexString(revl));\r
219e2247 126 throw new BuildException("CreateMtFile failed!");\r
a15bb0d3 127 }\r
128 } catch (Exception e) {\r
129 throw new BuildException(e.getMessage());\r
130 }\r
131 }\r
132\r
133 /**\r
134 * getFileSize\r
ff225cbb 135 *\r
a15bb0d3 136 * This function is to get class member "fileSize".\r
ff225cbb 137 *\r
a15bb0d3 138 * @return fileSize string of file size.\r
139 */\r
140 public String getFileSize() {\r
141 return this.fileSize;\r
142 }\r
143\r
144 /**\r
145 * setFileSize\r
ff225cbb 146 *\r
a15bb0d3 147 * This function is to set class member "fileSize".\r
ff225cbb 148 *\r
a15bb0d3 149 * @param fileSize\r
150 * string of file size value.\r
151 */\r
152 public void setFileSize(String fileSize) {\r
153 this.fileSize = fileSize;\r
154 }\r
155\r
156 /**\r
157 * getOutputFile\r
ff225cbb 158 *\r
a15bb0d3 159 * This function is to get class member "outputFile"\r
ff225cbb 160 *\r
a15bb0d3 161 * @return outputFile string of output file name.\r
162 */\r
163 public String getOutputFile() {\r
164 return outputFile;\r
165 }\r
166\r
167 /**\r
168 * setOutputFile\r
ff225cbb 169 *\r
a15bb0d3 170 * This function is to set class member "outputFile"\r
ff225cbb 171 *\r
a15bb0d3 172 * @param outputFile\r
173 * string of output file name.\r
174 */\r
175 public void setOutputFile(String outputFile) {\r
176 this.outputFile = outputFile;\r
177 }\r
178\r
179 /**\r
180 * getOutputDir\r
ff225cbb 181 *\r
a15bb0d3 182 * This function is to get class member "outputDir"\r
ff225cbb 183 *\r
a15bb0d3 184 * @return outputDir string of output directory.\r
185 */\r
186 public String getOutputDir() {\r
187 return outputDir;\r
188 }\r
189\r
190 /**\r
191 * setOutputDir\r
ff225cbb 192 *\r
a15bb0d3 193 * This function is to set class member "outputDir"\r
ff225cbb 194 *\r
a15bb0d3 195 * @param outputDir\r
196 * string of output directory.\r
197 */\r
198 public void setOutputDir(String outputDir) {\r
199 this.outputDir = outputDir;\r
200 }\r
201}\r