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