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