]> git.proxmox.com Git - mirror_edk2.git/blame - Tools/Source/GenBuild/org/tianocore/build/toolchain/ToolChainConfig.java
Changed spelling to manifest
[mirror_edk2.git] / Tools / Source / GenBuild / org / tianocore / build / toolchain / ToolChainConfig.java
CommitLineData
a29c47e0 1/** @file\r
5f42a4ba 2 ToolChainConfig class.\r
d2059d05 3 \r
4 ToolChainConfig class parse all config files and get tool chain information.\r
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
2279b26c 18import org.tianocore.build.exception.GenBuildException;\r
a29c47e0 19import org.tianocore.build.toolchain.ToolChainKey;\r
20import org.tianocore.build.toolchain.ToolChainMap;\r
21\r
22import java.io.File;\r
23import java.util.Iterator;\r
24import java.util.Set;\r
25\r
26\r
27/**\r
d2059d05 28 \r
29 ToolChainConfig class parse all config files and get tool chain information.\r
30 \r
5f42a4ba 31 **/\r
a29c47e0 32public class ToolChainConfig {\r
d2059d05 33 //\r
34 // tool chain definitions\r
35 //\r
a29c47e0 36 private ToolChainMap config = null;\r
d2059d05 37 //\r
38 // tool chain information (how many targets, archs, etc.)\r
39 // \r
a29c47e0 40 private ToolChainInfo info = new ToolChainInfo();\r
41\r
42 /**\r
43 Public construct method.\r
d2059d05 44 \r
45 @param toolChainFile File object representing the tool chain configuration file\r
46 **/\r
2279b26c 47 public ToolChainConfig (File toolChainFile) throws GenBuildException {\r
d2059d05 48 config = getToolChainConfig(toolChainFile);\r
49 parseToolChainDefKey(config.keySet());\r
a29c47e0 50 }\r
51\r
52 /**\r
d2059d05 53 Read tool chain definitions from specified file and put them in \r
54 ToolChainMap class.\r
ff225cbb 55\r
d2059d05 56 @param ConfigFile The file containing tool chain definitions\r
57 \r
58 @return ToolChainMap\r
59 **/\r
2279b26c 60 private ToolChainMap getToolChainConfig(File ConfigFile) throws GenBuildException {\r
d2059d05 61 ToolChainMap map = new ToolChainMap();\r
62 String[][] toolChainDef = ConfigReader.parse(ConfigFile);\r
63 \r
64 for (int i = 0; i < toolChainDef[0].length; ++i) {\r
65 map.put(toolChainDef[0][i], toolChainDef[1][i]);\r
a29c47e0 66 }\r
d2059d05 67\r
68 return map;\r
a29c47e0 69 }\r
70\r
5f42a4ba 71 /**\r
72 Collect target, tool chain tag, arch and command information from key part\r
73 of configuration\r
d2059d05 74 \r
5f42a4ba 75 @param toolChainDefKey The set of keys in tool chain configuration\r
76 **/\r
77 private void parseToolChainDefKey (Set<ToolChainKey> toolChainDefKey) {\r
a29c47e0 78 Iterator it = toolChainDefKey.iterator();\r
79 while (it.hasNext()) {\r
80 ToolChainKey key = (ToolChainKey)it.next();\r
81 String[] keySet = key.getKeySet();\r
d2059d05 82 info.addTargets(keySet[ToolChainElement.TARGET.value]);\r
83 info.addTagnames(keySet[ToolChainElement.TOOLCHAIN.value]);\r
84 info.addArchs(keySet[ToolChainElement.ARCH.value]);\r
85 info.addCommands(keySet[ToolChainElement.TOOLCODE.value]);\r
a29c47e0 86 }\r
87 }\r
88\r
5f42a4ba 89 /**\r
d2059d05 90 Return the tool chain configuration information in a Map form \r
91 \r
5f42a4ba 92 @return ToolChainMap Tool chain configurations in a ToolChainMap\r
93 **/\r
a29c47e0 94 public ToolChainMap getConfig() {\r
95 return config;\r
96 }\r
97\r
5f42a4ba 98 /**\r
99 Return the tool chain's target, arch, tag and commands information\r
d2059d05 100 \r
101 @return ToolChainInfo Tool chain information summary\r
5f42a4ba 102 **/\r
a29c47e0 103 public ToolChainInfo getConfigInfo() {\r
104 return info;\r
105 }\r
106\r
5f42a4ba 107 /**\r
108 override toString()\r
d2059d05 109 \r
5f42a4ba 110 @return String The converted configuration string in name=value form\r
111 **/\r
a29c47e0 112 public String toString() {\r
113 StringBuffer ts = new StringBuffer(10240);\r
114\r
115 Iterator it = config.keySet().iterator();\r
116 while (it.hasNext()) {\r
117 ToolChainKey key = (ToolChainKey)it.next();\r
118 ts.append(key.toString() + " = ");\r
5f42a4ba 119 ts.append(config.get(key) + "\n");\r
a29c47e0 120 }\r
121\r
122 return ts.toString();\r
123 }\r
124}\r
125\r