]> git.proxmox.com Git - mirror_edk2.git/blob - Tools/Java/Source/CheckTools/src/org/tianocore/CheckTools/ToolChecks.java
Added the DbTools that will update the FrameworkDatabase.db file based on what is...
[mirror_edk2.git] / Tools / Java / Source / CheckTools / src / org / tianocore / CheckTools / ToolChecks.java
1 /** @file
2 Verify the tool configuration file for location of the correct tools.
3
4 Copyright (c) 2006, Intel Corporation
5 All rights reserved. This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
9
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12
13 **/
14
15 /**
16 * This tool checks to see if specified tool chain paths exist.
17 * It will check all specified paths, as indicated by the last field of the
18 * tool property line equal to _PATH
19 *
20 * no option = check 1) the file specified in target.txt or 2) tools_def.txt
21 * if neither is found, we check the tools_def.template file.
22 * -i = INIT checks the tools_def.template file
23 *
24 * -s = SCAN will check all standard locations for tool chains
25 * C:\Program Files\Microsoft Visual Studio *
26 * C:\WINDDK
27 * C:\Bin
28 * C:\ASL
29 * C:\MASM*
30 * /opt/tiano
31 *
32 * -f = FILE check the tools in this file instead of tools_def.txt, or
33 * a file that was specified in target.txt
34 */
35 package org.tianocore.CheckTools;
36
37 import java.io.*;
38 import java.util.*;
39
40 public class ToolChecks {
41 private static int DEBUG = 0;
42
43 private final int DEFAULT = 1;
44
45 private final int TEST = 2;
46
47 private final int SCAN = 4;
48
49 private final int DUMP = 8;
50
51 private final int INTERACTIVE = 16;
52
53 private final int PASS = 0;
54
55 private final int FAIL = 1;
56
57 private ArrayList<String> errLog = new ArrayList<String>();
58
59 private ArrayList<String> goodLog = new ArrayList<String>();
60
61 private ArrayList<String> warnLog = new ArrayList<String>();
62
63 public int checkTools(String toolConfFile, int cmdCode, int VERBOSE, boolean QUIET) {
64
65 int returnCode = FAIL;
66 boolean interActive = false;
67
68 if ((DEBUG > 0) || (VERBOSE > 0)) {
69 if ((cmdCode & DUMP) == DUMP)
70 System.out.print("Using Tool Configuration File: " + toolConfFile + " ");
71 else
72 System.out.println("Using Tool Configuration File: " + toolConfFile);
73 }
74
75 if (DEBUG > 2)
76 System.out.println("The cmdCode: " + cmdCode);
77
78 if ((cmdCode & INTERACTIVE) == INTERACTIVE) {
79 interActive = true;
80 if (QUIET == false)
81 System.out.println("***** WARNING ***** The Interactive function has not been implemented yet!");
82 }
83
84 if ((cmdCode & DUMP) == DUMP) {
85 returnCode = dumpFile(toolConfFile, VERBOSE, QUIET);
86 if (DEBUG > 10)
87 System.out.println("dumpFile returned: " + returnCode);
88 }
89
90 if ((cmdCode & SCAN) == SCAN) {
91 returnCode = scanFile(toolConfFile, interActive, VERBOSE, QUIET);
92 }
93
94 if (((cmdCode & TEST) == TEST) || ((cmdCode & DEFAULT) == DEFAULT))
95 returnCode = testFile(toolConfFile, interActive, VERBOSE, QUIET);
96
97 if ((errLog.isEmpty() == false) && (QUIET == false)) {
98 // We had ERRORS, not just Warnings.
99 // System.out.println("Tool Configuration File: " + toolConfFile);
100 System.out.println(" goodLog has: " + goodLog.size() + " entries");
101 if ((goodLog.isEmpty() == false) && (VERBOSE > 1))
102 for (int i = 0; i < goodLog.size(); i++)
103 System.out.println("Tool Chain Tag Name: " + goodLog.get(i) + " is valid!");
104 for (int i = 0; i < errLog.size(); i++)
105 System.out.println(errLog.get(i));
106 if (warnLog.isEmpty() == false)
107 for (int i = 0; i < warnLog.size(); i++)
108 System.out.println(" " + warnLog.get(i));
109 if (VERBOSE > 0) {
110 System.out.println();
111 System.out.println("You can remove these WARNING messages by editing the file:");
112 System.out.println(" " + toolConfFile);
113 System.out.println("and commenting out out or deleting the entries for the tool");
114 System.out.println("chain tag names that do not apply to your system.");
115 }
116 } else {
117 if (QUIET == false) {
118 if ((cmdCode & DUMP) == DUMP)
119 System.out.println("");
120 if (VERBOSE > 0) {
121 System.out.print("Valid Tag Names:");
122 for (int i = 0; i < goodLog.size(); i++)
123 System.out.print(" " + goodLog.get(i));
124 System.out.println("");
125 }
126 if (warnLog.isEmpty() == false)
127 for (int i = 0; i < warnLog.size(); i++)
128 System.out.println(" " + warnLog.get(i));
129 if (returnCode == 0)
130 if (warnLog.isEmpty())
131 System.out.println(" Tool Configuration File: " + toolConfFile + " is valid!");
132 else
133 System.out.println(" Tool Configuration File: " + toolConfFile
134 + " is valid! However, there are WARNINGS!");
135 else
136 System.out.println(" Tool Configuration File: " + toolConfFile
137 + " contains INVALID tool tag names!");
138 }
139 }
140
141 return returnCode;
142 }
143
144 private int scanFile(String testFile, boolean interActive, int VERBOSE, boolean QUIET) {
145 if ((DEBUG > 0) || (VERBOSE > 0))
146 System.out.println("Scanning the Normal Installation Locations ...");
147 System.out.println("The Scan function has not been implemented yet!");
148 return FAIL;
149 }
150
151 private int dumpFile(String testFile, int VERBOSE, boolean QUIET) {
152 int retCode = PASS;
153 try {
154 //
155 // initialize local variables
156 //
157 ArrayList<ToolInfo> info = new ArrayList<ToolInfo>();
158 String readLine = "";
159 String fileLine[] = new String[2];
160 String property[] = new String[5];
161 ToolInfo toolInf = null;
162 String lastTagName = "arf";
163 String lastFamily = "arf";
164 String lastArch = "IA32";
165 String lastCmdCode = "arf";
166 // String lastFlags = "arf";
167 boolean found = false;
168 String tFamily = "arf";
169 String tCmdName = "arf";
170 String acpiPath = "";
171 String cmdPath = "";
172 String asmPath = "";
173 int ctr = 0;
174 //
175 // Setup the reader
176 //
177 FileReader toolConfFile = new FileReader(testFile);
178 BufferedReader bufReader = new BufferedReader(toolConfFile);
179
180 while ((readLine = bufReader.readLine()) != null) {
181 if (!readLine.startsWith("#")) {
182 if (readLine.contains("IDENTIFIER")) {
183 readLine = readLine.trim();
184 fileLine = readLine.split("=");
185 if (QUIET == false)
186 System.out.println("IDENTIFIER: " + fileLine[1].trim());
187 toolInf = new ToolInfo();
188 toolInf.setValid();
189 } else if (readLine.contains("_")) {
190 /**
191 * This section should complete array values
192 * String TagName
193 * String Family
194 * boolean Valid
195 * String Arch
196 * ArrayList<String> Targets
197 * ArrayList<String> CmdCode
198 * ArrayList<String> Path
199 * ArrayList<String> Arguments
200 */
201 if (DEBUG > 10)
202 System.out.println("Processing: " + readLine.trim());
203 readLine = readLine.trim();
204 readLine = readLine.replaceFirst("=", "_SPLIT_HERE_");
205 fileLine = readLine.split("_SPLIT_HERE_");
206 fileLine[0] = fileLine[0].trim();
207 fileLine[1] = fileLine[1].trim();
208 property = fileLine[0].split("_");
209
210 // Covert to simple string names
211 String tTarget = property[0].trim();
212 if (tTarget.contentEquals("*"))
213 tTarget = "All Targets";
214 String tTag = property[1].trim();
215 String tArch = property[2].trim();
216 String tCmdCode = property[3].trim();
217 String tArg = property[4].trim();
218 if (tArg.contentEquals("FAMILY"))
219 tFamily = fileLine[1].trim();
220 if (tArg.contentEquals("NAME")) {
221 tCmdName = fileLine[1].trim();
222 tCmdCode = tCmdCode + " (" + tCmdName + ")";
223 }
224
225 String tVal = fileLine[1].trim();
226
227 // Process the TagName
228 if ((!tTag.contentEquals(lastTagName))
229 || ((!tArch.contentEquals(lastArch)) && (!tArch.contentEquals("*")))
230 || (!tFamily.contentEquals(lastFamily))) {
231 if (DEBUG > 10) {
232 System.out.println(" LAST Tag: " + lastTagName + " Arch: " + lastArch + " Family: "
233 + lastFamily);
234 System.out.println(" NEXT Tag: " + tTag + " Arch: " + tArch + " Family: " + tFamily);
235 }
236 if ((!lastTagName.equals("arf")) && (!tTag.equals("*"))) {
237 toolInf.setTagName(lastTagName);
238 toolInf.setFamily(lastFamily);
239 toolInf.setArch(lastArch);
240 if (toolInf.getCmdCode().size() < 1)
241 toolInf.addCmdCode(lastCmdCode);
242 info.add(toolInf);
243 toolInf = new ToolInfo();
244 toolInf.setValid();
245 if (DEBUG > 3)
246 System.out.println(" ADDED " + ctr + " Tag: " + lastTagName + " Arch: " + lastArch
247 + " Family: " + lastFamily + " CmdCode: " + lastCmdCode);
248 ctr++;
249
250 }
251
252 if ((!tTag.contentEquals("*")) && (!tTag.contentEquals(lastTagName)))
253 lastTagName = tTag;
254
255 if ((!tArch.contentEquals(lastArch)) && (!tArch.contentEquals("*")))
256 lastArch = tArch;
257 if ((!tArch.contentEquals(lastArch)) && (tArch.contentEquals("*")))
258 lastArch = "IA32";
259
260 if (!tFamily.contentEquals(lastFamily))
261 lastFamily = tFamily;
262 if (DEBUG > 10)
263 System.out.println(" Setting Tag: " + lastTagName + " Arch: " + lastArch
264 + " Family: " + lastFamily);
265 }
266
267 // Set the Arch
268 if ((!lastArch.contentEquals(tArch)) && (!tArch.contentEquals("*"))) {
269 toolInf.setArch(tArch);
270 lastArch = tArch;
271 if (DEBUG > 10)
272 System.out.println(" Setting Arch: " + tArch);
273 }
274
275 // Process Target field - making sure we add only unique values.
276 if (!tTarget.contains("*")) {
277 found = false;
278 for (int k = 0; k < toolInf.getTargetName().size(); k++)
279 if (toolInf.getTargetName(k).contentEquals(tTarget))
280 found = true;
281 if (!found) {
282 toolInf.addTargetName(tTarget);
283 if (DEBUG > 10)
284 System.out.println(" Adding Target: " + tTarget);
285 }
286 }
287
288 // Process Command Code Field - making sure we add only unique values.
289 if (!tCmdCode.contentEquals("*")) {
290 found = false;
291 for (int k = 0; k < toolInf.getCmdCode().size(); k++)
292 if (toolInf.getCmdCode(k).startsWith(tCmdCode))
293 found = true;
294 if (!found) {
295 if (!tCmdCode.contains(" (")) {
296 boolean nf = true;
297 for (int m = toolInf.size(); m >= 0; --m) {
298 if (nf) {
299 ArrayList<String> lastCmdEntry = info.get(m).getCmdCode();
300 for (int l = 0; l < lastCmdEntry.size(); l++) {
301 if (lastCmdEntry.get(l).startsWith(tCmdCode)) {
302 tCmdCode = lastCmdEntry.get(l).trim();
303 if (DEBUG > 20)
304 System.out.println("found tCmdCode here: " + tCmdCode);
305 nf = false;
306 }
307 }
308 }
309 }
310 if (nf == false) {
311 toolInf.addCmdCode(tCmdCode);
312 if (DEBUG > 10)
313 System.out.println(" Adding previous CmdCode: " + tCmdCode);
314 }
315 } else {
316 toolInf.addCmdCode(tCmdCode);
317 lastCmdCode = tCmdCode;
318 if (DEBUG > 10)
319 System.out.println(" Adding first CmdCode: " + tCmdCode);
320 }
321 }
322 }
323
324 // Process Path Field - making sure we add only unique values.
325 if (tArg.contentEquals("PATH")) {
326 String prefix = "PATH_";
327 if (tCmdCode.contentEquals("ASM"))
328 prefix = "ASMPATH_";
329 if (tCmdCode.contentEquals("ASMLINK"))
330 prefix = "ALPATH_";
331 if (tCmdCode.contentEquals("ASL"))
332 prefix = "ASLPATH_";
333 File path = new File(tVal);
334 found = false;
335 if (path.exists()) {
336 for (int k = 0; k < toolInf.getPath().size(); k++)
337 if (toolInf.getPath(k).startsWith(prefix))
338 found = true;
339 if (found == false) {
340 toolInf.addPath(prefix + tVal);
341 if (DEBUG > 10)
342 System.out.println(" Adding valid path: " + tVal);
343 }
344 if (prefix.contentEquals("ASLPATH_"))
345 acpiPath = tVal;
346 if (prefix.contentEquals("PATH_"))
347 cmdPath = tVal;
348 if (prefix.contentEquals("ASMPATH_"))
349 asmPath = tVal;
350 } else {
351 toolInf.setInvalid();
352 for (int k = 0; k < toolInf.getBadPath().size(); k++)
353 if (toolInf.getBadPath(k).startsWith(prefix))
354 found = true;
355 if (!found) {
356 toolInf.addBadPath(prefix + tVal);
357 if (DEBUG > 10)
358 System.out.println(" Adding NOT valid Path: " + tVal);
359 retCode = FAIL;
360 }
361 }
362 }
363
364 if (tArg.contentEquals("DPATH")) {
365 found = false;
366 File path = new File(tVal);
367 if (path.exists()) {
368 for (int k = 0; k < toolInf.getPath().size(); k++)
369 if (toolInf.getPath(k).startsWith("DPATH_"))
370 found = true;
371 if (!found) {
372 toolInf.addPath("DPATH_" + tVal);
373 if (DEBUG > 10)
374 System.out.println(" Adding valid DPath: " + tVal);
375 }
376 } else {
377 toolInf.setInvalid();
378 for (int k = 0; k < toolInf.getBadPath().size(); k++)
379 if (toolInf.getBadPath(k).contentEquals("DPATH_" + tVal))
380 found = true;
381 if (!found) {
382 toolInf.addBadPath("DPATH_" + tVal);
383 if (DEBUG > 10)
384 System.out.println(" Adding NOT valid DPath: " + tVal);
385 retCode = FAIL;
386 }
387 }
388 }
389
390 if (tArg.contentEquals("SPATH")) {
391 found = false;
392 File path = new File(tVal);
393 if (path.exists()) {
394 for (int k = 0; k < toolInf.getPath().size(); k++)
395 if (toolInf.getPath(k).contentEquals("SPATH_" + tVal))
396 found = true;
397 if (!found) {
398 toolInf.addPath("SPATH_" + tVal);
399 if (DEBUG > 10)
400 System.out.println(" Adding valid SPath: " + tVal);
401 }
402 } else {
403 toolInf.setInvalid();
404 for (int k = 0; k < toolInf.getBadPath().size(); k++)
405 if (toolInf.getBadPath(k).contentEquals("SPATH_" + tVal))
406 found = true;
407 if (!found) {
408 toolInf.addBadPath("SPATH_" + tVal);
409 if (DEBUG > 10)
410 System.out.println(" Adding NOT valid SPath: " + tVal);
411 retCode = FAIL;
412 }
413 }
414 }
415
416 if (tArg.equals("INCLUDEPATH")) {
417 found = false;
418 File path = new File(tVal);
419 if (path.exists()) {
420 for (int k = 0; k < toolInf.getPath().size(); k++)
421 if (toolInf.getPath(k).contentEquals("INCLUDEPATH_" + tVal))
422 found = true;
423 if (!found) {
424 toolInf.addPath("INCLUDEPATH_" + tVal);
425 if (DEBUG > 10)
426 System.out.println(" Adding valid IPath: " + tVal);
427 }
428 } else {
429 toolInf.setInvalid();
430 for (int k = 0; k < toolInf.getBadPath().size(); k++)
431 if (toolInf.getBadPath(k).contentEquals("INCLUDE_" + tVal))
432 found = true;
433 if (!found) {
434 toolInf.addBadPath("INCLUDE_" + tVal);
435 if (DEBUG > 10)
436 System.out.println(" Adding NOT valid IPath: " + tVal);
437 retCode = FAIL;
438 }
439 }
440 }
441
442 if (tArg.equals("LIBPATH")) {
443 found = false;
444 File path = new File(tVal);
445 if (path.exists()) {
446 for (int k = 0; k < toolInf.getPath().size(); k++)
447 if (toolInf.getPath(k).contentEquals("LIB_" + tVal))
448 found = true;
449 if (!found) {
450 toolInf.addPath("LIB_" + tVal);
451 if (DEBUG > 10)
452 System.out.println(" Adding valid LPath: " + tVal);
453 }
454 } else {
455 toolInf.setInvalid();
456 for (int k = 0; k < toolInf.getBadPath().size(); k++)
457 if (toolInf.getBadPath(k).contentEquals("LIB_" + tVal))
458 found = true;
459 if (!found) {
460 toolInf.addBadPath("LIB_" + tVal);
461 if (DEBUG > 10)
462 System.out.println(" Adding NOT valid LPath: " + tVal);
463 retCode = FAIL;
464 }
465 }
466 }
467
468 if (tArg.equals("FLAGS")) {
469 String flags = fileLine[1].trim();
470 String fLine = tTarget + "_" + tCmdCode + "_FLAGS_" + flags;
471 toolInf.addArguments(fLine);
472 if (DEBUG > 10)
473 System.out.println(" Adding flag line: " + fLine);
474 }
475 }
476 }
477 }
478 toolInf.setArch(lastArch);
479 toolInf.setFamily(lastFamily);
480 toolInf.setTagName(lastTagName);
481 info.add(toolInf);
482 if (DEBUG > 2)
483 System.out.println(" ADDED " + ctr + " LAST Tag: " + lastTagName + " Arch: " + lastArch + " Family: "
484 + lastFamily + " Last CmdCode: " + lastCmdCode);
485 //
486 // Finished collecting data, print it out in Human Readable Format
487 if (info.size() > 0) {
488 if (QUIET == false)
489 System.out.println(" **** TOOL CHAINS ****");
490 if ((DEBUG > 0) || (VERBOSE > 1))
491 System.out.println("There are " + info.size()
492 + " different combinations of Tag Names and Architectures.");
493 lastTagName = "arf";
494
495 boolean asmExists = false;
496 boolean asmPathDefined = false;
497
498 boolean cmdPathDefined = false;
499 boolean dPathDefined = false;
500
501 boolean acpiPathDefined = false;
502 boolean acpiDeclared = false;
503 ArrayList<String> warnMsgs = null;
504
505 for (int i = 0; i < info.size(); i++) {
506 if (!lastTagName.contentEquals(info.get(i).getTagName())) {
507 if ((acpiDeclared == false) && (!lastTagName.contentEquals("arf"))) {
508 if (QUIET == false) {
509 System.out
510 .println(" ----WARNING: No ACPI assembler has been defined for "
511 + lastTagName
512 + ", you will not be able to successfully create a complete firmware image.");
513 System.out.println("");
514 }
515 }
516 if ((asmExists == false) && (!lastTagName.contentEquals("arf"))) {
517 if (QUIET == false) {
518 System.out.println(" ----WARNING: No Assembler has been defined for " + lastTagName
519 + ", you will not be able to successfully compile all platforms.");
520 System.out.println("");
521 }
522 }
523 asmPath = "";
524 asmPathDefined = false;
525 cmdPath = "";
526 cmdPathDefined = false;
527 dPathDefined = false;
528 acpiPath = "";
529 acpiPathDefined = false;
530 acpiDeclared = false;
531 warnMsgs = new ArrayList<String>();
532 lastTagName = info.get(i).getTagName();
533 }
534
535 if ((DEBUG > 0) || (VERBOSE > 1))
536 System.out.print("Tool Chain " + i + " Tag Name: " + info.get(i).getTagName() + ", Family: "
537 + info.get(i).getFamily());
538 else if (QUIET == false)
539 System.out.print("Tool Chain Tag Name: " + info.get(i).getTagName() + ", Family: "
540 + info.get(i).getFamily());
541
542 if (info.get(i).isValid()) {
543 ToolInfo vTool = info.get(i);
544 if (QUIET == false)
545 System.out.println(" is Valid for Architecture: " + info.get(i).getArch());
546 // OK, let's print out the command w/flags
547
548 for (int m = 0; m < vTool.getPath().size(); m++) {
549 String pathName[] = vTool.getPath(m).split("_");
550 String prefix = " Tool Path: ";
551 if (pathName[0].startsWith("DPATH")) {
552 prefix = " Dynamic Linker Path: ";
553 dPathDefined = true;
554 }
555 if (pathName[0].startsWith("PATH")) {
556 cmdPathDefined = true;
557 cmdPath = pathName[1].trim();
558 }
559 if (pathName[0].startsWith("APATH")) {
560 asmPathDefined = true;
561 asmPath = pathName[1].trim();
562 }
563 if (pathName[0].startsWith("ASLPATH")) {
564 acpiPathDefined = true;
565 acpiPath = pathName[1].trim();
566 }
567 if (VERBOSE > 0)
568 System.out.println(prefix + pathName[1].trim());
569 }
570 if (acpiPathDefined == false) {
571 if (VERBOSE > 0)
572 warnMsgs.add(" ---- WARNING: " + vTool.getTagName() + "ACPI Path is not defined!");
573 }
574 if ((VERBOSE == 0) && (QUIET == false))
575 System.out.print("Defined Targets: ");
576 for (int k = 0; k < vTool.getTargetName().size(); k++) {
577 String tTarget = vTool.getTargetName(k);
578 if (tTarget.contentEquals("*"))
579 break;
580
581 if (VERBOSE > 0)
582 System.out.println("+++ " + tTarget + " +++");
583 else if (QUIET == false)
584 System.out.print(" " + tTarget);
585
586 for (int j = 0; j < vTool.getCmdCode().size(); j++) {
587 String tCommand = vTool.getCmdCode(j);
588 if (tCommand.contains("ASL ")) {
589 acpiDeclared = true;
590 if (acpiPathDefined) {
591 // TODO: Check the acpi tool path
592 }
593 }
594 if (vTool.getArguments().size() > 1) {
595
596 if (!cmdPathDefined) {
597 warnMsgs.add(" ---- ERROR: Command Path is not defined!");
598 }
599 if ((vTool.getFamily().contentEquals("MSFT")) && (!dPathDefined)) {
600 warnMsgs
601 .add(" ---- ERROR: Microsoft Tool Chains require a Path (DPATH) to the mspdbXX.dll file");
602 }
603
604 // Process Flag lines!
605 for (int n = 0; n < vTool.getArguments().size(); n++) {
606 String tFlags = vTool.getArguments(n);
607 String aFlags[] = new String[2];
608 aFlags = tFlags.split("FLAGS_");
609 String tsCmd[] = tCommand.split(" ");
610 tsCmd[0] = tsCmd[0].trim();
611 if (DEBUG > 10)
612 System.out.println(" tCmd: " + tsCmd[0] + ", aFlags[0]: " + aFlags[0]
613 + ", tTarget: " + tTarget);
614 if (aFlags[0].contains(tsCmd[0])) {
615 if ((tFlags.contains("All")) || (aFlags[0].contains(tTarget))) {
616 String flagLine = aFlags[1].trim();
617 if (info.get(i).getFamily().contentEquals("MSFT")) {
618 if (tCommand.startsWith("PP")) {
619 if (QUIET == false)
620 if ((!flagLine.contains("/P "))
621 && (!flagLine.contains("/E "))) {
622 System.out
623 .println(" **** ERROR **** Pre-Processor Flags are NOT VALID!");
624 }
625 }
626 }
627 String cmdExe = "";
628
629 if (tCommand.contains("ASM ")) {
630 cmdExe = tCommand.replace("ASM (", "");
631 cmdExe = cmdExe.replace(")", "");
632 if (asmPathDefined)
633 cmdExe = asmPath.trim() + File.separator + cmdExe.trim();
634 else
635 cmdExe = cmdPath.trim() + File.separator + cmdExe.trim();
636 File testCmd = new File(cmdExe);
637 // System.out.println("Check: " + cmdExe);
638 if (!testCmd.exists()) {
639 String errMsg = " **** ERROR **** Assembler Command Defined, but does not exist! "
640 + cmdExe;
641 if (VERBOSE > 0) {
642 System.out.println(errMsg);
643 }
644 boolean nf = true;
645 for (int r = 0; r < warnMsgs.size(); r++)
646 if (warnMsgs.get(r).contentEquals(errMsg))
647 nf = false;
648 if (nf)
649 warnMsgs.add(errMsg);
650 } else
651 asmExists = true;
652
653 }
654
655 if ((tCommand.contains("ASM ")) && (asmPathDefined == false)
656 && (VERBOSE > 0))
657 System.out
658 .println(" --- WARNING: Assembler - "
659 + tCommand
660 + " defined, but a Separate Path to the Assembler was not defined, using: "
661 + cmdExe);
662 if ((asmPathDefined) && (tCommand.contains("ASM "))
663 && (asmPathDefined == false) && (VERBOSE == 0)) {
664 String msgIs = " --- WARNING: "
665 + info.get(i).getTagName()
666 + " Assembler "
667 + info.get(i).getArch()
668 + " - "
669 + tCommand
670 + " defined, but a Separate Path to the Assembler was not defined, using: "
671 + cmdExe;
672 boolean nf = true;
673 for (int r = 0; r < warnMsgs.size(); r++)
674 if (warnMsgs.get(r).contentEquals(msgIs))
675 nf = false;
676 if (nf)
677 warnMsgs.add(msgIs);
678 }
679 if (VERBOSE > 0)
680 System.out.println(" " + tCommand + " " + flagLine);
681 }
682 }
683 }
684 } else {
685 if (VERBOSE > 0)
686 System.out.println(" " + tCommand + " has no arguments defined.");
687 }
688 }
689 }
690
691 } else {
692 if (QUIET == false)
693 System.out.println(" is NOT VALID for Architecture: " + info.get(i).getArch());
694 retCode = FAIL;
695 for (int k = 0; k < info.get(i).getBadPath().size(); k++) {
696 String failureString = "";
697 String tempString = info.get(i).getBadPath(k);
698 if (tempString.startsWith("PATH_"))
699 failureString = "Common Command Path: " + tempString.replace("PATH_", "")
700 + " is NOT Valid!";
701 if (tempString.startsWith("SPATH"))
702 failureString = "Static Linker Path: " + tempString.replace("SPATH_", "")
703 + " is NOT valid!";
704 if (tempString.startsWith("DPATH"))
705 failureString = "Dynamic Linker Path: " + tempString.replace("DPATH_", "")
706 + " is NOT valid!";
707 if (tempString.startsWith("LIB_"))
708 failureString = "System Lib Path: " + tempString.replace("LIB_", "")
709 + " is NOT valid!";
710 if (tempString.startsWith("INCLUDEPATH_"))
711 failureString = "System include Path: " + tempString.replace("INCLUDEPATH_", "")
712 + " is NOT valid!";
713 if (tempString.startsWith("APATH"))
714 failureString = "Assembler Path: " + tempString.replace("APATH_", "")
715 + " is NOT valid!";
716 if (tempString.startsWith("ALPATH"))
717 failureString = "Assembler Link Path: " + tempString.replace("ALPATH_", "")
718 + " is NOT valid!";
719 if (tempString.startsWith("ASLPATH"))
720 failureString = "ACPI Path: " + tempString.replace("ASLPATH_", "")
721 + " is NOT valid!";
722 if (QUIET == false)
723 System.out.println(" --- " + failureString);
724 }
725
726 }
727
728 if ((VERBOSE == 0) && (QUIET == false)) {
729 System.out.println("");
730 for (int p = 0; p < warnMsgs.size(); p++)
731 System.out.println(warnMsgs.get(p));
732 }
733 if (QUIET == false)
734 System.out.println("");
735 }
736
737 }
738
739 } catch (IOException e) {
740 if (QUIET == false)
741 System.out.println("I/O Failure: " + e);
742 retCode = FAIL;
743 }
744
745 return retCode;
746 }
747
748 private int testFile(String testFile, boolean interActive, int VERBOSE, boolean QUIET) {
749
750 int retCode = PASS;
751 String readLine = "";
752 String fileLine[] = new String[2];
753 boolean definedAsl = false;
754
755 try {
756 FileReader toolConfFile = new FileReader(testFile);
757 BufferedReader reader = new BufferedReader(toolConfFile);
758 String path = "";
759 String props[] = new String[5];
760 String lastErrTag = "barf";
761 String lastTag = "barf";
762 while ((readLine = reader.readLine()) != null) {
763 if ((!readLine.startsWith("#")) && (readLine.contains("_PATH"))) {
764 if (DEBUG > 2) {
765 System.out.println(" PATH LINE: " + readLine);
766 }
767 readLine = readLine.trim();
768 fileLine = readLine.split("=");
769 path = fileLine[1].trim();
770 props = fileLine[0].split("_");
771 String tagName = props[1].trim();
772 // System.out.println(" Testing TagName: " + tagName);
773 String cmdTag = props[3].trim();
774 if (!lastTag.contentEquals(tagName)) {
775 // we have a new tagName
776 // first past lastTag = barf, lastErrTag = barf, tagName = something other than BARF
777 if (DEBUG > 0)
778 System.out.println(" lastTag: " + lastTag + " this Tag: " + tagName + " lastErrTag: "
779 + lastErrTag);
780
781 if ((definedAsl == false) && (lastTag.contentEquals("barf") == false))
782 warnLog.add(" -- WARNING: Tool Chain Tag Name: " + lastTag
783 + " does not have an ACPI assembler defined!");
784 definedAsl = false;
785
786 if ((lastErrTag.contentEquals("barf")) || (!tagName.contentEquals(lastErrTag))) {
787 if ((DEBUG > 2) || (VERBOSE > 3))
788 System.out.println("Adding tag: " + tagName + " to the goodLog");
789 goodLog.add(tagName);
790 }
791
792 lastTag = tagName;
793
794 } // end of adding the new tag name to the goodLog and
795 // checking if we had an ACPI compiler defined for the TagName
796 File testPath = new File(path);
797 if (cmdTag.contentEquals("ASL"))
798 definedAsl = true;
799 if (!testPath.exists()) {
800 if (VERBOSE > 0)
801 System.out.println(" Invalid path: " + path + ", path does not exist!");
802 if (!tagName.contentEquals(lastErrTag)) {
803 errLog.add(" -- WARNING: Tool Chain Tag Name: " + tagName + " is NOT valid!");
804 errLog.add(" Tool Code: [" + cmdTag + "] Path: " + path + " does not exist!");
805 }
806 retCode = 1;
807 lastErrTag = tagName;
808
809 } else {
810
811 if ((DEBUG > 0) || (VERBOSE > 0)) {
812 if ((!tagName.contentEquals(lastTag)) && (!tagName.contentEquals(lastErrTag))
813 && (!lastTag.contentEquals("barf"))) {
814 String goodMsg = "Tool Chain: " + tagName + " is valid";
815 System.out.println(goodMsg);
816 }
817 }
818 } // end of path existence check
819 } // end of parsing the PATH line
820 } // end of reading file
821 // Check the LAST Tag to see of ACPI has been defined.
822 if (definedAsl == false)
823 warnLog.add(" -- WARNING: Tool Chain Tag Name: " + lastTag
824 + " does not have an ACPI assembler defined!");
825 // CLEAN UP
826 toolConfFile.close();
827 } catch (IOException e) {
828 if (QUIET == false)
829 System.out.println(" [" + testFile + "] " + e);
830 System.exit(FAIL);
831 } // end of TRY-CATCH for reading file
832
833 if ((errLog.isEmpty() == false) && (QUIET == false))
834 for (int i = 0; i < goodLog.size(); i++) {
835 for (int j = 0; j < errLog.size(); j++) {
836 System.out.println(" Error Log [" + j + "] is " + errLog.get(j));
837 if (errLog.get(j).contains(goodLog.get(i).trim())) {
838 if (VERBOSE > 1)
839 System.out.println(" Removing: " + goodLog.get(i).trim());
840 goodLog.remove(i);
841 break;
842 }
843 }
844 }
845 if (DEBUG > 0)
846 System.out.println("Returning with goodLog having: " + goodLog.size());
847 return retCode;
848
849 }
850
851 }