4 ToolChainConfig class parse all config files and get tool chain information.
6 Copyright (c) 2006, Intel Corporation
7 All rights reserved. This program and the accompanying materials
8 are licensed and made available under the terms and conditions of the BSD License
9 which accompanies this distribution. The full text of the license may be found at
10 http://opensource.org/licenses/bsd-license.php
12 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
13 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
16 package org
.tianocore
.build
.toolchain
;
18 import org
.tianocore
.build
.exception
.GenBuildException
;
19 import org
.tianocore
.build
.toolchain
.ToolChainKey
;
20 import org
.tianocore
.build
.toolchain
.ToolChainMap
;
23 import java
.util
.Iterator
;
29 ToolChainConfig class parse all config files and get tool chain information.
32 public class ToolChainConfig
{
34 // tool chain definitions
36 private ToolChainMap config
= null;
38 // tool chain information (how many targets, archs, etc.)
40 private ToolChainInfo info
= new ToolChainInfo();
43 Public construct method.
45 @param toolChainFile File object representing the tool chain configuration file
47 public ToolChainConfig (File toolChainFile
) throws GenBuildException
{
48 config
= getToolChainConfig(toolChainFile
);
49 parseToolChainDefKey(config
.keySet());
53 Read tool chain definitions from specified file and put them in
56 @param ConfigFile The file containing tool chain definitions
60 private ToolChainMap
getToolChainConfig(File ConfigFile
) throws GenBuildException
{
61 ToolChainMap map
= new ToolChainMap();
62 String
[][] toolChainDef
= ConfigReader
.parse(ConfigFile
);
64 for (int i
= 0; i
< toolChainDef
[0].length
; ++i
) {
65 map
.put(toolChainDef
[0][i
], toolChainDef
[1][i
]);
72 Collect target, tool chain tag, arch and command information from key part
75 @param toolChainDefKey The set of keys in tool chain configuration
77 private void parseToolChainDefKey (Set
<ToolChainKey
> toolChainDefKey
) {
78 Iterator it
= toolChainDefKey
.iterator();
79 while (it
.hasNext()) {
80 ToolChainKey key
= (ToolChainKey
)it
.next();
81 String
[] keySet
= key
.getKeySet();
82 info
.addTargets(keySet
[ToolChainElement
.TARGET
.value
]);
83 info
.addTagnames(keySet
[ToolChainElement
.TOOLCHAIN
.value
]);
84 info
.addArchs(keySet
[ToolChainElement
.ARCH
.value
]);
85 info
.addCommands(keySet
[ToolChainElement
.TOOLCODE
.value
]);
90 Return the tool chain configuration information in a Map form
92 @return ToolChainMap Tool chain configurations in a ToolChainMap
94 public ToolChainMap
getConfig() {
99 Return the tool chain's target, arch, tag and commands information
101 @return ToolChainInfo Tool chain information summary
103 public ToolChainInfo
getConfigInfo() {
110 @return String The converted configuration string in name=value form
112 public String
toString() {
113 StringBuffer ts
= new StringBuffer(10240);
115 Iterator it
= config
.keySet().iterator();
116 while (it
.hasNext()) {
117 ToolChainKey key
= (ToolChainKey
)it
.next();
118 ts
.append(key
.toString() + " = ");
119 ts
.append(config
.get(key
) + "\n");
122 return ts
.toString();