]> git.proxmox.com Git - mirror_edk2.git/blame_incremental - Tools/Source/GenBuild/org/tianocore/build/toolchain/ToolChainConfig.java
Add boot script dispatch opcode 2
[mirror_edk2.git] / Tools / Source / GenBuild / org / tianocore / build / toolchain / ToolChainConfig.java
... / ...
CommitLineData
1/** @file\r
2 ToolChainConfig class.\r
3\r
4 ToolChainFactory class parse all config files and get tool chain information.\r
5\r
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
19\r
20import org.tianocore.common.exception.EdkException;\r
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
30\r
31 ToolChainFactory class parse all config files and get tool chain information.\r
32\r
33 **/\r
34public class ToolChainConfig {\r
35 ///\r
36 /// tool chain definitions\r
37 ///\r
38 private ToolChainMap config = null;\r
39 ///\r
40 /// tool chain information (how many targets, archs, etc.)\r
41 ///\r
42 private ToolChainInfo info = new ToolChainInfo();\r
43\r
44 /**\r
45 Public construct method.\r
46 **/\r
47 public ToolChainConfig () {\r
48 }\r
49\r
50 /**\r
51 Public construct method.\r
52\r
53 @param toolChainFile File object representing the tool chain configuration file\r
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
65 /**\r
66 Collect target, tool chain tag, arch and command information from key part\r
67 of configuration\r
68\r
69 @param toolChainDefKey The set of keys in tool chain configuration\r
70 **/\r
71 private void parseToolChainDefKey (Set<ToolChainKey> toolChainDefKey) {\r
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
83 /**\r
84 Return the tool chain configuration information in a Map form\r
85\r
86 @return ToolChainMap Tool chain configurations in a ToolChainMap\r
87 **/\r
88 public ToolChainMap getConfig() {\r
89 return config;\r
90 }\r
91\r
92 /**\r
93 Return the tool chain's target, arch, tag and commands information\r
94\r
95 @return ToolChainInfo\r
96 **/\r
97 public ToolChainInfo getConfigInfo() {\r
98 return info;\r
99 }\r
100\r
101 /**\r
102 override toString()\r
103\r
104 @return String The converted configuration string in name=value form\r
105 **/\r
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
113 ts.append(config.get(key) + "\n");\r
114 }\r
115\r
116 return ts.toString();\r
117 }\r
118}\r
119\r