]> git.proxmox.com Git - mirror_edk2.git/blame - Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/ModifyInfTask.java
Fixed grammar in messages.
[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
3f7b510e 74 FrameworkLogger logger = new FrameworkLogger(project, "modifyinftask");\r
47f2f011 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
219e2247 122 EdkLog.log(EdkLog.EDK_VERBOSE, Commandline.toString(cmdline.getCommandline()));\r
123 EdkLog.log(EdkLog.EDK_INFO, (new File(this.inputFVInfFileName)).getName());\r
47f2f011 124 revl = runner.execute();\r
125\r
126 if (EFI_SUCCESS == revl) {\r
127 //\r
128 // command execution success\r
129 //\r
219e2247 130 EdkLog.log(EdkLog.EDK_VERBOSE, "ModifyInfTask succeeded!");\r
47f2f011 131 } else {\r
132 //\r
133 // command execution fail\r
134 //\r
219e2247 135 EdkLog.log(EdkLog.EDK_INFO, "ERROR = " + Integer.toHexString(revl));\r
136 throw new BuildException("ModifyInfTask failed!");\r
47f2f011 137 }\r
138 } catch (Exception e) {\r
139 throw new BuildException(e.getMessage());\r
140 }\r
141 }\r
142\r
143 /**\r
144 * getinputFVInfFileName\r
145 * \r
146 * This function is to get class member "inputFVInfFileName".\r
147 * \r
148 * @return string of input inf file name.\r
149 */\r
150 public String getinputFVInfFileName() {\r
151 return this.inputFVInfFileName;\r
152 }\r
153\r
154 /**\r
155 * setinputFVInfFileName\r
156 * \r
157 * This function is to set class member "inputFVInfFileName".\r
158 * \r
159 * @param inputFile\r
160 * string of input inf file name.\r
161 */\r
162 public void setinputFVInfFileName(String inputFVInfFileName) {\r
163 this.inputFVInfFileName = inputFVInfFileName + " ";\r
164 }\r
165\r
166 /**\r
167 * getoutputFVInfFileName\r
168 * \r
169 * This function is to get class member "outputFVInfFileName"\r
170 * \r
171 * @return outputFVInfFileName string of output inf file name.\r
172 */\r
173 public String getoutputFVInfFileName() {\r
174 return this.outputFVInfFileName;\r
175 }\r
176\r
177 /**\r
178 * setoutputFVInfFileName\r
179 * \r
180 * This function is to set class member "outputFVInfFileName"\r
181 * \r
182 * @param outputFVInfFileName\r
183 * string of output inf file name.\r
184 */\r
185 public void setoutputFVInfFileName(String outputFVInfFileName) {\r
186 this.outputFVInfFileName = outputFVInfFileName + " ";\r
187 }\r
188\r
189 /**\r
190 * getpatternStr\r
191 * \r
192 * This function is to get class member "patternStr"\r
193 * \r
194 * @return patternStr string of pattern.\r
195 */\r
196 public String getpatternStr() {\r
197 return this.patternStr;\r
198 }\r
199\r
200 /**\r
201 * setpatternStr\r
202 * \r
203 * This function is to set class member "patternStr"\r
204 * \r
205 * @param patternStr\r
206 * string of patternStr.\r
207 */\r
208 public void setpatternStr(String patternStr) {\r
01026c70 209 this.patternStr = patternStr;\r
47f2f011 210 }\r
211\r
212 /**\r
213 * getoutputDir\r
214 * \r
215 * This function is to get class member "outputDir"\r
216 * \r
217 * @return outputDir string of output directory.\r
218 */\r
219 public String getoutputDir() {\r
220 return this.outputDir;\r
221 }\r
222\r
223 /**\r
224 * setoutputDir\r
225 * \r
226 * This function is to set class member "outputDir"\r
227 * \r
228 * @param patternStr\r
229 * string of output directory.\r
230 */\r
231 public void setoutputDir(String outputDir) {\r
232 this.outputDir = outputDir;\r
233 }\r
234}\r