]> git.proxmox.com Git - mirror_edk2.git/blame_incremental - Tools/Java/Source/GenBuild/org/tianocore/build/toolchain/ToolChainInfo.java
1. Update to just keep several line JAVA related msg; 2. Remove file PropertyManager...
[mirror_edk2.git] / Tools / Java / Source / GenBuild / org / tianocore / build / toolchain / ToolChainInfo.java
... / ...
CommitLineData
1/** @file\r
2ToolChainInfo class\r
3\r
4This file is to define ToolChainInfo class.\r
5\r
6Copyright (c) 2006, Intel Corporation\r
7All rights reserved. This program and the accompanying materials\r
8are licensed and made available under the terms and conditions of the BSD License\r
9which accompanies this distribution. The full text of the license may be found at\r
10http://opensource.org/licenses/bsd-license.php\r
11\r
12THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
13WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
14**/\r
15\r
16package org.tianocore.build.toolchain;\r
17\r
18import java.util.LinkedHashSet;\r
19import java.util.Set;\r
20\r
21/**\r
22 ToolChainInfo collects valid build targets, tool chain tag, ARCHs and commands \r
23 information for real build use.\r
24 **/\r
25public class ToolChainInfo {\r
26 //\r
27 // build target set\r
28 // \r
29 private Set<String> targets = new LinkedHashSet<String>();\r
30 //\r
31 // tool chain tag name set\r
32 // \r
33 private Set<String> tagnames = new LinkedHashSet<String>();\r
34 //\r
35 // build archs set\r
36 // \r
37 private Set<String> archs = new LinkedHashSet<String>();\r
38 //\r
39 // build commands set\r
40 // \r
41 private Set<String> commands = new LinkedHashSet<String>();\r
42\r
43 /**\r
44 Add a list of targets in the form of string separated by space\r
45\r
46 @param targetList target list string\r
47 **/\r
48 public void addTargets(String targetList) {\r
49 //\r
50 // targetList some targets separated by space " "\r
51 //\r
52 if (targetList == null || targetList.length() == 0) {\r
53 targets.add("*");\r
54 } else {\r
55 addTargets(targetList.split(" "));\r
56 }\r
57 }\r
58\r
59 /**\r
60 Add a list of targets in the form of string array\r
61 \r
62 @param targetArray target string array\r
63 **/\r
64 public void addTargets(String[] targetArray) {\r
65 if (targetArray != null ) {\r
66 for (int i = 0; i < targetArray.length; i++) {\r
67 targets.add(targetArray[i]);\r
68 }\r
69 }\r
70 }\r
71\r
72 /**\r
73 Add a list of target in the form of set\r
74 \r
75 @param targetSet target string set\r
76 **/\r
77 public void addTargets(Set<String> targetSet) {\r
78 if (targetSet != null) {\r
79 targets.addAll(targetSet);\r
80 }\r
81 }\r
82\r
83 /**\r
84 Add a list of tool chain tag name in the form of string separated by space\r
85\r
86 @param tagnameList Tool chain tag name list string\r
87 **/\r
88 public void addTagnames(String tagnameList) {\r
89 //\r
90 // tagnameList some tagnames separated by space " "\r
91 //\r
92 if (tagnameList == null || tagnameList.length() == 0) {\r
93 tagnames.add("*");\r
94 } else {\r
95 addTagnames(tagnameList.split(" "));\r
96 }\r
97 }\r
98\r
99 /**\r
100 Add a list of tool chain tag name in the form of string array\r
101 \r
102 @param tagnameArray Tool chain tag names array\r
103 **/\r
104 public void addTagnames(String[] tagnameArray) {\r
105 if (tagnameArray != null ) {\r
106 for (int i = 0; i < tagnameArray.length; i++) {\r
107 tagnames.add(tagnameArray[i]);\r
108 }\r
109 }\r
110 }\r
111\r
112 /**\r
113 Add a list of tool chain tag name in the form of Set\r
114 \r
115 @param tagnameSet Tool chain tag names set\r
116 **/\r
117 public void addTagnames(Set<String> tagnameSet) {\r
118 if (tagnameSet != null) {\r
119 tagnames.addAll(tagnameSet);\r
120 }\r
121 }\r
122\r
123 /**\r
124 Add a list of ARCH in the form of string\r
125 \r
126 @param archList ARCH string\r
127 **/\r
128 public void addArchs(String archList) {\r
129 //\r
130 // archList some archs separated by space " "\r
131 //\r
132 if (archList == null || archList.length() == 0) {\r
133 archs.add("*");\r
134 } else {\r
135 addArchs(archList.split(" "));\r
136 }\r
137 }\r
138\r
139 /**\r
140 Add a list of ARCH in the form of string array\r
141 \r
142 @param archArray ARCH array\r
143 **/\r
144 public void addArchs(String[] archArray) {\r
145 if (archArray != null ) {\r
146 for (int i = 0; i < archArray.length; i++) {\r
147 archs.add(archArray[i]);\r
148 }\r
149 }\r
150 }\r
151\r
152 /**\r
153 Add a list of ARCH in the form of set\r
154 \r
155 @param archSet ARCH set\r
156 **/\r
157 public void addArchs(Set<String> archSet) {\r
158 if (archSet != null) {\r
159 archs.addAll(archSet);\r
160 }\r
161 }\r
162\r
163 /**\r
164 Add a list of command in the form of string\r
165 \r
166 @param commandList Command list string\r
167 **/\r
168 public void addCommands(String commandList) {\r
169 //\r
170 // archList some archs separated by space " "\r
171 //\r
172 if (commandList == null || commandList.length() == 0) {\r
173 commands.add("*");\r
174 } else {\r
175 addCommands(commandList.split(" "));\r
176 }\r
177 }\r
178\r
179 /**\r
180 Add a list of ARCH in the form of array\r
181 \r
182 @param commandArray Commands array\r
183 **/\r
184 public void addCommands(String[] commandArray) {\r
185 if (commandArray != null ) {\r
186 for (int i = 0; i < commandArray.length; i++) {\r
187 commands.add(commandArray[i]);\r
188 }\r
189 }\r
190 }\r
191\r
192 /**\r
193 Add a list of ARCH in the form of set\r
194 \r
195 @param commandSet Commands set\r
196 **/\r
197 public void addCommands(Set<String> commandSet) {\r
198 if (commandSet != null) {\r
199 commands.addAll(commandSet);\r
200 }\r
201 }\r
202\r
203 /**\r
204 Make a union operation on this ToolChainInfo and the given one.\r
205\r
206 @param info Another ToolChainInfo object to merge with\r
207 \r
208 @return ToolChainInfo Merged ToolChainInfo object\r
209 **/\r
210 public ToolChainInfo union(ToolChainInfo info) {\r
211 ToolChainInfo result = new ToolChainInfo();\r
212 result.addTargets(union(this.targets, info.targets));\r
213 result.addTagnames(union(this.tagnames, info.tagnames));\r
214 result.addArchs(union(this.archs, info.archs));\r
215 return result;\r
216 }\r
217\r
218 /**\r
219 Make a intersection operation on this ToolChainInfo and the given one\r
220\r
221 @param info Another ToolChainInfo object to intersect with\r
222 \r
223 @return ToolChainInfo Intersected ToolChainInfo object\r
224 **/\r
225 public ToolChainInfo intersection(ToolChainInfo info) {\r
226 ToolChainInfo result = new ToolChainInfo();\r
227 result.addTargets(intersection(this.targets, info.targets));\r
228 result.addTagnames(intersection(this.tagnames, info.tagnames));\r
229 result.addArchs(intersection(this.archs, info.archs));\r
230 return result;\r
231 }\r
232\r
233 /**\r
234 Make a union operation on two Sets\r
235\r
236 @param set1 One Set\r
237 @param set2 Another Set\r
238 \r
239 @return Set<String> Merged Set object\r
240 **/\r
241 private Set<String> union(Set<String> set1, Set<String> set2) {\r
242 Set<String> result = new LinkedHashSet<String>();\r
243 result.addAll(set1);\r
244 result.addAll(set2);\r
245 result.remove("*");\r
246 return result;\r
247 }\r
248\r
249 /**\r
250 Make a intersection operation on two Sets with the consideration of wildcard.\r
251\r
252 @param set1 One Set\r
253 @param set2 Another Set\r
254 \r
255 @return Set<String> The intersected Set object\r
256 **/\r
257 private Set<String> intersection(Set<String> set1, Set<String> set2) {\r
258 Set<String> result = new LinkedHashSet<String>();\r
259 boolean set1HasWildcard = set1.contains("*");\r
260 boolean set2HasWildcard = set2.contains("*");\r
261\r
262 if (set1HasWildcard && set2HasWildcard) {\r
263 //\r
264 // Both Sets have wildcard, the result will have all elements in them\r
265 // \r
266 result.addAll(set1);\r
267 result.addAll(set2);\r
268 } else if (set1HasWildcard) {\r
269 //\r
270 // Only set1 has wildcard, then result will have only set2 elements.\r
271 // \r
272 result.addAll(set2);\r
273 } else if (set2HasWildcard) {\r
274 //\r
275 // Only set2 has wildcard, then result will have only set1 elements.\r
276 // \r
277 result.addAll(set1);\r
278 } else {\r
279 //\r
280 // No wildcard in both Sets, the result will have the elements in both Sets.\r
281 // \r
282 result.addAll(set1);\r
283 result.retainAll(set2);\r
284 }\r
285\r
286 return result;\r
287 }\r
288\r
289 /**\r
290 Get target array.\r
291\r
292 @return String[]\r
293 **/\r
294 public String[] getTargets() {\r
295 return (String[])targets.toArray(new String[targets.size()]);\r
296 }\r
297\r
298 /**\r
299 Get tool chain tag name array.\r
300\r
301 @return String[]\r
302 **/\r
303 public String[] getTagnames() {\r
304 return (String[])tagnames.toArray(new String[tagnames.size()]);\r
305 }\r
306\r
307 /**\r
308 Get ARCH array.\r
309\r
310 @return String[]\r
311 **/\r
312 public String[] getArchs() {\r
313 return (String[])archs.toArray(new String[archs.size()]);\r
314 }\r
315\r
316 /**\r
317 Get command name array.\r
318\r
319 @return String[]\r
320 **/\r
321 public String[] getCommands() {\r
322 return (String[])commands.toArray(new String[commands.size()]);\r
323 }\r
324\r
325 /**\r
326 Override the Object's toString().\r
327\r
328 @return String\r
329 **/\r
330 public String toString() {\r
331 return " TARGET :" + targets + "\n" + \r
332 " TAGNAME:" + tagnames + "\n" + \r
333 " ARCH :" + archs + "\n" + \r
334 " COMMAND:" + commands;\r
335 }\r
336\r
337 /**\r
338 Remove the wildcard element in the tool chain information because they\r
339 are useless when retrieved.\r
340 **/\r
341 public void normalize() {\r
342 targets.remove("*");\r
343 tagnames.remove("*");\r
344 archs.remove("*");\r
345 commands.remove("*");\r
346 }\r
347}\r