]>
git.proxmox.com Git - mirror_edk2.git/blob - Tools/Source/GenBuild/org/tianocore/build/toolchain/ToolChainInfo.java
2 This file is to define ToolChainInfo class.
4 Copyright (c) 2006, Intel Corporation
5 All rights reserved. This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
14 package org
.tianocore
.build
.toolchain
;
16 import java
.util
.HashMap
;
17 import java
.util
.LinkedHashSet
;
21 public class ToolChainInfo
{
25 private Set
<String
> targets
= new LinkedHashSet
<String
>();
27 // tool chain tag name set
29 private Set
<String
> tagnames
= new LinkedHashSet
<String
>();
33 private Set
<String
> archs
= new LinkedHashSet
<String
>();
37 private Set
<String
> commands
= new LinkedHashSet
<String
>();
39 // build commands for specific tool chain
41 private Map
<String
, Set
<String
>> commandMap
= new HashMap
<String
, Set
<String
>>();
43 Add a list of targets in the form of string separated by space
45 @param targetList target list string
47 public void addTargets(String targetList
) {
49 // targetList some targets separated by space " "
51 if (targetList
== null) {
55 addTargets(targetList
.split(" "));
58 Add a list of targets in the form of string array
60 @param targetArray target string array
62 public void addTargets(String
[] targetArray
) {
63 if (targetArray
== null ) {
66 for (int i
= 0; i
< targetArray
.length
; i
++) {
67 targets
.add(targetArray
[i
]);
71 Add a list of target in the form of set
73 @param targetSet target string set
75 public void addTargets(Set
<String
> targetSet
) {
76 targets
.addAll(targetSet
);
79 Add a list of tool chain tag name in the form of string separated by space
83 public void addTagnames(String tagnameList
) {
85 // tagnameList some tagnames separated by space " "
87 if (tagnameList
== null) {
91 addTagnames(tagnameList
.split(" "));
94 public void addTagnames(String
[] tagnameArray
) {
95 if (tagnameArray
== null ) {
98 for (int i
= 0; i
< tagnameArray
.length
; i
++) {
99 tagnames
.add(tagnameArray
[i
]);
103 public void addTagnames(Set
<String
> tagnameSet
) {
104 tagnames
.addAll(tagnameSet
);
107 public void addArchs(String archList
) {
109 // archList some archs separated by space " "
111 if (archList
== null) {
115 addArchs(archList
.split(" "));
118 public void addArchs(String
[] archArray
) {
119 if (archArray
== null ) {
122 for (int i
= 0; i
< archArray
.length
; i
++) {
123 archs
.add(archArray
[i
]);
127 public void addArchs(Set
<String
> archSet
) {
128 archs
.addAll(archSet
);
131 public void addCommands(String toolChain
, String commandList
) {
133 // archList some archs separated by space " "
135 if (commandList
== null || commandList
.length() == 0) {
138 addCommands(commandList
.split(" "));
141 public void addCommands(String
[] commandArray
) {
142 if (commandArray
== null ) {
145 for (int i
= 0; i
< commandArray
.length
; i
++) {
146 commands
.add(commandArray
[i
]);
150 public void addCommands(String toolChain
, String
[] commandArray
) {
151 if (commandArray
== null) {
155 Set
<String
> toolChainCommandSet
= commandMap
.get(toolChain
);
156 if (toolChainCommandSet
== null) {
157 toolChainCommandSet
= new LinkedHashSet
<String
>();
158 commandMap
.put(toolChain
, toolChainCommandSet
);
160 for (int i
= 0; i
< commandArray
.length
; i
++) {
161 commands
.add(commandArray
[i
]);
162 toolChainCommandSet
.add(commandArray
[i
]);
166 public void addCommands(String toolChain
, Set
<String
> commandSet
) {
167 if (commandSet
== null) {
170 Set
<String
> toolChainCommandSet
= commandMap
.get(toolChain
);
171 if (toolChainCommandSet
== null) {
172 toolChainCommandSet
= new LinkedHashSet
<String
>();
173 commandMap
.put(toolChain
, toolChainCommandSet
);
175 commands
.addAll(commandSet
);
176 toolChainCommandSet
.addAll(commandSet
);
179 public ToolChainInfo
union(ToolChainInfo info
) {
180 ToolChainInfo result
= new ToolChainInfo();
181 result
.addTargets(union(this.targets
, info
.targets
));
182 result
.addTagnames(union(this.tagnames
, info
.tagnames
));
183 result
.addArchs(union(this.archs
, info
.archs
));
187 public ToolChainInfo
intersection(ToolChainInfo info
) {
188 ToolChainInfo result
= new ToolChainInfo();
189 result
.addTargets(intersection(this.targets
, info
.targets
));
190 result
.addTagnames(intersection(this.tagnames
, info
.tagnames
));
191 result
.addArchs(intersection(this.archs
, info
.archs
));
195 private Set
<String
> union(Set
<String
> set1
, Set
<String
> set2
) {
196 Set
<String
> result
= new LinkedHashSet
<String
>();
203 private Set
<String
> intersection(Set
<String
> set1
, Set
<String
> set2
) {
204 Set
<String
> result
= new LinkedHashSet
<String
>();
205 boolean set1HasWildcard
= set1
.contains("*");
206 boolean set2HasWildcard
= set2
.contains("*");
208 if (set1HasWildcard
&& set2HasWildcard
) {
211 } else if (set1HasWildcard
) {
213 } else if (set2HasWildcard
) {
217 result
.retainAll(set2
);
223 public String
[] getTargets() {
224 return (String
[])targets
.toArray(new String
[targets
.size()]);
227 public String
[] getTagnames() {
228 return (String
[])tagnames
.toArray(new String
[tagnames
.size()]);
231 public String
[] getArchs() {
232 return (String
[])archs
.toArray(new String
[archs
.size()]);
235 public String
[] getCommands() {
236 return (String
[])commands
.toArray(new String
[commands
.size()]);
239 public Set
<String
> getCommands(String toolChain
) {
240 return commandMap
.get(toolChain
);
243 public String
toString() {
244 return targets
+ "\n" + tagnames
+ "\n" + archs
+ "\n" + commands
;
247 public void normalize() {
249 tagnames
.remove("*");
251 commands
.remove("*");