1
/*******************************************************************************
2
* Copyright (c) 2004, 2008 Intel Corporation and others.
3
* All rights reserved. This program and the accompanying materials
4
* are made available under the terms of the Eclipse Public License v1.0
5
* which accompanies this distribution, and is available at
6
* http://www.eclipse.org/legal/epl-v10.html
9
* Intel Corporation - Initial API and implementation
10
*******************************************************************************/
11
package org.eclipse.cdt.managedbuilder.internal.core;
13
import java.util.ArrayList;
14
import java.util.Arrays;
15
import java.util.Collection;
16
import java.util.HashMap;
17
import java.util.HashSet;
18
import java.util.Iterator;
19
import java.util.List;
22
import java.util.SortedMap;
23
import java.util.StringTokenizer;
25
import org.eclipse.cdt.build.internal.core.scannerconfig.CfgDiscoveredPathManager.PathInfoCache;
26
import org.eclipse.cdt.core.settings.model.ICStorageElement;
27
import org.eclipse.cdt.core.settings.model.extension.CTargetPlatformData;
28
import org.eclipse.cdt.core.settings.model.util.CDataUtil;
29
import org.eclipse.cdt.internal.core.cdtvariables.StorableCdtVariables;
30
import org.eclipse.cdt.managedbuilder.buildproperties.IBuildPropertyType;
31
import org.eclipse.cdt.managedbuilder.buildproperties.IBuildPropertyValue;
32
import org.eclipse.cdt.managedbuilder.core.IBuildObject;
33
import org.eclipse.cdt.managedbuilder.core.IBuildPropertiesRestriction;
34
import org.eclipse.cdt.managedbuilder.core.IBuilder;
35
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
36
import org.eclipse.cdt.managedbuilder.core.IFolderInfo;
37
import org.eclipse.cdt.managedbuilder.core.IManagedConfigElement;
38
import org.eclipse.cdt.managedbuilder.core.IManagedIsToolChainSupported;
39
import org.eclipse.cdt.managedbuilder.core.IManagedProject;
40
import org.eclipse.cdt.managedbuilder.core.IOptionPathConverter;
41
import org.eclipse.cdt.managedbuilder.core.IOutputType;
42
import org.eclipse.cdt.managedbuilder.core.IProjectType;
43
import org.eclipse.cdt.managedbuilder.core.IResourceInfo;
44
import org.eclipse.cdt.managedbuilder.core.ITargetPlatform;
45
import org.eclipse.cdt.managedbuilder.core.ITool;
46
import org.eclipse.cdt.managedbuilder.core.IToolChain;
47
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
48
import org.eclipse.cdt.managedbuilder.envvar.IConfigurationEnvironmentVariableSupplier;
49
import org.eclipse.cdt.managedbuilder.internal.dataprovider.ConfigurationDataProvider;
50
import org.eclipse.cdt.managedbuilder.internal.enablement.OptionEnablementExpression;
51
import org.eclipse.cdt.managedbuilder.macros.IConfigurationBuildMacroSupplier;
52
import org.eclipse.core.runtime.CoreException;
53
import org.eclipse.core.runtime.IConfigurationElement;
54
import org.eclipse.core.runtime.IExtension;
55
import org.eclipse.core.runtime.IExtensionPoint;
56
import org.eclipse.core.runtime.IPath;
57
import org.eclipse.core.runtime.Platform;
58
import org.eclipse.core.runtime.PluginVersionIdentifier;
60
public class ToolChain extends HoldsOptions implements IToolChain, IBuildPropertiesRestriction, IMatchKeyProvider, IRealBuildObjectAssociation {
62
private static final String EMPTY_STRING = new String();
64
private static final String REBUILD_STATE = "rebuildState"; //$NON-NLS-1$
66
private static final boolean resolvedDefault = true;
69
// Note that superClass itself is defined in the base and that the methods
70
// getSuperClass() and setSuperClassInternal(), defined in ToolChain must be used
71
// to access it. This avoids widespread casts from IHoldsOptions to IToolChain.
72
private String superClassId;
73
// Parent and children
74
private IConfiguration config;
75
private List<Tool> toolList;
76
private Map<String, Tool> toolMap;
77
private TargetPlatform targetPlatform;
78
private Builder builder;
79
// Managed Build model attributes
80
private String unusedChildren;
81
private String errorParserIds;
82
private List<String> osList;
83
private List<String> archList;
84
private String targetToolIds;
85
private String secondaryOutputIds;
86
private Boolean isAbstract;
87
private String scannerConfigDiscoveryProfileId;
88
private String versionsSupported;
89
private String convertToId;
90
private IConfigurationElement managedIsToolChainSupportedElement = null;
91
private IManagedIsToolChainSupported managedIsToolChainSupported = null;
92
private IConfigurationElement environmentVariableSupplierElement = null;
93
private IConfigurationEnvironmentVariableSupplier environmentVariableSupplier = null;
94
private IConfigurationElement buildMacroSupplierElement = null;
95
private IConfigurationBuildMacroSupplier buildMacroSupplier = null;
96
private IConfigurationElement pathconverterElement = null ;
97
private IOptionPathConverter optionPathConverter = null ;
98
private Boolean supportsManagedBuild;
99
private boolean isTest;
100
private SupportedProperties supportedProperties;
101
private String nonInternalBuilderId;
104
private boolean isExtensionToolChain = false;
105
private boolean isDirty = false;
106
private boolean resolved = resolvedDefault;
108
//used for loadding pre-4.0 projects only
109
private StorableCdtVariables userDefinedMacros;
110
//holds user-defined macros
111
// private StorableEnvironment userDefinedEnvironment;
113
private IConfigurationElement previousMbsVersionConversionElement = null;
114
private IConfigurationElement currentMbsVersionConversionElement = null;
115
private boolean rebuildState;
116
private BooleanExpressionApplicabilityCalculator booleanExpressionCalculator;
118
private List identicalList;
119
private Set<String> unusedChildrenSet;
122
private IFolderInfo parentFolderInfo;
124
private PathInfoCache discoveredInfo;
125
private Boolean isRcTypeBasedDiscovery;
129
* C O N S T R U C T O R S
133
* This constructor is called to create a tool-chain defined by an extension point in
134
* a plugin manifest file, or returned by a dynamic element provider
136
* @param parent The IConfiguration parent of this tool-chain, or <code>null</code> if
137
* defined at the top level
138
* @param element The tool-chain definition from the manifest file or a dynamic element
140
* @param managedBuildRevision the fileVersion of Managed Build System
142
public ToolChain(IFolderInfo folderInfo, IManagedConfigElement element, String managedBuildRevision) {
143
// setup for resolving
147
if(folderInfo != null){
148
this.config = folderInfo.getParent();
149
parentFolderInfo = folderInfo;
152
isExtensionToolChain = true;
154
// Set the managedBuildRevision
155
setManagedBuildRevision(managedBuildRevision);
157
IManagedConfigElement enablements[] = element.getChildren(OptionEnablementExpression.NAME);
158
if(enablements.length > 0)
159
booleanExpressionCalculator = new BooleanExpressionApplicabilityCalculator(enablements);
161
loadFromManifest(element);
163
// Hook me up to the Managed Build Manager
164
ManagedBuildManager.addExtensionToolChain(this);
166
// Load the TargetPlatform child
167
IManagedConfigElement[] targetPlatforms =
168
element.getChildren(ITargetPlatform.TARGET_PLATFORM_ELEMENT_NAME);
169
if (targetPlatforms.length < 1 || targetPlatforms.length > 1) {
170
// TODO: Report error
172
if (targetPlatforms.length > 0) {
173
targetPlatform = new TargetPlatform(this, targetPlatforms[0], managedBuildRevision);
176
// Load the Builder child
177
IManagedConfigElement[] builders =
178
element.getChildren(IBuilder.BUILDER_ELEMENT_NAME);
179
if (builders.length < 1 || builders.length > 1) {
180
// TODO: Report error
182
if (builders.length > 0) {
183
builder = new Builder(this, builders[0], managedBuildRevision);
187
IManagedConfigElement[] toolChainElements = element.getChildren();
188
for (int l = 0; l < toolChainElements.length; ++l) {
189
IManagedConfigElement toolChainElement = toolChainElements[l];
190
if (loadChild(toolChainElement)) {
192
} else if (toolChainElement.getName().equals(ITool.TOOL_ELEMENT_NAME)) {
193
Tool toolChild = new Tool(this, toolChainElement, managedBuildRevision);
195
} else if (toolChainElement.getName().equals(SupportedProperties.SUPPORTED_PROPERTIES)){
196
loadProperties(toolChainElement);
202
* This constructor is called to create a ToolChain whose attributes and children will be
203
* added by separate calls.
205
* @param Configuration The parent of the tool chain, if any
206
* @param ToolChain The superClass, if any
207
* @param String The id for the new tool chain
208
* @param String The name for the new tool chain
209
* @param boolean Indicates whether this is an extension element or a managed project element
211
public ToolChain(IFolderInfo folderInfo, IToolChain superClass, String Id, String name, boolean isExtensionElement) {
212
super(resolvedDefault);
213
this.config = folderInfo.getParent();
214
parentFolderInfo = folderInfo;
216
setSuperClassInternal(superClass);
217
setManagedBuildRevision(config.getManagedBuildRevision());
219
if (getSuperClass() != null) {
220
superClassId = getSuperClass().getId();
224
setVersion(getVersionFromId());
226
isExtensionToolChain = isExtensionElement;
227
if (isExtensionElement) {
228
// Hook me up to the Managed Build Manager
229
ManagedBuildManager.addExtensionToolChain(this);
232
setRebuildState(true);
237
* Create a <code>ToolChain</code> based on the specification stored in the
238
* project file (.cdtbuild).
240
* @param parent The <code>IConfiguration</code> the tool-chain will be added to.
241
* @param element The XML element that contains the tool-chain settings.
242
* @param managedBuildRevision the fileVersion of Managed Build System
244
public ToolChain(IFolderInfo folderInfo, ICStorageElement element, String managedBuildRevision) {
245
super(resolvedDefault);
246
this.config = folderInfo.getParent();
247
parentFolderInfo = folderInfo;
249
isExtensionToolChain = false;
251
// Set the managedBuildRevision
252
setManagedBuildRevision(managedBuildRevision);
254
// Initialize from the XML attributes
255
loadFromProject(element);
258
ICStorageElement configElements[] = element.getChildren();
259
for (int i = 0; i < configElements.length; ++i) {
260
ICStorageElement configElement = configElements[i];
261
if (loadChild(configElement)) {
263
} else if (configElement.getName().equals(ITool.TOOL_ELEMENT_NAME)) {
264
Tool tool = new Tool(this, configElement, managedBuildRevision);
266
}else if (configElement.getName().equals(ITargetPlatform.TARGET_PLATFORM_ELEMENT_NAME)) {
267
if (targetPlatform != null) {
268
// TODO: report error
270
targetPlatform = new TargetPlatform(this, configElement, managedBuildRevision);
271
}else if (configElement.getName().equals(IBuilder.BUILDER_ELEMENT_NAME)) {
272
if (builder != null) {
273
// TODO: report error
275
builder = new Builder(this, configElement, managedBuildRevision);
276
} else if (configElement.getName().equals("macros")) { //$NON-NLS-1$
277
//load user-defined macros
278
userDefinedMacros = new StorableCdtVariables(configElement, false);
282
String rebuild = PropertyManager.getInstance().getProperty(this, REBUILD_STATE);
283
if(rebuild == null || Boolean.valueOf(rebuild).booleanValue())
289
* Create a <code>ToolChain</code> based upon an existing tool chain.
291
* @param parent The <code>IConfiguration</code> the tool-chain will be added to.
292
* @param toolChain The existing tool-chain to clone.
294
public ToolChain(IFolderInfo folderInfo, String Id, String name, Map<IPath, Map<String, String>> superIdMap, ToolChain toolChain) {
295
super(resolvedDefault);
296
this.config = folderInfo.getParent();
297
parentFolderInfo = folderInfo;
298
setSuperClassInternal(toolChain.getSuperClass());
299
if (getSuperClass() != null) {
300
if (toolChain.superClassId != null) {
301
superClassId = new String(toolChain.superClassId);
307
// Set the managedBuildRevision and the version
308
setManagedBuildRevision(toolChain.getManagedBuildRevision());
309
setVersion(getVersionFromId());
311
isExtensionToolChain = false;
313
// Copy the remaining attributes
314
if(toolChain.versionsSupported != null) {
315
versionsSupported = new String(toolChain.versionsSupported);
317
if(toolChain.convertToId != null) {
318
convertToId = new String(toolChain.convertToId);
321
if (toolChain.unusedChildren != null) {
322
unusedChildren = new String(toolChain.unusedChildren);
324
if (toolChain.errorParserIds != null) {
325
errorParserIds = new String(toolChain.errorParserIds);
327
if (toolChain.osList != null) {
328
osList = new ArrayList<String>(toolChain.osList);
330
if (toolChain.archList != null) {
331
archList = new ArrayList<String>(toolChain.archList);
333
if (toolChain.targetToolIds != null) {
334
targetToolIds = new String(toolChain.targetToolIds);
336
if (toolChain.secondaryOutputIds != null) {
337
secondaryOutputIds = new String(toolChain.secondaryOutputIds);
339
if (toolChain.isAbstract != null) {
340
isAbstract = new Boolean(toolChain.isAbstract.booleanValue());
342
if (toolChain.scannerConfigDiscoveryProfileId != null) {
343
scannerConfigDiscoveryProfileId = new String(toolChain.scannerConfigDiscoveryProfileId);
346
isRcTypeBasedDiscovery = toolChain.isRcTypeBasedDiscovery;
348
supportsManagedBuild = toolChain.supportsManagedBuild;
350
managedIsToolChainSupportedElement = toolChain.managedIsToolChainSupportedElement;
351
managedIsToolChainSupported = toolChain.managedIsToolChainSupported;
353
environmentVariableSupplierElement = toolChain.environmentVariableSupplierElement;
354
environmentVariableSupplier = toolChain.environmentVariableSupplier;
356
buildMacroSupplierElement = toolChain.buildMacroSupplierElement;
357
buildMacroSupplier = toolChain.buildMacroSupplier;
359
pathconverterElement = toolChain.pathconverterElement ;
360
optionPathConverter = toolChain.optionPathConverter ;
362
nonInternalBuilderId = toolChain.nonInternalBuilderId;
364
discoveredInfo = toolChain.discoveredInfo;
366
userDefinedMacros = toolChain.userDefinedMacros;
368
// Clone the children in superclass
369
boolean copyIds = toolChain.getId().equals(id);
370
super.copyChildren(toolChain);
371
// Clone the children
372
if (toolChain.builder != null) {
376
if (toolChain.builder.getSuperClass() != null) {
377
subId = copyIds ? toolChain.builder.getId() : ManagedBuildManager.calculateChildId(
378
toolChain.builder.getSuperClass().getId(),
380
subName = toolChain.builder.getSuperClass().getName();
382
subId = copyIds ? toolChain.builder.getId() : ManagedBuildManager.calculateChildId(
383
toolChain.builder.getId(),
385
subName = toolChain.builder.getName();
388
builder = new Builder(this, subId, subName, toolChain.builder);
390
// if (toolChain.targetPlatform != null)
392
ITargetPlatform tpBase = toolChain.getTargetPlatform();
394
ITargetPlatform extTp = tpBase;
395
for(;extTp != null && !extTp.isExtensionElement();extTp = extTp.getSuperClass());
399
subId = tpBase != null ? tpBase.getId() : ManagedBuildManager.calculateChildId(getId(), null);
401
subId = extTp != null ? ManagedBuildManager.calculateChildId(extTp.getId(), null):
402
ManagedBuildManager.calculateChildId(getId(), null);
404
String subName = tpBase.getName();
406
// if (toolChain.targetPlatform.getSuperClass() != null) {
407
// subId = toolChain.targetPlatform.getSuperClass().getId() + "." + nnn; //$NON-NLS-1$
408
// subName = toolChain.targetPlatform.getSuperClass().getName();
410
// subId = toolChain.targetPlatform.getId() + "." + nnn; //$NON-NLS-1$
411
// subName = toolChain.targetPlatform.getName();
413
targetPlatform = new TargetPlatform(this, subId, subName, (TargetPlatform)tpBase);
418
IConfiguration cfg = parentFolderInfo.getParent();
419
if (toolChain.toolList != null) {
420
for (Tool toolChild : toolChain.getToolList()) {
425
ITool extTool = ManagedBuildManager.getExtensionTool(toolChild);
426
Map<String, String> curIdMap = (Map<String, String>)superIdMap.get(folderInfo.getPath());
427
if(curIdMap != null){
429
subId = (String)curIdMap.get(extTool.getId());
432
subName = toolChild.getName();
435
if (extTool != null) {
436
subId = copyIds ? toolChild.getId() : ManagedBuildManager.calculateChildId(extTool.getId(), null);
437
// subName = toolChild.getSuperClass().getName();
439
subId = copyIds ? toolChild.getId() : ManagedBuildManager.calculateChildId(toolChild.getId(), null);
440
// subName = toolChild.getName();
443
// version = ManagedBuildManager.getVersionFromIdAndVersion(tmpId);
444
// if ( version != null) { // If the 'tmpId' contains version information
445
// subId = ManagedBuildManager.getIdFromIdAndVersion(tmpId) + "." + nnn + "_" + version; //$NON-NLS-1$ //$NON-NLS-2$
447
// subId = tmpId + "." + nnn; //$NON-NLS-1$
450
// The superclass for the cloned tool is not the same as the one from the tool being cloned.
451
// The superclasses reside in different configurations.
452
ITool toolSuperClass = null;
453
String superId = null;
454
// Search for the tool in this configuration that has the same grand-superClass as the
456
ITool otherSuperTool = toolChild.getSuperClass();
457
if(otherSuperTool != null){
458
if(otherSuperTool.isExtensionElement()){
459
toolSuperClass = otherSuperTool;
461
IResourceInfo otherRcInfo = otherSuperTool.getParentResourceInfo();
462
IResourceInfo thisRcInfo = cfg.getResourceInfo(otherRcInfo.getPath(), true);
463
ITool otherExtTool = ManagedBuildManager.getExtensionTool(otherSuperTool);
464
if(otherExtTool != null){
465
if(thisRcInfo != null){
466
ITool tools[] = thisRcInfo.getTools();
467
for(int i = 0; i < tools.length; i++){
468
ITool thisExtTool = ManagedBuildManager.getExtensionTool(tools[i]);
469
if(otherExtTool.equals(thisExtTool)){
470
toolSuperClass = tools[i];
471
superId = toolSuperClass.getId();
476
superId = copyIds ? otherSuperTool.getId() : ManagedBuildManager.calculateChildId(otherExtTool.getId(), null);
477
Map<String, String> idMap = (Map<String, String>)superIdMap.get(otherRcInfo.getPath());
479
idMap = new HashMap<String, String>();
480
superIdMap.put(otherRcInfo.getPath(), idMap);
482
idMap.put(otherExtTool.getId(), superId);
487
// Tool newTool = new Tool(this, (Tool)null, subId, subName, toolChild);
491
if(toolSuperClass != null)
492
newTool = new Tool(this, toolSuperClass, subId, subName, toolChild);
493
else if(superId != null)
494
newTool = new Tool(this, superId, subId, subName, toolChild);
505
rebuildState = toolChain.rebuildState;
506
isDirty = toolChain.isDirty;
509
setRebuildState(true);
514
* E L E M E N T A T T R I B U T E R E A D E R S A N D W R I T E R S
518
* Loads the tool-chain information from the ManagedConfigElement specified in the
521
* @param element Contains the tool-chain information
523
protected void loadFromManifest(IManagedConfigElement element) {
524
ManagedBuildManager.putConfigElement(this, element);
527
setId(element.getAttribute(IBuildObject.ID));
530
setName(element.getAttribute(IBuildObject.NAME));
533
setVersion(getVersionFromId());
536
superClassId = element.getAttribute(IProjectType.SUPERCLASS);
538
// Get the unused children, if any
539
unusedChildren = element.getAttribute(IProjectType.UNUSED_CHILDREN);
542
String isAbs = element.getAttribute(IProjectType.IS_ABSTRACT);
544
isAbstract = new Boolean("true".equals(isAbs)); //$NON-NLS-1$
547
// Get the semicolon separated list of IDs of the error parsers
548
errorParserIds = element.getAttribute(ERROR_PARSERS);
550
// Get the semicolon separated list of IDs of the secondary outputs
551
secondaryOutputIds = element.getAttribute(SECONDARY_OUTPUTS);
553
// Get the target tool id
554
targetToolIds = element.getAttribute(TARGET_TOOL);
556
// Get the scanner config discovery profile id
557
scannerConfigDiscoveryProfileId = element.getAttribute(SCANNER_CONFIG_PROFILE_ID);
558
String tmp = element.getAttribute(RESOURCE_TYPE_BASED_DISCOVERY);
560
isRcTypeBasedDiscovery = Boolean.valueOf(tmp);
562
// Get the 'versionsSupported' attribute
563
versionsSupported =element.getAttribute(VERSIONS_SUPPORTED);
565
// Get the 'convertToId' attribute
566
convertToId = element.getAttribute(CONVERT_TO_ID);
568
tmp = element.getAttribute(SUPPORTS_MANAGED_BUILD);
570
supportsManagedBuild = Boolean.valueOf(tmp);
572
tmp = element.getAttribute(IS_SYSTEM);
574
isTest = Boolean.valueOf(tmp).booleanValue();
577
// Get the comma-separated list of valid OS
578
String os = element.getAttribute(OS_LIST);
580
osList = new ArrayList<String>();
581
String[] osTokens = os.split(","); //$NON-NLS-1$
582
for (int i = 0; i < osTokens.length; ++i) {
583
osList.add(osTokens[i].trim());
587
// Get the comma-separated list of valid Architectures
588
String arch = element.getAttribute(ARCH_LIST);
590
archList = new ArrayList<String>();
591
String[] archTokens = arch.split(","); //$NON-NLS-1$
592
for (int j = 0; j < archTokens.length; ++j) {
593
archList.add(archTokens[j].trim());
597
// Get the isToolchainSupported configuration element
598
String managedIsToolChainSupported = element.getAttribute(IS_TOOL_CHAIN_SUPPORTED);
599
if (managedIsToolChainSupported != null && element instanceof DefaultManagedConfigElement) {
600
managedIsToolChainSupportedElement = ((DefaultManagedConfigElement)element).getConfigurationElement();
603
// Get the environmentVariableSupplier configuration element
604
String environmentVariableSupplier = element.getAttribute(CONFIGURATION_ENVIRONMENT_SUPPLIER);
605
if(environmentVariableSupplier != null && element instanceof DefaultManagedConfigElement){
606
environmentVariableSupplierElement = ((DefaultManagedConfigElement)element).getConfigurationElement();
609
// Get the configurationMacroSupplier configuration element
610
String buildMacroSupplier = element.getAttribute(CONFIGURATION_MACRO_SUPPLIER);
611
if(buildMacroSupplier != null && element instanceof DefaultManagedConfigElement){
612
buildMacroSupplierElement = ((DefaultManagedConfigElement)element).getConfigurationElement();
615
// optionPathConverter
616
String pathconverterTypeName = element.getAttribute(ITool.OPTIONPATHCONVERTER);
617
if (pathconverterTypeName != null && element instanceof DefaultManagedConfigElement) {
618
pathconverterElement = ((DefaultManagedConfigElement)element).getConfigurationElement();
621
nonInternalBuilderId = element.getAttribute(NON_INTERNAL_BUILDER_ID);
626
* Initialize the tool-chain information from the XML element
627
* specified in the argument
629
* @param element An XML element containing the tool-chain information
631
protected void loadFromProject(ICStorageElement element) {
634
setId(element.getAttribute(IBuildObject.ID));
637
if (element.getAttribute(IBuildObject.NAME) != null) {
638
setName(element.getAttribute(IBuildObject.NAME));
642
setVersion(getVersionFromId());
645
superClassId = element.getAttribute(IProjectType.SUPERCLASS);
646
if (superClassId != null && superClassId.length() > 0) {
647
setSuperClassInternal( ManagedBuildManager.getExtensionToolChain(superClassId) );
648
// Check for migration support
649
checkForMigrationSupport();
652
// Get the unused children, if any
653
if (element.getAttribute(IProjectType.UNUSED_CHILDREN) != null) {
654
unusedChildren = element.getAttribute(IProjectType.UNUSED_CHILDREN);
658
if (element.getAttribute(IProjectType.IS_ABSTRACT) != null) {
659
String isAbs = element.getAttribute(IProjectType.IS_ABSTRACT);
661
isAbstract = new Boolean("true".equals(isAbs)); //$NON-NLS-1$
665
// Get the semicolon separated list of IDs of the error parsers
666
if (element.getAttribute(ERROR_PARSERS) != null) {
667
errorParserIds = element.getAttribute(ERROR_PARSERS);
670
// Get the semicolon separated list of IDs of the secondary outputs
671
if (element.getAttribute(SECONDARY_OUTPUTS) != null) {
672
secondaryOutputIds = element.getAttribute(SECONDARY_OUTPUTS);
675
// Get the target tool id
676
if (element.getAttribute(TARGET_TOOL) != null) {
677
targetToolIds = element.getAttribute(TARGET_TOOL);
680
// Get the scanner config discovery profile id
681
if (element.getAttribute(SCANNER_CONFIG_PROFILE_ID) != null) {
682
scannerConfigDiscoveryProfileId = element.getAttribute(SCANNER_CONFIG_PROFILE_ID);
685
// Get the 'versionSupported' attribute
686
if (element.getAttribute(VERSIONS_SUPPORTED) != null) {
687
versionsSupported = element.getAttribute(VERSIONS_SUPPORTED);
690
// Get the 'convertToId' id
691
if (element.getAttribute(CONVERT_TO_ID) != null) {
692
convertToId = element.getAttribute(CONVERT_TO_ID);
695
// Get the comma-separated list of valid OS
696
if (element.getAttribute(OS_LIST) != null) {
697
String os = element.getAttribute(OS_LIST);
699
osList = new ArrayList<String>();
700
String[] osTokens = os.split(","); //$NON-NLS-1$
701
for (int i = 0; i < osTokens.length; ++i) {
702
osList.add(osTokens[i].trim());
707
// Get the comma-separated list of valid Architectures
708
if (element.getAttribute(ARCH_LIST) != null) {
709
String arch = element.getAttribute(ARCH_LIST);
711
archList = new ArrayList<String>();
712
String[] archTokens = arch.split(","); //$NON-NLS-1$
713
for (int j = 0; j < archTokens.length; ++j) {
714
archList.add(archTokens[j].trim());
719
// Note: optionPathConverter cannot be specified in a project file because
720
// an IConfigurationElement is needed to load it!
721
if (pathconverterElement != null) {
722
// TODO: issue warning?
725
// Get the scanner config discovery profile id
726
scannerConfigDiscoveryProfileId = element.getAttribute(SCANNER_CONFIG_PROFILE_ID);
727
String tmp = element.getAttribute(RESOURCE_TYPE_BASED_DISCOVERY);
729
isRcTypeBasedDiscovery = Boolean.valueOf(tmp);
731
nonInternalBuilderId = element.getAttribute(NON_INTERNAL_BUILDER_ID);
733
// String tmp = element.getAttribute(name)
737
* Persist the tool-chain to the project file.
742
public void serialize(ICStorageElement element) {
744
if (getSuperClass() != null)
745
element.setAttribute(IProjectType.SUPERCLASS, getSuperClass().getId());
747
element.setAttribute(IBuildObject.ID, id);
750
element.setAttribute(IBuildObject.NAME, name);
753
if (unusedChildren != null) {
754
element.setAttribute(IProjectType.UNUSED_CHILDREN, unusedChildren);
757
if (isAbstract != null) {
758
element.setAttribute(IProjectType.IS_ABSTRACT, isAbstract.toString());
761
if (errorParserIds != null) {
762
element.setAttribute(ERROR_PARSERS, errorParserIds);
765
if (secondaryOutputIds != null) {
766
element.setAttribute(SECONDARY_OUTPUTS, secondaryOutputIds);
769
if (targetToolIds != null) {
770
element.setAttribute(TARGET_TOOL, targetToolIds);
773
if (scannerConfigDiscoveryProfileId != null) {
774
element.setAttribute(SCANNER_CONFIG_PROFILE_ID, scannerConfigDiscoveryProfileId);
778
if (versionsSupported != null) {
779
element.setAttribute(VERSIONS_SUPPORTED, versionsSupported);
783
if (convertToId != null) {
784
element.setAttribute(CONVERT_TO_ID, convertToId);
787
if (osList != null) {
788
Iterator<String> osIter = osList.listIterator();
789
String listValue = EMPTY_STRING;
790
while (osIter.hasNext()) {
791
String current = (String) osIter.next();
792
listValue += current;
793
if ((osIter.hasNext())) {
794
listValue += ","; //$NON-NLS-1$
797
element.setAttribute(OS_LIST, listValue);
800
if (archList != null) {
801
Iterator<String> archIter = archList.listIterator();
802
String listValue = EMPTY_STRING;
803
while (archIter.hasNext()) {
804
String current = (String) archIter.next();
805
listValue += current;
806
if ((archIter.hasNext())) {
807
listValue += ","; //$NON-NLS-1$
810
element.setAttribute(ARCH_LIST, listValue);
813
// Serialize elements from my super class
814
super.serialize(element);
816
// Serialize my children
817
if (targetPlatform != null) {
818
ICStorageElement targetPlatformElement = element.createChild(ITargetPlatform.TARGET_PLATFORM_ELEMENT_NAME);
819
targetPlatform.serialize(targetPlatformElement);
821
if (builder != null) {
822
ICStorageElement builderElement = element.createChild(IBuilder.BUILDER_ELEMENT_NAME);
823
builder.serialize(builderElement);
825
for (Tool tool : getToolList()) {
826
ICStorageElement toolElement = element.createChild(ITool.TOOL_ELEMENT_NAME);
827
tool.serialize(toolElement);
830
// Note: isToolChainSupported cannot be specified in a project file because
831
// an IConfigurationElement is needed to load it!
832
if (managedIsToolChainSupportedElement != null) {
833
// TODO: issue warning?
836
// Note: environmentVariableSupplier cannot be specified in a project file because
837
// an IConfigurationElement is needed to load it!
838
if(environmentVariableSupplierElement != null) {
839
// TODO: issue warning?
842
// Note: buildMacroSupplier cannot be specified in a project file because
843
// an IConfigurationElement is needed to load it!
844
if(buildMacroSupplierElement != null) {
845
// TODO: issue warning?
848
//serialize user-defined macros
849
/* if(userDefinedMacros != null){
850
ICStorageElement macrosElement = element.createChild(StorableMacros.MACROS_ELEMENT_NAME);
851
userDefinedMacros.serialize(macrosElement);
854
// Note: optionPathConverter cannot be specified in a project file because
855
// an IConfigurationElement is needed to load it!
856
if (pathconverterElement != null) {
857
// TODO: issue warning?
860
// if(userDefinedEnvironment != null)
861
// EnvironmentVariableProvider.fUserSupplier.storeEnvironment(getParent(),true);
863
if(nonInternalBuilderId != null)
864
element.setAttribute(NON_INTERNAL_BUILDER_ID, nonInternalBuilderId);
867
if(scannerConfigDiscoveryProfileId != null)
868
element.setAttribute(SCANNER_CONFIG_PROFILE_ID, scannerConfigDiscoveryProfileId);
869
if(isRcTypeBasedDiscovery != null)
870
element.setAttribute(RESOURCE_TYPE_BASED_DISCOVERY, isRcTypeBasedDiscovery.toString());
875
} catch (Exception e) {
876
// TODO: issue an error message
881
* P A R E N T A N D C H I L D H A N D L I N G
885
* @see org.eclipse.cdt.core.build.managed.IToolChain#getConfiguration()
887
public IConfiguration getParent() {
892
* @see org.eclipse.cdt.core.build.managed.IToolChain#createTargetPlatform(ITargetPlatform, String, String, boolean)
894
public ITargetPlatform createTargetPlatform(ITargetPlatform superClass, String id, String name, boolean isExtensionElement) {
895
targetPlatform = new TargetPlatform(this, superClass, id, name, isExtensionElement);
897
return (ITargetPlatform)targetPlatform;
901
* @see org.eclipse.cdt.core.build.managed.IToolChain#getTargetPlatform()
903
public ITargetPlatform getTargetPlatform() {
904
if (targetPlatform == null) {
905
if (getSuperClass() != null) {
906
return getSuperClass().getTargetPlatform();
909
return (ITargetPlatform)targetPlatform;
913
* @see org.eclipse.cdt.core.build.managed.IToolChain#removeLocalTargetPlatform()
915
public void removeLocalTargetPlatform() {
916
if (targetPlatform == null) return;
917
targetPlatform = null;
922
* @see org.eclipse.cdt.core.build.managed.IToolChain#createBuilder(IBuilder, String, String, boolean)
924
public IBuilder createBuilder(IBuilder superClass, String id, String name, boolean isExtensionElement) {
925
builder = new Builder(this, superClass, id, name, isExtensionElement);
927
return (IBuilder)builder;
930
public void setBuilder(Builder builder){
931
this.builder = builder;
935
* @see org.eclipse.cdt.core.build.managed.IToolChain#getBuilder()
937
public IBuilder getBuilder() {
938
if (builder == null) {
939
if (getSuperClass() != null) {
940
return getSuperClass().getBuilder();
943
return (IBuilder)builder;
947
* @see org.eclipse.cdt.core.build.managed.IToolChain#removeLocalBuilder()
949
public void removeLocalBuilder() {
950
if (builder == null) return;
956
* @see org.eclipse.cdt.core.build.managed.IToolChain#createTool(ITool, String, String, boolean)
958
public ITool createTool(ITool superClass, String id, String name, boolean isExtensionElement) {
959
Tool tool = new Tool(this, superClass, id, name, isExtensionElement);
966
* @see org.eclipse.cdt.core.build.managed.IToolChain#getTools()
968
public ITool[] getTools() {
969
ITool tools[] = getAllTools(false);
970
if(!isExtensionToolChain){
971
for(int i = 0; i < tools.length; i++){
972
if(tools[i].isExtensionElement()){
973
String subId = ManagedBuildManager.calculateChildId(tools[i].getId(), null);
974
tools[i] = createTool(tools[i], subId, tools[i].getName(), false);
982
public Tool[] getAllTools(boolean includeCurrentUnused) {
984
// Merge our tools with our superclass' tools
985
if (getSuperClass() != null) {
986
tools = ((ToolChain)getSuperClass()).getAllTools(false);
988
// Our tools take precedence
990
for (Tool tool : getToolList()) {
992
for (; j < tools.length; j++) {
993
ITool superTool = tool.getSuperClass();
994
if(superTool != null){
995
superTool = ManagedBuildManager.getExtensionTool(superTool);
996
if(superTool != null && superTool.getId().equals(tools[j].getId())){
1002
// No Match? Insert it (may be re-ordered)
1003
if (j == tools.length) {
1004
Tool[] newTools = new Tool[tools.length + 1];
1005
for (int k = 0; k < tools.length; k++) {
1006
newTools[k] = tools[k];
1013
// if(!isExtensionToolChain){
1014
// for(int i = 0; i < tools.length; i++){
1015
// if(tools[i].getParent() != this){
1016
// ArrayList list = new ArrayList(Arrays.asList(tools));
1017
// for(int k = 0; k < list.size(); k++){
1018
// if(((ITool)list.get(k)).getParent() != this){
1022
// tools = (ITool[])list.toArray(new ITool[list.size()]);
1028
tools = new Tool[getToolList().size()];
1030
for (Tool tool : getToolList()) {
1034
if(includeCurrentUnused)
1036
return filterUsedTools(tools, true);
1039
private Tool[] filterUsedTools(Tool tools[], boolean used){
1040
Set<String> set = getUnusedChilrenSet();
1042
return used ? tools : new Tool[0];
1044
List<Tool> list = new ArrayList<Tool>(tools.length);
1045
for(Tool t : tools){
1046
if(set.contains(t.getId()) != used)
1049
return list.toArray(new Tool[list.size()]);
1052
public Tool[] getUnusedTools(){
1053
Tool[] all = getAllTools(true);
1054
return filterUsedTools(all, false);
1058
* @see org.eclipse.cdt.managedbuilder.core.IToolChain#getTool(java.lang.String)
1060
public ITool getTool(String id) {
1061
Tool tool = (Tool)getToolMap().get(id);
1066
* @see org.eclipse.cdt.managedbuilder.core.IToolChain#getToolsBySuperClassId(java.lang.String)
1068
public ITool[] getToolsBySuperClassId(String id) {
1069
List<ITool> retTools = new ArrayList<ITool>();
1071
// Look for a tool with this ID, or the tool(s) with a superclass with this id
1072
ITool[] tools = getTools();
1073
for (ITool targetTool : tools) {
1074
ITool tool = targetTool;
1076
if (id.equals(tool.getId())) {
1077
retTools.add(targetTool);
1080
tool = tool.getSuperClass();
1081
} while (tool != null);
1084
return retTools.toArray( new ITool[retTools.size()]);
1088
* Safe accessor for the list of tools.
1090
* @return List containing the tools
1092
public List<Tool> getToolList() {
1093
if (toolList == null) {
1094
toolList = new ArrayList<Tool>();
1100
* Safe accessor for the map of tool ids to tools
1104
private Map<String, Tool> getToolMap() {
1105
if (toolMap == null) {
1106
toolMap = new HashMap<String, Tool>();
1112
* Adds the Tool to the Tool-chain list and map
1116
public void addTool(Tool tool) {
1117
getToolList().add(tool);
1118
getToolMap().put(tool.getId(), tool);
1121
void setToolsInternal(ITool[] tools){
1122
List<Tool> list = getToolList();
1123
Map<String, Tool> map = getToolMap();
1128
for (ITool t : tools) {
1130
map.put(t.getId(), (Tool)t);
1134
public void removeTool(Tool tool){
1135
getToolList().remove(tool);
1136
getToolMap().remove(tool.getId());
1137
ITool extTool = ManagedBuildManager.getExtensionTool(tool);
1138
if(extTool.getParent() == getSuperClass())
1139
addUnusedChild(extTool);
1143
* M O D E L A T T R I B U T E A C C E S S O R S
1147
* @see org.eclipse.cdt.managedbuilder.core.IToolChain#getSuperClass()
1149
public IToolChain getSuperClass() {
1150
return (IToolChain)superClass;
1154
* Access function to set the superclass element that is defined in
1157
private void setSuperClassInternal(IToolChain superClass) {
1158
this.superClass = superClass;
1161
public void setSuperClass(IToolChain superClass) {
1162
if ( this.superClass != superClass ) {
1163
this.superClass = superClass;
1164
if ( this.superClass == null) {
1165
superClassId = null;
1167
superClassId = this.superClass.getId();
1170
if(!isExtensionElement())
1176
* @see org.eclipse.cdt.core.build.managed.IToolChain#getName()
1178
public String getName() {
1179
return (name == null && getSuperClass() != null) ? getSuperClass().getName() : name;
1183
* @see org.eclipse.cdt.core.build.managed.IToolChain#isAbstract()
1185
public boolean isAbstract() {
1186
if (isAbstract != null) {
1187
return isAbstract.booleanValue();
1189
return false; // Note: no inheritance from superClass
1194
* @see org.eclipse.cdt.core.build.managed.IToolChain#getUnusedChildren()
1196
public String getUnusedChildren() {
1197
if (unusedChildren != null) {
1198
return unusedChildren;
1200
return EMPTY_STRING; // Note: no inheritance from superClass
1204
* @see org.eclipse.cdt.managedbuilder.core.IToolChain#getErrorParserIds()
1206
public String getErrorParserIds() {
1207
String ids = errorParserIds;
1209
// If I have a superClass, ask it
1210
if (getSuperClass() != null) {
1211
ids = getSuperClass().getErrorParserIds();
1215
// Collect the error parsers from my children
1216
ids = builder.getErrorParserIds();
1217
ITool[] tools = getTools();
1218
for (int i = 0; i < tools.length; i++) {
1219
ITool tool = tools[i];
1220
String toolIds = tool.getErrorParserIds();
1221
if (toolIds != null && toolIds.length() > 0) {
1223
ids += ";"; //$NON-NLS-1$
1234
public String getErrorParserIdsAttribute() {
1235
String ids = errorParserIds;
1237
// If I have a superClass, ask it
1238
if (getSuperClass() != null) {
1239
ids = ((ToolChain)getSuperClass()).getErrorParserIdsAttribute();
1246
* @see org.eclipse.cdt.managedbuilder.core.IToolChain#getSecondaryOutputs()
1248
public IOutputType[] getSecondaryOutputs() {
1249
IOutputType[] types = null;
1250
String ids = secondaryOutputIds;
1252
if (getSuperClass() != null) {
1253
return getSuperClass().getSecondaryOutputs();
1256
return new IOutputType[0];
1259
StringTokenizer tok = new StringTokenizer(ids, ";"); //$NON-NLS-1$
1260
types = new IOutputType[tok.countTokens()];
1261
ITool[] tools = getTools();
1263
while (tok.hasMoreElements()) {
1264
String id = tok.nextToken();
1265
for (int j=0; j<tools.length; j++) {
1267
type = tools[j].getOutputTypeById(id);
1278
* @see org.eclipse.cdt.managedbuilder.core.IToolChain#getTargetToolIds()
1280
public String getTargetToolIds() {
1281
if (targetToolIds == null) {
1282
// Ask superClass for its list
1283
if (getSuperClass() != null) {
1284
return getSuperClass().getTargetToolIds();
1289
return targetToolIds;
1293
* @see org.eclipse.cdt.managedbuilder.core.IToolChain#getTargetToolList()
1295
public String[] getTargetToolList() {
1296
String IDs = getTargetToolIds();
1297
String[] targetTools;
1299
// Check for an empty string
1300
if (IDs.length() == 0) {
1301
targetTools = new String[0];
1303
StringTokenizer tok = new StringTokenizer(IDs, ";"); //$NON-NLS-1$
1304
List<String> list = new ArrayList<String>(tok.countTokens());
1305
while (tok.hasMoreElements()) {
1306
list.add(tok.nextToken());
1308
String[] strArr = {""}; //$NON-NLS-1$
1309
targetTools = (String[]) list.toArray(strArr);
1312
targetTools = new String[0];
1318
* @see org.eclipse.cdt.managedbuilder.core.IToolChain#getErrorParserIds(IConfiguration)
1320
public String getErrorParserIds(IConfiguration config) {
1321
String ids = errorParserIds;
1323
// If I have a superClass, ask it
1324
if (getSuperClass() != null) {
1325
ids = getSuperClass().getErrorParserIds(config);
1329
// Collect the error parsers from my children
1330
if (builder != null) {
1331
ids = builder.getErrorParserIds();
1333
ITool[] tools = config.getFilteredTools();
1334
for (int i = 0; i < tools.length; i++) {
1335
ITool tool = tools[i];
1336
String toolIds = tool.getErrorParserIds();
1337
if (toolIds != null && toolIds.length() > 0) {
1339
ids += ";"; //$NON-NLS-1$
1351
* @see org.eclipse.cdt.managedbuilder.core.IToolChain#getErrorParserList()
1353
public String[] getErrorParserList() {
1354
String parserIDs = getErrorParserIds();
1355
String[] errorParsers;
1356
if (parserIDs != null) {
1357
// Check for an empty string
1358
if (parserIDs.length() == 0) {
1359
errorParsers = new String[0];
1361
StringTokenizer tok = new StringTokenizer(parserIDs, ";"); //$NON-NLS-1$
1362
List<String> list = new ArrayList<String>(tok.countTokens());
1363
while (tok.hasMoreElements()) {
1364
list.add(tok.nextToken());
1366
String[] strArr = {""}; //$NON-NLS-1$
1367
errorParsers = (String[]) list.toArray(strArr);
1370
errorParsers = new String[0];
1372
return errorParsers;
1375
public Set<String> contributeErrorParsers(FolderInfo info, Set<String> set, boolean includeChildren){
1376
String parserIDs = getErrorParserIdsAttribute();
1377
if (parserIDs != null){
1379
set = new HashSet<String>();
1380
if(parserIDs.length() != 0) {
1381
StringTokenizer tok = new StringTokenizer(parserIDs, ";"); //$NON-NLS-1$
1382
while (tok.hasMoreElements()) {
1383
set.add(tok.nextToken());
1388
if(includeChildren){
1389
ITool tools[] = info.getFilteredTools();
1390
set = info.contributeErrorParsers(tools, set);
1393
Builder builder = (Builder)getBuilder();
1394
set = builder.contributeErrorParsers(set);
1401
* @see org.eclipse.cdt.managedbuilder.core.IToolChain#getArchList()
1403
public String[] getArchList() {
1404
if (archList == null) {
1405
// Ask superClass for its list
1406
if (getSuperClass() != null) {
1407
return getSuperClass().getArchList();
1409
// I have no superClass and no defined list
1410
return new String[] {"all"}; //$NON-NLS-1$
1413
return (String[]) archList.toArray(new String[archList.size()]);
1417
* @see org.eclipse.cdt.managedbuilder.core.IToolChain#getOSList()
1419
public String[] getOSList() {
1420
if (osList == null) {
1421
// Ask superClass for its list
1422
if (getSuperClass() != null) {
1423
return getSuperClass().getOSList();
1425
// I have no superClass and no defined filter list
1426
return new String[] {"all"}; //$NON-NLS-1$
1429
return (String[]) osList.toArray(new String[osList.size()]);
1433
* @see org.eclipse.cdt.managedbuilder.core.IToolChain#setIsAbstract(boolean)
1435
public void setIsAbstract(boolean b) {
1436
isAbstract = new Boolean(b);
1441
* @see org.eclipse.cdt.managedbuilder.core.IToolChain#setErrorParserIds(String)
1443
public void setErrorParserIds(String ids) {
1444
String currentIds = getErrorParserIds();
1445
if (ids == null && currentIds == null) return;
1446
if (currentIds == null || ids == null || !(currentIds.equals(ids))) {
1447
errorParserIds = ids;
1453
* @see org.eclipse.cdt.managedbuilder.core.IToolChain#setSecondaryOutputs()
1455
public void setSecondaryOutputs(String newIds) {
1456
if (secondaryOutputIds == null && newIds == null) return;
1457
if (secondaryOutputIds == null || newIds == null || !newIds.equals(secondaryOutputIds)) {
1458
secondaryOutputIds = newIds;
1464
* @see org.eclipse.cdt.managedbuilder.core.IToolChain#setTargetToolIds()
1466
public void setTargetToolIds(String newIds) {
1467
if (targetToolIds == null && newIds == null) return;
1468
if (targetToolIds == null || newIds == null || !newIds.equals(targetToolIds)) {
1469
targetToolIds = newIds;
1475
* @see org.eclipse.cdt.managedbuilder.core.IToolChain#setOSList(String[])
1477
public void setOSList(String[] OSs) {
1478
if (osList == null) {
1479
osList = new ArrayList<String>();
1483
for (int i = 0; i < OSs.length; i++) {
1490
* @see org.eclipse.cdt.managedbuilder.core.IToolChain#setArchList(String[])
1492
public void setArchList(String[] archs) {
1493
if (archList == null) {
1494
archList = new ArrayList<String>();
1498
for (int i = 0; i < archs.length; i++) {
1499
archList.add(archs[i]);
1505
* @see org.eclipse.cdt.managedbuilder.core.IToolChain#getScannerConfigDiscoveryProfileId()
1507
public String getScannerConfigDiscoveryProfileId() {
1508
if (scannerConfigDiscoveryProfileId == null) {
1509
if (getSuperClass() != null) {
1510
return getSuperClass().getScannerConfigDiscoveryProfileId();
1513
return scannerConfigDiscoveryProfileId;
1517
* @see org.eclipse.cdt.managedbuilder.core.IToolChain#setScannerConfigDiscoveryProfileId(java.lang.String)
1519
public void setScannerConfigDiscoveryProfileId(String profileId) {
1520
if (scannerConfigDiscoveryProfileId == null && profileId == null) return;
1521
if (scannerConfigDiscoveryProfileId == null ||
1522
!scannerConfigDiscoveryProfileId.equals(profileId)) {
1523
scannerConfigDiscoveryProfileId = profileId;
1529
* @return the pathconverterElement
1531
public IConfigurationElement getPathconverterElement() {
1532
return pathconverterElement;
1536
* @see org.eclipse.cdt.managedbuilder.core.IToolChain#getPathConverter()
1538
public IOptionPathConverter getOptionPathConverter() {
1539
if (optionPathConverter != null) {
1540
return optionPathConverter ;
1542
IConfigurationElement element = getPathconverterElement();
1543
if (element != null) {
1545
if (element.getAttribute(ITool.OPTIONPATHCONVERTER) != null) {
1546
optionPathConverter = (IOptionPathConverter) element.createExecutableExtension(ITool.OPTIONPATHCONVERTER);
1547
return optionPathConverter;
1549
} catch (CoreException e) {}
1551
if (getSuperClass() instanceof IToolChain) {
1552
IToolChain superTool = (IToolChain) getSuperClass();
1553
return superTool.getOptionPathConverter() ;
1562
* O B J E C T S T A T E M A I N T E N A N C E
1566
* @see org.eclipse.cdt.managedbuilder.core.IToolChain#isExtensionElement()
1568
public boolean isExtensionElement() {
1569
return isExtensionToolChain;
1573
* @see org.eclipse.cdt.managedbuilder.core.IToolChain#isDirty()
1575
public boolean isDirty() {
1576
// This shouldn't be called for an extension tool-chain
1577
if (isExtensionToolChain) return false;
1579
// If I need saving, just say yes
1580
if (isDirty) return true;
1582
//check whether the tool-chain - specific macros are dirty
1583
// if(userDefinedMacros != null && userDefinedMacros.isDirty())
1586
// if(userDefinedEnvironment != null && userDefinedEnvironment.isDirty())
1589
if(builder != null && builder.isDirty())
1592
// Otherwise see if any tools need saving
1593
for (Tool toolChild : getToolList()) {
1594
if (toolChild.isDirty())
1598
// Otherwise see if any options need saving
1599
if (super.isDirty()) {
1607
* @see org.eclipse.cdt.managedbuilder.core.IToolChain#setDirty(boolean)
1609
public void setDirty(boolean isDirty) {
1610
this.isDirty = isDirty;
1611
// Propagate "false" to options
1612
super.setDirty(isDirty);
1613
// Propagate "false" to the children
1615
for (Tool toolChild : getToolList())
1616
toolChild.setDirty(false);
1621
* Resolve the element IDs to interface references
1623
public void resolveReferences() {
1626
// Resolve superClass
1627
if (superClassId != null && superClassId.length() > 0) {
1628
setSuperClassInternal(ManagedBuildManager.getExtensionToolChain(superClassId));
1629
if (getSuperClass() == null) {
1631
ManagedBuildManager.outputResolveError(
1632
"superClass", //$NON-NLS-1$
1634
"toolChain", //$NON-NLS-1$
1637
// All of our superclasses must be resolved in order to properly
1638
// resolve options to option categories
1639
((ToolChain)getSuperClass()).resolveReferences();
1642
// Resolve HoldsOptions
1643
super.resolveReferences();
1644
// Call resolveReferences on our children
1645
if (targetPlatform != null) {
1646
targetPlatform.resolveReferences();
1648
if (builder != null) {
1649
builder.resolveReferences();
1651
for (Tool toolChild : getToolList())
1652
toolChild.resolveReferences();
1657
* Normalize the list of output extensions,for all tools in the toolchain by populating the list
1658
* with an empty string for those tools which have no explicit output extension (as defined in the
1659
* manifest file. In a post 2.1 manifest, all tools must have a specifed output extension, even
1662
public void normalizeOutputExtensions(){
1663
ITool[] tools = getTools();
1664
if (tools != null) {
1665
for (int i = 0; i < tools.length; i++) {
1666
ITool tool = tools[i];
1667
String[] extensions = tool.getOutputsAttribute();
1668
if (extensions == null) {
1669
tool.setOutputsAttribute(""); //$NON-NLS-1$
1672
if (extensions.length == 0){
1673
tool.setOutputsAttribute(""); //$NON-NLS-1$
1681
* @see org.eclipse.cdt.managedbuilder.core.IToolChain#getConvertToId()
1683
public String getConvertToId() {
1684
if (convertToId == null) {
1685
// If I have a superClass, ask it
1686
if (getSuperClass() != null) {
1687
return getSuperClass().getConvertToId();
1689
return EMPTY_STRING;
1696
* @see org.eclipse.cdt.managedbuilder.core.IToolChain#setConvertToId(String)
1698
public void setConvertToId(String convertToId) {
1699
if (convertToId == null && this.convertToId == null) return;
1700
if (convertToId == null || this.convertToId == null || !convertToId.equals(this.convertToId)) {
1701
this.convertToId = convertToId;
1708
* @see org.eclipse.cdt.managedbuilder.core.IToolChain#getVersionsSupported()
1710
public String getVersionsSupported() {
1711
if (versionsSupported == null) {
1712
// If I have a superClass, ask it
1713
if (getSuperClass() != null) {
1714
return getSuperClass().getVersionsSupported();
1716
return EMPTY_STRING;
1719
return versionsSupported;
1723
* @see org.eclipse.cdt.managedbuilder.core.IToolChain#setVersionsSupported(String)
1725
public void setVersionsSupported(String versionsSupported) {
1726
if (versionsSupported == null && this.versionsSupported == null) return;
1727
if (versionsSupported == null || this.versionsSupported == null || !versionsSupported.equals(this.versionsSupported)) {
1728
this.versionsSupported = versionsSupported;
1734
private IConfigurationElement getIsToolChainSupportedElement(){
1735
if (managedIsToolChainSupportedElement == null) {
1736
if (superClass != null && superClass instanceof ToolChain) {
1737
return ((ToolChain)superClass).getIsToolChainSupportedElement();
1740
return managedIsToolChainSupportedElement;
1744
* @see org.eclipse.cdt.managedbuilder.core.IToolChain#isSupported()
1746
public boolean isSupported(){
1747
if (managedIsToolChainSupported == null) {
1748
IConfigurationElement element = getIsToolChainSupportedElement();
1749
if (element != null) {
1751
if (element.getAttribute(IS_TOOL_CHAIN_SUPPORTED) != null) {
1752
managedIsToolChainSupported = (IManagedIsToolChainSupported) element.createExecutableExtension(IS_TOOL_CHAIN_SUPPORTED);
1754
} catch (CoreException e) {}
1758
if(managedIsToolChainSupported != null)
1759
return managedIsToolChainSupported.isSupported(this,null,null);
1764
* Returns the plugin.xml element of the configurationEnvironmentSupplier extension or <code>null</code> if none.
1766
* @return IConfigurationElement
1768
public IConfigurationElement getEnvironmentVariableSupplierElement(){
1769
if (environmentVariableSupplierElement == null) {
1770
if (getSuperClass() != null && getSuperClass() instanceof ToolChain) {
1771
return ((ToolChain)getSuperClass()).getEnvironmentVariableSupplierElement();
1774
return environmentVariableSupplierElement;
1779
* @see org.eclipse.cdt.managedbuilder.core.IToolChain#getEnvironmentVariableSupplier()
1781
public IConfigurationEnvironmentVariableSupplier getEnvironmentVariableSupplier(){
1782
if (environmentVariableSupplier != null) {
1783
return environmentVariableSupplier;
1785
IConfigurationElement element = getEnvironmentVariableSupplierElement();
1786
if (element != null) {
1788
if (element.getAttribute(CONFIGURATION_ENVIRONMENT_SUPPLIER) != null) {
1789
environmentVariableSupplier = (IConfigurationEnvironmentVariableSupplier) element.createExecutableExtension(CONFIGURATION_ENVIRONMENT_SUPPLIER);
1790
return environmentVariableSupplier;
1792
} catch (CoreException e) {}
1798
* this method is called by the UserDefinedMacroSupplier to obtain user-defined
1799
* macros available for this tool-chain
1801
/* public StorableMacros getUserDefinedMacros(){
1802
if(isExtensionToolChain)
1805
if(userDefinedMacros == null)
1806
userDefinedMacros = new StorableMacros();
1807
return userDefinedMacros;
1810
// public StorableEnvironment getUserDefinedEnvironment(){
1811
// if(isExtensionToolChain)
1814
// return userDefinedEnvironment;
1817
// public void setUserDefinedEnvironment(StorableEnvironment env){
1818
// if(!isExtensionToolChain)
1819
// userDefinedEnvironment = env;
1824
* Returns the plugin.xml element of the configurationMacroSupplier extension or <code>null</code> if none.
1826
* @return IConfigurationElement
1828
public IConfigurationElement getBuildMacroSupplierElement(){
1829
if (buildMacroSupplierElement == null) {
1830
if (superClass != null && superClass instanceof ToolChain) {
1831
return ((ToolChain)superClass).getBuildMacroSupplierElement();
1834
return buildMacroSupplierElement;
1839
* @see org.eclipse.cdt.managedbuilder.core.IToolChain#getBuildMacroSupplier()
1841
public IConfigurationBuildMacroSupplier getBuildMacroSupplier(){
1842
if (buildMacroSupplier != null) {
1843
return buildMacroSupplier;
1845
IConfigurationElement element = getBuildMacroSupplierElement();
1846
if (element != null) {
1848
if (element.getAttribute(CONFIGURATION_MACRO_SUPPLIER) != null) {
1849
buildMacroSupplier = (IConfigurationBuildMacroSupplier) element.createExecutableExtension(CONFIGURATION_MACRO_SUPPLIER);
1850
return buildMacroSupplier;
1852
} catch (CoreException e) {}
1858
* This function checks for migration support for the toolchain, while
1859
* loading. If migration support is needed, looks for the available
1860
* converters and adds them to the list.
1863
public void checkForMigrationSupport() {
1865
boolean isExists = false;
1867
if (getSuperClass() == null) {
1868
// If 'getSuperClass()' is null, then there is no toolchain available in
1869
// plugin manifest file with the 'id' & version.
1870
// Look for the 'versionsSupported' attribute
1871
String high = (String) ManagedBuildManager
1872
.getExtensionToolChainMap().lastKey();
1874
SortedMap subMap = null;
1875
if (superClassId.compareTo(high) <= 0) {
1876
subMap = ManagedBuildManager.getExtensionToolChainMap().subMap(
1877
superClassId, high + "\0"); //$NON-NLS-1$
1879
// It means there are no entries in the map for the given id.
1880
// make the project is invalid
1881
IConfiguration parentConfig = getParent();
1882
IManagedProject managedProject = parentConfig.getManagedProject();
1883
if (managedProject != null) {
1884
managedProject.setValid(false);
1889
// for each element in the 'subMap',
1890
// check the 'versionsSupported' attribute whether the given
1891
// toolChain version is supported
1893
String baseId = ManagedBuildManager.getIdFromIdAndVersion(superClassId);
1894
String version = getVersionFromId().toString();
1896
Collection<IToolChain[]> c = subMap.values();
1897
IToolChain[] toolChainElements = (IToolChain[]) c.toArray(new IToolChain[c.size()]);
1899
for (int i = 0; i < toolChainElements.length; i++) {
1900
IToolChain toolChainElement = toolChainElements[i];
1902
if (ManagedBuildManager.getIdFromIdAndVersion(
1903
toolChainElement.getId()).compareTo(baseId) > 0)
1906
// First check if both base ids are equal
1907
if (ManagedBuildManager.getIdFromIdAndVersion(
1908
toolChainElement.getId()).equals(baseId)) {
1910
// Check if 'versionsSupported' attribute is available'
1911
String versionsSupported = toolChainElement.getVersionsSupported();
1913
if ((versionsSupported != null)
1914
&& (!versionsSupported.equals(""))) { //$NON-NLS-1$
1915
String[] tmpVersions = versionsSupported.split(","); //$NON-NLS-1$
1917
for (int j = 0; j < tmpVersions.length; j++) {
1918
if (new PluginVersionIdentifier(version).equals(new PluginVersionIdentifier(tmpVersions[j]))) {
1919
// version is supported.
1920
// Do the automatic conversion without
1921
// prompting the user.
1922
// Get the supported version
1923
String supportedVersion = ManagedBuildManager.getVersionFromIdAndVersion(
1924
toolChainElement.getId());
1925
setId(ManagedBuildManager.getIdFromIdAndVersion(getId())
1926
+ "_" + supportedVersion); //$NON-NLS-1$
1928
// If control comes here means that 'superClass' is null
1929
// So, set the superClass to this toolChain element
1930
setSuperClassInternal(toolChainElement);
1931
superClassId = getSuperClass().getId();
1937
break; // break the outer for loop if 'isExists' is true
1943
if (getSuperClass() != null) {
1944
// If 'getSuperClass()' is not null, look for 'convertToId' attribute in plugin
1945
// manifest file for this toolchain.
1946
String convertToId = getSuperClass().getConvertToId();
1947
if ((convertToId == null) || (convertToId.equals(""))) { //$NON-NLS-1$
1948
// It means there is no 'convertToId' attribute available and
1949
// the version is still actively
1950
// supported by the tool integrator. So do nothing, just return
1953
// In case the 'convertToId' attribute is available,
1954
// it means that Tool integrator currently does not support this
1955
// version of toolchain.
1956
// Look for the converters available for this toolchain version.
1958
getConverter(convertToId);
1962
// make the project is invalid
1964
IConfiguration parentConfig = getParent();
1965
IManagedProject managedProject = parentConfig.getManagedProject();
1966
if (managedProject != null) {
1967
managedProject.setValid(false);
1973
private void getConverter(String convertToId) {
1975
String fromId = null;
1978
// Get the Converter Extension Point
1979
IExtensionPoint extensionPoint = Platform.getExtensionRegistry()
1980
.getExtensionPoint("org.eclipse.cdt.managedbuilder.core", //$NON-NLS-1$
1981
"projectConverter"); //$NON-NLS-1$
1982
if (extensionPoint != null) {
1983
// Get the extensions
1984
IExtension[] extensions = extensionPoint.getExtensions();
1985
for (int i = 0; i < extensions.length; i++) {
1986
// Get the configuration elements of each extension
1987
IConfigurationElement[] configElements = extensions[i]
1988
.getConfigurationElements();
1989
for (int j = 0; j < configElements.length; j++) {
1991
IConfigurationElement element = configElements[j];
1993
if (element.getName().equals("converter")) { //$NON-NLS-1$
1995
fromId = element.getAttribute("fromId"); //$NON-NLS-1$
1996
toId = element.getAttribute("toId"); //$NON-NLS-1$
1997
// Check whether the current converter can be used for
1998
// the selected toolchain
2000
if (fromId.equals(getSuperClass().getId())
2001
&& toId.equals(convertToId)) {
2003
String mbsVersion = element
2004
.getAttribute("mbsVersion"); //$NON-NLS-1$
2005
PluginVersionIdentifier currentMbsVersion = ManagedBuildManager
2006
.getBuildInfoVersion();
2008
// set the converter element based on the MbsVersion
2009
if (currentMbsVersion
2010
.isGreaterThan(new PluginVersionIdentifier(
2012
previousMbsVersionConversionElement = element;
2014
currentMbsVersionConversionElement = element;
2023
// If control comes here, it means 'Tool Integrator' specified
2024
// 'convertToId' attribute in toolchain definition file, but
2025
// has not provided any converter.
2026
// So, make the project is invalid
2028
IConfiguration parentConfig = getParent();
2029
IManagedProject managedProject = parentConfig.getManagedProject();
2030
if (managedProject != null) {
2031
managedProject.setValid(false);
2036
public IConfigurationElement getPreviousMbsVersionConversionElement() {
2037
return previousMbsVersionConversionElement;
2040
public IConfigurationElement getCurrentMbsVersionConversionElement() {
2041
return currentMbsVersionConversionElement;
2045
* @see org.eclipse.cdt.managedbuilder.internal.core.BuildObject#updateManagedBuildRevision(java.lang.String)
2047
public void updateManagedBuildRevision(String revision){
2048
super.updateManagedBuildRevision(revision);
2050
for (Tool t : getToolList())
2051
t.updateManagedBuildRevision(revision);
2054
builder.updateManagedBuildRevision(revision);
2058
* @see org.eclipse.cdt.managedbuilder.internal.core.HoldsOptions#needsRebuild()
2060
public boolean needsRebuild() {
2064
ITool tools[] = getTools();
2065
for(int i = 0; i < tools.length; i++){
2066
if(tools[i].needsRebuild())
2070
return super.needsRebuild();
2074
* @see org.eclipse.cdt.managedbuilder.internal.core.HoldsOptions#setRebuildState(boolean)
2076
public void setRebuildState(boolean rebuild) {
2077
if(isExtensionElement() && rebuild)
2080
if(rebuildState != rebuild){
2081
rebuildState = rebuild;
2086
super.setRebuildState(false);
2088
ITool tools[] = getTools();
2089
for(int i = 0; i < tools.length; i++){
2090
tools[i].setRebuildState(false);
2095
private void saveRebuildState(){
2096
if(((Configuration)config).isPreference())
2098
PropertyManager.getInstance().setProperty(this, REBUILD_STATE, Boolean.toString(needsRebuild()));
2101
public IFolderInfo getParentFolderInfo() {
2102
return parentFolderInfo;
2105
void setTargetPlatform(TargetPlatform tp){
2106
targetPlatform = tp;
2109
public CTargetPlatformData getTargetPlatformData() {
2110
if(isExtensionToolChain)
2112
if(targetPlatform == null){
2113
ITargetPlatform platform = getTargetPlatform();
2114
if(platform != null){
2115
ITargetPlatform extPlatform = platform;
2116
for(;extPlatform != null && !extPlatform.isExtensionElement();
2117
extPlatform = extPlatform.getSuperClass());
2119
if(extPlatform != null)
2120
subId = ManagedBuildManager.calculateChildId(extPlatform.getId(), null);
2122
subId = ManagedBuildManager.calculateChildId(getId(), null);
2124
targetPlatform = new TargetPlatform(this, subId, platform.getName(), (TargetPlatform)extPlatform);
2126
String subId = ManagedBuildManager.calculateChildId(getId(), null);
2127
targetPlatform = new TargetPlatform(this, null, subId, "", false); //$NON-NLS-1$
2131
return targetPlatform.getTargetPlatformData();
2134
public boolean supportsType(String type, boolean checkTools) {
2135
SupportedProperties props = findSupportedProperties();
2136
boolean supports = false;
2138
supports = props.supportsType(type);
2140
BooleanExpressionApplicabilityCalculator calc = getBooleanExpressionCalculator();
2142
supports = calc.referesProperty(type);
2146
supports = super.supportsType(type);
2148
if(!supports && checkTools){
2149
ITool tools[] = getTools();
2150
for(int i = 0; i < tools.length; i++){
2151
if(((Tool)tools[i]).supportsType(type)){
2160
public boolean supportsType(String type) {
2161
return supportsType(type, true);
2164
public boolean supportsType(IBuildPropertyType type) {
2165
return supportsType(type.getId());
2168
public boolean supportsValue(String type, String value){
2169
return supportsValue(type, value, true);
2172
public boolean supportsValue(String type, String value, boolean checkTools){
2173
SupportedProperties props = findSupportedProperties();
2174
boolean supports = false;
2176
supports = props.supportsValue(type, value);
2178
BooleanExpressionApplicabilityCalculator calc = getBooleanExpressionCalculator();
2180
supports = calc.referesPropertyValue(type, value);
2184
supports = super.supportsValue(type, value);
2187
if(!supports && checkTools){
2188
ITool tools[] = getTools();
2189
for(int i = 0; i < tools.length; i++){
2190
if(((Tool)tools[i]).supportsValue(type, value)){
2199
public boolean supportsValue(IBuildPropertyType type,
2200
IBuildPropertyValue value) {
2201
return supportsValue(type.getId(), value.getId());
2204
public void propertiesChanged() {
2205
if(isExtensionToolChain)
2208
BooleanExpressionApplicabilityCalculator calculator = getBooleanExpressionCalculator();
2209
if(calculator != null)
2210
calculator.adjustToolChain(getParentFolderInfo(), this, false);
2212
super.propertiesChanged();
2214
for (ITool t : getTools())
2215
((Tool)t).propertiesChanged();
2218
public BooleanExpressionApplicabilityCalculator getBooleanExpressionCalculator(){
2219
if(booleanExpressionCalculator == null){
2220
if(superClass != null){
2221
return ((ToolChain)superClass).getBooleanExpressionCalculator();
2224
return booleanExpressionCalculator;
2227
protected IResourceInfo getParentResourceInfo() {
2228
return getParentFolderInfo();
2231
public boolean matches(IToolChain tc){
2235
IToolChain rTc = ManagedBuildManager.getRealToolChain(this);
2239
return rTc == ManagedBuildManager.getRealToolChain(tc);
2242
private boolean performMatchCompatison(IToolChain tCh){
2249
// if(tCh.isReal() && isReal())
2252
String name = tCh.getName();
2254
if(getName() != null)
2256
} else if(!name.equals(getName())){
2260
String thisVersion = ManagedBuildManager.getVersionFromIdAndVersion(getId());
2261
String otherVersion = ManagedBuildManager.getVersionFromIdAndVersion(tCh.getId());
2262
if(thisVersion == null || thisVersion.length() == 0){
2263
if(otherVersion != null && otherVersion.length() != 0)
2266
if(!thisVersion.equals(otherVersion))
2275
// ITool tools[] = getTools();
2276
// ITool otherTools[] = tCh.getTools();
2278
// if(tools.length != otherTools.length)
2281
// if(!ListComparator.match(tools,
2283
// new Comparator(){
2284
// public boolean equal(Object o1, Object o2){
2285
// return ((Tool)o1).performMatchComparison((Tool)o2);
2293
public List getIdenticalList(){
2294
return identicalList;//;(ArrayList)identicalToolChainsList.clone();
2297
public boolean supportsBuild(boolean managed) {
2298
if(!getSupportsManagedBuildAttribute())
2301
IBuilder builder = getBuilder();
2302
if(builder != null && !builder.supportsBuild(managed))
2305
ITool tools[] = getTools();
2306
for(int i = 0; i < tools.length; i++){
2307
if(!tools[i].supportsBuild(managed))
2314
public boolean getSupportsManagedBuildAttribute(){
2315
if(supportsManagedBuild == null){
2316
if(superClass != null){
2317
return ((ToolChain)superClass).getSupportsManagedBuildAttribute();
2321
return supportsManagedBuild.booleanValue();
2324
public boolean isSystemObject() {
2328
if(getConvertToId().length() != 0)
2331
if(getParent() != null)
2332
return getParent().isSystemObject();
2337
private class MatchKey {
2338
ToolChain toolChain;
2340
public MatchKey(ToolChain tch) {
2344
public boolean equals(Object obj) {
2347
if(!(obj instanceof MatchKey))
2349
MatchKey other = (MatchKey)obj;
2350
return toolChain.performMatchCompatison(other.toolChain);
2353
public int hashCode() {
2354
String name = getName();
2357
int code = name.hashCode();
2358
String version = ManagedBuildManager.getVersionFromIdAndVersion(getId());
2360
code += version.hashCode();
2366
public Object getMatchKey() {
2369
if(!isExtensionToolChain)
2371
return new MatchKey(this);
2374
public void setIdenticalList(List list) {
2375
identicalList = list;
2378
public String getNameAndVersion(){
2379
String name = getName();
2380
String version = ManagedBuildManager.getVersionFromIdAndVersion(getId());
2381
if(version != null && version.length() != 0){
2382
return new StringBuffer().append(name).append(" (").append(version).append("").toString(); //$NON-NLS-1$ //$NON-NLS-2$
2387
public IConfigurationElement getConverterModificationElement(IToolChain tc){
2388
Map<String, IConfigurationElement> map = ManagedBuildManager.getConversionElements(this);
2389
IConfigurationElement element = null;
2391
for(IConfigurationElement el : map.values()){
2392
String toId = el.getAttribute("toId"); //$NON-NLS-1$
2393
IToolChain toTc = tc;
2395
for(;toTc != null; toTc = toTc.getSuperClass()){
2396
if(toId.equals(toTc.getId()))
2409
public IConfigurationElement getConverterModificationElement(ITool fromTool, ITool toTool){
2410
return ((Tool)fromTool).getConverterModificationElement(toTool);
2413
void updateParentFolderInfo(FolderInfo info){
2414
parentFolderInfo = info;
2415
config = parentFolderInfo.getParent();
2418
public String[] getRequiredTypeIds() {
2419
return getRequiredTypeIds(true);
2422
public String[] getRequiredTypeIds(boolean checkTools) {
2423
SupportedProperties props = findSupportedProperties();
2424
List<String> result = new ArrayList<String>();
2426
result.addAll(Arrays.asList(props.getRequiredTypeIds()));
2428
// BooleanExpressionApplicabilityCalculator calc = getBooleanExpressionCalculator();
2429
// if(calc != null){
2430
// result.addAll(Arrays.asList(calc.getReferencedPropertyIds()));
2433
result.addAll(Arrays.asList(super.getRequiredTypeIds()));
2438
ITool tools[] = getTools();
2439
for(int i = 0; i < tools.length; i++){
2440
result.addAll(Arrays.asList(((Tool)tools[i]).getRequiredTypeIds()));
2443
return (String[])result.toArray(new String[result.size()]);
2446
public String[] getSupportedTypeIds() {
2447
return getSupportedTypeIds(true);
2450
public String[] getSupportedTypeIds(boolean checkTools) {
2451
SupportedProperties props = findSupportedProperties();
2452
List<String> result = new ArrayList<String>();
2454
result.addAll(Arrays.asList(props.getSupportedTypeIds()));
2456
BooleanExpressionApplicabilityCalculator calc = getBooleanExpressionCalculator();
2458
result.addAll(Arrays.asList(calc.getReferencedPropertyIds()));
2461
result.addAll(Arrays.asList(super.getSupportedTypeIds()));
2466
ITool tools[] = getTools();
2467
for(int i = 0; i < tools.length; i++){
2468
result.addAll(Arrays.asList(((Tool)tools[i]).getSupportedTypeIds()));
2471
return result.toArray(new String[result.size()]);
2474
public String[] getSupportedValueIds(String typeId) {
2475
return getSupportedValueIds(typeId, true);
2478
public String[] getSupportedValueIds(String typeId, boolean checkTools) {
2479
SupportedProperties props = findSupportedProperties();
2480
List<String> result = new ArrayList<String>();
2482
result.addAll(Arrays.asList(props.getSupportedValueIds(typeId)));
2484
BooleanExpressionApplicabilityCalculator calc = getBooleanExpressionCalculator();
2486
result.addAll(Arrays.asList(calc.getReferencedValueIds(typeId)));
2489
result.addAll(Arrays.asList(super.getSupportedValueIds(typeId)));
2494
ITool tools[] = getTools();
2495
for(int i = 0; i < tools.length; i++){
2496
result.addAll(Arrays.asList(((Tool)tools[i]).getSupportedValueIds(typeId)));
2499
return result.toArray(new String[result.size()]);
2502
public boolean requiresType(String typeId) {
2503
return requiresType(typeId, true);
2506
public boolean requiresType(String typeId, boolean checkTools) {
2507
SupportedProperties props = findSupportedProperties();
2508
boolean required = false;
2510
required = props.requiresType(typeId);
2512
required = super.requiresType(typeId);
2515
//call tools if not found
2516
if(!required && checkTools){
2517
ITool tools[] = getTools();
2518
for(int i = 0; i < tools.length; i++){
2519
if(((Tool)tools[i]).requiresType(typeId)){
2528
private SupportedProperties findSupportedProperties(){
2529
if(supportedProperties == null){
2530
if(superClass != null){
2531
return ((ToolChain)superClass).findSupportedProperties();
2534
return supportedProperties;
2537
private void loadProperties(IManagedConfigElement el){
2538
supportedProperties = new SupportedProperties(el);
2541
void setNonInternalBuilderId(String id){
2542
nonInternalBuilderId = id;
2545
String getNonInternalBuilderId(){
2546
if(nonInternalBuilderId == null){
2547
if(superClass != null){
2548
return ((ToolChain)superClass).getNonInternalBuilderId();
2552
return nonInternalBuilderId;
2555
public void resetErrorParsers(FolderInfo info){
2556
errorParserIds = null;
2557
info.resetErrorParsers(info.getFilteredTools());
2560
if(builder != null){
2561
builder.resetErrorParsers();
2566
void removeErrorParsers(FolderInfo info, Set<String> set){
2567
Set<String> oldSet = contributeErrorParsers(info, null, false);
2569
oldSet = new HashSet<String>();
2571
oldSet.removeAll(set);
2572
setErrorParserList((String[])oldSet.toArray(new String[oldSet.size()]));
2574
info.removeErrorParsers(info.getFilteredTools(), set);
2578
Builder builder = (Builder)info.getParent().getEditableBuilder();
2579
builder.removeErrorParsers(set);
2583
public void setErrorParserList(String[] ids) {
2585
errorParserIds = null;
2586
} else if(ids.length == 0){
2587
errorParserIds = EMPTY_STRING;
2589
StringBuffer buf = new StringBuffer();
2591
for(int i = 1; i < ids.length; i++){
2592
buf.append(";").append(ids[i]); //$NON-NLS-1$
2594
errorParserIds = buf.toString();
2598
public String getUniqueRealName() {
2599
String name = getName();
2603
String version = ManagedBuildManager.getVersionFromIdAndVersion(getId());
2604
if(version != null){
2605
StringBuffer buf = new StringBuffer();
2607
buf.append(" (v").append(version).append(")"); //$NON-NLS-1$ //$NON-NLS-2$
2608
name = buf.toString();
2614
void resolveProjectReferences(boolean onLoad){
2615
for(Tool tool : getToolList()){
2616
tool.resolveProjectReferences(onLoad);
2620
public boolean hasScannerConfigSettings(){
2622
if(getScannerConfigDiscoveryProfileId() != null)
2628
public boolean isPerRcTypeDiscovery(){
2629
if(isRcTypeBasedDiscovery == null){
2630
if(superClass != null){
2631
return ((ToolChain)superClass).isPerRcTypeDiscovery();
2635
return isRcTypeBasedDiscovery.booleanValue();
2638
public void setPerRcTypeDiscovery(boolean on){
2639
isRcTypeBasedDiscovery = Boolean.valueOf(on);
2642
public PathInfoCache setDiscoveredPathInfo(PathInfoCache info){
2643
PathInfoCache oldInfo = discoveredInfo;
2644
discoveredInfo = info;
2648
public PathInfoCache getDiscoveredPathInfo(){
2649
return discoveredInfo;
2652
public PathInfoCache clearDiscoveredPathInfo(){
2653
PathInfoCache oldInfo = discoveredInfo;
2654
discoveredInfo = null;
2658
public boolean isPreferenceToolChain(){
2659
IToolChain tch = ManagedBuildManager.getRealToolChain(this);
2660
return tch != null && tch.getId().equals(ConfigurationDataProvider.PREF_TC_ID);
2663
public boolean hasCustomSettings(ToolChain tCh){
2664
if(superClass == null)
2667
IToolChain realTc = ManagedBuildManager.getRealToolChain(this);
2668
IToolChain otherRealTc = ManagedBuildManager.getRealToolChain(tCh);
2669
if(realTc != otherRealTc)
2672
if(hasCustomSettings())
2675
ITool[] tools = getTools();
2676
ITool[] otherTools = tCh.getTools();
2677
if(tools.length != otherTools.length)
2680
for(int i = 0; i < tools.length; i++){
2681
Tool tool = (Tool)tools[i];
2682
Tool otherTool = (Tool)otherTools[i];
2683
if(tool.hasCustomSettings(otherTool))
2689
private int getSuperClassNum(){
2691
for(IToolChain superTool = getSuperClass(); superTool != null; superTool = superTool.getSuperClass()){
2697
public int compareTo(Object o) {
2698
ToolChain other = (ToolChain)o;
2699
if(other.isSystemObject() != isSystemObject())
2700
return isSystemObject() ? 1 : -1;
2702
return getSuperClassNum() - other.getSuperClassNum();
2705
private Set<String> getUnusedChilrenSet(){
2706
if(unusedChildrenSet == null){
2707
String childIds[] = CDataUtil.stringToArray(unusedChildren, ";"); //$NON-NLS-1$
2708
if(childIds == null)
2709
unusedChildrenSet = new HashSet<String>();
2711
unusedChildrenSet = new HashSet<String>();
2712
unusedChildrenSet.addAll(Arrays.asList(childIds));
2715
return unusedChildrenSet;
2718
void addUnusedChild(ITool tool){
2719
Set<String> set = getUnusedChilrenSet();
2720
set.add(tool.getId());
2721
unusedChildrenSet = set;
2722
unusedChildren = translateUnusedIdSetToString(set);
2725
void setUnusedChildren(String children){
2726
if(CDataUtil.objectsEqual(unusedChildren, children))
2729
unusedChildrenSet = null;
2730
unusedChildren = children;
2733
private String translateUnusedIdSetToString(Set<String> set){
2734
return CDataUtil.arrayToString(set.toArray(), ";"); //$NON-NLS-1$
2737
void addProjectVariables(StorableCdtVariables vars){
2738
if(vars != null && !vars.isEmpty()){
2739
StorableCdtVariables cfgVars = new StorableCdtVariables(vars, false);
2740
if(userDefinedMacros != null){
2741
cfgVars.createMacros(userDefinedMacros.getMacros());
2744
userDefinedMacros = cfgVars;
2748
public StorableCdtVariables getResetOldStyleProjectVariables(){
2749
StorableCdtVariables vars = userDefinedMacros;
2750
userDefinedMacros = null;
2754
public IRealBuildObjectAssociation getExtensionObject() {
2755
return (IRealBuildObjectAssociation)ManagedBuildManager.getExtensionToolChain(this);
2758
public IRealBuildObjectAssociation[] getIdenticBuildObjects() {
2759
return (IRealBuildObjectAssociation[])ManagedBuildManager.findIdenticalToolChains(this);
2762
public IRealBuildObjectAssociation getRealBuildObject() {
2763
return (IRealBuildObjectAssociation)ManagedBuildManager.getRealToolChain(this);
2766
public IRealBuildObjectAssociation getSuperClassObject() {
2767
return (IRealBuildObjectAssociation)getSuperClass();
2770
public final int getType() {
2771
return OBJECT_TOOLCHAIN;
2774
public boolean isRealBuildObject() {
2775
return getRealBuildObject() == this;
2778
public boolean isExtensionBuildObject() {
2779
return isExtensionElement();