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