diff options
Diffstat (limited to 'Tools/Java/Source/GenBuild/org/tianocore/build/toolchain')
6 files changed, 0 insertions, 1248 deletions
diff --git a/Tools/Java/Source/GenBuild/org/tianocore/build/toolchain/ConfigReader.java b/Tools/Java/Source/GenBuild/org/tianocore/build/toolchain/ConfigReader.java deleted file mode 100644 index 4275f8eb78..0000000000 --- a/Tools/Java/Source/GenBuild/org/tianocore/build/toolchain/ConfigReader.java +++ /dev/null @@ -1,114 +0,0 @@ -/** @file
- ConfigReader class.
-
- ConfigReader is used to read tool chain config file with flat format.
-
-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.build.toolchain;
-
-import org.apache.tools.ant.Project;
-
-import org.tianocore.build.exception.GenBuildException;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileReader;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
-
- ConfigReader is used to read tool chain config file with flat format. Comments
- is line starting with character '#'.
-
- @since GenBuild 1.0
-**/
-public class ConfigReader {
-
- /**
- Parse specified tool chain definition file.
-
- @param filename The config file name with full path
-
- @return String[][] The definition array
- **/
- public static synchronized String[][] parse(Project prj, String filename) throws GenBuildException {
- return parse(prj, new File(filename));
- }
-
- /**
- Get all definitions in config file. the config file format is flat
- with "A=B". If line started with '#' looks as comments.
-
- @param configFile The config file
-
- @return String[][] The variables defined in the config file
-
- @throws GenBuildException
- Config file's format is not valid
- **/
- public static synchronized String[][] parse(Project prj, File configFile) throws GenBuildException {
- List<String> keyList = new ArrayList<String>(256);
- List<String> valueList = new ArrayList<String>(256);
- int lines = 0;
-
- try {
- FileReader reader = new FileReader(configFile);
- BufferedReader in = new BufferedReader(reader);
- String str;
-
- while ((str = in.readLine()) != null) {
- ++lines;
- str = str.trim();
- //
- // skip empty line, comment (start with '#')
- //
- if (str.length() == 0 || str.startsWith("#")) {
- continue;
- }
-
- //
- // stop if the definition line is not in "name=value" form
- //
- int index;
- if ((index = str.indexOf('=')) <= 0) {
- throw new GenBuildException("ERROR Processing file ["
- + configFile.getAbsolutePath()
- + "] (line " + lines + ").\n");
- }
-
- //
- // look as line "A = B"
- //
- keyList.add(str.substring(0, index).trim());
- if (prj != null) {
- valueList.add(prj.replaceProperties(str.substring(index + 1).trim()));
- } else {
- valueList.add(str.substring(index + 1).trim());
- }
- }
- } catch (Exception ex) {
- GenBuildException e = new GenBuildException("ERROR Processing file ["
- + configFile.getAbsolutePath()
- + "] (line " + lines + ").\n" + ex.getMessage());
- e.setStackTrace(ex.getStackTrace());
- throw e;
- }
-
- String[][] definitions = new String[2][keyList.size()];
- definitions[0] = (String[])keyList.toArray(definitions[0]);
- definitions[1] = (String[])valueList.toArray(definitions[1]);
-
- return definitions;
- }
-}
-
-
diff --git a/Tools/Java/Source/GenBuild/org/tianocore/build/toolchain/ToolChainConfig.java b/Tools/Java/Source/GenBuild/org/tianocore/build/toolchain/ToolChainConfig.java deleted file mode 100644 index 9989ab65f8..0000000000 --- a/Tools/Java/Source/GenBuild/org/tianocore/build/toolchain/ToolChainConfig.java +++ /dev/null @@ -1,127 +0,0 @@ -/** @file
- ToolChainConfig class.
-
- ToolChainConfig class parse all config files and get tool chain information.
-
-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.build.toolchain;
-
-import java.io.File;
-import java.util.Iterator;
-import java.util.Set;
-
-import org.apache.tools.ant.Project;
-import org.tianocore.build.exception.GenBuildException;
-import org.tianocore.build.toolchain.ToolChainKey;
-import org.tianocore.build.toolchain.ToolChainMap;
-
-
-/**
-
- ToolChainConfig class parse all config files and get tool chain information.
-
- **/
-public class ToolChainConfig {
- //
- // tool chain definitions
- //
- private ToolChainMap config = null;
- //
- // tool chain information (how many targets, archs, etc.)
- //
- private ToolChainInfo info = new ToolChainInfo();
-
- /**
- Public construct method.
-
- @param toolChainFile File object representing the tool chain configuration file
- **/
- public ToolChainConfig (Project prj, File toolChainFile) throws GenBuildException {
- config = getToolChainConfig(prj, toolChainFile);
- parseToolChainDefKey(config.keySet());
- }
-
- /**
- Read tool chain definitions from specified file and put them in
- ToolChainMap class.
-
- @param ConfigFile The file containing tool chain definitions
-
- @return ToolChainMap
- **/
- private ToolChainMap getToolChainConfig(Project prj, File ConfigFile) throws GenBuildException {
- ToolChainMap map = new ToolChainMap();
- String[][] toolChainDef = ConfigReader.parse(prj, ConfigFile);
-
- for (int i = 0; i < toolChainDef[0].length; ++i) {
- map.put(toolChainDef[0][i], toolChainDef[1][i]);
- }
-
- return map;
- }
-
- /**
- Collect target, tool chain tag, arch and command information from key part
- of configuration
-
- @param toolChainDefKey The set of keys in tool chain configuration
- **/
- private void parseToolChainDefKey (Set<ToolChainKey> toolChainDefKey) {
- Iterator it = toolChainDefKey.iterator();
- while (it.hasNext()) {
- ToolChainKey key = (ToolChainKey)it.next();
- String[] keySet = key.getKeySet();
- info.addTargets(keySet[ToolChainElement.TARGET.value]);
- info.addTagnames(keySet[ToolChainElement.TOOLCHAIN.value]);
- info.addArchs(keySet[ToolChainElement.ARCH.value]);
- info.addCommands(keySet[ToolChainElement.TOOLCODE.value]);
- info.normalize();
- }
- }
-
- /**
- Return the tool chain configuration information in a Map form
-
- @return ToolChainMap Tool chain configurations in a ToolChainMap
- **/
- public ToolChainMap getConfig() {
- return config;
- }
-
- /**
- Return the tool chain's target, arch, tag and commands information
-
- @return ToolChainInfo Tool chain information summary
- **/
- public ToolChainInfo getConfigInfo() {
- return info;
- }
-
- /**
- override toString()
-
- @return String The converted configuration string in name=value form
- **/
- public String toString() {
- StringBuffer ts = new StringBuffer(10240);
-
- Iterator it = config.keySet().iterator();
- while (it.hasNext()) {
- ToolChainKey key = (ToolChainKey)it.next();
- ts.append(key.toString() + " = ");
- ts.append(config.get(key) + "\n");
- }
-
- return ts.toString();
- }
-}
-
diff --git a/Tools/Java/Source/GenBuild/org/tianocore/build/toolchain/ToolChainElement.java b/Tools/Java/Source/GenBuild/org/tianocore/build/toolchain/ToolChainElement.java deleted file mode 100644 index 103b3a6362..0000000000 --- a/Tools/Java/Source/GenBuild/org/tianocore/build/toolchain/ToolChainElement.java +++ /dev/null @@ -1,54 +0,0 @@ -/** @file
-ToolChainElement class
-
-ToolChainElement class is defining enumeration value of key part names.
-
-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.build.toolchain;
-
-/**
-
- This class is an enumeration definition for key elements in tool chain definition
- file.
-
- **/
-public class ToolChainElement {
- private static int nextValue = 0;
-
- //
- // "TARGET", "TOOLCHAIN", "ARCH", "TOOLCODE", "ATTRIBUTE"
- //
- public final static ToolChainElement TARGET = new ToolChainElement("TARGET");
- public final static ToolChainElement TOOLCHAIN = new ToolChainElement("TOOLCHAIN");
- public final static ToolChainElement ARCH = new ToolChainElement("ARCH");
- public final static ToolChainElement TOOLCODE = new ToolChainElement("TOOLCODE");
- public final static ToolChainElement ATTRIBUTE = new ToolChainElement("ATTRIBUTE");
-
- private final String name;
- public final int value = nextValue++;
-
- /**
- * Default constructor
- */
- private ToolChainElement(String name) {
- this.name = name;
- }
-
- public String toString() {
- return name;
- }
-}
-
-
-
-
-
diff --git a/Tools/Java/Source/GenBuild/org/tianocore/build/toolchain/ToolChainInfo.java b/Tools/Java/Source/GenBuild/org/tianocore/build/toolchain/ToolChainInfo.java deleted file mode 100644 index 9952c0beda..0000000000 --- a/Tools/Java/Source/GenBuild/org/tianocore/build/toolchain/ToolChainInfo.java +++ /dev/null @@ -1,347 +0,0 @@ -/** @file
-ToolChainInfo class
-
-This file is to define ToolChainInfo class.
-
-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.build.toolchain;
-
-import java.util.LinkedHashSet;
-import java.util.Set;
-
-/**
- ToolChainInfo collects valid build targets, tool chain tag, ARCHs and commands
- information for real build use.
- **/
-public class ToolChainInfo {
- //
- // build target set
- //
- private Set<String> targets = new LinkedHashSet<String>();
- //
- // tool chain tag name set
- //
- private Set<String> tagnames = new LinkedHashSet<String>();
- //
- // build archs set
- //
- private Set<String> archs = new LinkedHashSet<String>();
- //
- // build commands set
- //
- private Set<String> commands = new LinkedHashSet<String>();
-
- /**
- Add a list of targets in the form of string separated by space
-
- @param targetList target list string
- **/
- public void addTargets(String targetList) {
- //
- // targetList some targets separated by space " "
- //
- if (targetList == null || targetList.length() == 0) {
- targets.add("*");
- } else {
- addTargets(targetList.split(" "));
- }
- }
-
- /**
- Add a list of targets in the form of string array
-
- @param targetArray target string array
- **/
- public void addTargets(String[] targetArray) {
- if (targetArray != null ) {
- for (int i = 0; i < targetArray.length; i++) {
- targets.add(targetArray[i]);
- }
- }
- }
-
- /**
- Add a list of target in the form of set
-
- @param targetSet target string set
- **/
- public void addTargets(Set<String> targetSet) {
- if (targetSet != null) {
- targets.addAll(targetSet);
- }
- }
-
- /**
- Add a list of tool chain tag name in the form of string separated by space
-
- @param tagnameList Tool chain tag name list string
- **/
- public void addTagnames(String tagnameList) {
- //
- // tagnameList some tagnames separated by space " "
- //
- if (tagnameList == null || tagnameList.length() == 0) {
- tagnames.add("*");
- } else {
- addTagnames(tagnameList.split(" "));
- }
- }
-
- /**
- Add a list of tool chain tag name in the form of string array
-
- @param tagnameArray Tool chain tag names array
- **/
- public void addTagnames(String[] tagnameArray) {
- if (tagnameArray != null ) {
- for (int i = 0; i < tagnameArray.length; i++) {
- tagnames.add(tagnameArray[i]);
- }
- }
- }
-
- /**
- Add a list of tool chain tag name in the form of Set
-
- @param tagnameSet Tool chain tag names set
- **/
- public void addTagnames(Set<String> tagnameSet) {
- if (tagnameSet != null) {
- tagnames.addAll(tagnameSet);
- }
- }
-
- /**
- Add a list of ARCH in the form of string
-
- @param archList ARCH string
- **/
- public void addArchs(String archList) {
- //
- // archList some archs separated by space " "
- //
- if (archList == null || archList.length() == 0) {
- archs.add("*");
- } else {
- addArchs(archList.split(" "));
- }
- }
-
- /**
- Add a list of ARCH in the form of string array
-
- @param archArray ARCH array
- **/
- public void addArchs(String[] archArray) {
- if (archArray != null ) {
- for (int i = 0; i < archArray.length; i++) {
- archs.add(archArray[i]);
- }
- }
- }
-
- /**
- Add a list of ARCH in the form of set
-
- @param archSet ARCH set
- **/
- public void addArchs(Set<String> archSet) {
- if (archSet != null) {
- archs.addAll(archSet);
- }
- }
-
- /**
- Add a list of command in the form of string
-
- @param commandList Command list string
- **/
- public void addCommands(String commandList) {
- //
- // archList some archs separated by space " "
- //
- if (commandList == null || commandList.length() == 0) {
- commands.add("*");
- } else {
- addCommands(commandList.split(" "));
- }
- }
-
- /**
- Add a list of ARCH in the form of array
-
- @param commandArray Commands array
- **/
- public void addCommands(String[] commandArray) {
- if (commandArray != null ) {
- for (int i = 0; i < commandArray.length; i++) {
- commands.add(commandArray[i]);
- }
- }
- }
-
- /**
- Add a list of ARCH in the form of set
-
- @param commandSet Commands set
- **/
- public void addCommands(Set<String> commandSet) {
- if (commandSet != null) {
- commands.addAll(commandSet);
- }
- }
-
- /**
- Make a union operation on this ToolChainInfo and the given one.
-
- @param info Another ToolChainInfo object to merge with
-
- @return ToolChainInfo Merged ToolChainInfo object
- **/
- public ToolChainInfo union(ToolChainInfo info) {
- ToolChainInfo result = new ToolChainInfo();
- result.addTargets(union(this.targets, info.targets));
- result.addTagnames(union(this.tagnames, info.tagnames));
- result.addArchs(union(this.archs, info.archs));
- return result;
- }
-
- /**
- Make a intersection operation on this ToolChainInfo and the given one
-
- @param info Another ToolChainInfo object to intersect with
-
- @return ToolChainInfo Intersected ToolChainInfo object
- **/
- public ToolChainInfo intersection(ToolChainInfo info) {
- ToolChainInfo result = new ToolChainInfo();
- result.addTargets(intersection(this.targets, info.targets));
- result.addTagnames(intersection(this.tagnames, info.tagnames));
- result.addArchs(intersection(this.archs, info.archs));
- return result;
- }
-
- /**
- Make a union operation on two Sets
-
- @param set1 One Set
- @param set2 Another Set
-
- @return Set<String> Merged Set object
- **/
- private Set<String> union(Set<String> set1, Set<String> set2) {
- Set<String> result = new LinkedHashSet<String>();
- result.addAll(set1);
- result.addAll(set2);
- result.remove("*");
- return result;
- }
-
- /**
- Make a intersection operation on two Sets with the consideration of wildcard.
-
- @param set1 One Set
- @param set2 Another Set
-
- @return Set<String> The intersected Set object
- **/
- private Set<String> intersection(Set<String> set1, Set<String> set2) {
- Set<String> result = new LinkedHashSet<String>();
- boolean set1HasWildcard = set1.contains("*");
- boolean set2HasWildcard = set2.contains("*");
-
- if (set1HasWildcard && set2HasWildcard) {
- //
- // Both Sets have wildcard, the result will have all elements in them
- //
- result.addAll(set1);
- result.addAll(set2);
- } else if (set1HasWildcard) {
- //
- // Only set1 has wildcard, then result will have only set2 elements.
- //
- result.addAll(set2);
- } else if (set2HasWildcard) {
- //
- // Only set2 has wildcard, then result will have only set1 elements.
- //
- result.addAll(set1);
- } else {
- //
- // No wildcard in both Sets, the result will have the elements in both Sets.
- //
- result.addAll(set1);
- result.retainAll(set2);
- }
-
- return result;
- }
-
- /**
- Get target array.
-
- @return String[]
- **/
- public String[] getTargets() {
- return (String[])targets.toArray(new String[targets.size()]);
- }
-
- /**
- Get tool chain tag name array.
-
- @return String[]
- **/
- public String[] getTagnames() {
- return (String[])tagnames.toArray(new String[tagnames.size()]);
- }
-
- /**
- Get ARCH array.
-
- @return String[]
- **/
- public String[] getArchs() {
- return (String[])archs.toArray(new String[archs.size()]);
- }
-
- /**
- Get command name array.
-
- @return String[]
- **/
- public String[] getCommands() {
- return (String[])commands.toArray(new String[commands.size()]);
- }
-
- /**
- Override the Object's toString().
-
- @return String
- **/
- public String toString() {
- return " TARGET :" + targets + "\n" +
- " TAGNAME:" + tagnames + "\n" +
- " ARCH :" + archs + "\n" +
- " COMMAND:" + commands;
- }
-
- /**
- Remove the wildcard element in the tool chain information because they
- are useless when retrieved.
- **/
- public void normalize() {
- targets.remove("*");
- tagnames.remove("*");
- archs.remove("*");
- commands.remove("*");
- }
-}
diff --git a/Tools/Java/Source/GenBuild/org/tianocore/build/toolchain/ToolChainKey.java b/Tools/Java/Source/GenBuild/org/tianocore/build/toolchain/ToolChainKey.java deleted file mode 100644 index 1bedf3c685..0000000000 --- a/Tools/Java/Source/GenBuild/org/tianocore/build/toolchain/ToolChainKey.java +++ /dev/null @@ -1,278 +0,0 @@ -/** @file
-ToolChainKey class
-
-ToolChainKey class is representing the "name" part of tool chain definition.
-
-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.build.toolchain;
-
-import org.tianocore.build.exception.GenBuildException;
-
-/**
- ToolChainKey class is the java class form of the "name" of tool chain definition.
- It's primarily for the key of a Map data structure.
- **/
-public class ToolChainKey implements java.io.Serializable, Comparable<ToolChainKey> {
- static final long serialVersionUID = -8034897190740066933L;
-
- ///
- /// The part number of key. Currently we only support fixed five parts.
- ///
- public final static int keyLength = 5;
-
- //
- // Default delimiter which is used for concatenating the parts of key
- //
- private String delimiter = "_";
-
- //
- // Key value in string array form
- //
- private String[] keySet = null;
-
- //
- // Key value in one string form
- //
- private String keyString = null;
-
- //
- // Key hash value used for hash table
- //
- private int hashValue = 0;
-
- /**
- Public constructor which can override default delimiter.
-
- @param keyString The key string value
- @param delimiter Delimiter charater concatenating the key parts
- **/
- public ToolChainKey(String keyString, String delimiter) throws GenBuildException {
- setKey(keyString, delimiter);
- }
-
- /**
- Public constructor which uses default delimiter.
-
- @param keyString The key string value
- **/
- public ToolChainKey(String keyString) throws GenBuildException {
- setKey(keyString);
- }
-
- /**
- Public constructor which doesn't use any delimiter.
-
- @param keySet
- **/
- public ToolChainKey(String[] keySet) throws GenBuildException {
- setKey(keySet);
- }
-
- /**
- Calculate hash value of the key string (without the delimiter). It's used
- for Hash Table kind of Map.
-
- @return int The hash value
- **/
- public int hashCode() {
- if (hashValue != 0) {
- return hashValue;
- }
-
- for (int i = 0; i < keySet.length; ++i) {
- char[] keyStringValue = new char[keySet[i].length()];
- this.keySet[i].getChars(0, keyStringValue.length, keyStringValue, 0);
-
- for (int j = 0; j < keyStringValue.length; ++j) {
- hashValue = keyStringValue[j] + hashValue * 31;
- }
- }
-
- return hashValue;
- }
-
- /**
- Compare the string value of two keys . It's used for Tree kind of Map.
-
- @param dstKey Another key to compare to.
-
- @retval 0 Two keys are equal
- @retval >0 This key is after the given key
- @retval <0 This key is before the given key
- **/
- public int compareTo(ToolChainKey dstKey) {
- String[] dstKeySet = dstKey.getKeySet();
- int result = 0;
- for (int i = 0; i < ToolChainKey.keyLength; ++i) {
- result = this.keySet[i].compareToIgnoreCase(dstKeySet[i]);
- if (result != 0) {
- break;
- }
- }
-
- return result;
- }
-
- /**
- Check if this key is the same as the given key.
-
- @param o Another key to compare to
-
- @return boolean
- **/
- public boolean equals(Object o) {
- ToolChainKey dstKey = (ToolChainKey)o;
- String[] dstKeySet = dstKey.getKeySet();
-
- if (this == dstKey) {
- return true;
- }
-
- if (dstKeySet.length != ToolChainKey.keyLength) {
- return false;
- }
-
- for (int i = 0; i < ToolChainKey.keyLength; ++i) {
- if (!this.keySet[i].equalsIgnoreCase(dstKeySet[i])) {
- return false;
- }
- }
-
- return true;
- }
-
- /**
- Set the key value in form of string array.
-
- @param keySet The string array of key value
- **/
- public void setKey(String[] keySet) throws GenBuildException {
- if (keySet.length != ToolChainKey.keyLength) {
- throw new GenBuildException("Invalid ToolChain key");
- }
-
- //
- // Clone the string array because we don't want to change original one
- //
- this.keySet = new String[ToolChainKey.keyLength];
- System.arraycopy(keySet, 0, this.keySet, 0, ToolChainKey.keyLength);
- for (int i = 0; i < ToolChainKey.keyLength; ++i) {
- if (this.keySet[i] == null || this.keySet[i].length() == 0) {
- this.keySet[i] = "*";
- }
- }
-
- //
- // We need to re-generate the single key string and hash value.
- //
- this.keyString = null;
- this.hashValue = 0;
- }
-
- /**
- Set key value at the specified key part .
-
- @param keySetString The new value of "index" part of key
- @param index The key part index
- **/
- public void setKey(String keySetString, int index) throws GenBuildException {
- if (index >= ToolChainKey.keyLength) {
- throw new GenBuildException("Invalid ToolChain key index");
- }
-
- //
- // Allow wildcard in key string
- //
- if (keySetString == null || keySetString.length() == 0) {
- keySetString = "*";
- }
- this.keySet[index] = keySetString;
-
- //
- // We need to re-generate the single key string and hash value.
- //
- this.keyString = null;
- this.hashValue = 0;
- }
-
- /**
- Set key value in the form of single string.
-
- @param keyString The key value string
- **/
- public void setKey(String keyString) throws GenBuildException {
- this.keySet = keyString.split(this.delimiter);
-
- if (this.keySet.length != ToolChainKey.keyLength) {
- throw new GenBuildException("Invalid ToolChain key");
- }
-
- this.keyString = keyString;
- //
- // We need to re-generate hash value.
- //
- this.hashValue = 0;
- }
-
- /**
- Set key value in the form of single string with specified delimiter.
-
- @param keyString The key value string
- @param delimiter The delimiter concatenating the key string
- **/
- public void setKey(String keyString, String delimiter) throws GenBuildException {
- this.keySet = keyString.split(delimiter);
-
- if (this.keySet.length != ToolChainKey.keyLength) {
- throw new GenBuildException("Invalid ToolChain key");
- }
-
- this.keyString = keyString;
- this.delimiter = delimiter;
- //
- // We need to re-generate hash value.
- //
- this.hashValue = 0;
- }
-
- /**
- Return the string array form of key
-
- @return String[]
- **/
- public String[] getKeySet() {
- return keySet;
- }
-
- /**
- Return the single string form of key.
-
- @return String
- **/
- public String toString() {
- if (this.keyString == null) {
- StringBuffer keyStringBuf = new StringBuffer(64);
-
- keyStringBuf.append(this.keySet[0]);
- for (int i = 1; i < ToolChainKey.keyLength; ++i) {
- keyStringBuf.append(this.delimiter);
- keyStringBuf.append(this.keySet[i]);
- }
-
- this.keyString = keyStringBuf.toString();
- }
-
- return this.keyString;
- }
-}
-
diff --git a/Tools/Java/Source/GenBuild/org/tianocore/build/toolchain/ToolChainMap.java b/Tools/Java/Source/GenBuild/org/tianocore/build/toolchain/ToolChainMap.java deleted file mode 100644 index 18e664ccf8..0000000000 --- a/Tools/Java/Source/GenBuild/org/tianocore/build/toolchain/ToolChainMap.java +++ /dev/null @@ -1,328 +0,0 @@ -/** @file
-ToolChainMap class
-
-ToolChainMap class is used for storing tool chain configurations.
-
-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.build.toolchain;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Set;
-
-/**
- ToolChainMap is a wrapper class for a generic Map class which uses ToolChainKey
- class as its key. It's used to store and retrieve tool chain configuration
- information.
- **/
-public class ToolChainMap {
- //
- // From which part of key can be used to match "*"
- //
- private int matchLevel = ToolChainKey.keyLength - 1;
-
- //
- // A Map object in which tool chain configuration information will be stored
- //
- private Map<ToolChainKey, String> map = null;
-
- /**
- Public constructor. It just initializes the private Map object.
- **/
- public ToolChainMap() {
- this.map = new HashMap<ToolChainKey, String>();
- }
-
- /**
- Wrapper function for Map.put(). It's used when default delimiter of
- ToolChainKey is not wanted and will be overrided by "delimiter" parameter.
-
- @param key Key string which is concatenated with "delimiter"
- @param delimiter The delimiter string in the key string
- @param value Value string associated with the "key"
-
- @retval String The "value" string if the "key" is valid.
- @retval null if the "key" is invalid
- **/
- public String put(String key, String delimiter, String value) {
- ToolChainKey toolChainKey;
-
- try {
- toolChainKey = new ToolChainKey(key, delimiter);
- } catch (Exception e) {
- return null;
- }
- return (String)map.put(toolChainKey, value);
- }
-
- /**
- Wrapper function for Map.put().
-
- @param key Key string which is concatenated with default "delimiter"
- @param value Value string associated with the "key"
-
- @retval String The "value" string if the "key" is valid.
- @retval null if the "key" is invalid
- **/
- public String put(String key, String value) {
- ToolChainKey toolChainKey;
-
- try {
- toolChainKey = new ToolChainKey(key);
- } catch (Exception e) {
- return null;
- }
- return (String)map.put(toolChainKey, value);
- }
-
- /**
- Wrapper function for Map.put(). The key is given in the form of string
- array.
-
- @param key Key string array
- @param value Value string associated with the "key"
-
- @retval String The "value" string if the "key" is valid.
- @retval null if the "key" is invalid
- **/
- public String put(String[] key, String value) {
- ToolChainKey toolChainKey;
-
- try {
- toolChainKey = new ToolChainKey(key);
- } catch (Exception e) {
- return null;
- }
- return (String)map.put(toolChainKey, value);
- }
-
- /**
- Wrapper function for Map.put(). The key is given in ToolChainKey class.
-
- @param key ToolChainKey class
- @param value Value string associated with the "key"
-
- @retval String The "value" string if the "key" is valid.
- @retval null if the "key" is invalid
- **/
- public String put(ToolChainKey key, String value) {
- return (String)map.put(key, value);
- }
-
- /**
- Wrapper function for Map.get().
-
- @param key Key string which is concatenated with default "delimiter"
-
- @return String
- **/
- public String get(String key) {
- ToolChainKey toolChainKey;
-
- try {
- toolChainKey = new ToolChainKey(key);
- } catch (Exception e) {
- return null;
- }
- return get(toolChainKey);
- }
-
- /**
- Wrapper function for Map.get(). It's used when default delimiter of
- ToolChainKey is not wanted and will be overrided by "delimiter" parameter.
-
- @param key Key string which is concatenated with "delimiter"
- @param delimiter The delimiter string in the key string
-
- @return String
- **/
- public String get(String key, String delimiter) {
- ToolChainKey toolChainKey;
-
- try {
- toolChainKey = new ToolChainKey(key, delimiter);
- } catch (Exception e) {
- return null;
- }
- return get(toolChainKey);
- }
-
- /**
- Wrapper function for Map.get(). The key is given in the form of string
- array.
-
- @param key Key string array
-
- @return String
- **/
- public String get(String[] key) {
- ToolChainKey toolChainKey;
-
- try {
- toolChainKey = new ToolChainKey(key);
- } catch (Exception e) {
- return null;
- }
- return get(toolChainKey);
- }
-
- /**
- Wrapper function for Map.get(). The key is given in ToolChainKey class.
- All other form of get() method will eventually call this form of get. It
- will do real job of finding the value associated with the given key. Most
- of the job is to try to match the key with "wildcard".
-
- @param key ToolChainKey class
-
- @return String The value associated with the key
- **/
- public String get(ToolChainKey key) {
- ///
- /// First, we'll try to get the value through the exact given key
- ///
- String result = map.get(key);
- if (result != null || map.containsKey(key)) {
- return result;
- }
-
- ///
- /// If nothing is found, then, we'll try all possible keys combined with
- /// wildcard "*". In order not to change the original key value, we have
- /// to clone one for later use.
- ///
- String[] keySet = key.getKeySet();
- ToolChainKey tmpKey;
- try {
- tmpKey = new ToolChainKey(keySet);
- } catch (Exception e) {
- return null;
- }
-
- ///
- /// In the current tool chain definition format (in name/value pair),
- /// there're five parts in the "name". The last part of the "name" must
- /// not be "wildcard". We should start combining "*" from left to right.
- /// We'll try all the possible combinations until the value can be fetched.
- ///
- /// The following code implements the logic which will try to use, for example,
- /// following key parts combinations sequentially to get the value.
- ///
- /// TARGET_TOOLCHAIN_ARCH_TOOLCODE_ATTRIBUTE
- /// ******_TOOLCHAIN_ARCH_TOOLCODE_ATTRIBUTE
- /// TARGET_*********_ARCH_TOOLCODE_ATTRIBUTE
- /// ******_*********_ARCH_TOOLCODE_ATTRIBUTE
- /// TARGET_TOOLCHAIN_****_TOOLCODE_ATTRIBUTE
- /// ******_TOOLCHAIN_****_TOOLCODE_ATTRIBUTE
- /// TARGET_*********_****_TOOLCODE_ATTRIBUTE
- /// ******_*********_****_TOOLCODE_ATTRIBUTE
- /// TARGET_TOOLCHAIN_ARCH_********_ATTRIBUTE
- /// ******_TOOLCHAIN_ARCH_********_ATTRIBUTE
- /// TARGET_*********_ARCH_********_ATTRIBUTE
- /// ******_*********_ARCH_********_ATTRIBUTE
- /// TARGET_TOOLCHAIN_****_********_ATTRIBUTE
- /// ******_TOOLCHAIN_****_********_ATTRIBUTE
- /// TARGET_*********_****_********_ATTRIBUTE
- /// ******_*********_****_********_ATTRIBUTE
- ///
-
- //
- // The wildcard "*" appears regularly (2^n). "*" in TARGET appears 2^0
- // times at every 2^0 TARGET, "*" in TOOLCHAIN appears 2^1 times at
- // every 2^1 TOOLCHAIN, and "*" in TOOLCODE appears 2^3 times at every
- // 2^3 TOOLCODE. We're going to use this to form all the combinations of key.
- //
- int[] combinations = new int[matchLevel];
- for (int i = 0; i < matchLevel; ++i) {
- //
- // initialize the array with 2^n
- //
- combinations[i] = 1 << (i + 1);
- }
-
- //
- // when last part goes down to zero, we tried all combinations of key
- //
- int lastIndex = matchLevel - 1;
- while (combinations[lastIndex] > 0) {
- //
- // form the key which has "*" in it
- //
- for (int i = 0; i < matchLevel; ++i) {
- //
- // start again if not finished
- //
- if (combinations[i] == 0) {
- combinations[i] = 1 << (i + 1);
- }
-
- //
- // half of 2^n is "*", the rest is non-*
- //
- try {
- if (combinations[i] > (1 << i)) {
- tmpKey.setKey(keySet[i], i);
- } else {
- tmpKey.setKey("*", i);
- }
- } catch (Exception e) {
- return null;
- }
-
- combinations[i] -= 1;
- }
-
- //
- // Try get the value from the map
- //
- result = map.get(tmpKey);
- if (result != null) {
- //
- // The map actually has no exact key as the given "key",
- // putting it back into map can speed up the get() next time
- //
- map.put(key, result);
- return result;
- }
- }
-
- //
- // The map actually has no exact key as the given "key", putting it back
- // into map can speed up the get() next time even we got nothing.
- //
- map.put(key, null);
- return null;
- }
-
- /**
- Wrapper function for Map.size().
-
- @return int The size of map
- **/
- public int size() {
- return map.size();
- }
-
- /**
- Wrapper function for Map.keySet().
-
- @return Set<ToolChainKey> A set of ToolChainKey objects
- */
- public Set<ToolChainKey> keySet() {
- return (Set<ToolChainKey>)map.keySet();
- }
-
- public String toString() {
- return map + "";
- }
-}
-
|