]> git.proxmox.com Git - mirror_edk2.git/blame - Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/SecFixupTask.java
Changed spelling to manifest
[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
0fdb42ac 36 //\r
37 // tool name\r
38 //\r
a15bb0d3 39 private String toolName = "SecFixup";\r
40\r
0fdb42ac 41 //\r
42 // input file\r
43 //\r
44 private FileArg secExeFile = new FileArg();\r
a15bb0d3 45\r
0fdb42ac 46 //\r
47 // output file\r
48 //\r
49 private FileArg resetVectorDataFile = new FileArg();\r
a15bb0d3 50\r
0fdb42ac 51 //\r
52 // output file\r
53 //\r
54 private FileArg outputFile = new FileArg();\r
a15bb0d3 55\r
0fdb42ac 56 //\r
57 // output directory, this variable is added by jave wrap\r
58 //\r
59 private String outputDir = ".";\r
a15bb0d3 60\r
61 /**\r
0fdb42ac 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
a15bb0d3 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
0fdb42ac 87 argument = "" + secExeFile + resetVectorDataFile + outputFile;\r
a15bb0d3 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
0fdb42ac 105 runner.setWorkingDirectory(new File(outputDir));\r
106\r
a15bb0d3 107 //\r
108 // Set debug log information.\r
109 //\r
91f7d582 110 EdkLog.log(this, EdkLog.EDK_VERBOSE, Commandline.toString(cmdline.getCommandline()));\r
0fdb42ac 111 EdkLog.log(this, EdkLog.EDK_INFO, secExeFile.toFileList() \r
112 + resetVectorDataFile.toFileList() + " => " + outputFile.toFileList());\r
a15bb0d3 113\r
114 revl = runner.execute();\r
115\r
116 if (EFI_SUCCESS == revl) {\r
117 //\r
118 // command execution success\r
119 //\r
0fdb42ac 120 EdkLog.log(this, EdkLog.EDK_VERBOSE, toolName + " succeeded!");\r
a15bb0d3 121 } else {\r
122 //\r
123 // command execution fail\r
124 //\r
91f7d582 125 EdkLog.log(this, EdkLog.EDK_INFO, "ERROR = "+ Integer.toHexString(revl));\r
0fdb42ac 126 throw new BuildException(toolName + " failed!");\r
a15bb0d3 127 }\r
128 } catch (Exception e) {\r
129 throw new BuildException(e.getMessage());\r
130 }\r
131 }\r
132\r
133 /**\r
0fdb42ac 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
a15bb0d3 140 public String getSecExeFile() {\r
0fdb42ac 141 return this.secExeFile.getValue();\r
a15bb0d3 142 }\r
143\r
144 /**\r
0fdb42ac 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
a15bb0d3 152 public void setSecExeFile(String secExeFile) {\r
0fdb42ac 153 this.secExeFile.setArg(" ", secExeFile);\r
a15bb0d3 154 }\r
155\r
156 /**\r
0fdb42ac 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
a15bb0d3 163 public String getResetVectorDataFile() {\r
0fdb42ac 164 return this.resetVectorDataFile.getValue();\r
a15bb0d3 165 }\r
166\r
167 /**\r
0fdb42ac 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
a15bb0d3 175 public void setResetVectorDataFile(String resetVectorDataFile) {\r
0fdb42ac 176 this.resetVectorDataFile.setArg(" ", resetVectorDataFile);\r
a15bb0d3 177 }\r
178\r
179 /**\r
0fdb42ac 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
a15bb0d3 186 public String getOutputFile() {\r
0fdb42ac 187 return this.outputFile.getValue();\r
a15bb0d3 188 }\r
189\r
190 /**\r
0fdb42ac 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
a15bb0d3 198 public void setOutputFile(String outputFile) {\r
0fdb42ac 199 this.outputFile.setArg(" ", outputFile);\r
a15bb0d3 200 }\r
201\r
202 /**\r
0fdb42ac 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
a15bb0d3 209 public String getOutputDir() {\r
210 return outputDir;\r
211 }\r
212\r
213 /**\r
0fdb42ac 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
a15bb0d3 221 public void setOutputDir(String outputDir) {\r
222 this.outputDir = outputDir;\r
223 }\r
224}\r