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