]>
git.proxmox.com Git - mirror_edk2.git/blob - Tools/Source/GenBuild/org/tianocore/build/toolchain/ToolChainInfo.java
146f6e5a131b3ee9f8aa0204ba5cbcea6e2d4cc3
1 package org
.tianocore
.build
.toolchain
;
3 import java
.util
.HashMap
;
4 import java
.util
.LinkedHashSet
;
8 public class ToolChainInfo
{
10 private Set
<String
> targets
= new LinkedHashSet
<String
>();
12 private Set
<String
> tagnames
= new LinkedHashSet
<String
>();
14 private Set
<String
> archs
= new LinkedHashSet
<String
>();
16 private Set
<String
> commands
= new LinkedHashSet
<String
>();
18 private Map
<String
, Set
<String
>> commandMap
= new HashMap
<String
, Set
<String
>>();
20 public void addTargets(String targetList
) {
22 // targetList some targets separated by space " "
24 if (targetList
== null) {
28 addTargets(targetList
.split(" "));
31 public void addTargets(String
[] targetArray
) {
32 if (targetArray
== null ) {
35 for (int i
= 0; i
< targetArray
.length
; i
++) {
36 targets
.add(targetArray
[i
]);
40 public void addTargets(Set
<String
> targetSet
) {
41 targets
.addAll(targetSet
);
44 public void addTagnames(String tagnameList
) {
46 // tagnameList some tagnames separated by space " "
48 if (tagnameList
== null) {
52 addTagnames(tagnameList
.split(" "));
55 public void addTagnames(String
[] tagnameArray
) {
56 if (tagnameArray
== null ) {
59 for (int i
= 0; i
< tagnameArray
.length
; i
++) {
60 tagnames
.add(tagnameArray
[i
]);
64 public void addTagnames(Set
<String
> tagnameSet
) {
65 tagnames
.addAll(tagnameSet
);
68 public void addArchs(String archList
) {
70 // archList some archs separated by space " "
72 if (archList
== null) {
76 addArchs(archList
.split(" "));
79 public void addArchs(String
[] archArray
) {
80 if (archArray
== null ) {
83 for (int i
= 0; i
< archArray
.length
; i
++) {
84 archs
.add(archArray
[i
]);
88 public void addArchs(Set
<String
> archSet
) {
89 archs
.addAll(archSet
);
92 public void addCommands(String toolChain
, String commandList
) {
94 // archList some archs separated by space " "
96 if (commandList
== null || commandList
.length() == 0) {
99 addCommands(commandList
.split(" "));
102 public void addCommands(String
[] commandArray
) {
103 if (commandArray
== null ) {
106 for (int i
= 0; i
< commandArray
.length
; i
++) {
107 commands
.add(commandArray
[i
]);
111 public void addCommands(String toolChain
, String
[] commandArray
) {
112 if (commandArray
== null) {
116 Set
<String
> toolChainCommandSet
= commandMap
.get(toolChain
);
117 if (toolChainCommandSet
== null) {
118 toolChainCommandSet
= new LinkedHashSet
<String
>();
119 commandMap
.put(toolChain
, toolChainCommandSet
);
121 for (int i
= 0; i
< commandArray
.length
; i
++) {
122 commands
.add(commandArray
[i
]);
123 toolChainCommandSet
.add(commandArray
[i
]);
127 public void addCommands(String toolChain
, Set
<String
> commandSet
) {
128 if (commandSet
== null) {
131 Set
<String
> toolChainCommandSet
= commandMap
.get(toolChain
);
132 if (toolChainCommandSet
== null) {
133 toolChainCommandSet
= new LinkedHashSet
<String
>();
134 commandMap
.put(toolChain
, toolChainCommandSet
);
136 commands
.addAll(commandSet
);
137 toolChainCommandSet
.addAll(commandSet
);
140 public ToolChainInfo
union(ToolChainInfo info
) {
141 ToolChainInfo result
= new ToolChainInfo();
142 result
.addTargets(union(this.targets
, info
.targets
));
143 result
.addTagnames(union(this.tagnames
, info
.tagnames
));
144 result
.addArchs(union(this.archs
, info
.archs
));
145 //result.addCommands(union(this.getCommands(), info.getCommands()));
149 public ToolChainInfo
intersection(ToolChainInfo info
) {
150 // System.out.println(this + "\n" + info);
151 ToolChainInfo result
= new ToolChainInfo();
152 result
.addTargets(intersection(this.targets
, info
.targets
));
153 result
.addTagnames(intersection(this.tagnames
, info
.tagnames
));
154 result
.addArchs(intersection(this.archs
, info
.archs
));
155 // result.addCommands(union(this.commands, info.commands));
156 // System.out.println("result: " + result);
160 private Set
<String
> union(Set
<String
> set1
, Set
<String
> set2
) {
161 Set
<String
> result
= new LinkedHashSet
<String
>();
168 private Set
<String
> intersection(Set
<String
> set1
, Set
<String
> set2
) {
169 Set
<String
> result
= new LinkedHashSet
<String
>();
170 boolean set1HasWildcard
= set1
.contains("*");
171 boolean set2HasWildcard
= set2
.contains("*");
173 if (set1HasWildcard
&& set2HasWildcard
) {
176 } else if (set1HasWildcard
) {
178 } else if (set2HasWildcard
) {
182 result
.retainAll(set2
);
185 // result.remove("*");
189 public String
[] getTargets() {
190 return (String
[])targets
.toArray(new String
[targets
.size()]);
193 public String
[] getTagnames() {
194 return (String
[])tagnames
.toArray(new String
[tagnames
.size()]);
197 public String
[] getArchs() {
198 return (String
[])archs
.toArray(new String
[archs
.size()]);
201 public String
[] getCommands() {
202 return (String
[])commands
.toArray(new String
[commands
.size()]);
205 public Set
<String
> getCommands(String toolChain
) {
206 return commandMap
.get(toolChain
);
209 public String
toString() {
210 return targets
+ "\n" + tagnames
+ "\n" + archs
+ "\n" + commands
;
213 public void normalize() {
215 tagnames
.remove("*");
217 commands
.remove("*");