]>
git.proxmox.com Git - mirror_edk2.git/blob - Tools/Java/Source/GenBuild/org/tianocore/build/toolchain/ToolChainConfig.java
f78d49f507eede1d81c7699469a112f81a396fbc
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
]);
91 Return the tool chain configuration information in a Map form
93 @return ToolChainMap Tool chain configurations in a ToolChainMap
95 public ToolChainMap
getConfig() {
100 Return the tool chain's target, arch, tag and commands information
102 @return ToolChainInfo Tool chain information summary
104 public ToolChainInfo
getConfigInfo() {
111 @return String The converted configuration string in name=value form
113 public String
toString() {
114 StringBuffer ts
= new StringBuffer(10240);
116 Iterator it
= config
.keySet().iterator();
117 while (it
.hasNext()) {
118 ToolChainKey key
= (ToolChainKey
)it
.next();
119 ts
.append(key
.toString() + " = ");
120 ts
.append(config
.get(key
) + "\n");
123 return ts
.toString();