]> git.proxmox.com Git - mirror_edk2.git/blame - Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/SecFixupTask.java
Changed FAT source module to FAT binary module
[mirror_edk2.git] / Tools / Source / FrameworkTasks / org / tianocore / framework / tasks / SecFixupTask.java
CommitLineData
a15bb0d3 1/** @file\r
2 SecFixupTask class.\r
3\r
4 SecFixupTask is used to call SecFixup.exe to fix up sec image.\r
5 \r
6 \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
12 \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
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
27import org.tianocore.logger.EdkLog;\r
28\r
29/**\r
30 * SecFixupTask class.\r
31 * \r
32 * SecFixupTask is used to call SecFixup.exe to fix up sec image.\r
33 */\r
34public class SecFixupTask extends Task implements EfiDefine {\r
35 // /\r
36 // / tool name\r
37 // /\r
38 private String toolName = "SecFixup";\r
39\r
40 // /\r
41 // / input file\r
42 // /\r
43 private String secExeFile = "";\r
44\r
45 // /\r
46 // / output file\r
47 // /\r
48 private String resetVectorDataFile = "";\r
49\r
50 // /\r
51 // / output directory, this variable is added by jave wrap\r
52 // /\r
53 private String outputFile = "";\r
54\r
55 // /\r
56 // / output directory\r
57 // /\r
58 private String outputDir = "";\r
59\r
60 /**\r
61 * execute\r
62 * \r
63 * SecFixupTask execute function is to assemble tool command line & execute\r
64 * tool command line\r
65 * \r
66 * @throws BuidException\r
67 */\r
68 public void execute() throws BuildException {\r
69\r
70 Project project = this.getOwningTarget().getProject();\r
71 //\r
72 // set Logger\r
73 //\r
74 FrameworkLogger logger = new FrameworkLogger(project, toolName\r
75 .toLowerCase());\r
76 EdkLog.setLogLevel(project.getProperty("env.LOGLEVEL"));\r
77 EdkLog.setLogger(logger);\r
78 //\r
79 // absolute path of efi tools\r
80 //\r
81 String path = project.getProperty("env.FRAMEWORK_TOOLS_PATH");\r
82 String command;\r
83 String argument;\r
84 if (path == null) {\r
85 command = toolName;\r
86 } else {\r
87 command = path + File.separatorChar + toolName;\r
88 }\r
89 //\r
90 // argument of tools\r
91 //\r
92 if (!this.outputDir.equalsIgnoreCase("")) {\r
93 argument = this.secExeFile + " " + this.resetVectorDataFile + " "\r
94 + this.outputDir + File.separatorChar + this.outputFile;\r
95 } else {\r
96 argument = this.secExeFile + " " + this.resetVectorDataFile + " "\r
97 + this.outputFile;\r
98 }\r
99\r
100 //\r
101 // return value of fwimage execution\r
102 //\r
103 int revl = -1;\r
104\r
105 try {\r
106 Commandline cmdline = new Commandline();\r
107 cmdline.setExecutable(command);\r
108 cmdline.createArgument().setLine(argument);\r
109\r
110 LogStreamHandler streamHandler = new LogStreamHandler(this,\r
111 Project.MSG_INFO, Project.MSG_WARN);\r
112 Execute runner = new Execute(streamHandler, null);\r
113\r
114 runner.setAntRun(project);\r
115 runner.setCommandline(cmdline.getCommandline());\r
116 //\r
117 // Set debug log information.\r
118 //\r
119 EdkLog.log(EdkLog.EDK_INFO, Commandline.toString(cmdline\r
120 .getCommandline()));\r
121\r
122 revl = runner.execute();\r
123\r
124 if (EFI_SUCCESS == revl) {\r
125 //\r
126 // command execution success\r
127 //\r
128 EdkLog.log(EdkLog.EDK_INFO, "SecFixup succeeded!");\r
129 } else {\r
130 //\r
131 // command execution fail\r
132 //\r
133 EdkLog.log(EdkLog.EDK_ERROR, "SecFixup failed. (error="\r
134 + Integer.toHexString(revl) + ")");\r
135 throw new BuildException("SecFixup failed. (error="\r
136 + Integer.toHexString(revl) + ")");\r
137\r
138 }\r
139 } catch (Exception e) {\r
140 throw new BuildException(e.getMessage());\r
141 }\r
142 }\r
143\r
144 /**\r
145 * getSecExeFile\r
146 * \r
147 * This function is to get class member "secExeFile".\r
148 * \r
149 * @return string of sectExe file name.\r
150 */\r
151 public String getSecExeFile() {\r
152 return this.secExeFile;\r
153 }\r
154\r
155 /**\r
156 * setSecExeFile\r
157 * \r
158 * This function is to set class member "secExeFile".\r
159 * \r
160 * @param secExeFile\r
161 * string of secExe file name.\r
162 */\r
163 public void setSecExeFile(String secExeFile) {\r
164 this.secExeFile = secExeFile;\r
165 }\r
166\r
167 /**\r
168 * getResetVectorDataFile\r
169 * \r
170 * This function is to get class member "resetVectorDataFile"\r
171 * \r
172 * @return resetVectorDataFile string of resetVectorData file name.\r
173 */\r
174 public String getResetVectorDataFile() {\r
175 return this.resetVectorDataFile;\r
176 }\r
177\r
178 /**\r
179 * setResetVectorDataFile\r
180 * \r
181 * This function is to set class member "resetVectorDataFile"\r
182 * \r
183 * @param resetVectorDataFile\r
184 * string of resetVectorData file name.\r
185 */\r
186 public void setResetVectorDataFile(String resetVectorDataFile) {\r
187 this.resetVectorDataFile = resetVectorDataFile;\r
188 }\r
189\r
190 /**\r
191 * getOutputFile\r
192 * \r
193 * This function is to get class member "outputFile"\r
194 * \r
195 * @return outputFile string of output file name.\r
196 */\r
197 public String getOutputFile() {\r
198 return outputFile;\r
199 }\r
200\r
201 /**\r
202 * setOutputFile\r
203 * \r
204 * This function is to set class member "outputFile"\r
205 * \r
206 * @param outputFile\r
207 * string of output file name.\r
208 */\r
209 public void setOutputFile(String outputFile) {\r
210 this.outputFile = outputFile;\r
211 }\r
212\r
213 /**\r
214 * getOutputDir\r
215 * \r
216 * This function is to get class member "outputDir"\r
217 * \r
218 * @return outputDir name of output directory\r
219 */\r
220 public String getOutputDir() {\r
221 return outputDir;\r
222 }\r
223\r
224 /**\r
225 * setOutputDir\r
226 * \r
227 * This function is to set class member "outputDir"\r
228 * \r
229 * @param outputDir\r
230 * name of output directory\r
231 */\r
232 public void setOutputDir(String outputDir) {\r
233 this.outputDir = outputDir;\r
234 }\r
235}\r