587
|
1 |
/*
|
|
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 |
|
|
18 |
package com.nokia.helium.sbs.ant.types;
|
|
19 |
|
628
|
20 |
import java.util.List;
|
|
21 |
|
|
22 |
import org.apache.tools.ant.BuildException;
|
587
|
23 |
import org.apache.tools.ant.types.Reference;
|
628
|
24 |
|
|
25 |
import com.nokia.helium.core.ant.types.VariableSet;
|
587
|
26 |
|
|
27 |
/**
|
|
28 |
* Helper class to store the variable set (list of variables
|
|
29 |
* with name / value pair) for sbsmakeoptions inheriting from argSet.
|
|
30 |
|
|
31 |
* * <sbsbuild id="sbs.dfs_build_ncp">
|
|
32 |
* <sbsinput refid="dfs_build_ncp_input"/>
|
|
33 |
* </sbsbuild>
|
|
34 |
|
|
35 |
* <hlm:sbsmakeoptions id="commonEMakeOptions" engine="emake">
|
|
36 |
* <arg name="--emake-emulation" value="gmake" />
|
|
37 |
* <arg name="--emake-annodetail" value="basic,history,waiting" />
|
|
38 |
* <arg name="--emake-class" value="${ec.build.class}" />
|
|
39 |
* <arg name="--emake-historyfile" value="${build.log.dir}/ec_history/raptor_clean.emake.data" />
|
|
40 |
* <arg name="--case-sensitive" value="0" />
|
|
41 |
* <arg name="--emake-root" value="${build.drive}/;${env.EMAKE_ROOT};${helium.dir};${env.SBS_HOME}" />
|
|
42 |
* </hlm:sbsmakeoptions>
|
|
43 |
*
|
|
44 |
* @ant.type name="sbsMakeOptions" category="SBS"
|
|
45 |
*/
|
|
46 |
public class SBSMakeOptions extends VariableSet {
|
|
47 |
|
|
48 |
private String engine;
|
|
49 |
|
|
50 |
private String ppThreads;
|
|
51 |
|
|
52 |
private boolean initialized;
|
|
53 |
|
|
54 |
/**
|
|
55 |
* Helper function called by ant to create the new sbs make options
|
|
56 |
*/
|
|
57 |
public SBSMakeOptions createSBSMakeOptions() {
|
|
58 |
SBSMakeOptions options = new SBSMakeOptions();
|
|
59 |
add(options);
|
|
60 |
return options;
|
|
61 |
}
|
|
62 |
|
|
63 |
/**
|
|
64 |
* Helper function to add the created varset
|
|
65 |
* @param filter to be added to the varset
|
|
66 |
*/
|
|
67 |
public void add(SBSMakeOptions option) {
|
|
68 |
super.add(option);
|
|
69 |
}
|
|
70 |
|
|
71 |
/**
|
|
72 |
* Sets the engine type for this options
|
|
73 |
* @param engine for which the make options are used
|
|
74 |
*/
|
|
75 |
public void setEngine(String engineName) {
|
|
76 |
engine = engineName;
|
|
77 |
}
|
|
78 |
|
|
79 |
/**
|
|
80 |
* Sets the ppthreads (no. bldinfs to process)
|
|
81 |
* @param ppBlock no. bldinfs to process per block
|
|
82 |
*/
|
|
83 |
public void setPPThreads(String ppBlock) {
|
|
84 |
ppThreads = ppBlock;
|
|
85 |
}
|
|
86 |
|
|
87 |
/**
|
|
88 |
* Returns the ppthreads required for parallel parsing support from raptor
|
|
89 |
* available from 2.11.2 of raptor for parallel builds.
|
|
90 |
* @return the no. of threads to be used for parallel parsing the makefile.
|
|
91 |
*/
|
|
92 |
public String getPPThreads() {
|
|
93 |
if (ppThreads == null) {
|
|
94 |
if (!initialized) {
|
|
95 |
initializeAll();
|
|
96 |
initialized = true;
|
|
97 |
}
|
|
98 |
}
|
|
99 |
return ppThreads;
|
|
100 |
}
|
|
101 |
|
|
102 |
/**
|
|
103 |
* Returns the engine name
|
|
104 |
* @return type of make engine
|
|
105 |
*/
|
|
106 |
public String getEngine() {
|
|
107 |
if (engine == null) {
|
|
108 |
if (!initialized) {
|
|
109 |
initializeAll();
|
|
110 |
initialized = true;
|
|
111 |
}
|
|
112 |
if (engine == null) {
|
|
113 |
throw new BuildException("engine should not be null");
|
|
114 |
}
|
|
115 |
}
|
|
116 |
return engine;
|
|
117 |
}
|
|
118 |
|
|
119 |
/**
|
|
120 |
* Initializes all the variableset associated with this options. First
|
|
121 |
* initializes the current object and then the objects embedded within this
|
|
122 |
* input.
|
|
123 |
*/
|
|
124 |
private void initializeAll() {
|
|
125 |
List<VariableSet> varSets = getVariableSets();
|
|
126 |
initialize(this);
|
|
127 |
for (VariableSet varSet : varSets) {
|
|
128 |
initialize(varSet);
|
|
129 |
}
|
|
130 |
}
|
|
131 |
|
|
132 |
/**
|
|
133 |
* Initializes individual variable set
|
|
134 |
*/
|
|
135 |
private void initialize(VariableSet varSet) {
|
|
136 |
SBSMakeOptions makeOptions = null;
|
|
137 |
Reference refId = varSet.getRefid();
|
|
138 |
if (refId != null) {
|
|
139 |
try {
|
|
140 |
makeOptions = (SBSMakeOptions)refId.getReferencedObject();
|
|
141 |
if (makeOptions != null) {
|
|
142 |
String refEngine = makeOptions.getEngine();
|
|
143 |
String threads = makeOptions.getPPThreads();
|
|
144 |
if (engine != null && !(engine.equals(refEngine))) {
|
|
145 |
throw new BuildException(" Config's engine type " + engine + " not matching with reference : "
|
|
146 |
+ refId.getRefId() + ": engine: " + refEngine);
|
|
147 |
}
|
|
148 |
if (ppThreads == null && threads != null) {
|
|
149 |
ppThreads = threads;
|
|
150 |
}
|
|
151 |
if (engine == null) {
|
|
152 |
engine = refEngine;
|
|
153 |
}
|
|
154 |
}
|
|
155 |
} catch ( BuildException ex) {
|
|
156 |
throw new BuildException(ex.getMessage());
|
|
157 |
}
|
|
158 |
}
|
|
159 |
}
|
|
160 |
} |