9989ab65f848450b4090b404f4694536f8e888e9
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
;
19 import java
.util
.Iterator
;
22 import org
.apache
.tools
.ant
.Project
;
23 import org
.tianocore
.build
.exception
.GenBuildException
;
24 import org
.tianocore
.build
.toolchain
.ToolChainKey
;
25 import org
.tianocore
.build
.toolchain
.ToolChainMap
;
30 ToolChainConfig class parse all config files and get tool chain information.
33 public class ToolChainConfig
{
35 // tool chain definitions
37 private ToolChainMap config
= null;
39 // tool chain information (how many targets, archs, etc.)
41 private ToolChainInfo info
= new ToolChainInfo();
44 Public construct method.
46 @param toolChainFile File object representing the tool chain configuration file
48 public ToolChainConfig (Project prj
, File toolChainFile
) throws GenBuildException
{
49 config
= getToolChainConfig(prj
, toolChainFile
);
50 parseToolChainDefKey(config
.keySet());
54 Read tool chain definitions from specified file and put them in
57 @param ConfigFile The file containing tool chain definitions
61 private ToolChainMap
getToolChainConfig(Project prj
, File ConfigFile
) throws GenBuildException
{
62 ToolChainMap map
= new ToolChainMap();
63 String
[][] toolChainDef
= ConfigReader
.parse(prj
, ConfigFile
);
65 for (int i
= 0; i
< toolChainDef
[0].length
; ++i
) {
66 map
.put(toolChainDef
[0][i
], toolChainDef
[1][i
]);
73 Collect target, tool chain tag, arch and command information from key part
76 @param toolChainDefKey The set of keys in tool chain configuration
78 private void parseToolChainDefKey (Set
<ToolChainKey
> toolChainDefKey
) {
79 Iterator it
= toolChainDefKey
.iterator();
80 while (it
.hasNext()) {
81 ToolChainKey key
= (ToolChainKey
)it
.next();
82 String
[] keySet
= key
.getKeySet();
83 info
.addTargets(keySet
[ToolChainElement
.TARGET
.value
]);
84 info
.addTagnames(keySet
[ToolChainElement
.TOOLCHAIN
.value
]);
85 info
.addArchs(keySet
[ToolChainElement
.ARCH
.value
]);
86 info
.addCommands(keySet
[ToolChainElement
.TOOLCODE
.value
]);
92 Return the tool chain configuration information in a Map form
94 @return ToolChainMap Tool chain configurations in a ToolChainMap
96 public ToolChainMap
getConfig() {
101 Return the tool chain's target, arch, tag and commands information
103 @return ToolChainInfo Tool chain information summary
105 public ToolChainInfo
getConfigInfo() {
112 @return String The converted configuration string in name=value form
114 public String
toString() {
115 StringBuffer ts
= new StringBuffer(10240);
117 Iterator it
= config
.keySet().iterator();
118 while (it
.hasNext()) {
119 ToolChainKey key
= (ToolChainKey
)it
.next();
120 ts
.append(key
.toString() + " = ");
121 ts
.append(config
.get(key
) + "\n");
124 return ts
.toString();