]>
git.proxmox.com Git - mirror_edk2.git/blob - Tools/Source/GenBuild/org/tianocore/build/toolchain/ToolChainInfo.java
4 This file is to define ToolChainInfo class.
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 java
.util
.HashMap
;
19 import java
.util
.LinkedHashSet
;
24 ToolChainInfo collects valid build targets, tool chain tag, ARCHs and commands
25 information for real build use.
27 public class ToolChainInfo
{
31 private Set
<String
> targets
= new LinkedHashSet
<String
>();
33 // tool chain tag name set
35 private Set
<String
> tagnames
= new LinkedHashSet
<String
>();
39 private Set
<String
> archs
= new LinkedHashSet
<String
>();
43 private Set
<String
> commands
= new LinkedHashSet
<String
>();
46 Add a list of targets in the form of string separated by space
48 @param targetList target list string
50 public void addTargets(String targetList
) {
52 // targetList some targets separated by space " "
54 if (targetList
== null || targetList
.length() == 0) {
57 addTargets(targetList
.split(" "));
62 Add a list of targets in the form of string array
64 @param targetArray target string array
66 public void addTargets(String
[] targetArray
) {
67 if (targetArray
!= null ) {
68 for (int i
= 0; i
< targetArray
.length
; i
++) {
69 targets
.add(targetArray
[i
]);
75 Add a list of target in the form of set
77 @param targetSet target string set
79 public void addTargets(Set
<String
> targetSet
) {
80 if (targetSet
!= null) {
81 targets
.addAll(targetSet
);
86 Add a list of tool chain tag name in the form of string separated by space
88 @param tagnameList Tool chain tag name list string
90 public void addTagnames(String tagnameList
) {
92 // tagnameList some tagnames separated by space " "
94 if (tagnameList
== null || tagnameList
.length() == 0) {
97 addTagnames(tagnameList
.split(" "));
102 Add a list of tool chain tag name in the form of string array
104 @param tagnameArray Tool chain tag names array
106 public void addTagnames(String
[] tagnameArray
) {
107 if (tagnameArray
!= null ) {
108 for (int i
= 0; i
< tagnameArray
.length
; i
++) {
109 tagnames
.add(tagnameArray
[i
]);
115 Add a list of tool chain tag name in the form of Set
117 @param tagnameSet Tool chain tag names set
119 public void addTagnames(Set
<String
> tagnameSet
) {
120 if (tagnameSet
!= null) {
121 tagnames
.addAll(tagnameSet
);
126 Add a list of ARCH in the form of string
128 @param archList ARCH string
130 public void addArchs(String archList
) {
132 // archList some archs separated by space " "
134 if (archList
== null || archList
.length() == 0) {
137 addArchs(archList
.split(" "));
142 Add a list of ARCH in the form of string array
144 @param archArray ARCH array
146 public void addArchs(String
[] archArray
) {
147 if (archArray
!= null ) {
148 for (int i
= 0; i
< archArray
.length
; i
++) {
149 archs
.add(archArray
[i
]);
155 Add a list of ARCH in the form of set
157 @param archSet ARCH set
159 public void addArchs(Set
<String
> archSet
) {
160 if (archSet
!= null) {
161 archs
.addAll(archSet
);
166 Add a list of command in the form of string
168 @param commandList Command list string
170 public void addCommands(String commandList
) {
172 // archList some archs separated by space " "
174 if (commandList
== null || commandList
.length() == 0) {
177 addCommands(commandList
.split(" "));
182 Add a list of ARCH in the form of array
184 @param commandArray Commands array
186 public void addCommands(String
[] commandArray
) {
187 if (commandArray
!= null ) {
188 for (int i
= 0; i
< commandArray
.length
; i
++) {
189 commands
.add(commandArray
[i
]);
195 Add a list of ARCH in the form of set
197 @param commandSet Commands set
199 public void addCommands(Set
<String
> commandSet
) {
200 if (commandSet
!= null) {
201 commands
.addAll(commandSet
);
206 Make a union operation on this ToolChainInfo and the given one.
208 @param info Another ToolChainInfo object to merge with
210 @return ToolChainInfo Merged ToolChainInfo object
212 public ToolChainInfo
union(ToolChainInfo info
) {
213 ToolChainInfo result
= new ToolChainInfo();
214 result
.addTargets(union(this.targets
, info
.targets
));
215 result
.addTagnames(union(this.tagnames
, info
.tagnames
));
216 result
.addArchs(union(this.archs
, info
.archs
));
221 Make a intersection operation on this ToolChainInfo and the given one
223 @param info Another ToolChainInfo object to intersect with
225 @return ToolChainInfo Intersected ToolChainInfo object
227 public ToolChainInfo
intersection(ToolChainInfo info
) {
228 ToolChainInfo result
= new ToolChainInfo();
229 result
.addTargets(intersection(this.targets
, info
.targets
));
230 result
.addTagnames(intersection(this.tagnames
, info
.tagnames
));
231 result
.addArchs(intersection(this.archs
, info
.archs
));
236 Make a union operation on two Sets
239 @param set2 Another Set
241 @return Set<String> Merged Set object
243 private Set
<String
> union(Set
<String
> set1
, Set
<String
> set2
) {
244 Set
<String
> result
= new LinkedHashSet
<String
>();
252 Make a intersection operation on two Sets with the consideration of wildcard.
255 @param set2 Another Set
257 @return Set<String> The intersected Set object
259 private Set
<String
> intersection(Set
<String
> set1
, Set
<String
> set2
) {
260 Set
<String
> result
= new LinkedHashSet
<String
>();
261 boolean set1HasWildcard
= set1
.contains("*");
262 boolean set2HasWildcard
= set2
.contains("*");
264 if (set1HasWildcard
&& set2HasWildcard
) {
266 // Both Sets have wildcard, the result will have all elements in them
270 } else if (set1HasWildcard
) {
272 // Only set1 has wildcard, then result will have only set2 elements.
275 } else if (set2HasWildcard
) {
277 // Only set2 has wildcard, then result will have only set1 elements.
282 // No wildcard in both Sets, the result will have the elements in both Sets.
285 result
.retainAll(set2
);
296 public String
[] getTargets() {
297 return (String
[])targets
.toArray(new String
[targets
.size()]);
301 Get tool chain tag name array.
305 public String
[] getTagnames() {
306 return (String
[])tagnames
.toArray(new String
[tagnames
.size()]);
314 public String
[] getArchs() {
315 return (String
[])archs
.toArray(new String
[archs
.size()]);
319 Get command name array.
323 public String
[] getCommands() {
324 return (String
[])commands
.toArray(new String
[commands
.size()]);
328 Override the Object's toString().
332 public String
toString() {
333 return targets
+ "\n" + tagnames
+ "\n" + archs
+ "\n" + commands
;
337 Remove the wildcard element in the tool chain information because they
338 are useless when retrieved.
340 public void normalize() {
342 tagnames
.remove("*");
344 commands
.remove("*");