]> git.proxmox.com Git - mirror_edk2.git/blame - Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/ModifyInfTask.java
Fixed EDKT102;
[mirror_edk2.git] / Tools / Source / FrameworkTasks / org / tianocore / framework / tasks / ModifyInfTask.java
CommitLineData
47f2f011 1/** @file\r
2 ModifyInfTask class.\r
3\r
4 ModifyInfTask is used to call Modify.exe to generate inf file.\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
27import org.tianocore.logger.EdkLog;\r
28\r
29/**\r
30 ModifyInfTask class.\r
31\r
32 ModifyInfTask is used to call Modify.exe to generate inf file.\r
33**/\r
34public class ModifyInfTask extends Task implements EfiDefine {\r
35 ///\r
36 /// tool name\r
37 ///\r
38 private String toolName = "ModifyInf";\r
39 \r
40 ///\r
41 /// input FV inf file\r
42 ///\r
43 private String inputFVInfFileName = "";\r
44\r
45 ///\r
46 /// output FV inf file\r
47 ///\r
48 private String outputFVInfFileName = "";\r
49\r
50 ///\r
51 /// pattern string\r
52 ///\r
53 private String patternStr = "";\r
54\r
55 ///\r
56 /// Output dir\r
57 /// \r
58 private String outputDir = "";\r
59 \r
60 /**\r
61 * execute\r
62 * \r
63 * ModifyInfTask execute function is to assemble tool command line & execute\r
64 * tool command line\r
65 * \r
66 * @throws BuidException\r
67 */\r
68 public void execute() throws BuildException {\r
69\r
70 Project project = this.getOwningTarget().getProject();\r
71 //\r
72 // set Logger\r
73 //\r
74 FrameworkLogger logger = new FrameworkLogger(project, "modifytask");\r
75 EdkLog.setLogLevel(project.getProperty("env.LOGLEVEL"));\r
76 EdkLog.setLogger(logger);\r
77 //\r
78 // absolute path of efi tools\r
79 //\r
80 String path = project.getProperty("env.FRAMEWORK_TOOLS_PATH");\r
81 String command;\r
82 String argument;\r
83 if (path == null) {\r
84 command = toolName;\r
85 } else {\r
86 command = path + File.separatorChar + toolName;\r
87 }\r
88 //\r
89 // argument of tools\r
90 //\r
91 File file = new File(outputFVInfFileName);\r
92 if (!file.isAbsolute() && (!this.outputDir.equalsIgnoreCase(""))) {\r
93 argument = this.inputFVInfFileName +\r
94 this.outputDir + \r
95 File.separatorChar +\r
96 this.outputFVInfFileName +\r
97 this.patternStr;\r
98 } else {\r
99 argument = this.inputFVInfFileName + \r
100 this.outputFVInfFileName +\r
101 this.patternStr;\r
102 }\r
103 //\r
104 // return value of fwimage execution\r
105 //\r
106 int revl = -1;\r
107\r
108 try {\r
109 Commandline cmdline = new Commandline();\r
110 cmdline.setExecutable(command);\r
111 cmdline.createArgument().setLine(argument);\r
112\r
113 LogStreamHandler streamHandler = new LogStreamHandler(this,\r
114 Project.MSG_INFO, Project.MSG_WARN);\r
115 Execute runner = new Execute(streamHandler, null);\r
116\r
117 runner.setAntRun(project);\r
118 runner.setCommandline(cmdline.getCommandline());\r
119 //\r
120 // Set debug log information.\r
121 //\r
122 EdkLog.log(EdkLog.EDK_INFO, Commandline.toString(cmdline\r
123 .getCommandline()));\r
124\r
125 revl = runner.execute();\r
126\r
127 if (EFI_SUCCESS == revl) {\r
128 //\r
129 // command execution success\r
130 //\r
131 EdkLog.log(EdkLog.EDK_INFO, "ModifyInfTask succeeded!");\r
132 } else {\r
133 //\r
134 // command execution fail\r
135 //\r
136 EdkLog.log(EdkLog.EDK_ERROR, "ModifyInfTask failed. (error="\r
137 + Integer.toHexString(revl) + ")");\r
138 throw new BuildException("ModifyInfTask failed. (error="\r
139 + Integer.toHexString(revl) + ")");\r
140\r
141 }\r
142 } catch (Exception e) {\r
143 throw new BuildException(e.getMessage());\r
144 }\r
145 }\r
146\r
147 /**\r
148 * getinputFVInfFileName\r
149 * \r
150 * This function is to get class member "inputFVInfFileName".\r
151 * \r
152 * @return string of input inf file name.\r
153 */\r
154 public String getinputFVInfFileName() {\r
155 return this.inputFVInfFileName;\r
156 }\r
157\r
158 /**\r
159 * setinputFVInfFileName\r
160 * \r
161 * This function is to set class member "inputFVInfFileName".\r
162 * \r
163 * @param inputFile\r
164 * string of input inf file name.\r
165 */\r
166 public void setinputFVInfFileName(String inputFVInfFileName) {\r
167 this.inputFVInfFileName = inputFVInfFileName + " ";\r
168 }\r
169\r
170 /**\r
171 * getoutputFVInfFileName\r
172 * \r
173 * This function is to get class member "outputFVInfFileName"\r
174 * \r
175 * @return outputFVInfFileName string of output inf file name.\r
176 */\r
177 public String getoutputFVInfFileName() {\r
178 return this.outputFVInfFileName;\r
179 }\r
180\r
181 /**\r
182 * setoutputFVInfFileName\r
183 * \r
184 * This function is to set class member "outputFVInfFileName"\r
185 * \r
186 * @param outputFVInfFileName\r
187 * string of output inf file name.\r
188 */\r
189 public void setoutputFVInfFileName(String outputFVInfFileName) {\r
190 this.outputFVInfFileName = outputFVInfFileName + " ";\r
191 }\r
192\r
193 /**\r
194 * getpatternStr\r
195 * \r
196 * This function is to get class member "patternStr"\r
197 * \r
198 * @return patternStr string of pattern.\r
199 */\r
200 public String getpatternStr() {\r
201 return this.patternStr;\r
202 }\r
203\r
204 /**\r
205 * setpatternStr\r
206 * \r
207 * This function is to set class member "patternStr"\r
208 * \r
209 * @param patternStr\r
210 * string of patternStr.\r
211 */\r
212 public void setpatternStr(String patternStr) {\r
01026c70 213 this.patternStr = patternStr;\r
47f2f011 214 }\r
215\r
216 /**\r
217 * getoutputDir\r
218 * \r
219 * This function is to get class member "outputDir"\r
220 * \r
221 * @return outputDir string of output directory.\r
222 */\r
223 public String getoutputDir() {\r
224 return this.outputDir;\r
225 }\r
226\r
227 /**\r
228 * setoutputDir\r
229 * \r
230 * This function is to set class member "outputDir"\r
231 * \r
232 * @param patternStr\r
233 * string of output directory.\r
234 */\r
235 public void setoutputDir(String outputDir) {\r
236 this.outputDir = outputDir;\r
237 }\r
238}\r