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