]> git.proxmox.com Git - mirror_edk2.git/blame - Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/CreateMtFileTask.java
Changed spelling to manifest
[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
0fdb42ac 36 //\r
37 // Tool name\r
38 //\r
39 private String toolName = "CreateMtFile";\r
40 //\r
41 // file size\r
42 //\r
43 private ToolArg fileSize = new ToolArg();\r
44\r
45 //\r
46 // output file\r
47 //\r
48 private FileArg outputFile = new FileArg();\r
49\r
50 //\r
51 // output directory, this variable is added by jave wrap\r
52 //\r
53 private String outputDir = ".";\r
a15bb0d3 54\r
55 /**\r
0fdb42ac 56 execute\r
57 \r
58 StripTask execute function is to assemble tool command line & execute\r
59 tool command line\r
60 \r
61 @throws BuidException\r
62 **/\r
a15bb0d3 63 public void execute() throws BuildException {\r
64\r
65 Project project = this.getOwningTarget().getProject();\r
91f7d582 66\r
a15bb0d3 67 //\r
68 // absolute path of efi tools\r
69 //\r
70 String path = project.getProperty("env.FRAMEWORK_TOOLS_PATH");\r
71 String command;\r
72 String argument;\r
73 if (path == null) {\r
74 command = toolName;\r
75 } else {\r
0fdb42ac 76 command = path + File.separator + toolName;\r
a15bb0d3 77 }\r
78 //\r
79 // argument of tools\r
80 //\r
0fdb42ac 81 argument = "" + outputFile + fileSize;\r
a15bb0d3 82 //\r
83 // return value of fwimage execution\r
84 //\r
85 int revl = -1;\r
86\r
87 try {\r
88 Commandline cmdline = new Commandline();\r
89 cmdline.setExecutable(command);\r
90 cmdline.createArgument().setLine(argument);\r
91\r
92 LogStreamHandler streamHandler = new LogStreamHandler(this,\r
93 Project.MSG_INFO, Project.MSG_WARN);\r
94 Execute runner = new Execute(streamHandler, null);\r
95\r
96 runner.setAntRun(project);\r
97 runner.setCommandline(cmdline.getCommandline());\r
0fdb42ac 98 runner.setWorkingDirectory(new File(outputDir));\r
99\r
a15bb0d3 100 //\r
101 // Set debug log information.\r
102 //\r
91f7d582 103 EdkLog.log(this, EdkLog.EDK_VERBOSE, Commandline.toString(cmdline.getCommandline()));\r
0fdb42ac 104 EdkLog.log(this, EdkLog.EDK_INFO, this.outputFile.toFileList());\r
ff225cbb 105\r
0fdb42ac 106 revl = runner.execute();\r
a15bb0d3 107 if (EFI_SUCCESS == revl) {\r
108 //\r
109 // command execution success\r
110 //\r
0fdb42ac 111 EdkLog.log(this, EdkLog.EDK_VERBOSE, toolName + " succeeded!");\r
a15bb0d3 112 } else {\r
113 //\r
114 // command execution fail\r
115 //\r
91f7d582 116 EdkLog.log(this, EdkLog.EDK_INFO, "ERROR = " + Integer.toHexString(revl));\r
0fdb42ac 117 throw new BuildException(toolName + " failed!");\r
a15bb0d3 118 }\r
119 } catch (Exception e) {\r
120 throw new BuildException(e.getMessage());\r
121 }\r
122 }\r
123\r
124 /**\r
0fdb42ac 125 getFileSize\r
126 \r
127 This function is to get class member "fileSize".\r
128 \r
129 @return fileSize string of file size.\r
130 **/\r
a15bb0d3 131 public String getFileSize() {\r
0fdb42ac 132 return this.fileSize.getValue();\r
a15bb0d3 133 }\r
134\r
135 /**\r
0fdb42ac 136 setFileSize\r
137 \r
138 This function is to set class member "fileSize".\r
139 \r
140 @param fileSize\r
141 string of file size value.\r
142 **/\r
a15bb0d3 143 public void setFileSize(String fileSize) {\r
0fdb42ac 144 this.fileSize.setArg(" ", fileSize);\r
a15bb0d3 145 }\r
146\r
147 /**\r
0fdb42ac 148 getOutputFile\r
149 \r
150 This function is to get class member "outputFile"\r
151 \r
152 @return outputFile string of output file name.\r
153 **/\r
a15bb0d3 154 public String getOutputFile() {\r
0fdb42ac 155 return outputFile.getValue();\r
a15bb0d3 156 }\r
157\r
158 /**\r
0fdb42ac 159 setOutputFile\r
160 \r
161 This function is to set class member "outputFile"\r
162 \r
163 @param outputFile\r
164 string of output file name.\r
165 **/\r
a15bb0d3 166 public void setOutputFile(String outputFile) {\r
0fdb42ac 167 this.outputFile.setArg(" ", outputFile);\r
a15bb0d3 168 }\r
169\r
170 /**\r
0fdb42ac 171 getOutputDir\r
172 \r
173 This function is to get class member "outputDir"\r
174 \r
175 @return outputDir string of output directory.\r
176 **/\r
a15bb0d3 177 public String getOutputDir() {\r
178 return outputDir;\r
179 }\r
180\r
181 /**\r
0fdb42ac 182 setOutputDir\r
183 \r
184 This function is to set class member "outputDir"\r
185 \r
186 @param outputDir\r
187 string of output directory.\r
188 **/\r
a15bb0d3 189 public void setOutputDir(String outputDir) {\r
190 this.outputDir = outputDir;\r
191 }\r
192}\r