]> git.proxmox.com Git - mirror_edk2.git/blame - Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/SecFixupTask.java
Polished the build tools' screen output to be in a more coherent form
[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
219e2247 119 EdkLog.log(EdkLog.EDK_VERBOSE, Commandline.toString(cmdline.getCommandline()));\r
a15bb0d3 120\r
121 revl = runner.execute();\r
122\r
123 if (EFI_SUCCESS == revl) {\r
124 //\r
125 // command execution success\r
126 //\r
219e2247 127 EdkLog.log(EdkLog.EDK_VERBOSE, "SecFixup succeeded!");\r
a15bb0d3 128 } else {\r
129 //\r
130 // command execution fail\r
131 //\r
219e2247 132 EdkLog.log(EdkLog.EDK_INFO, "ERROR = "+ Integer.toHexString(revl));\r
133 throw new BuildException("SecFixup failed!");\r
a15bb0d3 134 }\r
135 } catch (Exception e) {\r
136 throw new BuildException(e.getMessage());\r
137 }\r
138 }\r
139\r
140 /**\r
141 * getSecExeFile\r
142 * \r
143 * This function is to get class member "secExeFile".\r
144 * \r
145 * @return string of sectExe file name.\r
146 */\r
147 public String getSecExeFile() {\r
148 return this.secExeFile;\r
149 }\r
150\r
151 /**\r
152 * setSecExeFile\r
153 * \r
154 * This function is to set class member "secExeFile".\r
155 * \r
156 * @param secExeFile\r
157 * string of secExe file name.\r
158 */\r
159 public void setSecExeFile(String secExeFile) {\r
160 this.secExeFile = secExeFile;\r
161 }\r
162\r
163 /**\r
164 * getResetVectorDataFile\r
165 * \r
166 * This function is to get class member "resetVectorDataFile"\r
167 * \r
168 * @return resetVectorDataFile string of resetVectorData file name.\r
169 */\r
170 public String getResetVectorDataFile() {\r
171 return this.resetVectorDataFile;\r
172 }\r
173\r
174 /**\r
175 * setResetVectorDataFile\r
176 * \r
177 * This function is to set class member "resetVectorDataFile"\r
178 * \r
179 * @param resetVectorDataFile\r
180 * string of resetVectorData file name.\r
181 */\r
182 public void setResetVectorDataFile(String resetVectorDataFile) {\r
183 this.resetVectorDataFile = resetVectorDataFile;\r
184 }\r
185\r
186 /**\r
187 * getOutputFile\r
188 * \r
189 * This function is to get class member "outputFile"\r
190 * \r
191 * @return outputFile string of output file name.\r
192 */\r
193 public String getOutputFile() {\r
194 return outputFile;\r
195 }\r
196\r
197 /**\r
198 * setOutputFile\r
199 * \r
200 * This function is to set class member "outputFile"\r
201 * \r
202 * @param outputFile\r
203 * string of output file name.\r
204 */\r
205 public void setOutputFile(String outputFile) {\r
206 this.outputFile = outputFile;\r
207 }\r
208\r
209 /**\r
210 * getOutputDir\r
211 * \r
212 * This function is to get class member "outputDir"\r
213 * \r
214 * @return outputDir name of output directory\r
215 */\r
216 public String getOutputDir() {\r
217 return outputDir;\r
218 }\r
219\r
220 /**\r
221 * setOutputDir\r
222 * \r
223 * This function is to set class member "outputDir"\r
224 * \r
225 * @param outputDir\r
226 * name of output directory\r
227 */\r
228 public void setOutputDir(String outputDir) {\r
229 this.outputDir = outputDir;\r
230 }\r
231}\r