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