]> git.proxmox.com Git - mirror_edk2.git/blame - Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/SecFixupTask.java
Update log.
[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
91f7d582 72\r
a15bb0d3 73 //\r
74 // absolute path of efi tools\r
75 //\r
76 String path = project.getProperty("env.FRAMEWORK_TOOLS_PATH");\r
77 String command;\r
78 String argument;\r
79 if (path == null) {\r
80 command = toolName;\r
81 } else {\r
82 command = path + File.separatorChar + toolName;\r
83 }\r
84 //\r
85 // argument of tools\r
86 //\r
87 if (!this.outputDir.equalsIgnoreCase("")) {\r
88 argument = this.secExeFile + " " + this.resetVectorDataFile + " "\r
89 + this.outputDir + File.separatorChar + this.outputFile;\r
90 } else {\r
91 argument = this.secExeFile + " " + this.resetVectorDataFile + " "\r
92 + this.outputFile;\r
93 }\r
94\r
95 //\r
96 // return value of fwimage execution\r
97 //\r
98 int revl = -1;\r
99\r
100 try {\r
101 Commandline cmdline = new Commandline();\r
102 cmdline.setExecutable(command);\r
103 cmdline.createArgument().setLine(argument);\r
104\r
105 LogStreamHandler streamHandler = new LogStreamHandler(this,\r
106 Project.MSG_INFO, Project.MSG_WARN);\r
107 Execute runner = new Execute(streamHandler, null);\r
108\r
109 runner.setAntRun(project);\r
110 runner.setCommandline(cmdline.getCommandline());\r
111 //\r
112 // Set debug log information.\r
113 //\r
91f7d582 114 EdkLog.log(this, EdkLog.EDK_VERBOSE, Commandline.toString(cmdline.getCommandline()));\r
a15bb0d3 115\r
116 revl = runner.execute();\r
117\r
118 if (EFI_SUCCESS == revl) {\r
119 //\r
120 // command execution success\r
121 //\r
91f7d582 122 EdkLog.log(this, EdkLog.EDK_VERBOSE, "SecFixup succeeded!");\r
a15bb0d3 123 } else {\r
124 //\r
125 // command execution fail\r
126 //\r
91f7d582 127 EdkLog.log(this, EdkLog.EDK_INFO, "ERROR = "+ Integer.toHexString(revl));\r
219e2247 128 throw new BuildException("SecFixup failed!");\r
a15bb0d3 129 }\r
130 } catch (Exception e) {\r
131 throw new BuildException(e.getMessage());\r
132 }\r
133 }\r
134\r
135 /**\r
136 * getSecExeFile\r
ff225cbb 137 *\r
a15bb0d3 138 * This function is to get class member "secExeFile".\r
ff225cbb 139 *\r
a15bb0d3 140 * @return string of sectExe file name.\r
141 */\r
142 public String getSecExeFile() {\r
143 return this.secExeFile;\r
144 }\r
145\r
146 /**\r
147 * setSecExeFile\r
ff225cbb 148 *\r
a15bb0d3 149 * This function is to set class member "secExeFile".\r
ff225cbb 150 *\r
a15bb0d3 151 * @param secExeFile\r
152 * string of secExe file name.\r
153 */\r
154 public void setSecExeFile(String secExeFile) {\r
155 this.secExeFile = secExeFile;\r
156 }\r
157\r
158 /**\r
159 * getResetVectorDataFile\r
ff225cbb 160 *\r
a15bb0d3 161 * This function is to get class member "resetVectorDataFile"\r
ff225cbb 162 *\r
a15bb0d3 163 * @return resetVectorDataFile string of resetVectorData file name.\r
164 */\r
165 public String getResetVectorDataFile() {\r
166 return this.resetVectorDataFile;\r
167 }\r
168\r
169 /**\r
170 * setResetVectorDataFile\r
ff225cbb 171 *\r
a15bb0d3 172 * This function is to set class member "resetVectorDataFile"\r
ff225cbb 173 *\r
a15bb0d3 174 * @param resetVectorDataFile\r
175 * string of resetVectorData file name.\r
176 */\r
177 public void setResetVectorDataFile(String resetVectorDataFile) {\r
178 this.resetVectorDataFile = resetVectorDataFile;\r
179 }\r
180\r
181 /**\r
182 * getOutputFile\r
ff225cbb 183 *\r
a15bb0d3 184 * This function is to get class member "outputFile"\r
ff225cbb 185 *\r
a15bb0d3 186 * @return outputFile string of output file name.\r
187 */\r
188 public String getOutputFile() {\r
189 return outputFile;\r
190 }\r
191\r
192 /**\r
193 * setOutputFile\r
ff225cbb 194 *\r
a15bb0d3 195 * This function is to set class member "outputFile"\r
ff225cbb 196 *\r
a15bb0d3 197 * @param outputFile\r
198 * string of output file name.\r
199 */\r
200 public void setOutputFile(String outputFile) {\r
201 this.outputFile = outputFile;\r
202 }\r
203\r
204 /**\r
205 * getOutputDir\r
ff225cbb 206 *\r
a15bb0d3 207 * This function is to get class member "outputDir"\r
ff225cbb 208 *\r
a15bb0d3 209 * @return outputDir name of output directory\r
210 */\r
211 public String getOutputDir() {\r
212 return outputDir;\r
213 }\r
214\r
215 /**\r
216 * setOutputDir\r
ff225cbb 217 *\r
a15bb0d3 218 * This function is to set class member "outputDir"\r
ff225cbb 219 *\r
a15bb0d3 220 * @param outputDir\r
221 * name of output directory\r
222 */\r
223 public void setOutputDir(String outputDir) {\r
224 this.outputDir = outputDir;\r
225 }\r
226}\r