]> git.proxmox.com Git - mirror_edk2.git/blame - 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
a15bb0d3 1/** @file\r
2 SecFixupTask class.\r
3\r
4 SecFixupTask is used to call SecFixup.exe to fix up sec image.\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 * SecFixupTask class.\r
ff225cbb 32 *\r
a15bb0d3 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
ff225cbb 63 *\r
a15bb0d3 64 * SecFixupTask execute function is to assemble tool command line & execute\r
65 * tool command line\r
ff225cbb 66 *\r
a15bb0d3 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
219e2247 120 EdkLog.log(EdkLog.EDK_VERBOSE, Commandline.toString(cmdline.getCommandline()));\r
a15bb0d3 121\r
122 revl = runner.execute();\r
123\r
124 if (EFI_SUCCESS == revl) {\r
125 //\r
126 // command execution success\r
127 //\r
219e2247 128 EdkLog.log(EdkLog.EDK_VERBOSE, "SecFixup succeeded!");\r
a15bb0d3 129 } else {\r
130 //\r
131 // command execution fail\r
132 //\r
219e2247 133 EdkLog.log(EdkLog.EDK_INFO, "ERROR = "+ Integer.toHexString(revl));\r
134 throw new BuildException("SecFixup failed!");\r
a15bb0d3 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
ff225cbb 143 *\r
a15bb0d3 144 * This function is to get class member "secExeFile".\r
ff225cbb 145 *\r
a15bb0d3 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
ff225cbb 154 *\r
a15bb0d3 155 * This function is to set class member "secExeFile".\r
ff225cbb 156 *\r
a15bb0d3 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
ff225cbb 166 *\r
a15bb0d3 167 * This function is to get class member "resetVectorDataFile"\r
ff225cbb 168 *\r
a15bb0d3 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
ff225cbb 177 *\r
a15bb0d3 178 * This function is to set class member "resetVectorDataFile"\r
ff225cbb 179 *\r
a15bb0d3 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
ff225cbb 189 *\r
a15bb0d3 190 * This function is to get class member "outputFile"\r
ff225cbb 191 *\r
a15bb0d3 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
ff225cbb 200 *\r
a15bb0d3 201 * This function is to set class member "outputFile"\r
ff225cbb 202 *\r
a15bb0d3 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
ff225cbb 212 *\r
a15bb0d3 213 * This function is to get class member "outputDir"\r
ff225cbb 214 *\r
a15bb0d3 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
ff225cbb 223 *\r
a15bb0d3 224 * This function is to set class member "outputDir"\r
ff225cbb 225 *\r
a15bb0d3 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