]> git.proxmox.com Git - mirror_edk2.git/blame - Tools/Source/GenBuild/org/tianocore/build/toolchain/ToolChainConfig.java
moved exception and logger classes to org.tianocore.common package
[mirror_edk2.git] / Tools / Source / GenBuild / org / tianocore / build / toolchain / ToolChainConfig.java
CommitLineData
a29c47e0 1/** @file\r
5f42a4ba 2 ToolChainConfig class.\r
ff225cbb 3\r
5f42a4ba 4 ToolChainFactory class parse all config files and get tool chain information.\r
ff225cbb 5\r
a29c47e0 6Copyright (c) 2006, Intel Corporation\r
7All rights reserved. This program and the accompanying materials\r
8are licensed and made available under the terms and conditions of the BSD License\r
9which accompanies this distribution. The full text of the license may be found at\r
10http://opensource.org/licenses/bsd-license.php\r
11\r
12THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
13WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
14\r
15**/\r
16package org.tianocore.build.toolchain;\r
17\r
18import org.apache.tools.ant.BuildException;\r
ff225cbb 19\r
20import org.tianocore.common.exception.EdkException;\r
a29c47e0 21import org.tianocore.build.toolchain.ToolChainKey;\r
22import org.tianocore.build.toolchain.ToolChainMap;\r
23\r
24import java.io.File;\r
25import java.util.Iterator;\r
26import java.util.Set;\r
27\r
28\r
29/**\r
ff225cbb 30\r
5f42a4ba 31 ToolChainFactory class parse all config files and get tool chain information.\r
ff225cbb 32\r
5f42a4ba 33 **/\r
a29c47e0 34public class ToolChainConfig {\r
a29c47e0 35 ///\r
36 /// tool chain definitions\r
37 ///\r
38 private ToolChainMap config = null;\r
5f42a4ba 39 ///\r
40 /// tool chain information (how many targets, archs, etc.)\r
ff225cbb 41 ///\r
a29c47e0 42 private ToolChainInfo info = new ToolChainInfo();\r
43\r
44 /**\r
45 Public construct method.\r
5f42a4ba 46 **/\r
a29c47e0 47 public ToolChainConfig () {\r
48 }\r
49\r
50 /**\r
51 Public construct method.\r
ff225cbb 52\r
5f42a4ba 53 @param toolChainFile File object representing the tool chain configuration file\r
a29c47e0 54 **/\r
55 public ToolChainConfig (File toolChainFile) {\r
56 try {\r
57 config = ConfigReader.parseToolChainConfig(toolChainFile);\r
58 parseToolChainDefKey(config.keySet());\r
59 }\r
60 catch (EdkException ex) {\r
61 throw new BuildException(ex.getMessage());\r
62 }\r
63 }\r
64\r
5f42a4ba 65 /**\r
66 Collect target, tool chain tag, arch and command information from key part\r
67 of configuration\r
ff225cbb 68\r
5f42a4ba 69 @param toolChainDefKey The set of keys in tool chain configuration\r
70 **/\r
71 private void parseToolChainDefKey (Set<ToolChainKey> toolChainDefKey) {\r
a29c47e0 72 Iterator it = toolChainDefKey.iterator();\r
73 while (it.hasNext()) {\r
74 ToolChainKey key = (ToolChainKey)it.next();\r
75 String[] keySet = key.getKeySet();\r
76 info.addTargets(keySet[0]);\r
77 info.addTagnames(keySet[1]);\r
78 info.addArchs(keySet[2]);\r
79 info.addCommands(keySet[1], keySet[3]);\r
80 }\r
81 }\r
82\r
5f42a4ba 83 /**\r
ff225cbb 84 Return the tool chain configuration information in a Map form\r
85\r
5f42a4ba 86 @return ToolChainMap Tool chain configurations in a ToolChainMap\r
87 **/\r
a29c47e0 88 public ToolChainMap getConfig() {\r
89 return config;\r
90 }\r
91\r
5f42a4ba 92 /**\r
93 Return the tool chain's target, arch, tag and commands information\r
ff225cbb 94\r
5f42a4ba 95 @return ToolChainInfo\r
96 **/\r
a29c47e0 97 public ToolChainInfo getConfigInfo() {\r
98 return info;\r
99 }\r
100\r
5f42a4ba 101 /**\r
102 override toString()\r
ff225cbb 103\r
5f42a4ba 104 @return String The converted configuration string in name=value form\r
105 **/\r
a29c47e0 106 public String toString() {\r
107 StringBuffer ts = new StringBuffer(10240);\r
108\r
109 Iterator it = config.keySet().iterator();\r
110 while (it.hasNext()) {\r
111 ToolChainKey key = (ToolChainKey)it.next();\r
112 ts.append(key.toString() + " = ");\r
5f42a4ba 113 ts.append(config.get(key) + "\n");\r
a29c47e0 114 }\r
115\r
116 return ts.toString();\r
117 }\r
118}\r
119\r