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