587
|
1 |
/*
|
628
|
2 |
* Copyright (c) 2007-2008 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of the License "Eclipse Public License v1.0"
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description:
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
587
|
18 |
package com.nokia.helium.sbs.ant.types;
|
|
19 |
|
|
20 |
import java.util.Collection;
|
|
21 |
import java.util.Vector;
|
588
|
22 |
|
628
|
23 |
import org.apache.tools.ant.BuildException;
|
588
|
24 |
import org.apache.tools.ant.types.DataType;
|
587
|
25 |
import org.apache.tools.ant.types.Reference;
|
|
26 |
|
628
|
27 |
import com.nokia.helium.core.ant.MappedVariable;
|
|
28 |
import com.nokia.helium.core.ant.VariableMap;
|
|
29 |
import com.nokia.helium.core.ant.types.VariableSet;
|
|
30 |
|
587
|
31 |
/**
|
628
|
32 |
* Helper class to store the variable set (list of variables with name / value pair)
|
|
33 |
*
|
|
34 |
* <hlm:sbsinput id="export-sbs-ec"> <sbsoptions refid="exportSBS"
|
|
35 |
* /> <sbsmakeoptions refid="exportSBSEC" /> </hlm:sbsinput>
|
587
|
36 |
*
|
|
37 |
* @ant.type name="sbsinput" category="SBS"
|
|
38 |
*/
|
588
|
39 |
public class SBSInput extends DataType implements VariableMap {
|
628
|
40 |
|
587
|
41 |
private Vector<VariableSet> sbsOptions = new Vector<VariableSet>();
|
|
42 |
private Vector<SBSMakeOptions> sbsMakeOptions = new Vector<SBSMakeOptions>();
|
|
43 |
private Vector<SBSInput> sbsInputList = new Vector<SBSInput>();
|
|
44 |
|
|
45 |
/**
|
628
|
46 |
* Creates an empty variable element and adds it to the variables list
|
|
47 |
*
|
587
|
48 |
* @return empty Variable pair
|
|
49 |
*/
|
|
50 |
public VariableSet createSBSOptions() {
|
|
51 |
SBSInput sbsInput = new SBSInput();
|
628
|
52 |
VariableSet varSet = new VariableSet();
|
587
|
53 |
sbsInput.addSBSOptions(varSet);
|
|
54 |
sbsInputList.add(sbsInput);
|
|
55 |
return varSet;
|
|
56 |
}
|
|
57 |
|
|
58 |
/**
|
628
|
59 |
* Adds sbs options to variableset. Called by ant whenever the varSet is added to current sbs
|
|
60 |
* options.
|
|
61 |
*
|
587
|
62 |
* @param varSet, variable set to be added to current sbs options.
|
|
63 |
*/
|
|
64 |
public void addSBSOptions(VariableSet varSet) {
|
|
65 |
sbsOptions.add(varSet);
|
|
66 |
}
|
628
|
67 |
|
587
|
68 |
/**
|
628
|
69 |
* Creates an empty sbs make options and add it sbs make options list
|
|
70 |
*
|
587
|
71 |
* @return empty Variable pair
|
|
72 |
*/
|
|
73 |
public VariableSet createSBSMakeOptions() {
|
|
74 |
SBSInput sbsInput = new SBSInput();
|
628
|
75 |
SBSMakeOptions varSet = new SBSMakeOptions();
|
587
|
76 |
sbsInput.addSBSMakeOptions(varSet);
|
|
77 |
sbsInputList.add(sbsInput);
|
|
78 |
return varSet;
|
|
79 |
}
|
|
80 |
|
|
81 |
/**
|
628
|
82 |
* Adds sbs make options to variableset. Called by ant whenever the make option is added to
|
|
83 |
* current sbs options.
|
|
84 |
*
|
587
|
85 |
* @param varSet, variable set to be added to current sbs options.
|
|
86 |
*/
|
|
87 |
public void addSBSMakeOptions(SBSMakeOptions varSet) {
|
|
88 |
sbsMakeOptions.add(varSet);
|
|
89 |
}
|
|
90 |
|
|
91 |
/**
|
628
|
92 |
* Creates a new sbsinput type for the current, and the created sbs input is only containing
|
|
93 |
* refid of sbs options / sbs makeoptions.
|
|
94 |
*
|
587
|
95 |
* @return empty sbsinput type.
|
|
96 |
*/
|
|
97 |
public SBSInput createSBSInput() {
|
|
98 |
SBSInput sbsInput = new SBSInput();
|
|
99 |
sbsInputList.add(sbsInput);
|
|
100 |
return sbsInput;
|
|
101 |
}
|
|
102 |
|
|
103 |
/**
|
628
|
104 |
* Helper function to provide the sbs options associated with this sbsinput.
|
|
105 |
*
|
587
|
106 |
* @return sbs options associated with this sbs input.
|
|
107 |
*/
|
|
108 |
public Vector<VariableSet> getSBSOptions() {
|
|
109 |
return sbsOptions;
|
|
110 |
}
|
|
111 |
|
|
112 |
/**
|
628
|
113 |
* Helper function to provide the sbs make options associated with this sbsinput.
|
|
114 |
*
|
587
|
115 |
* @return sbs make options associated with this sbs input.
|
|
116 |
*/
|
|
117 |
public Vector<SBSMakeOptions> getSBSMakeOptions() {
|
|
118 |
return sbsMakeOptions;
|
|
119 |
}
|
|
120 |
|
|
121 |
/**
|
628
|
122 |
* Internal function to validate the sbsinput and throw exception if the input is not valid.
|
587
|
123 |
*/
|
|
124 |
private void validateInput() {
|
|
125 |
if (getRefid() != null && (!sbsMakeOptions.isEmpty() || !sbsOptions.isEmpty())) {
|
|
126 |
throw new BuildException("SBSInput with refid should not have sbsoptions / sbsmakeoptions");
|
|
127 |
}
|
|
128 |
}
|
|
129 |
|
|
130 |
/**
|
628
|
131 |
* Internal function to recursively gothrough the sbs options refered by this sbsinput and
|
|
132 |
* provides the complete list of variables associated with this input.
|
|
133 |
*
|
587
|
134 |
* @return collection of variableset associatied with this sbsinput.
|
|
135 |
*/
|
|
136 |
private Vector<VariableSet> getSBSOptions(SBSInput sbsInput) {
|
|
137 |
Vector<VariableSet> fullList = null;
|
|
138 |
sbsInput.validateInput();
|
|
139 |
Reference refId = sbsInput.getRefid();
|
|
140 |
Object sbsInputObject = null;
|
|
141 |
if (refId != null) {
|
|
142 |
try {
|
|
143 |
sbsInputObject = refId.getReferencedObject();
|
628
|
144 |
}
|
|
145 |
catch (BuildException ex) {
|
|
146 |
// log.info("Reference id of sbsinput list is not valid");
|
|
147 |
throw new BuildException("Reference id (" + refId.getRefId()
|
|
148 |
+ ") of sbsinput list is not valid");
|
587
|
149 |
}
|
|
150 |
if (sbsInputObject != null && sbsInputObject instanceof SBSInput) {
|
628
|
151 |
VariableSet options = ((SBSInput) sbsInputObject).getFullSBSOptions();
|
|
152 |
if (options != null) {
|
587
|
153 |
if (fullList == null) {
|
|
154 |
fullList = new Vector<VariableSet>();
|
|
155 |
}
|
|
156 |
fullList.add(options);
|
|
157 |
}
|
|
158 |
}
|
|
159 |
}
|
|
160 |
Vector<VariableSet> optionsList = sbsInput.getSBSOptions();
|
628
|
161 |
if (optionsList != null) {
|
587
|
162 |
if (fullList == null) {
|
|
163 |
fullList = new Vector<VariableSet>();
|
|
164 |
}
|
|
165 |
fullList.addAll(optionsList);
|
|
166 |
}
|
|
167 |
return fullList;
|
|
168 |
}
|
|
169 |
|
|
170 |
/**
|
628
|
171 |
* Internal function to recursively gothrough the sbs make options refered by this sbsinput and
|
|
172 |
* provides the complete list of sbs make options associated with this input.
|
|
173 |
*
|
587
|
174 |
* @return collection of sbs make options associatied with this sbsinput.
|
|
175 |
*/
|
|
176 |
private Vector<SBSMakeOptions> getSBSMakeOptions(SBSInput sbsInput) {
|
|
177 |
Vector<SBSMakeOptions> sbsMakeOptionsList = null;
|
|
178 |
Reference refId = sbsInput.getRefid();
|
|
179 |
Object sbsInputObject = null;
|
|
180 |
if (refId != null) {
|
|
181 |
try {
|
|
182 |
sbsInputObject = refId.getReferencedObject();
|
628
|
183 |
}
|
|
184 |
catch (BuildException ex) {
|
|
185 |
throw new BuildException("Reference id (" + refId.getRefId()
|
|
186 |
+ ") of sbsinput list is not valid");
|
587
|
187 |
}
|
|
188 |
if (sbsInputObject != null && sbsInputObject instanceof SBSInput) {
|
628
|
189 |
SBSMakeOptions options = ((SBSInput) sbsInputObject).getFullSBSMakeOptions();
|
|
190 |
if (options != null) {
|
587
|
191 |
if (sbsMakeOptionsList == null) {
|
|
192 |
sbsMakeOptionsList = new Vector<SBSMakeOptions>();
|
|
193 |
}
|
|
194 |
sbsMakeOptionsList.add(options);
|
|
195 |
}
|
|
196 |
}
|
|
197 |
}
|
|
198 |
Vector<SBSMakeOptions> options = sbsInput.getSBSMakeOptions();
|
|
199 |
if (options != null) {
|
|
200 |
if (sbsMakeOptionsList == null) {
|
|
201 |
sbsMakeOptionsList = new Vector<SBSMakeOptions>();
|
|
202 |
}
|
|
203 |
sbsMakeOptionsList.addAll(options);
|
|
204 |
}
|
|
205 |
return sbsMakeOptionsList;
|
|
206 |
}
|
|
207 |
|
|
208 |
/**
|
628
|
209 |
* Internal function to recursively gothrough the sbs make options refered by this sbsinput and
|
|
210 |
* provides the complete list of sbs make options associated with this input.
|
|
211 |
*
|
587
|
212 |
* @return collection of sbs make options associatied with this sbsinput.
|
|
213 |
*/
|
|
214 |
public VariableSet getFullSBSOptions() {
|
|
215 |
Vector<VariableSet> fullList = null;
|
|
216 |
VariableSet resultSet = null;
|
|
217 |
Vector<VariableSet> currentOptions = getSBSOptions(this);
|
|
218 |
if (currentOptions != null && !currentOptions.isEmpty()) {
|
628
|
219 |
if (fullList == null) {
|
587
|
220 |
fullList = new Vector<VariableSet>();
|
|
221 |
}
|
|
222 |
fullList.addAll(currentOptions);
|
|
223 |
}
|
|
224 |
for (SBSInput sbsInput : sbsInputList) {
|
|
225 |
Vector<VariableSet> options = getSBSOptions(sbsInput);
|
|
226 |
if (options != null && !options.isEmpty()) {
|
628
|
227 |
if (fullList == null) {
|
587
|
228 |
fullList = new Vector<VariableSet>();
|
|
229 |
}
|
|
230 |
fullList.addAll(options);
|
|
231 |
}
|
|
232 |
}
|
|
233 |
if (fullList != null) {
|
|
234 |
for (VariableSet varSet : fullList) {
|
588
|
235 |
for (MappedVariable var : varSet.getVariables()) {
|
587
|
236 |
if (resultSet == null) {
|
|
237 |
resultSet = new VariableSet();
|
|
238 |
}
|
|
239 |
resultSet.add(var);
|
|
240 |
}
|
|
241 |
}
|
|
242 |
}
|
|
243 |
return resultSet;
|
|
244 |
}
|
|
245 |
|
|
246 |
/**
|
628
|
247 |
* Internal function to recursively gothrough the sbs make options refered by this sbsinput and
|
|
248 |
* provides the complete list of sbs make options associated with this input.
|
|
249 |
*
|
587
|
250 |
* @return collection of sbs make options associatied with this sbsinput.
|
|
251 |
*/
|
|
252 |
public SBSMakeOptions getFullSBSMakeOptions() {
|
|
253 |
Vector<SBSMakeOptions> sbsMakeOptionsList = null;
|
|
254 |
SBSMakeOptions resultSet = null;
|
|
255 |
Vector<SBSMakeOptions> currentOptions = getSBSMakeOptions(this);
|
|
256 |
if (currentOptions != null && !currentOptions.isEmpty()) {
|
628
|
257 |
if (sbsMakeOptionsList == null) {
|
587
|
258 |
sbsMakeOptionsList = new Vector<SBSMakeOptions>();
|
|
259 |
}
|
|
260 |
sbsMakeOptionsList.addAll(currentOptions);
|
|
261 |
}
|
|
262 |
for (SBSInput sbsInput : sbsInputList) {
|
|
263 |
Vector<SBSMakeOptions> options = getSBSMakeOptions(sbsInput);
|
|
264 |
if (options != null && !options.isEmpty()) {
|
628
|
265 |
if (sbsMakeOptionsList == null) {
|
587
|
266 |
sbsMakeOptionsList = new Vector<SBSMakeOptions>();
|
|
267 |
}
|
|
268 |
sbsMakeOptionsList.addAll(options);
|
|
269 |
}
|
|
270 |
}
|
628
|
271 |
if (sbsMakeOptionsList != null) {
|
587
|
272 |
String engine = null;
|
|
273 |
String ppThreads = null;
|
|
274 |
for (SBSMakeOptions varSet : sbsMakeOptionsList) {
|
|
275 |
String currentEngine = varSet.getEngine();
|
|
276 |
String currentThread = varSet.getPPThreads();
|
|
277 |
if (currentEngine != null) {
|
|
278 |
if (engine == null) {
|
|
279 |
engine = currentEngine;
|
628
|
280 |
if (resultSet == null) {
|
587
|
281 |
resultSet = new SBSMakeOptions();
|
|
282 |
}
|
|
283 |
resultSet.setEngine(currentEngine);
|
628
|
284 |
}
|
|
285 |
else {
|
|
286 |
if (!engine.equals(currentEngine)) {
|
|
287 |
throw new BuildException("inheriting engine types mismatch: " + engine
|
|
288 |
+ " != " + currentEngine);
|
587
|
289 |
}
|
|
290 |
}
|
|
291 |
}
|
628
|
292 |
if (resultSet == null) {
|
587
|
293 |
resultSet = new SBSMakeOptions();
|
|
294 |
}
|
|
295 |
if (ppThreads == null && currentThread != null) {
|
|
296 |
ppThreads = currentThread;
|
|
297 |
resultSet.setPPThreads(ppThreads);
|
|
298 |
}
|
588
|
299 |
for (MappedVariable var : varSet.getVariables()) {
|
587
|
300 |
resultSet.add(var);
|
|
301 |
}
|
|
302 |
}
|
|
303 |
}
|
|
304 |
return resultSet;
|
|
305 |
}
|
628
|
306 |
|
587
|
307 |
/**
|
|
308 |
* Helper function to return the collection of variabes associated with this
|
628
|
309 |
*
|
587
|
310 |
* @return collection of sbs options associatied with this sbsinput.
|
|
311 |
*/
|
588
|
312 |
public Collection<MappedVariable> getVariables() {
|
|
313 |
Collection<MappedVariable> varList = null;
|
628
|
314 |
VariableSet options = getFullSBSOptions();
|
587
|
315 |
if (options != null) {
|
|
316 |
varList = options.getVariables();
|
|
317 |
}
|
|
318 |
return varList;
|
|
319 |
}
|
|
320 |
} |