]> git.proxmox.com Git - mirror_edk2.git/blame - Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/GuidChkTask.java
Polished the build tools' screen output to be in a more coherent form
[mirror_edk2.git] / Tools / Source / FrameworkTasks / org / tianocore / framework / tasks / GuidChkTask.java
CommitLineData
878ddf1f 1/** @file\r
2 GuidChkTask class.\r
3\r
4 GuidChkTask is to call GuidChk.exe to generate Section.\r
5 \r
6 Copyright (c) 2006, Intel Corporation\r
7 All rights reserved. This program and the accompanying materials\r
8 are licensed and made available under the terms and conditions of the BSD License\r
9 which accompanies this distribution. The full text of the license may be found at\r
10 http://opensource.org/licenses/bsd-license.php\r
11 \r
12 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
13 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
14 \r
15**/\r
16package org.tianocore.framework.tasks;\r
17import java.io.BufferedReader;\r
18import java.io.InputStreamReader;\r
19import java.io.PrintWriter;\r
20import java.io.File;\r
21\r
22import org.apache.tools.ant.BuildException;\r
23import org.apache.tools.ant.Project;\r
24import org.apache.tools.ant.Task;\r
25\r
26/**\r
27 GuidChkTask\r
28 \r
29 GuidChkTask is to call GuidChk.exe to generate Section.\r
30 \r
31**/\r
32public class GuidChkTask extends Task implements EfiDefine{\r
33 /**\r
34 * GuidChk task class\r
35 * class member\r
36 * -exDir : directory name of exclusion searching \r
37 * -exFile : file name of exclusion searching\r
38 * -exExt : extension name of exclusion searching\r
39 * -exSubDir: extesnion name of sub dir which excluded searching\r
40 * -outFile : out put file wrote internal GUID+basename list\r
41 * -chkGui : check for duplicate guids\r
42 * -chkSign : check for duplicate signatures\r
43 * -printGuiDef : if set will print guid+defined symbol name\r
44 * -printAllGuid: if set will print all GUIDS found\r
45 * -outPut : redirection file name\r
46 * -fos : out put redirect to this file \r
47 * \r
48 */\r
49 ///\r
50 /// Directory name of exclusion searching \r
51 ///\r
52 private String exDir = "";\r
53 ///\r
54 /// File name of exclusion searching.\r
55 ///\r
56 private String exFile = "";\r
57 ///\r
58 /// Extension name of exclusion searching.\r
59 ///\r
60 private String exExt = "";\r
61 ///\r
62 /// Extesnion name of sub dir which excluded searching.\r
63 ///\r
64 private String exSubDir = "";\r
65 ///\r
66 /// Out put file wrote internal GUID+basename list\r
67 ///\r
68 private String outFile = "";\r
69 ///\r
70 /// Check for duplicate guids.\r
71 ///\r
72 private String chkGui = "";\r
73 ///\r
74 /// Check for duplicate signatures\r
75 ///\r
76 private String chkSign = "";\r
77 ///\r
78 /// If set will print guid+defined symbol name\r
79 ///\r
80 private String printGuiDef = "";\r
81 ///\r
82 /// If set will print all GUIDS found\r
83 ///\r
84 private String printAllGuid = "";\r
85 ///\r
86 /// redirection file name.\r
87 ///\r
88 private String outPut = "";\r
89 ///\r
90 /// out put redirect to this file.\r
91 ///\r
92 protected PrintWriter fos = null;\r
93 \r
94 //\r
95 // overload class execute method\r
96 // \r
97 public void execute() throws BuildException {\r
98 Project project = this.getOwningTarget().getProject();\r
2da8968b 99 String path = project.getProperty("env.FRAMEWORK_TOOLS_PATH");\r
878ddf1f 100 String command;\r
101 if (path == null) {\r
102 command = "GuidChk";\r
103 } else {\r
104 command = path + File.separatorChar + "GuidChk";\r
105 }\r
106 String argument = exDir +\r
107 exFile +\r
108 exExt +\r
109 exSubDir +\r
110 outFile +\r
111 chkGui +\r
112 chkSign +\r
113 printGuiDef + \r
114 printAllGuid; \r
115 try {\r
219e2247 116 log(command + " " + argument, Project.MSG_VERBOSE);\r
878ddf1f 117 //\r
118 // execute command line \r
119 //\r
120 Process proc = Runtime.getRuntime().exec(command + "" + argument);\r
121 //\r
122 // if set output, redirect out put to output file, else print output to screen\r
123 // \r
124 if ( !this.outPut.equals("")) {\r
125 fos = new PrintWriter(this.outPut);\r
126 BufferedReader bin = new BufferedReader(new InputStreamReader(proc.getInputStream()));\r
127 String line = bin.readLine();\r
128 while (line != null ){ \r
129 fos.println(line);\r
130 line = bin.readLine();\r
131 }\r
132 fos.close();\r
133 }\r
134 else {\r
135 BufferedReader bin = new BufferedReader(new InputStreamReader(proc.getInputStream()));\r
136 String line = bin.readLine();\r
878ddf1f 137 while (line != null ){\r
878ddf1f 138 line = bin.readLine();\r
139 } \r
140 } \r
219e2247 141 log("GuidChkTask Succeeded!", Project.MSG_VERBOSE);\r
878ddf1f 142 } catch (Exception e) {\r
219e2247 143 throw new BuildException("GuidChkTask failed!");\r
878ddf1f 144 }\r
145 }\r
146 /**\r
147 getChkGui\r
148 \r
149 This function is to get the string of flag of ChkGui\r
150 \r
151 @return string of flag of ChkGui\r
152 **/\r
153 public String getChkGui() {\r
154 return chkGui;\r
155 }\r
156 \r
157 /**\r
158 setChkGui\r
159 \r
160 This function is to set chkGui\r
161 \r
162 @param chkGui set class member of chkGui\r
163 **/\r
164 public void setChkGui(String chkGui) {\r
165 if (chkGui.equals("on")||(chkGui.equals("ON"))){\r
166 this.chkGui = " -g ";\r
167 }\r
168 \r
169 }\r
170 \r
171 /**\r
172 getChkSign\r
173 \r
174 This function is to get chkSign\r
175 \r
176 @return chkSign\r
177 **/\r
178 public String getChkSign() {\r
179 return chkSign;\r
180 }\r
181 \r
182 /**\r
183 setChkSign\r
184 \r
185 This function is to set class member of chkSign\r
186 * @param chkSign\r
187 */\r
188 public void setChkSign(String chkSign) {\r
189 if (chkSign.equals("on")|| chkSign.equals("ON")){\r
190 this.chkSign = " -s ";\r
191 } \r
192 }\r
193 /**\r
194 getExDir\r
195 \r
196 This function is to get class member of exDir\r
197 \r
198 @return exDir\r
199 **/\r
200 public String getExDir() {\r
201 return exDir;\r
202 }\r
203 \r
204 /**\r
205 setExDir\r
206 \r
207 This function is to set class member of exDir\r
208 \r
209 @param exDir\r
210 **/\r
211 public void setExDir(String exDir) {\r
212 this.exDir = " -d " + exDir;\r
213 }\r
214 \r
215 /**\r
216 getExExt\r
217 \r
218 This function is to get class member of exExt\r
219 \r
220 @return exExt\r
221 **/\r
222 public String getExExt() {\r
223 return exExt;\r
224 }\r
225 \r
226 /**\r
227 setExExt\r
228 \r
229 This function is to set class member of exExt\r
230 @param exExt\r
231 **/\r
232 public void setExExt(String exExt) {\r
233 this.exExt = " -e " + exExt;\r
234 }\r
235 \r
236 /**\r
237 getExFile\r
238 \r
239 This function is to get class member of exFile\r
240 @return exFile\r
241 **/\r
242 public String getExFile() {\r
243 return exFile;\r
244 }\r
245 \r
246 /**\r
247 setExFile\r
248 \r
249 This function is to set class member of exFile.\r
250 \r
251 @param exFile\r
252 **/\r
253 public void setExFile(String exFile) {\r
254 this.exFile = " -f " + exFile;\r
255 }\r
256 \r
257 /**\r
258 getExSubDir\r
259 \r
260 This function is to get class member of exSubDir\r
261 \r
262 @return exSubDir\r
263 **/\r
264 public String getExSubDir() {\r
265 return exSubDir;\r
266 }\r
267 \r
268 /**\r
269 setExSubDir\r
270 \r
271 This function is to set class member of exSubDir.\r
272 @param exSubDir\r
273 **/\r
274 public void setExSubDir(String exSubDir) {\r
275 this.exSubDir = " -u " + exSubDir;\r
276 }\r
277 \r
278 /**\r
279 getOutFile\r
280 \r
281 This function is to get outFile\r
282 \r
283 @return outFile\r
284 **/\r
285 public String getOutFile() {\r
286 return outFile;\r
287 }\r
288 /**\r
289 * set class member of outFile\r
290 * @param outFile\r
291 */\r
292 public void setOutFile(String outFile) {\r
293 this.outFile = " -b " + outFile;\r
294 }\r
295 /**\r
296 getPrintGuidDef\r
297 \r
298 This function is to get printGuidDef\r
299 \r
300 @return flage of printing (guid+defined symbol name)\r
301 **/\r
302 public String getPrintGuiDef() {\r
303 return printGuiDef;\r
304 }\r
305 \r
306 \r
307 /**\r
308 setPrintGuidDef\r
309 \r
310 This function is to set class member of printGuiDef.\r
311 @param printGuiDef\r
312 **/\r
313 public void setPrintGuiDef(String printGuiDef) {\r
314 if (printGuiDef.equals("on")|| printGuiDef.equals("ON")){\r
315 this.printGuiDef = " -x ";\r
316 }\r
317 \r
318 }\r
319 \r
320 /**\r
321 getOutput\r
322 \r
323 This function is to get output\r
324 \r
325 @return name of outPut file\r
326 **/\r
327 public String getOutPut() {\r
328 return outPut;\r
329 }\r
330 \r
331 /**\r
332 setOutPut\r
333 \r
334 This function is to set class member of outPut.\r
335 @param outPut\r
336 **/\r
337 public void setOutPut(String outPut) {\r
338 this.outPut = outPut;\r
339 }\r
340 \r
341 /**\r
342 getPrintAllGuid\r
343 \r
344 This function is to get printAllGuid\r
345 @return printAllGuid\r
346 **/\r
347 public String getPrintAllGuid() {\r
348 return printAllGuid;\r
349 }\r
350 \r
351 /**\r
352 setPrintAllGuid\r
353 \r
354 This function is to set class member of printAllGuid.\r
355 @param printAllGuid\r
356 **/\r
357 public void setPrintAllGuid(String printAllGuid) {\r
358 if (printAllGuid.equals("on")||printAllGuid.equals("ON")) {\r
359 this.printAllGuid = " -p ";\r
360 } \r
361 }\r
362}\r
363\r