]> git.proxmox.com Git - mirror_edk2.git/blob - Tools/Source/GenBuild/org/tianocore/build/toolchain/ToolChainConfig.java
Change to new XML Schema.
[mirror_edk2.git] / Tools / Source / GenBuild / org / tianocore / build / toolchain / ToolChainConfig.java
1 /** @file
2 ToolChainFactory class.
3
4 ToolChainFactory class parse all config files and get STD_FLAGS, GLOBAL_FLAGS,
5 and also command path + name.
6
7 Copyright (c) 2006, Intel Corporation
8 All rights reserved. This program and the accompanying materials
9 are licensed and made available under the terms and conditions of the BSD License
10 which accompanies this distribution. The full text of the license may be found at
11 http://opensource.org/licenses/bsd-license.php
12
13 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
14 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
15
16 **/
17 package org.tianocore.build.toolchain;
18
19 import org.apache.tools.ant.BuildException;
20 import org.tianocore.build.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 This class parse all config files and get STD_FLAGS, GLOBAL_FLAGS, and also
31 command path + name.
32
33 @since GenBuild 1.0
34 **/
35 public class ToolChainConfig {
36 ///
37 /// list of attributes
38 ///
39 private final static String[] attributes = {"NAME", "PATH", "DPATH", "SPATH", "EXT", "FAMILY", "FLAGS"};
40 ///
41 /// elements which are used to define one type of tool
42 ///
43 private final static String[] elements = {"TARGET", "TOOLCHAIN", "ARCH", "CMD", "ATTRIBUTE" };
44
45 ///
46 /// tool chain definitions
47 ///
48 private ToolChainMap config = null;
49 private ToolChainInfo info = new ToolChainInfo();
50
51 /**
52 Public construct method.
53 **/
54 public ToolChainConfig () {
55 }
56
57 /**
58 Public construct method.
59
60 @param confPath the path of config files
61 @param toolChainTag TOOL_CHAIN name
62 **/
63 public ToolChainConfig (File toolChainFile) {
64 try {
65 config = ConfigReader.parseToolChainConfig(toolChainFile);
66 parseToolChainDefKey(config.keySet());
67 }
68 catch (EdkException ex) {
69 throw new BuildException(ex.getMessage());
70 }
71 }
72
73 ///
74 ///
75 ///
76 public void parseToolChainDefKey (Set<ToolChainKey> toolChainDefKey) {
77 Iterator it = toolChainDefKey.iterator();
78 while (it.hasNext()) {
79 ToolChainKey key = (ToolChainKey)it.next();
80 String[] keySet = key.getKeySet();
81 info.addTargets(keySet[0]);
82 info.addTagnames(keySet[1]);
83 info.addArchs(keySet[2]);
84 info.addCommands(keySet[1], keySet[3]);
85 }
86 }
87
88 /**
89 public Set<String> getTargets() {
90 return info.getTargets();
91 }
92
93 public Set<String> getTagnames() {
94 return info.getTagnames();
95 }
96
97 public Set<String> getArchs() {
98 return info.getArchs();
99 }
100
101 public Set<String> getCommands() {
102 return info.getCommands();
103 }
104
105 public String getValue(String key) {
106 return config.get(key);
107 }
108
109 public String getValue(String[] keySet) {
110 return config.get(keySet);
111 }
112
113 public String getValue(ToolChainKey key) {
114 return config.get(key);
115 }
116 **/
117
118 public ToolChainMap getConfig() {
119 return config;
120 }
121
122 public ToolChainInfo getConfigInfo() {
123 return info;
124 }
125
126 ///
127 /// override toString()
128 ///
129 public String toString() {
130 StringBuffer ts = new StringBuffer(10240);
131
132 Iterator it = config.keySet().iterator();
133 while (it.hasNext()) {
134 ToolChainKey key = (ToolChainKey)it.next();
135 ts.append(key.toString() + " = ");
136 // ts.append(config.get(key) + "\n");
137 }
138
139 return ts.toString();
140 }
141 }
142