summaryrefslogtreecommitdiff
path: root/Tools/Java/Source/DbTools
diff options
context:
space:
mode:
Diffstat (limited to 'Tools/Java/Source/DbTools')
-rw-r--r--Tools/Java/Source/DbTools/DbTools.msa31
-rw-r--r--Tools/Java/Source/DbTools/build.xml42
-rw-r--r--Tools/Java/Source/DbTools/src/org/tianocore/DbTools/DbCmds.java501
-rw-r--r--Tools/Java/Source/DbTools/src/org/tianocore/DbTools/DbTool.java24
-rw-r--r--Tools/Java/Source/DbTools/src/org/tianocore/DbTools/UpdateDb.java594
5 files changed, 0 insertions, 1192 deletions
diff --git a/Tools/Java/Source/DbTools/DbTools.msa b/Tools/Java/Source/DbTools/DbTools.msa
deleted file mode 100644
index 254b0bec2d..0000000000
--- a/Tools/Java/Source/DbTools/DbTools.msa
+++ /dev/null
@@ -1,31 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<ModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
- <MsaHeader>
- <ModuleName>Database Manipulation Tools</ModuleName>
- <ModuleType>TOOL</ModuleType>
- <GuidValue>c51d72c2-6e85-4fcf-adb2-7c44b2f57f19</GuidValue>
- <Version>0.3</Version>
- <Abstract>The tool manipulates the FrameworkDatabase.db file</Abstract>
- <Description>
-This tool will scan the current workspace and update the FrameworkDatabase.db file if the workspace content is not consistent with the database.
-USAGE:
-DbTool [-v] [-t] [-q] [-V] [--package] [--platform] [-h | -? | --help]</Description>
- <Copyright>Copyright (c) 2006, Intel Corporation All rights reserved.</Copyright>
- <License URL="http://opensource.org/licenses/bsd-license.php">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.</License>
- <Specification>FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052</Specification>
- </MsaHeader>
- <ModuleDefinitions>
- <SupportedArchitectures>IA32 X64 IPF</SupportedArchitectures>
- <BinaryModule>false</BinaryModule>
- <OutputFileBasename>DbTools</OutputFileBasename>
- </ModuleDefinitions>
- <SourceFiles>
- <Filename>src/org/tianocore/DbTools/UpdateDb.java</Filename>
- <Filename>src/org/tianocore/DbTools/DbTool.java</Filename>
- <Filename>src/org/tianocore/DbTools/DbCmds.java</Filename>
- <Filename>build.xml</Filename>
- </SourceFiles>
-</ModuleSurfaceArea>
diff --git a/Tools/Java/Source/DbTools/build.xml b/Tools/Java/Source/DbTools/build.xml
deleted file mode 100644
index 5ae43e9223..0000000000
--- a/Tools/Java/Source/DbTools/build.xml
+++ /dev/null
@@ -1,42 +0,0 @@
-<?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="DbTools" default="DbTools" basedir=".">
- <taskdef resource="net/sf/antcontrib/antlib.xml"/>
- <property environment="env"/>
- <property name="WORKSPACE" value="${env.WORKSPACE}"/>
- <path id="classpath">
- <fileset dir="${WORKSPACE}/Tools/Jars" includes="*.jar"/>
- <fileset dir="${env.XMLBEANS_HOME}/lib" includes="*.jar"/>
- </path>
- <property name="buildDir" value="build"/>
- <property name="installLocation" value="${WORKSPACE}/Tools/Jars"/>
- <target name="DbTools" depends="install"/>
- <target name="source">
- <mkdir dir="${buildDir}"/>
- <javac srcdir="src" destdir="${buildDir}">
- <classpath refid="classpath"/>
- <!-- <compilerarg value="-Xlint"/> -->
- </javac>
- </target>
- <target name="clean">
- <delete dir="${buildDir}"/>
- </target>
- <target name="cleanall">
- <delete dir="${buildDir}"/>
- <delete file="${installLocation}/DbTools.jar"/>
- </target>
- <target name="install" depends="source">
- <jar destfile="${installLocation}/DbTools.jar">
- <fileset dir="${buildDir}"/>
- </jar>
- </target>
-</project>
diff --git a/Tools/Java/Source/DbTools/src/org/tianocore/DbTools/DbCmds.java b/Tools/Java/Source/DbTools/src/org/tianocore/DbTools/DbCmds.java
deleted file mode 100644
index f4d45a4cbd..0000000000
--- a/Tools/Java/Source/DbTools/src/org/tianocore/DbTools/DbCmds.java
+++ /dev/null
@@ -1,501 +0,0 @@
-// @file
-// DbCmds command-line interface to the classes that
-// update the FrameworkDatabase.db file based on WORKSPACE Contents
-//
-// 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 program is the command line interface to the CombineMsa class, which
-// will take the following arguments:
-//
-// Input:
-// -t, --test Test the Workspace against the FrameworkDatabase.db file
-// Returns 0 if valid, returns 1 if failed
-//
-// -f, --fix Fix the FrameworkDatabase.db file, so that it matches the
-// the contents of the WORKSPACE
-// Returns 0 if valid, returns 1 if failed
-//
-// -v [-v] Verbose Flag - sum of these will be used to set different
-// levels of verbosity
-//
-// -i Interactive, when used with -f or --fix, will query the user
-// regarding adds and deletes of packages and platforms from
-// the database.
-//
-// -a, --add Add an SPD or FPD file to the FrameworkDatabase.db file. The
-// SPD/FPD file must exist, or the command will fail.
-// Returns 0 if valid, returns 1 if failed
-//
-// -r, --del Remove an SPD or FPD file from the FrameworkDatabase.db file.
-// If the SPD/FPD file exists, the user will be queried to
-// remove it from the directory tree. For SPD files, the user
-// will also be presented with a list of Modules in the SPD
-// file, with the query to remove the modules as well as the
-// SPD file.
-// Returns 0 if valid, returns 1 if failed
-//
-// -u Display the UiName for all Packages and Platforms currently in
-// the FrameworkDatabase.db file.
-// Returns 0 if valid, returns 1 if failed
-//
-// -c Display a CSV listing of Type (SPD|FPD) UiName and Filename of
-// every entry in the FrameworkDatabase.db file.
-// Returns 0 if valid, returns 1 if failed
-//
-// No Options Display a list of Type (Package|Platfrom) and Filename of every
-// entry in the FrameworkDatabase.db file.
-// Returns 0 if valid, returns 1 if failed
-//
-// -h, -?, --help Displays this usage and exits.
-// Returns 0 if valid, returns 1 if failed
-//
-//
-// Output:
-// Displayed information
-//
-// Modifies - OPTIONAL
-// FrameworkDatabase.db
-//
-
-package org.tianocore.DbTools;
-
-import java.io.*;
-
-public class DbCmds {
-
- protected enum Cmd {
- SHOW_CSV, SHOW_PLATFORMS, SHOW_PACKAGES, FIX_DB, TEST_DB, FIND_SOMETHING, SHOW_FAR, ADD_SOMETHING,
- DELETE_SOMETHING
- }
-
- private 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 static final String Specification = "FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052";
-
- private int VERBOSE = 0;
-
- public boolean INTERACTIVE = false;
-
- private String workspace = System.getenv("WORKSPACE");
-
- private final String frameworkDatabase = workspace + File.separator + "Tools" + File.separator + "Conf"
- + File.separator + "FrameworkDatabase.db";
-
- private final int ESUCCESS = 0;
-
- private final int EFAILURE = 1;
-
- private final int MIN_VERBOSE = 0;
-
- private final int MED_VERBOSE = 1;
-
- private final int MAX_VERBOSE = 2;
-
- private final static int FOUND = 1;
-
- private final static int NOTFOUND = 0;
-
- private boolean TEST = false;
-
- private int result = ESUCCESS;
-
- private Cmd commandToCall;
-
- private boolean isPlatform = false;
-
- private boolean isPackage = false;
-
- private boolean isFar = false;
-
- private boolean QUIET = false;
-
- private String commandArgs = "";
-
- private String whatToFind = "";
-
- public int DbUpdateCmdLine(String[] args) {
-
- if (testFile(frameworkDatabase) == NOTFOUND) {
- System.out.println("ERROR: E000 Invalid Workspace!");
- System.out.println("The environment variable, WORKSPACE, does not point to a valid workspace");
- System.out.println("DbUpdate Aborted!");
- System.err.flush();
- System.exit(EFAILURE);
- }
- result = parseCmdLine(args);
- if (result == ESUCCESS) {
- if (DEBUG > 2)
- System.out.println("Parse Succeeded!");
- if (VERBOSE > MAX_VERBOSE)
- System.out.println("WORKSPACE: " + workspace);
- if (DEBUG > 1)
- System.out.println("Command to call: " + commandToCall.toString());
- result = processCmdLine(commandToCall);
- } else {
- if (QUIET == false) {
- System.out.println("Invalid Arguments");
- outputUsage();
- result = EFAILURE;
- }
- }
- if (DEBUG > 2)
- System.out.println(" Result: " + result);
-
- return result;
- }
-
- private int processCmdLine(Cmd cmdCode) {
- UpdateDb dbUp = new UpdateDb();
- int res = ESUCCESS;
- switch (cmdCode) {
- case SHOW_CSV:
- // display current Database contents in CSV format
- // Modifies: NOTHING
- if ((DEBUG > 3) || (VERBOSE > MED_VERBOSE))
- System.out.println("Display contents of the FrameworkDatabase.db file in CSV format.");
- result = dbUp.getCsvEntries(frameworkDatabase, VERBOSE);
- break;
- case FIX_DB:
- // Automatically make the database match the contents of the workspace
- // Modifies: FrameworkDatabase.db
- if ((VERBOSE > MIN_VERBOSE) && (QUIET == false)) {
- if (TEST == false)
- System.out.println("Adjusting the FrameworkDatabase to match the contents of the WORKSPACE: "
- + workspace);
- if (TEST)
- System.out.println("Verify the FrameworkDatabase matches the contents of the WORKSPACE: "
- + workspace);
- }
- if ((DEBUG > 3) || (VERBOSE > MED_VERBOSE))
- System.out.println("Scan the Workspace and update the FrameworkDatabase.db file.");
- result = dbUp.fixDatabase(workspace, VERBOSE, INTERACTIVE, TEST, QUIET);
-
- break;
- case ADD_SOMETHING:
- // Add a Platform, package or FAR to the workspace.
- // Modifies: FrameworkDatabase.db
- if (((DEBUG > 3) || (VERBOSE > MED_VERBOSE)) && (isPlatform))
- System.out.println("Add Platform " + commandArgs + " to the FrameworkDatabase.db file");
- else if (((DEBUG > 3) || (VERBOSE > MED_VERBOSE)) && (isPackage))
- System.out.println("Add Package " + commandArgs + " to the FrameworkDatabase.db file");
- else if (((DEBUG > 3) || (VERBOSE > MED_VERBOSE)) && (isFar))
- System.out.println("Add Framework Archive " + commandArgs + " to the FrameworkDatabase.db file");
- result = dbUp.addItem(frameworkDatabase, commandArgs, VERBOSE, INTERACTIVE);
- break;
- case DELETE_SOMETHING:
- // Remove a platform, package or FAR from the workspace
- // Modifies: FrameworkDatabase.db, AND Filesystem
- if (((DEBUG > 3) || (VERBOSE > MED_VERBOSE)) && (isPlatform))
- System.out.println("Removing Platform " + commandArgs + " from the FrameworkDatabase.db file");
- else if (((DEBUG > 3) || (VERBOSE > MED_VERBOSE)) && (isPackage))
- System.out.println("Removing Package " + commandArgs + " from the FrameworkDatabase.db file");
- else if (((DEBUG > 3) || (VERBOSE > MED_VERBOSE)) && (isFar))
- System.out.println("Removing Framework Archive " + commandArgs + " from the FrameworkDatabase.db file");
- result = dbUp.addItem(workspace, commandArgs, VERBOSE, INTERACTIVE);
- break;
- case FIND_SOMETHING:
- // Find something in the workspace
- // Modifies: NOTHING
- if ((DEBUG > 3) || (VERBOSE > MED_VERBOSE))
- System.out.println("Finding " + whatToFind + " " + commandArgs + " in the Workspace");
- result = dbUp.findItem(workspace, VERBOSE, whatToFind, commandArgs);
- break;
- case SHOW_FAR:
- // Display FAR information for all SPDs in the workspace
- // Modifies: NOTHING
- if ((DEBUG > 3) || (VERBOSE > MED_VERBOSE))
- System.out.println("Display Framework Archives in the Workspace");
- result = dbUp.findFars(workspace, VERBOSE);
- break;
- case SHOW_PACKAGES:
- // Display SPD information for all SPDs in the workspace
- // Modifies: NOTHING
- if ((DEBUG > 3) || (VERBOSE > MED_VERBOSE))
- System.out.println("Display Packages in the Workspace");
- result = dbUp.findSpds(workspace, VERBOSE);
- break;
- case SHOW_PLATFORMS:
- // Display FPD information for all SPDs in the workspace
- // Modifies: NOTHING
- if ((DEBUG > 3) || (VERBOSE > MED_VERBOSE))
- System.out.println("Display Platforms in the Workspace");
- result = dbUp.findFpds(workspace, VERBOSE);
- break;
- default:
- // ERROR IF WE GET HERE!
- if ((DEBUG > 3) || (VERBOSE > MAX_VERBOSE))
- System.out.println("We could not process the following: " + commandToCall.toString());
- else if (QUIET == false)
- outputUsage();
- result = EFAILURE;
- break;
- }
- return res;
- }
-
- private int parseCmdLine(String[] args) {
-
- // Default is to fix the database.
- commandToCall = Cmd.FIX_DB;
- if (args.length == NOTFOUND) {
- if ((DEBUG > 3) || (VERBOSE > MAX_VERBOSE))
- System.out.println("NO ARGUMENTS! " + commandToCall.toString());
- return (ESUCCESS);
- }
-
- for (int i = 0; i < args.length; i++)
- if (args[i].toLowerCase().contentEquals("-q"))
- QUIET = true;
-
- for (int i = 0; i < args.length; i++) {
- String arg = args[i].trim();
- // This is the list of valid options
- if (!((arg.toLowerCase().startsWith("-t")) || (arg.toLowerCase().startsWith("--t"))
- || (arg.toLowerCase().startsWith("-q")) || (arg.toLowerCase().startsWith("-i"))
- || (arg.toLowerCase().startsWith("-f")) || (arg.toLowerCase().startsWith("--f"))
- || (arg.toLowerCase().startsWith("-c")) || (arg.toLowerCase().startsWith("--c"))
- || (arg.toLowerCase().startsWith("-a")) || (arg.toLowerCase().startsWith("--a"))
- || (arg.toLowerCase().startsWith("-r")) || (arg.toLowerCase().startsWith("--d"))
- || (arg.toLowerCase().startsWith("-v")) || (arg.toLowerCase().startsWith("--c"))
- || (arg.toLowerCase().startsWith("--p")) || (arg.toLowerCase().startsWith("-h"))
- || (arg.toLowerCase().startsWith("--h")) || (arg.toLowerCase().startsWith("/h")) || (arg
- .toLowerCase()
- .startsWith("-?")))) {
- // This is the fall through, we got something we did not know how to
- // process!
- if (args[i].startsWith("-")) {
- System.out.println("ERROR: E1004 Unknown Option: " + arg);
- System.out.println("Try running with -h or --help");
- } else {
- System.out.println("ERROR: E1005 Unknown Argument: " + arg);
- System.out.println("Try running with -h or --help");
- }
- System.out.println("Program Aborted!");
- System.err.flush();
- System.exit(EFAILURE);
- }
- if ((arg.toLowerCase().contentEquals("-t")) || (arg.toLowerCase().contains("--test"))) {
- // Test Workspace, do not fix.
- TEST = true;
- }
- if (arg.toLowerCase().contentEquals("-q")) {
- QUIET = true;
- }
- if (arg.toLowerCase().contentEquals("-i")) {
- INTERACTIVE = true;
- }
- if ((arg.toLowerCase().contentEquals("-f")) || (arg.toLowerCase().contains("--fix"))) {
- // Non-interactive fix of the database
- commandToCall = Cmd.FIX_DB;
- }
- if ((arg.toLowerCase().contentEquals("-c")) || (arg.toLowerCase().contains("--csv"))) {
- // Dump database in CSV format
- commandToCall = Cmd.SHOW_CSV;
- }
- if ((arg.toLowerCase().trim().contentEquals("-a")) || (arg.toLowerCase().contains("--add"))) {
- i++;
- if (args[i].startsWith("-")) {
- System.out.println("ERROR: E002 Missing Argument!");
- System.out
- .println("The add function requires an argument, either a package name or a platform name!");
- System.out.println("DbUpdate Aborted!");
- System.err.flush();
- System.exit(EFAILURE);
- }
- commandToCall = Cmd.ADD_SOMETHING;
- commandArgs = args[i];
- setArgType(commandArgs);
- }
- if ((arg.toLowerCase().trim().contentEquals("-r")) || (arg.toLowerCase().contains("--del"))) {
- i++;
- if (args[i].startsWith("-")) {
- System.out.println("ERROR: E002 Missing Argument!");
- System.out
- .println("The remove function requires an argument, either a package name or a platform name!");
- System.out.println("DbUpdate Aborted!");
- System.err.flush();
- System.exit(EFAILURE);
- }
- commandToCall = Cmd.DELETE_SOMETHING;
- commandArgs = args[i];
- setArgType(commandArgs);
- }
- if (arg.toLowerCase().contains("--find")) {
- commandToCall = Cmd.FIND_SOMETHING;
- i++;
- if (args[i].toLowerCase().contains("--lib"))
- whatToFind = "LIBRARY";
- else if (args[i].toLowerCase().contains("--guid"))
- whatToFind = "GUID";
- else if (args[i].toLowerCase().contains("--ppi"))
- whatToFind = "PPI";
- else if (args[i].toLowerCase().contains("--prot"))
- whatToFind = "PROTOCOL";
- else if (args[i].toLowerCase().contains("--pcd"))
- whatToFind = "PCD";
- else if (args[i].startsWith("-")) {
- System.out.println("ERROR: E001 Invalid Argument");
- System.out.println("The find function takes either a qualifier of --guid, --ppi,");
- System.out.println(" --proto, --pcd, or the string to search for.");
- System.err.flush();
- System.exit(EFAILURE);
- } else
- commandArgs = args[i];
-
- if (!whatToFind.contentEquals("")) {
- i++;
- if (args[i].startsWith("-")) {
- System.out.println("ERROR: E001 Invalid Argument");
- System.out.println("The find function qualifier (--guid, --ppi, --proto, --pcd)");
- System.out.println(" must be followed by the string to search for.");
- System.err.flush();
- System.exit(EFAILURE);
- } else
- commandArgs = args[i];
- }
-
- }
- if (arg.trim().contentEquals("-v")) {
- VERBOSE++;
- }
- if (arg.toLowerCase().contains("--lib")) {
- whatToFind = "LIBRARY";
- }
- if (arg.toLowerCase().contains("--guid")) {
- whatToFind = "GUID";
- }
- if (arg.toLowerCase().contains("--ppi")) {
- whatToFind = "PPI";
- }
- if (arg.toLowerCase().contains("--prot")) {
- whatToFind = "PROTOCOL";
- }
- if (arg.toLowerCase().contains("--pcd")) {
- whatToFind = "PCD";
- }
- if (arg.toLowerCase().contentEquals("-d") || arg.trim().toLowerCase().contains("--debug")) {
- if ((i + 1 == args.length) || (args[i + 1].trim().startsWith("-"))) {
- DEBUG = 1;
- } else if (i + 1 < args.length) {
- String pattern = "^\\d+";
- if (args[i + 1].trim().matches(pattern)) {
- i++;
- DEBUG = Integer.parseInt(args[i]);
- } else
- DEBUG = 1;
- }
- }
- if (arg.trim().contentEquals("-V")) {
- System.out.println("DbTools, " + version);
- System.out.println(copyright);
- System.out.println(Specification);
- System.err.flush();
- System.exit(ESUCCESS);
- }
- if (arg.toLowerCase().trim().startsWith("--pack")) {
- commandToCall = Cmd.SHOW_PACKAGES;
- }
- if (arg.toLowerCase().trim().startsWith("--far")) {
- commandToCall = Cmd.SHOW_FAR;
- }
- if (arg.toLowerCase().trim().startsWith("--plat")) {
- commandToCall = Cmd.SHOW_PLATFORMS;
- }
- if ((arg.toLowerCase().contentEquals("-h")) || (arg.toLowerCase().contentEquals("-?"))
- || (arg.toLowerCase().startsWith("/h")) || (arg.toLowerCase().contentEquals("--help"))) {
- outputUsage();
- System.exit(EFAILURE);
- }
-
- }
- return ESUCCESS;
- }
-
- private int testFile(String Filename) {
- File tFile = new File(Filename);
- if (DEBUG > 4)
- System.out.println("File is located: " + tFile.getPath());
- if (tFile.exists())
- return FOUND;
- else
- return NOTFOUND;
- }
-
- private void setArgType(String argv) {
- if (argv.trim().toLowerCase().contains(".spd"))
- isPackage = true;
- if (argv.trim().toLowerCase().contains(".fpd"))
- isPlatform = true;
- if (argv.trim().toLowerCase().contains(".far"))
- isFar = true;
- }
-
- public String getArgType() {
- String argt = "UNKNOWN";
- if (isPackage)
- argt = "SPD";
- if (isFar)
- argt = "FAR";
- if (isPlatform)
- argt = "FPD";
- return argt;
- }
-
- private static void outputUsage() {
-
- System.out.println("DbTool, " + version);
- System.out.println(copyright);
- System.out.println("Usage:");
- System.out.println(" DbTool [-v] [-t] [-q] [-V] [--package] [--platform] [-h | -? | --help]");
- System.out.println(" where:");
- System.out.println(" -h | -? | --help OPTIONAL - This Help Text");
- System.out
- .println(" -t | --test OPTIONAL - Test the FrameworkDatabase Contents against the WORKSPACE");
- System.out
- .println(" -q OPTIONAL - Quiet mode - pass or fail only on return value, nothing is printed");
- System.out
- .println(" -f | --fix OPTIONAL - Automatically fix (non-interactive) the Database file to match the WORKSPACE.");
- System.out
- .println(" -v OPTIONAL - Verbose, print information messages. Adding more -v arguments increases verbosity.");
- System.out.println(" --package OPTIONAL - Show all Packages installed in the WORKSPACE.");
- System.out.println(" --platforms OPTIONAL - Show all Platforms installed in the WORKSPACE.");
- System.out.println(" -V OPTIONAL - Display Version information and exit.");
- //
- // TODO: Implement the following options.
- //
- /**
- System.out.println("");
- System.out.println(" =================== Options below this line have not been implemented in this release ===================");
- System.out
- .println(" -i OPTIONAL - Force interactive on commands that modify the WORKSPACE");
- System.out
- .println(" --far OPTIONAL - Show all Framework Archives installed in the WORKSPACE.");
- System.out
- .println(" --find [qualifier] value OPTIONAL - Search the WORKSPACE for value, with one and only one optional Qualifier.");
- System.out.println(" qualifiers: --guid Find a GUID by Guid C Name");
- System.out.println(" --prot Find a Protocol or ProtocolNotify by C Name");
- System.out.println(" --ppi Find a PPI or PpiNotify by C Name");
- System.out.println(" --pcd Find a PCD entry by C Name");
- System.out.println(" --lib Find information about a Library Class");
- System.out
- .println(" -c OPTIONAL - Print a comma separated value listing of TYPE,UiName,Filename");
- System.out
- .println(" -a, --add value OPTIONAL - Add a value (package, platform or far) to the database");
- System.out
- .println(" -r, --del value OPTIONAL - Remove a value (package, platform or far) from the database");
- System.out.println("");
- */
- }
-}
diff --git a/Tools/Java/Source/DbTools/src/org/tianocore/DbTools/DbTool.java b/Tools/Java/Source/DbTools/src/org/tianocore/DbTools/DbTool.java
deleted file mode 100644
index 5e502b710c..0000000000
--- a/Tools/Java/Source/DbTools/src/org/tianocore/DbTools/DbTool.java
+++ /dev/null
@@ -1,24 +0,0 @@
-// @file
-// DbUpdate wrapper
-//
-// 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.
-//
-
-package org.tianocore.DbTools;
-
-public class DbTool {
-
- public static void main(String[] args) {
- if (new DbCmds().DbUpdateCmdLine(args) != 0)
- System.exit(1);
- System.exit(0);
- }
-}
diff --git a/Tools/Java/Source/DbTools/src/org/tianocore/DbTools/UpdateDb.java b/Tools/Java/Source/DbTools/src/org/tianocore/DbTools/UpdateDb.java
deleted file mode 100644
index 6d3ef98fc9..0000000000
--- a/Tools/Java/Source/DbTools/src/org/tianocore/DbTools/UpdateDb.java
+++ /dev/null
@@ -1,594 +0,0 @@
-// @file
-// This Class processes multiple MSA files and merges them into a single,
-// merged MSA file. It will optionally add the merged MSA file into a package.
-//
-//
-// 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.
-//
-//
-
-package org.tianocore.DbTools;
-
-import java.io.*;
-import java.util.*;
-// import java.sql.Time;
-
-// import java.lang.*;
-// import java.lang.ExceptionInInitializerError;
-
-// import org.apache.xmlbeans.*;
-import org.apache.xmlbeans.XmlCursor;
-// import org.apache.xmlbeans.XmlObject;
-import org.apache.xmlbeans.XmlOptions;
-// import org.apache.xmlbeans.XmlException;
-import org.tianocore.*;
-
-// import org.tianocore.*;
-// FrameworkDatabase.db Schema Elements
-import org.tianocore.FrameworkDatabaseDocument.*;
-import org.tianocore.FdbHeaderDocument.*;
-import org.tianocore.PackageListDocument.*;
-import org.tianocore.PlatformListDocument.*;
-import org.tianocore.FarListDocument.*;
-
-// FAR Schema Elements
-// import org.tianocore.FrameworkArchiveManifestDocument.*;
-// import org.tianocore.FarHeaderDocument.*;
-// import org.tianocore.FarPackageDocument.*;
-// import org.tianocore.FarPlatformDocument.*;
-
-// FPD Schema Elements
-import org.tianocore.PlatformSurfaceAreaDocument.*;
-import org.tianocore.PlatformHeaderDocument.*;
-
-// import org.tianocore.FrameworkModulesDocument.*;
-// import org.tianocore.DynamicPcdBuildDefinitionsDocument.*;
-
-// SPD Schema Elements
-// import org.tianocore.PackageSurfaceAreaDocument.*;
-// import org.tianocore.SpdHeaderDocument.*;
-// import org.tianocore.LibraryClassDeclarationsDocument.*;
-// import org.tianocore.GuidDeclarationsDocument.*;
-// import org.tianocore.ProtocolDeclarationsDocument.*;
-// import org.tianocore.PpiDeclarationsDocument.*;
-// import org.tianocore.PcdDeclarationsDocument.*;
-
-// MSA Schema Elements
-// import org.tianocore.ModuleSurfaceAreaDocument.*;
-// import org.tianocore.MsaHeaderDocument.*;
-// import org.tianocore.LicenseDocument.*;
-// import org.tianocore.LibraryClassDefinitionsDocument.*;
-// import org.tianocore.PackageDependenciesDocument.*;
-// import org.tianocore.ProtocolsDocument.*;
-// import org.tianocore.PPIsDocument.*;
-// import org.tianocore.PcdCodedDocument.*;
-
-public class UpdateDb {
-
- private final int DEBUG = 0;
-
- private final int PASS = 0;
-
- private final int FAIL = 1;
-
- private int dCtr = 0;
-
- private int lCtr = 0;
-
- // Future implementations
- // private XmlCursor cursor = null;
-
- // FrameworkDatabase Component Elements
- // private FrameworkDatabaseDocument fdbDoc = null;
-
- // private FrameworkDatabase fdbInstance = null;
-
- // private FdbHeader fdbHeader = null;
-
- // private PackageList fdbPackageList = null;
-
- // private ArrayList<String> packageList = new ArrayList<String>();
-
- // private PlatformList fdbPlatformList = null;
-
- // private ArrayList<String> platformList = new ArrayList<String>();
-
- // private FarList fdbFarList = null;
-
- // private ArrayList<String> farList = new ArrayList<String>();
-
- private ArrayList<String> spdList = new ArrayList<String>();
-
- private ArrayList<String> fpdList = new ArrayList<String>();
-
- // Platform Components
- // private PlatformSurfaceAreaDocument fpdDoc = null;
-
- // private PlatformSurfaceArea fpd = null;
-
- // private PlatformHeader fpdHeader = null;
-
- private boolean wasModified = false;
-
- private int VERBOSE = 0;
-
- // The combineMsaFiles routine is the primary routine for creating a
- // Merged MSA file.
-
- public UpdateDb() {
- init();
- }
-
- private void init() {
-
- }
-
- public int getAllEntries(String dbFilename, int VERBOSE_FLAG) {
- System.out.println("Function not yet implemented!");
- return FAIL;
- }
-
- public int getCsvEntries(String dbFilename, int VERBOSE_FLAG) {
- System.out.println("Function not yet implemented!");
- return FAIL;
- }
-
- public int fixDatabase(String workspace, int VERBOSE_FLAG, boolean INTERACTIVE, boolean TEST, boolean QUIET) {
- int result = PASS;
- String dbFile = workspace + File.separator + "Tools" + File.separator + "Conf" + File.separator
- + "FrameworkDatabase.db";
- String dbBak = dbFile + ".bak";
-
- try {
- // Make a backup file for frameworkDatabase
- if (VERBOSE_FLAG > 3)
- System.out.println("Creating Backup file: " + dbBak);
- copyFile(dbFile, dbBak);
- } catch (IOException e) {
- System.out.println("Error: Cannot make backup file " + dbBak);
- return FAIL;
- }
-
- // Datebase update for SPD and FPD files
- result = fixDB(workspace, dbFile, VERBOSE_FLAG, INTERACTIVE, TEST, QUIET);
- if ((result == 0) && (TEST) && (QUIET == false))
- System.out.println("Workspace is consistent with current database!");
- return PASS;
- }
-
- public int addItem(String dbFilename, String item, int VERBOSE_FLAG, boolean INTERACTIVE) {
- System.out.println("Function not yet implemented!");
- return FAIL;
- }
-
- public int delItem(String workspace, String item, int VERBOSE_FLAG, boolean INTERACTIVE) {
- System.out.println("Function not yet implemented!");
- return FAIL;
- }
-
- public int findItem(String workspace, int VERBOSE_FLAG, String findWhat, String item) {
- System.out.println("Function not yet implemented!");
- return FAIL;
- }
-
- public int findFars(String workspace, int VERBOSE_FLAG) {
- System.out.println("Function not yet implemented!");
- return FAIL;
- }
-
- public int findSpds(String workspace, int VERBOSE_FLAG) {
- System.out.println("The following Package (SPD) files are in the workspace" + workspace);
- File wsDir = new File(workspace);
- findSPDFiles(wsDir, workspace, VERBOSE);
- for (int i = 0; i < spdList.size(); i++) {
- String Filename = workspace + File.separator + spdList.get(i).trim();
- File spdFilename = new File(Filename);
- try {
- FileReader fileReader = new FileReader(spdFilename);
- BufferedReader reader = new BufferedReader(fileReader);
- String PackageName = null;
- String rLine = null;
- while ((rLine = reader.readLine()) != null) {
- if (rLine.contains("<PackageName>")) {
- PackageName = rLine.replace("<PackageName>", "").trim();
- PackageName = PackageName.replace("</PackageName>", "").trim();
- System.out.printf(" %25s - %s\n",PackageName, spdList.get(i).trim());
- break;
- }
- }
- reader.close();
- } catch (IOException e) {
- System.out.println("ERROR Reading File: " + Filename + e);
- System.exit(FAIL);
- }
-
- }
- return PASS;
- }
-
- public int findFpds(String workspace, int VERBOSE_FLAG) {
- System.out.println("The following Platform (FPD) files are in the workspace: " + workspace);
- File wsDir = new File(workspace);
- findFPDFiles(wsDir, workspace, VERBOSE);
- for (int i = 0; i < fpdList.size(); i++) {
- String Filename = workspace + File.separator + fpdList.get(i).trim();
- File fpdFilename = new File(Filename);
- try {
- FileReader fileReader = new FileReader(fpdFilename);
- BufferedReader reader = new BufferedReader(fileReader);
- String PlatformName = null;
- String rLine = null;
- while ((rLine = reader.readLine()) != null) {
- if (rLine.contains("<PlatformName>")) {
- PlatformName = rLine.replace("<PlatformName>", "").trim();
- PlatformName = PlatformName.replace("</PlatformName>", "").trim();
- System.out.printf(" %25s - %s\n",PlatformName, fpdList.get(i).trim());
- break;
- }
- }
- reader.close();
- } catch (IOException e) {
- System.out.println("ERROR Reading File: " + Filename + e);
- System.exit(FAIL);
- }
- }
- return PASS;
- }
-
- // copy from source file to destination file
- private int copyFile(String src, String dst) throws IOException {
- try {
- File srcFile = new File(src);
- FileReader fileReader = new FileReader(srcFile);
- BufferedReader reader = new BufferedReader(fileReader);
-
- File dstFile = new File(dst);
- FileWriter fileWriter = new FileWriter(dstFile);
- BufferedWriter writer = new BufferedWriter(fileWriter);
-
- String line = null;
- while ((line = reader.readLine()) != null) {
- writer.write(line);
- writer.newLine();
- }
-
- reader.close();
- writer.close();
- } catch (IOException e) {
- System.out.println("I/O Exception during file copy: " + e);
- }
-
- return PASS;
- }
-
- private int fixDB(String workspace, String dbFile, int VERBOSE, boolean INTERACTIVE, boolean TEST, boolean QUIET) {
- File wsDir = new File(workspace);
- int retValue = PASS;
- // Find all .spd and .fpd files in workspace and put them in spdList and fpdList
- if (VERBOSE > 0)
- System.out.println("SPD File Search ");
- findSPDFiles(wsDir, workspace, VERBOSE);
- dCtr = 0;
- lCtr = 0;
- if (VERBOSE > 0) {
- System.out.println(" ");
- System.out.println("FPD File Search ");
- }
- findFPDFiles(wsDir, workspace, VERBOSE);
- if (VERBOSE > 0)
- System.out.println(" ");
-
- try {
- // check database file for possible update
- retValue = checkDBForUpdate(workspace, dbFile, VERBOSE, INTERACTIVE, TEST, QUIET);
- } catch (IOException e) {
- if (QUIET == false)
- System.out.println("Error: Updating " + dbFile + " file.");
- return FAIL;
- }
-
- if ((VERBOSE > 0) && (TEST) && (wasModified)) {
- System.out.println("FRAMEWORK Database does NOT match the contents of the WORKSPACE");
- retValue = FAIL;
- }
- if ((VERBOSE > 0) && (wasModified == false) && (QUIET == false))
- System.out.println("FRAMEWORK Database matches the contents of the WORKSPACE");
-
- return retValue;
- }
-
- private void findSPDFiles(File dir, String workspace, int VERBOSE) {
- String str;
-
- if (dir.isDirectory()) {
- dCtr++;
- String[] subdir = dir.list();
- if (dCtr >= 10) {
- if (VERBOSE > 2)
- System.out.print(".");
- dCtr = 0;
- lCtr++;
- }
- if (lCtr > 79) {
- if (VERBOSE > 2)
- System.out.println(" ");
- lCtr = 0;
- dCtr = 0;
- }
-
- for (int i = 0; i < subdir.length; i++) {
- findSPDFiles(new File(dir, subdir[i]), workspace, VERBOSE);
- }
- } else {
- if (dir.toString().toLowerCase().endsWith(".spd")) {
- str = dir.getPath().replace('\\', '/');
- workspace = workspace.replace('\\', '/');
- str = strStrip(str, workspace + "/");
- spdList.add(str.toString());
- if (VERBOSE == 2)
- System.out.println(" " + str);
- if (VERBOSE > 2)
- System.out.print("+");
- lCtr++;
- }
- }
-
- }
-
- private void findFPDFiles(File dir, String workspace, int VERBOSE) {
- String str;
-
- if (dir.isDirectory()) {
- String[] subdir = dir.list();
- if (dCtr >= 10) {
- if (VERBOSE > 2)
- System.out.print(".");
- dCtr = 0;
- lCtr++;
- }
- if (lCtr > 79) {
- if (VERBOSE > 2)
- System.out.println(" ");
- lCtr = 0;
- dCtr = 0;
- }
-
- for (int i = 0; i < subdir.length; i++) {
- findFPDFiles(new File(dir, subdir[i]), workspace, VERBOSE);
- }
- } else {
- if (dir.toString().toLowerCase().endsWith(".fpd")) {
- str = dir.getPath().replace('\\', '/');
- workspace = workspace.replace('\\', '/');
- str = strStrip(str, workspace + "/");
- fpdList.add(str.toString());
- if (VERBOSE == 2)
- System.out.println(" " + str);
- if (VERBOSE > 2)
- System.out.print("+");
- lCtr++;
- }
- }
- }
-
- private int checkDBForUpdate(String workspace, String dbFileName, int VERBOSE, boolean INTERACTIVE, boolean TEST, boolean QUIET)
- throws IOException {
- int SpdFlag = 0;
- int FpdFlag = 0;
- String SpdFile = null;
- String SpdFullFile = null;
- String FpdFile = null;
- String FpdFullFile = null;
-
- String tmpDbFile = dbFileName + ".tmp";
- String newSpd = null;
- String newFpd = null;
-
- FileReader fileReader = new FileReader(dbFileName);
- BufferedReader reader = new BufferedReader(fileReader);
-
- FileWriter fileWriter = new FileWriter(tmpDbFile);
- BufferedWriter writer = new BufferedWriter(fileWriter);
-
- String line = null;
- try {
- while ((line = reader.readLine()) != null) {
- if (line.indexOf("Added the following") >= 0) {
- wasModified = true;
- continue;
- }
- //
- // Process for .spd files
- //
- if (line.indexOf("<PackageList") >= 0) {
- SpdFlag = 1;
- } else {
- if (line.indexOf("</PackageList") >= 0) {
- SpdFlag = 2;
- }
- }
- if (SpdFlag == 1 && line.indexOf("Filename") >= 0) {
- SpdFile = strStrip(line, "<Filename>");
- SpdFile = strStrip(SpdFile, "</Filename>");
- SpdFile = SpdFile.trim();
- SpdFullFile = workspace + File.separator + SpdFile;
- if (!(new File(SpdFullFile)).exists()) {
- if (VERBOSE > 0)
- System.out.println("WARNING: Removing SPD file: " + SpdFile
- + "from the DB, as it does not exist!");
- wasModified = true;
- continue;
- }
- // Don't add files that are already in the database
- spdList.remove(SpdFile);
- }
- if (SpdFlag == 2) {
- int cflag = 0;
- for (int i = 0; i < spdList.size(); i++) {
- newSpd = spdList.get(i);
- newSpd = newSpd.trim();
- if (newSpd.length() > 0) {
- if (cflag == 0) {
- Calendar c = Calendar.getInstance();
- if (TEST == false)
- writer.write(" <!-- Adding the following SPD files " + c.getTime() + " -->\n");
- }
- if (VERBOSE > 0)
- System.out.println(" Adding SPD file: " + newSpd);
- if (TEST == false)
- writer.write(" <Filename>" + newSpd + "</Filename>\n");
- cflag++;
- wasModified = true;
- }
- }
- SpdFlag++;
- }
- //
- // Process for .fpd files
- //
- if (line.indexOf("<PlatformList") >= 0) {
- FpdFlag = 1;
- } else {
- if (line.indexOf("</PlatformList") >= 0) {
- FpdFlag = 2;
- }
- }
- if (FpdFlag == 1 && line.indexOf("Filename") >= 0) {
- FpdFile = strStrip(line, "<Filename>");
- FpdFile = strStrip(FpdFile, "</Filename>");
- FpdFile = FpdFile.trim();
- FpdFullFile = workspace + File.separator + FpdFile;
- if (!(new File(FpdFullFile)).exists()) {
- if (VERBOSE > 0)
- System.out.println("WARNING: Removing FPD file: " + FpdFile
- + " from the DB, as it does not exist!");
- wasModified = true;
- continue;
- }
- // Don't add files that are already in the database
- fpdList.remove(FpdFile);
- }
- if (FpdFlag == 2) {
- int cflag = 0;
- for (int i = 0; i < fpdList.size(); i++) {
- newFpd = fpdList.get(i);
- newFpd = newFpd.trim();
- if (newFpd.length() > 0) {
- if (cflag == 0) {
- Calendar c = Calendar.getInstance();
- if (TEST == false)
- writer.write(" <!-- Adding the following FPD files " + c.getTime() + " -->\n");
- }
- if (VERBOSE > 0)
- System.out.println(" Adding FPD file: " + newFpd);
- if (TEST == false)
- writer.write(" <Filename>" + newFpd + "</Filename>\n");
- cflag++;
- wasModified = true;
- }
- }
- FpdFlag++;
- }
-
- if (DEBUG > 2) {
- System.out.println(line);
- }
- if (TEST == false) {
- writer.write(line);
- writer.newLine();
- }
- }
- reader.close();
- writer.close();
-
- } catch (IOException e) {
- System.out.println("ERROR I/O Exception occured! " + e);
- System.exit(FAIL);
- }
-
- if (wasModified) {
- if ((VERBOSE > 0) && (QUIET == false))
- System.out.println("FrameworkDatabase has been UPDATED for this Workspace!\n");
- if (TEST == false)
- copyFile(tmpDbFile, dbFileName);
- } else {
- if ((VERBOSE > 0) && (QUIET == false))
- System.out.println("FrameworkDatabase correct for this Workspace!\n");
- }
-
- if (TEST == false) {
- File tmpFile = new File(tmpDbFile);
- if (tmpFile.exists()) {
- tmpFile.delete();
- }
- }
-
- return PASS;
- }
-
- static String strStrip(String str, String pattern) {
- int ps = 0;
- int pe = 0;
- StringBuffer result = new StringBuffer();
-
- while ((pe = str.indexOf(pattern, ps)) >= 0) {
- result.append(str.substring(ps, pe));
- ps = pe + pattern.length();
- }
- result.append(str.substring(ps));
- return result.toString();
- }
-
- private String checkDuplicateStrings(String aString, ArrayList<String> aList) {
- // This routine checks a string against an array.
- // If the string is found, it will return an empty string.
- // If the string is not found, it adds the string to the array, and
- // returns the string to the caller.
- for (int lctr = 0; lctr < aList.size(); lctr++) {
- if (DEBUG > 8)
- System.out.println("Comparing: \n" + aString.replace(" ", "").replace("\n", "") + "\nTo: \n"
- + aList.get(lctr).replace(" ", "").replace("\n", "").toString().trim());
- if (aString.replace(" ", "").replace("\n", "").contains(
- aList.get(lctr).replace(" ", "").replace("\n", "")
- .toString().trim())) {
- if ((DEBUG > 3) || (VERBOSE > 3))
- System.out.println("Found a duplicate String, skipping!");
- return "";
- }
- }
- if ((DEBUG > 3) || (VERBOSE > 3))
- System.out.println("Returning UNIQUE String!\n " + aString);
- aList.add(aString);
- return aString;
- }
-
- private static class XmlConfig {
- public static XmlCursor setupXmlCursor(XmlCursor cursor) {
- String uri = "http://www.TianoCore.org/2006/Edk2.0";
- cursor.push();
- cursor.toNextToken();
- cursor.insertNamespace("", uri);
- cursor.insertNamespace("xsi", "http://www.w3.org/2001/XMLSchema-instance");
- cursor.pop();
- return cursor;
-
- }
-
- public static XmlOptions setupXmlOptions() {
- XmlOptions options = new XmlOptions();
- options.setCharacterEncoding("UTF-8");
- options.setSavePrettyPrint();
- options.setSavePrettyPrintIndent(2);
- return options;
- }
-
- }
-}