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