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