]> git.proxmox.com Git - mirror_edk2.git/blob - Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/SecFixupTask.java
64c9295da4207ffaefd07409bbc54d22dc25ce76
[mirror_edk2.git] / Tools / Source / FrameworkTasks / org / tianocore / framework / tasks / SecFixupTask.java
1 /** @file
2 SecFixupTask class.
3
4 SecFixupTask is used to call SecFixup.exe to fix up sec image.
5
6
7 Copyright (c) 2006, Intel Corporation
8 All rights reserved. This program and the accompanying materials
9 are licensed and made available under the terms and conditions of the BSD License
10 which accompanies this distribution. The full text of the license may be found at
11 http://opensource.org/licenses/bsd-license.php
12
13 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
14 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
15
16 **/
17 package org.tianocore.framework.tasks;
18
19 import java.io.File;
20
21 import org.apache.tools.ant.Task;
22 import org.apache.tools.ant.Project;
23 import org.apache.tools.ant.BuildException;
24 import org.apache.tools.ant.taskdefs.Execute;
25 import org.apache.tools.ant.taskdefs.LogStreamHandler;
26 import org.apache.tools.ant.types.Commandline;
27 import org.tianocore.logger.EdkLog;
28
29 /**
30 * SecFixupTask class.
31 *
32 * SecFixupTask is used to call SecFixup.exe to fix up sec image.
33 */
34 public class SecFixupTask extends Task implements EfiDefine {
35 // /
36 // / tool name
37 // /
38 private String toolName = "SecFixup";
39
40 // /
41 // / input file
42 // /
43 private String secExeFile = "";
44
45 // /
46 // / output file
47 // /
48 private String resetVectorDataFile = "";
49
50 // /
51 // / output directory, this variable is added by jave wrap
52 // /
53 private String outputFile = "";
54
55 // /
56 // / output directory
57 // /
58 private String outputDir = "";
59
60 /**
61 * execute
62 *
63 * SecFixupTask execute function is to assemble tool command line & execute
64 * tool command line
65 *
66 * @throws BuidException
67 */
68 public void execute() throws BuildException {
69
70 Project project = this.getOwningTarget().getProject();
71 //
72 // set Logger
73 //
74 FrameworkLogger logger = new FrameworkLogger(project, toolName
75 .toLowerCase());
76 EdkLog.setLogLevel(project.getProperty("env.LOGLEVEL"));
77 EdkLog.setLogger(logger);
78 //
79 // absolute path of efi tools
80 //
81 String path = project.getProperty("env.FRAMEWORK_TOOLS_PATH");
82 String command;
83 String argument;
84 if (path == null) {
85 command = toolName;
86 } else {
87 command = path + File.separatorChar + toolName;
88 }
89 //
90 // argument of tools
91 //
92 if (!this.outputDir.equalsIgnoreCase("")) {
93 argument = this.secExeFile + " " + this.resetVectorDataFile + " "
94 + this.outputDir + File.separatorChar + this.outputFile;
95 } else {
96 argument = this.secExeFile + " " + this.resetVectorDataFile + " "
97 + this.outputFile;
98 }
99
100 //
101 // return value of fwimage execution
102 //
103 int revl = -1;
104
105 try {
106 Commandline cmdline = new Commandline();
107 cmdline.setExecutable(command);
108 cmdline.createArgument().setLine(argument);
109
110 LogStreamHandler streamHandler = new LogStreamHandler(this,
111 Project.MSG_INFO, Project.MSG_WARN);
112 Execute runner = new Execute(streamHandler, null);
113
114 runner.setAntRun(project);
115 runner.setCommandline(cmdline.getCommandline());
116 //
117 // Set debug log information.
118 //
119 EdkLog.log(EdkLog.EDK_INFO, Commandline.toString(cmdline
120 .getCommandline()));
121
122 revl = runner.execute();
123
124 if (EFI_SUCCESS == revl) {
125 //
126 // command execution success
127 //
128 EdkLog.log(EdkLog.EDK_INFO, "SecFixup succeeded!");
129 } else {
130 //
131 // command execution fail
132 //
133 EdkLog.log(EdkLog.EDK_ERROR, "SecFixup failed. (error="
134 + Integer.toHexString(revl) + ")");
135 throw new BuildException("SecFixup failed. (error="
136 + Integer.toHexString(revl) + ")");
137
138 }
139 } catch (Exception e) {
140 throw new BuildException(e.getMessage());
141 }
142 }
143
144 /**
145 * getSecExeFile
146 *
147 * This function is to get class member "secExeFile".
148 *
149 * @return string of sectExe file name.
150 */
151 public String getSecExeFile() {
152 return this.secExeFile;
153 }
154
155 /**
156 * setSecExeFile
157 *
158 * This function is to set class member "secExeFile".
159 *
160 * @param secExeFile
161 * string of secExe file name.
162 */
163 public void setSecExeFile(String secExeFile) {
164 this.secExeFile = secExeFile;
165 }
166
167 /**
168 * getResetVectorDataFile
169 *
170 * This function is to get class member "resetVectorDataFile"
171 *
172 * @return resetVectorDataFile string of resetVectorData file name.
173 */
174 public String getResetVectorDataFile() {
175 return this.resetVectorDataFile;
176 }
177
178 /**
179 * setResetVectorDataFile
180 *
181 * This function is to set class member "resetVectorDataFile"
182 *
183 * @param resetVectorDataFile
184 * string of resetVectorData file name.
185 */
186 public void setResetVectorDataFile(String resetVectorDataFile) {
187 this.resetVectorDataFile = resetVectorDataFile;
188 }
189
190 /**
191 * getOutputFile
192 *
193 * This function is to get class member "outputFile"
194 *
195 * @return outputFile string of output file name.
196 */
197 public String getOutputFile() {
198 return outputFile;
199 }
200
201 /**
202 * setOutputFile
203 *
204 * This function is to set class member "outputFile"
205 *
206 * @param outputFile
207 * string of output file name.
208 */
209 public void setOutputFile(String outputFile) {
210 this.outputFile = outputFile;
211 }
212
213 /**
214 * getOutputDir
215 *
216 * This function is to get class member "outputDir"
217 *
218 * @return outputDir name of output directory
219 */
220 public String getOutputDir() {
221 return outputDir;
222 }
223
224 /**
225 * setOutputDir
226 *
227 * This function is to set class member "outputDir"
228 *
229 * @param outputDir
230 * name of output directory
231 */
232 public void setOutputDir(String outputDir) {
233 this.outputDir = outputDir;
234 }
235 }