2 Verify the tool configuration file for location of the correct tools.
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
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.
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
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
24 * -s = SCAN will check all standard locations for tool chains
25 * C:\Program Files\Microsoft Visual Studio *
32 * -f = FILE check the tools in this file instead of tools_def.txt, or
33 * a file that was specified in target.txt
35 package org
.tianocore
.CheckTools
;
40 public class ToolChecks
{
41 private static int DEBUG
= 0;
43 private final int DEFAULT
= 1;
45 private final int TEST
= 2;
47 private final int SCAN
= 4;
49 private final int INTERACTIVE
= 8;
51 private final int PASS
= 0;
53 private final int FAIL
= 1;
55 private ArrayList
<String
> errLog
= new ArrayList
<String
>();
57 private ArrayList
<String
> goodLog
= new ArrayList
<String
>();
59 public int checkTools(String toolConfFile
, int cmdCode
, int VERBOSE
) {
61 int returnCode
= FAIL
;
62 boolean interActive
= false;
64 if ((DEBUG
> 0) || (VERBOSE
> 0)) {
65 System
.out
.println("Using Tool Configuration File: " + toolConfFile
);
69 System
.out
.println("The cmdCode: " + cmdCode
);
71 if ((cmdCode
& INTERACTIVE
) == INTERACTIVE
) {
73 System
.out
.println("***** WARNING ***** The Interactive function has not been implemented yet!");
76 if ((cmdCode
& SCAN
) == SCAN
) {
77 returnCode
= scanFile(toolConfFile
, interActive
, VERBOSE
);
80 if (((cmdCode
& TEST
) == TEST
) || ((cmdCode
& DEFAULT
) == DEFAULT
))
81 returnCode
= testFile(toolConfFile
, interActive
, VERBOSE
);
83 if (!errLog
.isEmpty()) {
84 System
.out
.println("Tool Configuration File: " + toolConfFile
);
85 for (int i
= 0; i
< goodLog
.size(); i
++)
86 System
.out
.println("Tool Chain Tag Name: " + goodLog
.get(i
) + " is valid!");
87 for (int i
= 0; i
< errLog
.size(); i
++)
88 System
.out
.println(errLog
.get(i
));
94 private int scanFile(String testFile
, boolean interActive
, int VERBOSE
) {
95 if ((DEBUG
> 0) || (VERBOSE
> 0))
96 System
.out
.println("Scanning the Normal Installation Locations ...");
97 System
.out
.println("The Scan function has not been implemented yet!");
100 private int testFile(String testFile
, boolean interActive
, int VERBOSE
) {
103 String readLine
= "";
104 String fileLine
[] = new String
[2];
106 FileReader toolConfFile
= new FileReader(testFile
);
107 BufferedReader reader
= new BufferedReader(toolConfFile
);
109 String props
[] = new String
[5];
110 String lastErrTag
= "barf";
111 String lastTag
= "barf";
112 while ((readLine
= reader
.readLine()) != null) {
113 if ((!readLine
.startsWith("#")) && (readLine
.contains("_PATH"))) {
115 System
.out
.println(" PATH LINE: " + readLine
);
117 readLine
= readLine
.trim();
118 fileLine
= readLine
.split("=");
119 path
= fileLine
[1].trim();
120 props
= fileLine
[0].split("_");
121 File testPath
= new File(path
);
122 if (!testPath
.exists()) {
123 if (!props
[1].trim().contentEquals(lastErrTag
))
124 errLog
.add(" -- ERROR: Tool Chain Tag Name: " + props
[1].trim() + " is invalid!");
125 // System.out.println(" +++++ ERROR: Tool Chain: " + props[1].trim() + " is invalid!");
126 errLog
.add(" Tool Code: [" + props
[3].trim() + "] Path: " + path
+ " does not exist!");
127 // System.out.println(" Tool: " + props[3].trim() + " Path: " + path + " does not exist!");
129 lastErrTag
= props
[1].trim();
131 if ((DEBUG
> 0) || (VERBOSE
> 0)) {
132 if ((!props
[1].trim().contentEquals(lastTag
))
133 && (!props
[1].trim().contentEquals(lastErrTag
)))
134 System
.out
.println("Tool Chain: " + props
[1].trim() + " is valid");
136 if (!props
[1].trim().contentEquals(lastTag
))
137 goodLog
.add(props
[1].trim());
138 lastTag
= props
[1].trim();
142 } catch (IOException e
) {
143 System
.out
.println(" [" + testFile
+ "] " + e
);
146 if (errLog
.size() > 0)
147 for (int i
= 0; i
< goodLog
.size(); i
++) {
148 for (int j
= 0; j
< errLog
.size(); j
++) {
149 if (errLog
.get(j
).contains(goodLog
.get(i
).trim())) {