]>
git.proxmox.com Git - mirror_edk2.git/blob - Tools/Java/Source/CheckTools/src/org/tianocore/CheckTools/ToolChecks.java
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
));
91 System
.out
.println("You can remove these WARNING messages by editing the file:");
92 System
.out
.println(" " + toolConfFile
);
93 System
.out
.println("and commenting out out or deleting the entries for the tool");
94 System
.out
.println("chain tag names that do not apply to your system.");
97 System
.out
.println("");
98 System
.out
.println(" Tool Configuration File: " + toolConfFile
+ " is valid!");
104 private int scanFile(String testFile
, boolean interActive
, int VERBOSE
) {
105 if ((DEBUG
> 0) || (VERBOSE
> 0))
106 System
.out
.println("Scanning the Normal Installation Locations ...");
107 System
.out
.println("The Scan function has not been implemented yet!");
110 private int testFile(String testFile
, boolean interActive
, int VERBOSE
) {
113 String readLine
= "";
114 String fileLine
[] = new String
[2];
116 FileReader toolConfFile
= new FileReader(testFile
);
117 BufferedReader reader
= new BufferedReader(toolConfFile
);
119 String props
[] = new String
[5];
120 String lastErrTag
= "barf";
121 String lastTag
= "barf";
122 while ((readLine
= reader
.readLine()) != null) {
123 if ((!readLine
.startsWith("#")) && (readLine
.contains("_PATH"))) {
125 System
.out
.println(" PATH LINE: " + readLine
);
127 readLine
= readLine
.trim();
128 fileLine
= readLine
.split("=");
129 path
= fileLine
[1].trim();
130 props
= fileLine
[0].split("_");
131 File testPath
= new File(path
);
132 if (!testPath
.exists()) {
133 if (!props
[1].trim().contentEquals(lastErrTag
))
134 errLog
.add(" -- WARNING: Tool Chain Tag Name: " + props
[1].trim() + " is NOT valid!");
136 errLog
.add(" Tool Code: [" + props
[3].trim() + "] Path: " + path
+ " does not exist!");
138 lastErrTag
= props
[1].trim();
140 if ((DEBUG
> 0) || (VERBOSE
> 0)) {
141 if ((!props
[1].trim().contentEquals(lastTag
))
142 && (!props
[1].trim().contentEquals(lastErrTag
)))
143 System
.out
.println("Tool Chain: " + props
[1].trim() + " is valid");
145 if (!props
[1].trim().contentEquals(lastTag
))
146 goodLog
.add(props
[1].trim());
147 lastTag
= props
[1].trim();
151 } catch (IOException e
) {
152 System
.out
.println(" [" + testFile
+ "] " + e
);
155 if (errLog
.size() > 0)
156 for (int i
= 0; i
< goodLog
.size(); i
++) {
157 for (int j
= 0; j
< errLog
.size(); j
++) {
158 if (errLog
.get(j
).contains(goodLog
.get(i
).trim())) {