/** @file\r
ToolChainConfig class.\r
-\r
- ToolChainFactory class parse all config files and get tool chain information.\r
-\r
+ \r
+ ToolChainConfig class parse all config files and get tool chain information.\r
+ \r
Copyright (c) 2006, Intel Corporation\r
All rights reserved. This program and the accompanying materials\r
are licensed and made available under the terms and conditions of the BSD License\r
**/\r
package org.tianocore.build.toolchain;\r
\r
-import org.apache.tools.ant.BuildException;\r
-\r
import org.tianocore.common.exception.EdkException;\r
import org.tianocore.build.toolchain.ToolChainKey;\r
import org.tianocore.build.toolchain.ToolChainMap;\r
\r
\r
/**\r
-\r
- ToolChainFactory class parse all config files and get tool chain information.\r
-\r
+ \r
+ ToolChainConfig class parse all config files and get tool chain information.\r
+ \r
**/\r
public class ToolChainConfig {\r
- ///\r
- /// tool chain definitions\r
- ///\r
+ //\r
+ // tool chain definitions\r
+ //\r
private ToolChainMap config = null;\r
- ///\r
- /// tool chain information (how many targets, archs, etc.)\r
- ///\r
+ //\r
+ // tool chain information (how many targets, archs, etc.)\r
+ // \r
private ToolChainInfo info = new ToolChainInfo();\r
\r
/**\r
Public construct method.\r
- **/\r
- public ToolChainConfig () {\r
+ \r
+ @param toolChainFile File object representing the tool chain configuration file\r
+ **/\r
+ public ToolChainConfig (File toolChainFile) throws EdkException {\r
+ config = getToolChainConfig(toolChainFile);\r
+ parseToolChainDefKey(config.keySet());\r
}\r
\r
/**\r
- Public construct method.\r
+ Read tool chain definitions from specified file and put them in \r
+ ToolChainMap class.\r
\r
- @param toolChainFile File object representing the tool chain configuration file\r
- **/\r
- public ToolChainConfig (File toolChainFile) {\r
- try {\r
- config = ConfigReader.parseToolChainConfig(toolChainFile);\r
- parseToolChainDefKey(config.keySet());\r
- }\r
- catch (EdkException ex) {\r
- throw new BuildException(ex.getMessage());\r
+ @param ConfigFile The file containing tool chain definitions\r
+ \r
+ @return ToolChainMap\r
+ **/\r
+ private ToolChainMap getToolChainConfig(File ConfigFile) throws EdkException {\r
+ ToolChainMap map = new ToolChainMap();\r
+ String[][] toolChainDef = ConfigReader.parse(ConfigFile);\r
+ \r
+ for (int i = 0; i < toolChainDef[0].length; ++i) {\r
+ map.put(toolChainDef[0][i], toolChainDef[1][i]);\r
}\r
+\r
+ return map;\r
}\r
\r
/**\r
Collect target, tool chain tag, arch and command information from key part\r
of configuration\r
-\r
+ \r
@param toolChainDefKey The set of keys in tool chain configuration\r
**/\r
private void parseToolChainDefKey (Set<ToolChainKey> toolChainDefKey) {\r
while (it.hasNext()) {\r
ToolChainKey key = (ToolChainKey)it.next();\r
String[] keySet = key.getKeySet();\r
- info.addTargets(keySet[0]);\r
- info.addTagnames(keySet[1]);\r
- info.addArchs(keySet[2]);\r
- info.addCommands(keySet[1], keySet[3]);\r
+ info.addTargets(keySet[ToolChainElement.TARGET.value]);\r
+ info.addTagnames(keySet[ToolChainElement.TOOLCHAIN.value]);\r
+ info.addArchs(keySet[ToolChainElement.ARCH.value]);\r
+ info.addCommands(keySet[ToolChainElement.TOOLCODE.value]);\r
}\r
}\r
\r
/**\r
- Return the tool chain configuration information in a Map form\r
-\r
+ Return the tool chain configuration information in a Map form \r
+ \r
@return ToolChainMap Tool chain configurations in a ToolChainMap\r
**/\r
public ToolChainMap getConfig() {\r
\r
/**\r
Return the tool chain's target, arch, tag and commands information\r
-\r
- @return ToolChainInfo\r
+ \r
+ @return ToolChainInfo Tool chain information summary\r
**/\r
public ToolChainInfo getConfigInfo() {\r
return info;\r
\r
/**\r
override toString()\r
-\r
+ \r
@return String The converted configuration string in name=value form\r
**/\r
public String toString() {\r