mirror of https://github.com/acidanthera/audk.git
Adding Java Tool: ckt.bat for CheckTools.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@1779 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
9eaf1b3c89
commit
ddfdc8e69d
|
@ -0,0 +1,42 @@
|
|||
<?xml version="1.0"?>
|
||||
<!--
|
||||
Copyright (c) 2006, Intel Corporation
|
||||
All rights reserved. This program and the accompanying materials
|
||||
are licensed and made available under the terms and conditions of the BSD License
|
||||
which accompanies this distribution. The full text of the license may be found at
|
||||
http://opensource.org/licenses/bsd-license.php
|
||||
|
||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
-->
|
||||
<project name="CheckTools" default="CheckTools" basedir=".">
|
||||
<taskdef resource="net/sf/antcontrib/antlib.xml"/>
|
||||
<property environment="env"/>
|
||||
<property name="WORKSPACE" value="${env.WORKSPACE}"/>
|
||||
<property name="buildDir" value="build"/>
|
||||
<property name="installLocation" value="${WORKSPACE}/Tools/bin"/>
|
||||
<target name="CheckTools" depends="install"/>
|
||||
|
||||
<target name="source">
|
||||
<mkdir dir="${buildDir}"/>
|
||||
<javac srcdir="src" destdir="${buildDir}"/>
|
||||
</target>
|
||||
|
||||
<target name="clean">
|
||||
<delete includeemptydirs="true" failonerror="false" quiet="true">
|
||||
<fileset dir="${WORKSPACE}/Tools/Java/Source/CheckTools" includes="${buildDir}"/>
|
||||
</delete>
|
||||
</target>
|
||||
|
||||
<target name="cleanall" depends="clean">
|
||||
<echo message="Removing Class Files and the Java Archive: CheckTools.jar"/>
|
||||
<delete file="${installLocation}/CheckTools.jar"/>
|
||||
</target>
|
||||
|
||||
<target name="install" depends="source">
|
||||
<jar destfile="${installLocation}/CheckTools.jar">
|
||||
<fileset dir="${buildDir}"/>
|
||||
</jar>
|
||||
</target>
|
||||
|
||||
</project>
|
|
@ -0,0 +1,222 @@
|
|||
/** @file
|
||||
Verify the tool configuration file for location of the correct tools.
|
||||
|
||||
Copyright (c) 2006, Intel Corporation
|
||||
All rights reserved. This program and the accompanying materials
|
||||
are licensed and made available under the terms and conditions of the BSD License
|
||||
which accompanies this distribution. The full text of the license may be found at
|
||||
http://opensource.org/licenses/bsd-license.php
|
||||
|
||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
|
||||
**/
|
||||
|
||||
/**
|
||||
* This tool checks to see if specified tool chain paths exist.
|
||||
* It will check all specified paths, as indicated by the last field of the
|
||||
* tool property line equal to _PATH
|
||||
*
|
||||
* no option = check 1) the file specified in target.txt or 2) tools_def.txt
|
||||
* if neither is found, we check the tools_def.template file.
|
||||
* -i = INTERACTIVE checks the "active" tools_def.txt file and lets the
|
||||
* user modify invalid entries.
|
||||
*
|
||||
* -s = SCAN will check all standard locations for tool chains
|
||||
* C:\Program Files\Microsoft Visual Studio *
|
||||
* C:\WINDDK
|
||||
* C:\Bin
|
||||
* C:\ASL
|
||||
* C:\MASM*
|
||||
* /opt/tiano
|
||||
*
|
||||
* -f = FILE check the tools in this file instead of tools_def.txt, or
|
||||
* a file that was specified in target.txt
|
||||
*
|
||||
* -t = TEST can be used with -f or -s, not with -i.
|
||||
*
|
||||
*/
|
||||
package org.tianocore.CheckTools;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
public class CheckTools {
|
||||
private static int DEBUG = 0;
|
||||
|
||||
private static final String copyright = "Copyright (c) 2006, Intel Corporation All rights reserved.";
|
||||
|
||||
private static final String version = "Version 0.1";
|
||||
|
||||
private int VERBOSE = 0;
|
||||
|
||||
// private String argv[];
|
||||
|
||||
private final int DEFAULT = 1;
|
||||
|
||||
private final int TEST = 2;
|
||||
|
||||
private final int SCAN = 4;
|
||||
|
||||
private final int INTERACTIVE = 8;
|
||||
|
||||
private boolean USERFILE = false;
|
||||
|
||||
private String inFile = "";
|
||||
|
||||
private final int PASS = 0;
|
||||
|
||||
private final int FAIL = 1;
|
||||
|
||||
public static void main(String[] argv) {
|
||||
int exitCode = new CheckTools().checkTool(argv);
|
||||
if (exitCode == -1) {
|
||||
new CheckTools().usage();
|
||||
System.exit(1);
|
||||
}
|
||||
System.exit(exitCode);
|
||||
}
|
||||
|
||||
private int checkTool(String[] arguments) {
|
||||
String WORKSPACE = System.getenv("WORKSPACE");
|
||||
if ((DEBUG > 0) || (VERBOSE > 0))
|
||||
System.out.println("Verifying Tool Chains for WORKSPACE: " + WORKSPACE);
|
||||
String SEP = System.getProperty("file.separator");
|
||||
int returnCode = 0;
|
||||
|
||||
if (WORKSPACE == null) {
|
||||
System.out.println("Please set the environment variable, WORKSPACE and run again.");
|
||||
System.exit(1);
|
||||
}
|
||||
String targetTxt = WORKSPACE + SEP + "Tools" + SEP + "Conf" + SEP + "target.txt";
|
||||
|
||||
if ((DEBUG > 1) && (arguments.length > 0))
|
||||
System.out.println("Arguments: ");
|
||||
int cmdCode = DEFAULT;
|
||||
if (arguments.length > 0) {
|
||||
cmdCode = DEFAULT;
|
||||
for (int i = 0; i < arguments.length; i++) {
|
||||
String arg = arguments[i];
|
||||
if (DEBUG > 1)
|
||||
System.out.println(" [" + i + "] " + arg);
|
||||
if (!(arg.toLowerCase().startsWith("-t") || arg.toLowerCase().startsWith("-s")
|
||||
|| arg.toLowerCase().startsWith("-i") || arg.toLowerCase().startsWith("-v") || arg
|
||||
.toLowerCase()
|
||||
.startsWith(
|
||||
"-f"))) {
|
||||
// Only allow valid option flags
|
||||
System.out.println("Invalid argument: " + arg);
|
||||
usage();
|
||||
System.exit(FAIL);
|
||||
}
|
||||
if (arg.toLowerCase().startsWith("-t")) {
|
||||
if (cmdCode == DEFAULT) {
|
||||
cmdCode = TEST;
|
||||
} else {
|
||||
System.out.println("Invalid Options");
|
||||
usage();
|
||||
System.exit(FAIL);
|
||||
}
|
||||
}
|
||||
if (arg.toLowerCase().startsWith("-s")) {
|
||||
if (cmdCode == DEFAULT) {
|
||||
cmdCode = SCAN;
|
||||
} else {
|
||||
System.out.println("Invalid Options");
|
||||
usage();
|
||||
System.exit(FAIL);
|
||||
}
|
||||
}
|
||||
if (arg.toLowerCase().startsWith("-i")) {
|
||||
// Interactive can be specified with any
|
||||
// other option - it turns on the query
|
||||
// on fail mode.
|
||||
cmdCode = cmdCode | INTERACTIVE;
|
||||
}
|
||||
if (arg.toLowerCase().startsWith("-f")) {
|
||||
i++;
|
||||
inFile = arguments[i];
|
||||
USERFILE = true;
|
||||
}
|
||||
if (arg.startsWith("-v")) {
|
||||
// Verbose level can be increased to print
|
||||
// more INFO messages.
|
||||
VERBOSE += 1;
|
||||
}
|
||||
if (arg.startsWith("-V")) {
|
||||
System.out.println(copyright);
|
||||
System.out.println("CheckTools, " + version);
|
||||
System.exit(PASS);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (inFile.length() < 1) {
|
||||
//
|
||||
// Check the target.txt file for a Tool Configuration File.
|
||||
// If not set, we use tools_def.txt, unless we are running with the
|
||||
// INTERACTIVE flag - where we check the template file before copying over to the
|
||||
// tools_def.txt file.
|
||||
//
|
||||
inFile = "tools_def.txt";
|
||||
File target = new File(targetTxt);
|
||||
String readLine = null;
|
||||
String fileLine[] = new String[2];
|
||||
if (target.exists()) {
|
||||
try {
|
||||
FileReader fileReader = new FileReader(targetTxt);
|
||||
BufferedReader bufReader = new BufferedReader(fileReader);
|
||||
while ((readLine = bufReader.readLine()) != null) {
|
||||
if (readLine.startsWith("TOOL_CHAIN_CONF")) {
|
||||
fileLine = readLine.trim().split("=");
|
||||
if (fileLine[1].trim().length() > 0) {
|
||||
if (fileLine[1].trim().contains("Tools/Conf/"))
|
||||
inFile = fileLine[1].replace("Tools/Conf/", "").trim();
|
||||
else
|
||||
inFile = fileLine[1].trim();
|
||||
}
|
||||
}
|
||||
}
|
||||
bufReader.close();
|
||||
} catch (IOException e) {
|
||||
System.out.println(" [target.txt] Read Error: " + e);
|
||||
System.exit(FAIL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// OK, now check the infile of we had one.
|
||||
String toolsDef = WORKSPACE + SEP + "Tools" + SEP + "Conf" + SEP + inFile;
|
||||
File toolsFile = new File(toolsDef);
|
||||
if (!toolsFile.exists()) {
|
||||
// use the template file
|
||||
if (USERFILE) {
|
||||
System.out.println("Could not locate the specified file: " + inFile);
|
||||
System.out.println(" It must be located in the WORKSPACE" + SEP + "Tools" + SEP + "Conf directory");
|
||||
System.exit(FAIL);
|
||||
}
|
||||
toolsDef = WORKSPACE + SEP + "Tools" + SEP + "Conf" + SEP + "tools_def.template";
|
||||
File toolsTemplate = new File(toolsDef);
|
||||
if (!toolsTemplate.exists()) {
|
||||
System.out.println("Your WORKSPACE is not properly configured!");
|
||||
System.exit(FAIL);
|
||||
} else {
|
||||
System.out.println("**** WARNING: No Tool Configuration File was found, using the template file, "
|
||||
+ toolsDef);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// at this point the file, toolsDef points to a tool configuration file of some sort.
|
||||
//
|
||||
// check tool configuration file
|
||||
if (DEBUG > 2)
|
||||
System.out.println("Calling checkTools(" + toolsDef + ", " + cmdCode + ", " + VERBOSE + ")");
|
||||
returnCode = new ToolChecks().checkTools(toolsDef, cmdCode, VERBOSE);
|
||||
|
||||
return returnCode;
|
||||
}
|
||||
|
||||
private void usage() {
|
||||
System.out.println("Usage: checkTools [-i] [-s | -scan] [-t | -test] [[-f | -filename] filename.txt]");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,159 @@
|
|||
/** @file
|
||||
Verify the tool configuration file for location of the correct tools.
|
||||
|
||||
Copyright (c) 2006, Intel Corporation
|
||||
All rights reserved. This program and the accompanying materials
|
||||
are licensed and made available under the terms and conditions of the BSD License
|
||||
which accompanies this distribution. The full text of the license may be found at
|
||||
http://opensource.org/licenses/bsd-license.php
|
||||
|
||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
|
||||
**/
|
||||
|
||||
/**
|
||||
* This tool checks to see if specified tool chain paths exist.
|
||||
* It will check all specified paths, as indicated by the last field of the
|
||||
* tool property line equal to _PATH
|
||||
*
|
||||
* no option = check 1) the file specified in target.txt or 2) tools_def.txt
|
||||
* if neither is found, we check the tools_def.template file.
|
||||
* -i = INIT checks the tools_def.template file
|
||||
*
|
||||
* -s = SCAN will check all standard locations for tool chains
|
||||
* C:\Program Files\Microsoft Visual Studio *
|
||||
* C:\WINDDK
|
||||
* C:\Bin
|
||||
* C:\ASL
|
||||
* C:\MASM*
|
||||
* /opt/tiano
|
||||
*
|
||||
* -f = FILE check the tools in this file instead of tools_def.txt, or
|
||||
* a file that was specified in target.txt
|
||||
*/
|
||||
package org.tianocore.CheckTools;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
|
||||
public class ToolChecks {
|
||||
private static int DEBUG = 0;
|
||||
|
||||
private final int DEFAULT = 1;
|
||||
|
||||
private final int TEST = 2;
|
||||
|
||||
private final int SCAN = 4;
|
||||
|
||||
private final int INTERACTIVE = 8;
|
||||
|
||||
private final int PASS = 0;
|
||||
|
||||
private final int FAIL = 1;
|
||||
|
||||
private ArrayList<String> errLog = new ArrayList<String>();
|
||||
|
||||
private ArrayList<String> goodLog = new ArrayList<String>();
|
||||
|
||||
public int checkTools(String toolConfFile, int cmdCode, int VERBOSE) {
|
||||
|
||||
int returnCode = FAIL;
|
||||
boolean interActive = false;
|
||||
|
||||
if ((DEBUG > 0) || (VERBOSE > 0)) {
|
||||
System.out.println("Using Tool Configuration File: " + toolConfFile);
|
||||
}
|
||||
|
||||
if (DEBUG > 2)
|
||||
System.out.println("The cmdCode: " + cmdCode);
|
||||
|
||||
if ((cmdCode & INTERACTIVE) == INTERACTIVE) {
|
||||
interActive = true;
|
||||
System.out.println("***** WARNING ***** The Interactive function has not been implemented yet!");
|
||||
}
|
||||
|
||||
if ((cmdCode & SCAN) == SCAN) {
|
||||
returnCode = scanFile(toolConfFile, interActive, VERBOSE);
|
||||
}
|
||||
|
||||
if (((cmdCode & TEST) == TEST) || ((cmdCode & DEFAULT) == DEFAULT))
|
||||
returnCode = testFile(toolConfFile, interActive, VERBOSE);
|
||||
|
||||
if (!errLog.isEmpty()) {
|
||||
System.out.println("Tool Configuration File: " + toolConfFile);
|
||||
for (int i = 0; i < goodLog.size(); i++)
|
||||
System.out.println("Tool Chain Tag Name: " + goodLog.get(i) + " is valid!");
|
||||
for (int i = 0; i < errLog.size(); i++)
|
||||
System.out.println(errLog.get(i));
|
||||
}
|
||||
|
||||
return returnCode;
|
||||
}
|
||||
|
||||
private int scanFile(String testFile, boolean interActive, int VERBOSE) {
|
||||
if ((DEBUG > 0) || (VERBOSE > 0))
|
||||
System.out.println("Scanning the Normal Installation Locations ...");
|
||||
System.out.println("The Scan function has not been implemented yet!");
|
||||
return FAIL;
|
||||
}
|
||||
private int testFile(String testFile, boolean interActive, int VERBOSE) {
|
||||
|
||||
int retCode = PASS;
|
||||
String readLine = "";
|
||||
String fileLine[] = new String[2];
|
||||
try {
|
||||
FileReader toolConfFile = new FileReader(testFile);
|
||||
BufferedReader reader = new BufferedReader(toolConfFile);
|
||||
String path = "";
|
||||
String props[] = new String[5];
|
||||
String lastErrTag = "barf";
|
||||
String lastTag = "barf";
|
||||
while ((readLine = reader.readLine()) != null) {
|
||||
if ((!readLine.startsWith("#")) && (readLine.contains("_PATH"))) {
|
||||
if (DEBUG > 2) {
|
||||
System.out.println(" PATH LINE: " + readLine);
|
||||
}
|
||||
readLine = readLine.trim();
|
||||
fileLine = readLine.split("=");
|
||||
path = fileLine[1].trim();
|
||||
props = fileLine[0].split("_");
|
||||
File testPath = new File(path);
|
||||
if (!testPath.exists()) {
|
||||
if (!props[1].trim().contentEquals(lastErrTag))
|
||||
errLog.add(" -- ERROR: Tool Chain Tag Name: " + props[1].trim() + " is invalid!");
|
||||
// System.out.println(" +++++ ERROR: Tool Chain: " + props[1].trim() + " is invalid!");
|
||||
errLog.add(" Tool Code: [" + props[3].trim() + "] Path: " + path + " does not exist!");
|
||||
// System.out.println(" Tool: " + props[3].trim() + " Path: " + path + " does not exist!");
|
||||
retCode = 1;
|
||||
lastErrTag = props[1].trim();
|
||||
} else {
|
||||
if ((DEBUG > 0) || (VERBOSE > 0)) {
|
||||
if ((!props[1].trim().contentEquals(lastTag))
|
||||
&& (!props[1].trim().contentEquals(lastErrTag)))
|
||||
System.out.println("Tool Chain: " + props[1].trim() + " is valid");
|
||||
}
|
||||
if (!props[1].trim().contentEquals(lastTag))
|
||||
goodLog.add(props[1].trim());
|
||||
lastTag = props[1].trim();
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
System.out.println(" [" + testFile + "] " + e);
|
||||
System.exit(1);
|
||||
}
|
||||
if (errLog.size() > 0)
|
||||
for (int i = 0; i < goodLog.size(); i++) {
|
||||
for (int j = 0; j < errLog.size(); j++) {
|
||||
if (errLog.get(j).contains(goodLog.get(i).trim())) {
|
||||
goodLog.remove(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return retCode;
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,73 @@
|
|||
@REM
|
||||
@REM Copyright (c) 2006, Intel Corporation
|
||||
@REM All rights reserved. This program and the accompanying materials
|
||||
@REM are licensed and made available under the terms and conditions of the BSD License
|
||||
@REM which accompanies this distribution. The full text of the license may be found at
|
||||
@REM http://opensource.org/licenses/bsd-license.php
|
||||
@REM
|
||||
@REM THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
@REM WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
@REM
|
||||
|
||||
@echo off
|
||||
|
||||
:check_java
|
||||
if "%JAVA_HOME%"=="" goto no_jdk
|
||||
:check_wks
|
||||
if "%WORKSPACE%"=="" goto no_wks
|
||||
:check_ant
|
||||
if "%ANT_HOME%"=="" goto no_ant
|
||||
:check_xmlbeans
|
||||
if "%XMLBEANS_HOME%"=="" goto no_xmlbeans
|
||||
:check_surfacearea
|
||||
if not exist %WORKSPACE%\Tools\Jars\SurfaceArea.jar (
|
||||
goto no_surfacearea
|
||||
)
|
||||
:check_CheckTools
|
||||
if not exist %WORKSPACE%\Tools\bin\CheckTools.jar (
|
||||
goto no_CheckTools
|
||||
)
|
||||
|
||||
@REM Run Framework Wizard
|
||||
call "java" -cp %WORKSPACE%\Tools\bin\CheckTools.jar org.tianocore.CheckTools.CheckTools %*
|
||||
|
||||
goto end
|
||||
|
||||
:no_jdk
|
||||
@echo.
|
||||
@echo !!! Please set JAVA_HOME !!!
|
||||
@echo.
|
||||
goto check_wks
|
||||
|
||||
:no_wks
|
||||
@echo.
|
||||
@echo !!! Please set WORKSPACE !!!
|
||||
@echo.
|
||||
goto check_ant
|
||||
|
||||
:no_ant
|
||||
@echo.
|
||||
@echo !!! Please set ANT_HOME !!!
|
||||
@echo.
|
||||
goto check_xmlbeans
|
||||
|
||||
:no_xmlbeans
|
||||
@echo.
|
||||
@echo !!! Please set XMLBEANS_HOME !!!
|
||||
@echo.
|
||||
goto end
|
||||
|
||||
:no_surfacearea
|
||||
@echo.
|
||||
@echo !!! Please run edksetup.bat to build SurfaceArea.jar !!!
|
||||
@echo.
|
||||
goto end
|
||||
|
||||
:no_CheckTools
|
||||
@echo.
|
||||
@echo !!! Please run edksetup.bat to build CheckTools.jar !!!
|
||||
@echo.
|
||||
goto end
|
||||
|
||||
:end
|
||||
@echo on
|
Loading…
Reference in New Issue