1
/*******************************************************************************
2
* Copyright (c) 2003, 2008 IBM 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
* IBM - 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.HashMap;
16
import java.util.LinkedHashMap;
17
import java.util.LinkedHashSet;
18
import java.util.List;
21
import java.util.StringTokenizer;
22
import java.util.Vector;
24
import org.eclipse.cdt.build.core.scannerconfig.ICfgScannerConfigBuilderInfo2Set;
25
import org.eclipse.cdt.build.internal.core.scannerconfig.CfgDiscoveredPathManager.PathInfoCache;
26
import org.eclipse.cdt.core.CCorePlugin;
27
import org.eclipse.cdt.core.settings.model.CIncludePathEntry;
28
import org.eclipse.cdt.core.settings.model.CLibraryPathEntry;
29
import org.eclipse.cdt.core.settings.model.CSourceEntry;
30
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
31
import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
32
import org.eclipse.cdt.core.settings.model.ICLibraryPathEntry;
33
import org.eclipse.cdt.core.settings.model.ICOutputEntry;
34
import org.eclipse.cdt.core.settings.model.ICSettingBase;
35
import org.eclipse.cdt.core.settings.model.ICSettingEntry;
36
import org.eclipse.cdt.core.settings.model.ICSourceEntry;
37
import org.eclipse.cdt.core.settings.model.ICStorageElement;
38
import org.eclipse.cdt.core.settings.model.extension.CBuildData;
39
import org.eclipse.cdt.core.settings.model.extension.CConfigurationData;
40
import org.eclipse.cdt.core.settings.model.util.CDataUtil;
41
import org.eclipse.cdt.core.settings.model.util.LanguageSettingEntriesSerializer;
42
import org.eclipse.cdt.core.settings.model.util.PathSettingsContainer;
43
import org.eclipse.cdt.managedbuilder.buildproperties.IBuildProperty;
44
import org.eclipse.cdt.managedbuilder.buildproperties.IBuildPropertyType;
45
import org.eclipse.cdt.managedbuilder.buildproperties.IBuildPropertyValue;
46
import org.eclipse.cdt.managedbuilder.core.BuildException;
47
import org.eclipse.cdt.managedbuilder.core.IBuildObjectProperties;
48
import org.eclipse.cdt.managedbuilder.core.IBuildPropertiesRestriction;
49
import org.eclipse.cdt.managedbuilder.core.IBuilder;
50
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
51
import org.eclipse.cdt.managedbuilder.core.IFileInfo;
52
import org.eclipse.cdt.managedbuilder.core.IFolderInfo;
53
import org.eclipse.cdt.managedbuilder.core.IHoldsOptions;
54
import org.eclipse.cdt.managedbuilder.core.IManagedCommandLineGenerator;
55
import org.eclipse.cdt.managedbuilder.core.IManagedCommandLineInfo;
56
import org.eclipse.cdt.managedbuilder.core.IManagedConfigElement;
57
import org.eclipse.cdt.managedbuilder.core.IManagedOptionValueHandler;
58
import org.eclipse.cdt.managedbuilder.core.IManagedProject;
59
import org.eclipse.cdt.managedbuilder.core.IOption;
60
import org.eclipse.cdt.managedbuilder.core.IOptionApplicability;
61
import org.eclipse.cdt.managedbuilder.core.IProjectType;
62
import org.eclipse.cdt.managedbuilder.core.IResourceConfiguration;
63
import org.eclipse.cdt.managedbuilder.core.IResourceInfo;
64
import org.eclipse.cdt.managedbuilder.core.ITargetPlatform;
65
import org.eclipse.cdt.managedbuilder.core.ITool;
66
import org.eclipse.cdt.managedbuilder.core.IToolChain;
67
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
68
import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
69
import org.eclipse.cdt.managedbuilder.envvar.IConfigurationEnvironmentVariableSupplier;
70
import org.eclipse.cdt.managedbuilder.internal.dataprovider.BuildConfigurationData;
71
import org.eclipse.cdt.managedbuilder.internal.enablement.OptionEnablementExpression;
72
import org.eclipse.cdt.managedbuilder.internal.macros.BuildMacroProvider;
73
import org.eclipse.cdt.managedbuilder.internal.macros.FileContextData;
74
import org.eclipse.cdt.managedbuilder.internal.macros.OptionContextData;
75
import org.eclipse.cdt.managedbuilder.macros.BuildMacroException;
76
import org.eclipse.cdt.managedbuilder.macros.IBuildMacroProvider;
77
import org.eclipse.cdt.managedbuilder.macros.IConfigurationBuildMacroSupplier;
78
import org.eclipse.core.resources.IFile;
79
import org.eclipse.core.resources.IProject;
80
import org.eclipse.core.resources.IResource;
81
import org.eclipse.core.resources.IResourceDelta;
82
import org.eclipse.core.resources.ProjectScope;
83
import org.eclipse.core.runtime.CoreException;
84
import org.eclipse.core.runtime.IPath;
85
import org.eclipse.core.runtime.Path;
86
import org.eclipse.core.runtime.Platform;
87
import org.eclipse.core.runtime.PluginVersionIdentifier;
88
import org.osgi.service.prefs.Preferences;
90
public class Configuration extends BuildObject implements IConfiguration, IBuildPropertiesRestriction, IBuildPropertyChangeListener, IRealBuildObjectAssociation {
92
private static final String EMPTY_STRING = ""; //$NON-NLS-1$
93
private static final IPath EMPTY_PATH_ARRAY[] = new IPath[0];
94
private static final String EMPTY_CFG_ID = "org.eclipse.cdt.build.core.emptycfg"; //$NON-NLS-1$
96
// Parent and children
97
private String parentId;
98
private IConfiguration parent;
99
private ProjectType projectType;
100
private ManagedProject managedProject;
101
private String artifactName;
102
private String cleanCommand;
103
private String artifactExtension;
104
private String errorParserIds;
105
private String prebuildStep;
106
private String postbuildStep;
107
private String preannouncebuildStep;
108
private String postannouncebuildStep;
109
private String description;
110
private ICSourceEntry[] sourceEntries;
111
private BuildObjectProperties buildProperties;
112
private boolean isTest;
113
private SupportedProperties supportedProperties;
116
private boolean isExtensionConfig = false;
117
private boolean isDirty = false;
118
private boolean rebuildNeeded = false;
119
private boolean resolved = true;
120
private boolean isTemporary = false;
122
private PathSettingsContainer pathSettings = PathSettingsContainer.createRootContainer();
123
private ResourceInfoContainer rcInfos = new ResourceInfoContainer(pathSettings, true);
124
private BooleanExpressionApplicabilityCalculator booleanExpressionCalculator;
126
private FolderInfo rootFolderInfo;
127
private BuildConfigurationData fCfgData;
128
private ICConfigurationDescription fCfgDes;
129
// private IScannerConfigBuilderInfo2 scannerCfgBuilderInfo;
130
// private IDiscoveredPathManager.IDiscoveredPathInfo discoveredInfo;
131
// private Boolean isPerResourceDiscovery;
132
private ICfgScannerConfigBuilderInfo2Set cfgScannerInfo;
133
private boolean isPreferenceConfig;
134
private List excludeList;
136
//property name for holding the rebuild state
137
private static final String REBUILD_STATE = "rebuildState"; //$NON-NLS-1$
139
//The resource delta passed to the builder is not always up-to-date
140
//for the given configuration because between two builds of the same configuration
141
//any number of other configuration builds may occur
142
//that is why we need to keep some information regarding what happened
143
//with the resource tree between the two configuration builds
145
//The trivial approach implemented currently is to hold
146
//the general information of whether some resources were
147
//removed,changed,etc. and detect whether the rebuild is needed
148
//based upon this information
150
//In the future we might implement some more smart mechanism
151
//for tracking delta, e.g calculate the pre-cinfiguration resource delta, etc.
153
//property for holding the resource change state
154
private static final String RC_CHANGE_STATE = "rcState"; //$NON-NLS-1$
155
//resource change state
156
private int resourceChangeState = -1;
158
//Internal Builder state
159
//NOTE: these are temporary properties
160
//In the future we are going present the Internal Builder
161
//as a special Builder object of the tool-chain and implement the internal
162
//builder enabling/disabling as the Builder substitution functionality
164
// private static final String INTERNAL_BUILDER = "internalBuilder"; //$NON-NLS-1$
165
//preference key that holds the Internal Builder enable state
166
// private static final String INTERNAL_BUILDER_ENABLED = "enabled"; //$NON-NLS-1$
167
//preference key that holds the internal builder mode
168
// private static final String INTERNAL_BUILDER_IGNORE_ERR = "ignoreErr"; //$NON-NLS-1$
169
//preference key that holds the internal builder mode
170
// private static final String INTERNAL_BUILDER_PARALLEL = "parallel"; //$NON-NLS-1$
171
//preference key that holds the internal builder mode
172
// private static final String INTERNAL_BUILDER_PARALLEL_DEF = "paralleldef"; //$NON-NLS-1$
173
//preference key that holds the internal builder mode
174
// private static final String INTERNAL_BUILDER_PARALLELNUMBER = "parallelnumber"; //$NON-NLS-1$
175
//Internal Builder enable state
176
// private boolean internalBuilderEnabled;
177
//Internal Builder mode
178
// private boolean internalBuilderIgnoreErr = true;
179
//Internal Builder parallel mode
180
// private boolean internalBuilderParallel = true;
181
//Internal Builder parallel mode - default jobs #
182
// private boolean internalBuilderParallelDef = true;
183
//Number of parallel threads
184
// private int internalBuilderParallelNumber = 1; // default value
186
* C O N S T R U C T O R S
190
* Create an extension configuration from the project manifest file element.
192
* @param projectType The <code>ProjectType</code> the configuration will be added to.
193
* @param element The element from the manifest that contains the configuration information.
194
* @param managedBuildRevision
196
public Configuration(ProjectType projectType, IManagedConfigElement element, String managedBuildRevision) {
197
this.projectType = projectType;
198
isExtensionConfig = true;
200
// setup for resolving
203
setManagedBuildRevision(managedBuildRevision);
205
// Initialize from the XML attributes
206
loadFromManifest(element);
208
// Hook me up to the Managed Build Manager
209
ManagedBuildManager.addExtensionConfiguration(this);
211
// Hook me up to the ProjectType
212
if (projectType != null) {
213
projectType.addConfiguration(this);
216
IManagedConfigElement enablements[] = element.getChildren(OptionEnablementExpression.NAME);
217
if(enablements.length > 0)
218
booleanExpressionCalculator = new BooleanExpressionApplicabilityCalculator(enablements);
222
IManagedConfigElement[] configElements = element.getChildren();
223
List srcPathList = new ArrayList();
224
excludeList = new ArrayList();
225
for (int l = 0; l < configElements.length; ++l) {
226
IManagedConfigElement configElement = configElements[l];
227
if (configElement.getName().equals(IToolChain.TOOL_CHAIN_ELEMENT_NAME)) {
228
rootFolderInfo = new FolderInfo(this, configElement, managedBuildRevision, false);
229
addResourceConfiguration(rootFolderInfo);
230
} else if (IFolderInfo.FOLDER_INFO_ELEMENT_NAME.equals(configElement.getName())) {
231
FolderInfo resConfig = new FolderInfo(this, configElement, managedBuildRevision, true);
232
addResourceConfiguration(resConfig);
233
} else if (IFileInfo.FILE_INFO_ELEMENT_NAME.equals(configElement.getName())
234
|| IResourceConfiguration.RESOURCE_CONFIGURATION_ELEMENT_NAME.equals(configElement.getName())) {
235
ResourceConfiguration resConfig = new ResourceConfiguration(this, configElement, managedBuildRevision);
236
addResourceConfiguration(resConfig);
237
} else if (SourcePath.ELEMENT_NAME.equals(configElement.getName())){
238
SourcePath p = new SourcePath(configElement);
239
if(p.getPath() != null)
240
srcPathList.add(p.getPath());
241
} else if (configElement.getName().equals(SupportedProperties.SUPPORTED_PROPERTIES)){
242
loadProperties(configElement);
243
} else if (SOURCE_ENTRIES.equals(configElement.getName())){
244
List seList = LanguageSettingEntriesSerializer.loadEntriesList(new ManagedConfigStorageElement(configElement), ICSettingEntry.SOURCE_PATH);
245
sourceEntries = (ICSourceEntry[])seList.toArray(new ICSourceEntry[seList.size()]);
249
sourceEntries = createSourceEntries(sourceEntries, srcPathList, excludeList);
253
if(rootFolderInfo == null)
254
createRootFolderInfo();
256
String props = element.getAttribute(BUILD_PROPERTIES);
258
buildProperties = new BuildObjectProperties(props, this, this);
260
String artType = element.getAttribute(BUILD_ARTEFACT_TYPE);
262
if(buildProperties == null)
263
buildProperties = new BuildObjectProperties(this, this);
266
buildProperties.setProperty(ManagedBuildManager.BUILD_ARTEFACT_TYPE_PROPERTY_ID, artType, true);
267
} catch (CoreException e) {
268
ManagedBuilderCorePlugin.log(e);
272
if(projectType != null && projectType.buildProperties != null){
273
if(buildProperties == null){
274
buildProperties = new BuildObjectProperties(projectType.buildProperties, this, this);
276
IBuildProperty properties[] = projectType.buildProperties.getProperties();
277
for(int i = 0; i < properties.length; i++){
279
buildProperties.internalSetProperty(properties[i].getPropertyType().getId(),
280
properties[i].getValue().getId());
281
} catch (CoreException e) {
290
private static ICSourceEntry[] createSourceEntries(ICSourceEntry[] curEntries, List pathList, List excludeList){
291
for(int i = 0; i < excludeList.size(); i++){
292
IPath path = (IPath)excludeList.get(i);
293
if(path.segmentCount() == 0)
294
excludeList.remove(i);
296
if(pathList.size() == 0)
297
pathList.add(Path.EMPTY);
299
if(pathList.size() == 1
300
&& pathList.get(0).equals(Path.EMPTY)
301
&& excludeList.size() == 0)
304
int pathSize = pathList.size();
305
Map map = new LinkedHashMap();
307
for(int i = 0; i < pathSize; i++){
308
IPath path = (IPath)pathList.get(i);
309
ICSourceEntry entry = (ICSourceEntry)map.get(path);
311
entry = new CSourceEntry(path, null, ICSettingEntry.VALUE_WORKSPACE_PATH | ICSettingEntry.RESOLVED);
313
entry = CDataUtil.addExcludePaths(entry, excludeList, true);
315
map.put(path, entry);
318
return (ICSourceEntry[])map.values().toArray(new ICSourceEntry[map.size()]);
322
* Create a new extension configuration based on one already defined.
324
* @param projectType The <code>ProjectType</code> the configuration will be added to.
325
* @param parentConfig The <code>IConfiguration</code> that is the parent configuration of this configuration
326
* @param id A unique ID for the new configuration.
328
public Configuration(ProjectType projectType, IConfiguration parentConfig, String id) {
330
this.projectType = projectType;
331
isExtensionConfig = true;
333
// setup for resolving
336
if (parentConfig != null) {
337
name = parentConfig.getName();
338
// If this contructor is called to clone an existing
339
// configuration, the parent of the parent should be stored.
340
// As of 2.1, there is still one single level of inheritence to
342
parent = parentConfig.getParent() == null ? parentConfig : parentConfig.getParent();
345
// Hook me up to the Managed Build Manager
346
ManagedBuildManager.addExtensionConfiguration(this);
348
// Hook me up to the ProjectType
349
if (projectType != null) {
350
projectType.addConfiguration(this);
351
// set managedBuildRevision
352
setManagedBuildRevision(projectType.getManagedBuildRevision());
357
* Create a new extension configuration and fill in the attributes and childen later.
359
* @param projectType The <code>ProjectType</code> the configuration will be added to.
360
* @param parentConfig The <code>IConfiguration</code> that is the parent configuration of this configuration
361
* @param id A unique ID for the new configuration.
362
* @param name A name for the new configuration.
364
public Configuration(ProjectType projectType, IConfiguration parentConfig, String id, String name) {
367
this.projectType = projectType;
368
parent = parentConfig;
369
isExtensionConfig = true;
371
// Hook me up to the Managed Build Manager
372
ManagedBuildManager.addExtensionConfiguration(this);
374
// Hook me up to the ProjectType
375
if (projectType != null) {
376
projectType.addConfiguration(this);
377
setManagedBuildRevision(projectType.getManagedBuildRevision());
382
* Create a <code>Configuration</code> based on the specification stored in the
383
* project file (.cdtbuild).
385
* @param managedProject The <code>ManagedProject</code> the configuration will be added to.
386
* @param element The XML element that contains the configuration settings.
389
public Configuration(ManagedProject managedProject, ICStorageElement element, String managedBuildRevision, boolean isPreference) {
390
this.managedProject = managedProject;
391
this.isPreferenceConfig = isPreference;
392
isExtensionConfig = false;
393
fCfgData = new BuildConfigurationData(this);
395
setManagedBuildRevision(managedBuildRevision);
397
// Initialize from the XML attributes
398
loadFromProject(element);
401
if(managedProject != null)
402
managedProject.addConfiguration(this);
404
ICStorageElement configElements[] = element.getChildren();
405
List srcPathList = new ArrayList();
406
excludeList = new ArrayList();
407
for (int i = 0; i < configElements.length; ++i) {
408
ICStorageElement configElement = configElements[i];
409
if (configElement.getName().equals(IToolChain.TOOL_CHAIN_ELEMENT_NAME)) {
410
rootFolderInfo = new FolderInfo(this, configElement, managedBuildRevision, false);
411
addResourceConfiguration(rootFolderInfo);
412
} else if (IFolderInfo.FOLDER_INFO_ELEMENT_NAME.equals(configElement.getName())) {
413
FolderInfo resConfig = new FolderInfo(this, configElement, managedBuildRevision, true);
414
addResourceConfiguration(resConfig);
415
} else if (IFileInfo.FILE_INFO_ELEMENT_NAME.equals(configElement.getName())
416
|| IResourceConfiguration.RESOURCE_CONFIGURATION_ELEMENT_NAME.equals(configElement.getName())) {
417
ResourceConfiguration resConfig = new ResourceConfiguration(this, configElement, managedBuildRevision);
418
addResourceConfiguration(resConfig);
419
} else if (SourcePath.ELEMENT_NAME.equals(configElement.getName())){
420
SourcePath p = new SourcePath(configElement);
421
if(p.getPath() != null)
422
srcPathList.add(p.getPath());
423
} else if (SOURCE_ENTRIES.equals(configElement.getName())){
424
List seList = LanguageSettingEntriesSerializer.loadEntriesList(configElement, ICSettingEntry.SOURCE_PATH);
425
sourceEntries = (ICSourceEntry[])seList.toArray(new ICSourceEntry[seList.size()]);
429
resolveProjectReferences(true);
431
sourceEntries = createSourceEntries(sourceEntries, srcPathList, excludeList);
435
PropertyManager mngr = PropertyManager.getInstance();
436
String rebuild = mngr.getProperty(this, REBUILD_STATE);
437
if(rebuild == null || Boolean.valueOf(rebuild).booleanValue())
438
rebuildNeeded = true;
440
String rcChangeState = mngr.getProperty(this, RC_CHANGE_STATE);
441
if(rcChangeState == null)
442
resourceChangeState = ~0;
445
resourceChangeState = Integer.parseInt(rcChangeState);
446
} catch (NumberFormatException e){
447
resourceChangeState = ~0;
453
// Preferences prefs = getPreferences(INTERNAL_BUILDER);
455
// internalBuilderEnabled = prefs != null ?
456
// prefs.getBoolean(INTERNAL_BUILDER_ENABLED, false) : false;
457
// internalBuilderIgnoreErr = prefs != null ?
458
// prefs.getBoolean(INTERNAL_BUILDER_IGNORE_ERR, true) : true;
461
public Configuration(ManagedProject managedProject, ToolChain tCh, String id, String name) {
465
// this.description = cloneConfig.getDescription();
466
this.managedProject = managedProject;
467
isExtensionConfig = false;
470
//create configuration based upon the preference config
471
IConfiguration cfg = ManagedBuildManager.getPreferenceConfiguration(false);
473
copySettingsFrom((Configuration)cfg, true);
475
Configuration baseCfg = (Configuration)ManagedBuildManager.getExtensionConfiguration(EMPTY_CFG_ID);
476
// this.isTemporary = temporary;
477
fCfgData = new BuildConfigurationData(this);
478
if(baseCfg.buildProperties != null)
479
this.buildProperties = new BuildObjectProperties(baseCfg.buildProperties, this, this);
481
// set managedBuildRevision
482
setManagedBuildRevision(baseCfg.getManagedBuildRevision());
484
// if(!baseCfg.isExtensionConfig)
485
// cloneChildren = true;
486
// If this contructor is called to clone an existing
487
// configuration, the parent of the cloning config should be stored.
488
parent = baseCfg.isExtensionConfig || baseCfg.getParent() == null ? baseCfg : baseCfg.getParent();
490
// Copy the remaining attributes
491
projectType = baseCfg.projectType;
493
artifactName = baseCfg.artifactName;
495
cleanCommand = baseCfg.cleanCommand;
497
artifactExtension = baseCfg.artifactExtension;
499
errorParserIds = baseCfg.errorParserIds;
501
prebuildStep = baseCfg.prebuildStep;
503
postbuildStep = baseCfg.postbuildStep;
505
preannouncebuildStep = baseCfg.preannouncebuildStep;
507
postannouncebuildStep = baseCfg.postannouncebuildStep;
509
if(baseCfg.sourceEntries != null)
510
sourceEntries = (ICSourceEntry[])baseCfg.sourceEntries.clone();
512
// enableInternalBuilder(baseCfg.isInternalBuilderEnabled());
513
// setInternalBuilderIgnoreErr(baseCfg.getInternalBuilderIgnoreErr());
514
// setInternalBuilderParallel(baseCfg.getInternalBuilderParallel());
515
// setParallelDef(baseCfg.getParallelDef());
516
// setParallelNumber(baseCfg.getParallelNumber());
517
// internalBuilderEnabled = cloneConfig.internalBuilderEnabled;
518
// internalBuilderIgnoreErr = cloneConfig.internalBuilderIgnoreErr;
520
// Clone the configuration's children
523
String tcId = ManagedBuildManager.calculateChildId(tCh.getId(), null);
525
IToolChain newChain = createToolChain(tCh, tcId, tCh.getId(), false);
527
// For each option/option category child of the tool-chain that is
528
// the child of the selected configuration element, create an option/
529
// option category child of the cloned configuration's tool-chain element
530
// that specifies the original tool element as its superClass.
531
newChain.createOptions(tCh);
533
// For each tool element child of the tool-chain that is the child of
534
// the selected configuration element, create a tool element child of
535
// the cloned configuration's tool-chain element that specifies the
536
// original tool element as its superClass.
538
ITool[] tools = tCh.getTools();
539
for (int i=0; i<tools.length; i++) {
540
Tool toolChild = (Tool)tools[i];
541
subId = ManagedBuildManager.calculateChildId(toolChild.getId(),null);
542
newChain.createTool(toolChild, subId, toolChild.getName(), false);
545
ITargetPlatform tpBase = tCh.getTargetPlatform();
546
ITargetPlatform extTp = tpBase;
547
for(;extTp != null && !extTp.isExtensionElement();extTp = extTp.getSuperClass());
551
int nnn = ManagedBuildManager.getRandomNumber();
552
subId = extTp.getId() + "." + nnn; //$NON-NLS-1$
553
// subName = tpBase.getName();
554
tp = new TargetPlatform(newChain, subId, tpBase.getName(), (TargetPlatform)tpBase);
556
subId = ManagedBuildManager.calculateChildId(getId(), null);
557
String subName = ""; //$NON-NLS-1$
558
tp = new TargetPlatform((ToolChain)newChain, null, subId, subName, false);
561
((ToolChain)newChain).setTargetPlatform(tp);
564
// if(cloneChildren){
565
//copy expand build macros setting
566
// BuildMacroProvider macroProvider = (BuildMacroProvider)ManagedBuildManager.getBuildMacroProvider();
567
// macroProvider.expandMacrosInBuildfile(this,
568
// macroProvider.areMacrosExpandedInBuildfile(baseCfg));
570
//copy user-defined build macros
571
/* UserDefinedMacroSupplier userMacros = BuildMacroProvider.fUserDefinedMacroSupplier;
572
userMacros.setMacros(
573
userMacros.getMacros(BuildMacroProvider.CONTEXT_CONFIGURATION,cloneConfig),
574
BuildMacroProvider.CONTEXT_CONFIGURATION,
577
//copy user-defined environment
578
// UserDefinedEnvironmentSupplier userEnv = EnvironmentVariableProvider.fUserSupplier;
579
// userEnv.setVariables(
580
// userEnv.getVariables(cloneConfig), this);
585
managedProject.addConfiguration(this);
587
IBuilder builder = getEditableBuilder();
589
builder.setManagedBuildOn(false);
590
} catch (CoreException e) {
596
setRebuildState(true);
599
public Configuration(ManagedProject managedProject, Configuration cloneConfig, String id, boolean cloneChildren, boolean temporary) {
600
this(managedProject, cloneConfig, id, cloneChildren, temporary, false);
604
* Create a new project, non-extension, configuration based on one already defined.
606
* @param managedProject The <code>ManagedProject</code> the configuration will be added to.
607
* @param cloneConfig The <code>IConfiguration</code> to copy the settings from.
608
* @param id A unique ID for the new configuration.
609
* @param cloneChildren If <code>true</code>, the configuration's tools are cloned
611
public Configuration(ManagedProject managedProject, Configuration cloneConfig, String id, boolean cloneChildren, boolean temporary, boolean isPreferenceConfig) {
613
setName(cloneConfig.getName());
614
this.isPreferenceConfig = isPreferenceConfig;
615
this.managedProject = managedProject;
616
isExtensionConfig = false;
617
this.isTemporary = temporary;
619
copySettingsFrom(cloneConfig, cloneChildren);
622
private void copySettingsFrom(Configuration cloneConfig, boolean cloneChildren){
623
fCfgData = new BuildConfigurationData(this);
624
if(cloneConfig.buildProperties != null)
625
this.buildProperties = new BuildObjectProperties(cloneConfig.buildProperties, this, this);
627
this.description = cloneConfig.getDescription();
629
// set managedBuildRevision
630
setManagedBuildRevision(cloneConfig.getManagedBuildRevision());
632
if(!cloneConfig.isExtensionConfig)
633
cloneChildren = true;
634
// If this contructor is called to clone an existing
635
// configuration, the parent of the cloning config should be stored.
636
parent = cloneConfig.isExtensionConfig || cloneConfig.getParent() == null ? cloneConfig : cloneConfig.getParent();
637
parentId = parent.getId();
639
// Copy the remaining attributes
640
projectType = cloneConfig.projectType;
641
if (cloneConfig.artifactName != null) {
642
artifactName = new String(cloneConfig.artifactName);
644
if (cloneConfig.cleanCommand != null) {
645
cleanCommand = new String(cloneConfig.cleanCommand);
647
if (cloneConfig.artifactExtension != null) {
648
artifactExtension = new String(cloneConfig.artifactExtension);
650
if (cloneConfig.errorParserIds != null) {
651
errorParserIds = new String(cloneConfig.errorParserIds);
653
if (cloneConfig.prebuildStep != null) {
654
prebuildStep = new String(cloneConfig.prebuildStep);
656
if (cloneConfig.postbuildStep != null) {
657
postbuildStep = new String(cloneConfig.postbuildStep);
659
if (cloneConfig.preannouncebuildStep != null) {
660
preannouncebuildStep = new String(cloneConfig.preannouncebuildStep);
662
if (cloneConfig.postannouncebuildStep != null) {
663
postannouncebuildStep = new String(cloneConfig.postannouncebuildStep);
665
if(cloneConfig.sourceEntries != null)
666
sourceEntries = (ICSourceEntry[])cloneConfig.sourceEntries.clone();
668
// enableInternalBuilder(cloneConfig.isInternalBuilderEnabled());
669
// setInternalBuilderIgnoreErr(cloneConfig.getInternalBuilderIgnoreErr());
670
// setInternalBuilderParallel(cloneConfig.getInternalBuilderParallel());
671
// setParallelDef(cloneConfig.getParallelDef());
672
// setParallelNumber(cloneConfig.getParallelNumber());
673
// internalBuilderEnabled = cloneConfig.internalBuilderEnabled;
674
// internalBuilderIgnoreErr = cloneConfig.internalBuilderIgnoreErr;
676
// Clone the configuration's children
678
boolean copyIds = cloneConfig.getId().equals(id);
680
// Resource Configurations
681
Map toolIdMap = new HashMap();
682
IResourceInfo infos[] = cloneConfig.rcInfos.getResourceInfos();
683
for(int i = 0; i < infos.length; i++){
684
if(infos[i] instanceof FolderInfo){
685
FolderInfo folderInfo = (FolderInfo)infos[i];
686
subId = copyIds ? folderInfo.getId() : ManagedBuildManager.calculateChildId(getId(), folderInfo.getPath().toString());
687
FolderInfo newFolderInfo = new FolderInfo(this, folderInfo, subId, toolIdMap, cloneChildren);
688
addResourceConfiguration(newFolderInfo);
690
ResourceConfiguration fileInfo = (ResourceConfiguration)infos[i];
691
subId = copyIds ? fileInfo.getId() : ManagedBuildManager.calculateChildId(getId(), fileInfo.getPath().toString());
692
ResourceConfiguration newResConfig = new ResourceConfiguration(this, fileInfo, subId, toolIdMap, cloneChildren);
693
addResourceConfiguration(newResConfig);
698
resolveProjectReferences(false);
701
//copy expand build macros setting
702
BuildMacroProvider macroProvider = (BuildMacroProvider)ManagedBuildManager.getBuildMacroProvider();
703
macroProvider.expandMacrosInBuildfile(this,
704
macroProvider.areMacrosExpandedInBuildfile(cloneConfig));
706
//copy user-defined build macros
707
/* UserDefinedMacroSupplier userMacros = BuildMacroProvider.fUserDefinedMacroSupplier;
708
userMacros.setMacros(
709
userMacros.getMacros(BuildMacroProvider.CONTEXT_CONFIGURATION,cloneConfig),
710
BuildMacroProvider.CONTEXT_CONFIGURATION,
713
//copy user-defined environment
714
// UserDefinedEnvironmentSupplier userEnv = EnvironmentVariableProvider.fUserSupplier;
715
// userEnv.setVariables(
716
// userEnv.getVariables(cloneConfig), this);
721
if(managedProject != null){
722
managedProject.addConfiguration(this);
725
if(cloneConfig.isExtensionConfig){
730
rebuildNeeded = cloneConfig.rebuildNeeded;
731
resourceChangeState = cloneConfig.resourceChangeState;
732
isDirty = cloneConfig.isDirty;
734
if(cloneConfig.isExtensionConfig)
735
exportArtifactInfo();
737
setRebuildState(true);
742
public void applyToManagedProject(ManagedProject mProj){
743
managedProject = mProj;
744
isPreferenceConfig = false;
746
managedProject.addConfiguration(this);
750
* 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
754
* Initialize the configuration information from an element in the
755
* manifest file or provided by a dynamicElementProvider
757
* @param element An obejct implementing IManagedConfigElement
759
protected void loadFromManifest(IManagedConfigElement element) {
760
ManagedBuildManager.putConfigElement(this, element);
763
setId(element.getAttribute(IConfiguration.ID));
766
name = element.getAttribute(IConfiguration.NAME);
769
description = element.getAttribute(IConfiguration.DESCRIPTION);
772
parentId = element.getAttribute(IConfiguration.PARENT);
773
// if (parentID != null) {
774
// // Lookup the parent configuration by ID
775
// parent = ManagedBuildManager.getExtensionConfiguration(parentID);
778
// Get the name of the build artifact associated with configuration
779
artifactName = element.getAttribute(ARTIFACT_NAME);
781
// Get the semicolon separated list of IDs of the error parsers
782
errorParserIds = element.getAttribute(ERROR_PARSERS);
784
// Get the artifact extension
785
artifactExtension = element.getAttribute(EXTENSION);
787
// Get the clean command
788
cleanCommand = element.getAttribute(CLEAN_COMMAND);
790
// Get the pre-build and post-build commands
791
prebuildStep = element.getAttribute(PREBUILD_STEP);
792
postbuildStep = element.getAttribute(POSTBUILD_STEP);
794
// Get the pre-build and post-build announcements
795
preannouncebuildStep = element.getAttribute(PREANNOUNCEBUILD_STEP);
796
postannouncebuildStep = element.getAttribute(POSTANNOUNCEBUILD_STEP);
798
String tmp = element.getAttribute(IS_SYSTEM);
800
isTest = Boolean.valueOf(tmp).booleanValue();
804
* Initialize the configuration information from the XML element
805
* specified in the argument
807
* @param element An XML element containing the configuration information
809
protected void loadFromProject(ICStorageElement element) {
812
setId(element.getAttribute(IConfiguration.ID));
815
if (element.getAttribute(IConfiguration.NAME) != null)
816
setName(element.getAttribute(IConfiguration.NAME));
819
if (element.getAttribute(IConfiguration.DESCRIPTION) != null)
820
this.description = element.getAttribute(IConfiguration.DESCRIPTION);
822
String props = element.getAttribute(BUILD_PROPERTIES);
824
buildProperties = new BuildObjectProperties(props, this, this);
826
String artType = element.getAttribute(BUILD_ARTEFACT_TYPE);
828
if(buildProperties == null)
829
buildProperties = new BuildObjectProperties(this, this);
832
buildProperties.setProperty(ManagedBuildManager.BUILD_ARTEFACT_TYPE_PROPERTY_ID, artType, true);
833
} catch (CoreException e) {
834
ManagedBuilderCorePlugin.log(e);
839
if (element.getAttribute(IConfiguration.PARENT) != null) {
840
// See if the parent belongs to the same project
841
if(managedProject != null)
842
parent = managedProject.getConfiguration(element.getAttribute(IConfiguration.PARENT));
843
// If not, then try the extension configurations
844
if (parent == null) {
845
parent = ManagedBuildManager.getExtensionConfiguration(element.getAttribute(IConfiguration.PARENT));
849
// Get the name of the build artifact associated with target (usually
850
// in the plugin specification).
851
if (element.getAttribute(ARTIFACT_NAME) != null) {
852
artifactName = element.getAttribute(ARTIFACT_NAME);
855
// Get the semicolon separated list of IDs of the error parsers
856
if (element.getAttribute(ERROR_PARSERS) != null) {
857
errorParserIds = element.getAttribute(ERROR_PARSERS);
860
// Get the artifact extension
861
if (element.getAttribute(EXTENSION) != null) {
862
artifactExtension = element.getAttribute(EXTENSION);
865
// Get the clean command
866
if (element.getAttribute(CLEAN_COMMAND) != null) {
867
cleanCommand = element.getAttribute(CLEAN_COMMAND);
870
// Get the pre-build and post-build commands
871
if (element.getAttribute(PREBUILD_STEP) != null) {
872
prebuildStep = element.getAttribute(PREBUILD_STEP);
875
if (element.getAttribute(POSTBUILD_STEP) != null) {
876
postbuildStep = element.getAttribute(POSTBUILD_STEP);
879
// Get the pre-build and post-build announcements
880
if (element.getAttribute(PREANNOUNCEBUILD_STEP) != null) {
881
preannouncebuildStep = element.getAttribute(PREANNOUNCEBUILD_STEP);
884
if (element.getAttribute(POSTANNOUNCEBUILD_STEP) != null) {
885
postannouncebuildStep = element
886
.getAttribute(POSTANNOUNCEBUILD_STEP);
891
* Persist this configuration to project file.
896
public void serialize(ICStorageElement element) {
897
element.setAttribute(IConfiguration.ID, id);
900
element.setAttribute(IConfiguration.NAME, name);
902
if (description != null)
903
element.setAttribute(IConfiguration.DESCRIPTION, description);
905
if(buildProperties != null){
906
element.setAttribute(BUILD_PROPERTIES, buildProperties.toString());
908
IBuildProperty prop = buildProperties.getProperty(ManagedBuildManager.BUILD_ARTEFACT_TYPE_PROPERTY_ID);
910
IBuildPropertyValue val = prop.getValue();
911
element.setAttribute(BUILD_ARTEFACT_TYPE, val.getId());
916
element.setAttribute(IConfiguration.PARENT, parent.getId());
918
if (artifactName != null)
919
element.setAttribute(ARTIFACT_NAME, artifactName);
921
if (errorParserIds != null)
922
element.setAttribute(ERROR_PARSERS, errorParserIds);
924
if (artifactExtension != null)
925
element.setAttribute(EXTENSION, artifactExtension);
927
if (cleanCommand != null)
928
element.setAttribute(CLEAN_COMMAND, cleanCommand);
930
if (prebuildStep != null)
931
element.setAttribute(PREBUILD_STEP, prebuildStep);
933
if (postbuildStep != null)
934
element.setAttribute(POSTBUILD_STEP, postbuildStep);
936
if (preannouncebuildStep != null)
937
element.setAttribute(PREANNOUNCEBUILD_STEP, preannouncebuildStep);
939
if (postannouncebuildStep != null)
940
element.setAttribute(POSTANNOUNCEBUILD_STEP, postannouncebuildStep);
942
// Serialize my children
943
IResourceInfo infos[] = rcInfos.getResourceInfos();
944
for(int i = 0; i < infos.length; i++){
945
String elementName = infos[i].getKind() == ICSettingBase.SETTING_FILE ? IFileInfo.FILE_INFO_ELEMENT_NAME :
946
IFolderInfo.FOLDER_INFO_ELEMENT_NAME;
948
ICStorageElement resElement = element.createChild(elementName);
949
((ResourceInfo)infos[i]).serialize(resElement);
952
PropertyManager.getInstance().serialize(this);
954
if(sourceEntries != null && sourceEntries.length > 0){
955
ICStorageElement el = element.createChild(SOURCE_ENTRIES);
956
LanguageSettingEntriesSerializer.serializeEntries(sourceEntries, el);
963
* P A R E N T A N D C H I L D H A N D L I N G
967
* @see org.eclipse.cdt.core.build.managed.IConfiguration#getParent()
969
public IConfiguration getParent() {
974
* @see org.eclipse.cdt.core.build.managed.IConfiguration#getOwner()
976
public IResource getOwner() {
977
if (managedProject != null)
978
return managedProject.getOwner();
980
return null; // Extension configurations don't have an "owner"
985
* @see org.eclipse.cdt.core.build.managed.IConfiguration#getProjectType()
987
public IProjectType getProjectType() {
988
return (IProjectType)projectType;
992
* @see org.eclipse.cdt.core.build.managed.IConfiguration#getManagedProject()
994
public IManagedProject getManagedProject() {
995
return (IManagedProject)managedProject;
999
* @see org.eclipse.cdt.core.build.managed.IConfiguration#getToolChain(IToolChain, String, String, boolean)
1001
public IToolChain createToolChain(IToolChain superClass, String Id, String name, boolean isExtensionElement) {
1002
if(rootFolderInfo == null){
1003
createRootFolderInfo();
1006
return rootFolderInfo.createToolChain(superClass, Id, name, isExtensionElement);
1009
private IFolderInfo createRootFolderInfo(){
1010
String id = ManagedBuildManager.calculateChildId(this.id, null);
1011
String name = "/"; //$NON-NLS-1$
1013
rootFolderInfo = new FolderInfo(this, new Path(name), id, name, isExtensionConfig);
1014
addResourceConfiguration(rootFolderInfo);
1015
return rootFolderInfo;
1018
public IFolderInfo createFolderInfo(IPath path, IToolChain superClass, String Id, String name){
1022
public IFolderInfo createFolderInfo(IPath path, IFolderInfo baseFolderInfo, String Id, String name){
1027
* @see org.eclipse.cdt.core.build.managed.IConfiguration#getToolChain()
1029
public IToolChain getToolChain() {
1030
return rootFolderInfo.getToolChain();
1034
* @see org.eclipse.cdt.core.build.managed.IConfiguration#getResourceConfigurations()
1036
public IResourceConfiguration[] getResourceConfigurations() {
1037
return (IResourceConfiguration[])rcInfos.getResourceInfos(ICSettingBase.SETTING_FILE, IResourceConfiguration.class);
1041
* @see org.eclipse.cdt.managedbuilder.core.IConfiguration#getResourceConfiguration(java.lang.String)
1043
public IResourceConfiguration getResourceConfiguration(String resPath) {
1044
return rcInfos.getFileInfo(new Path(resPath).removeFirstSegments(1));
1048
* @see org.eclipse.cdt.managedbuilder.core.IConfiguration#getFilteredTools()
1050
public ITool[] getFilteredTools() {
1051
return rootFolderInfo.getFilteredTools();
1055
* @see org.eclipse.cdt.core.build.managed.IConfiguration#getTools()
1057
public ITool[] getTools() {
1058
return rootFolderInfo.getTools();
1062
* @see org.eclipse.cdt.managedbuilder.core.IConfiguration#getTool(java.lang.String)
1064
public ITool getTool(String id) {
1065
return rootFolderInfo.getTool(id);
1069
* @see org.eclipse.cdt.managedbuilder.core.IConfiguration#getToolsBySuperClassId(java.lang.String)
1071
public ITool[] getToolsBySuperClassId(String id) {
1072
return rootFolderInfo.getToolsBySuperClassId(id);
1076
* @see org.eclipse.cdt.managedbuilder.core.IConfiguration#getTargetTool()
1078
public ITool getTargetTool() {
1079
String[] targetToolIds = rootFolderInfo.getToolChain().getTargetToolList();
1080
if (targetToolIds == null || targetToolIds.length == 0) return null;
1082
// For each target tool id, in list order,
1083
// look for a tool with this ID, or a tool with a superclass with this id.
1084
// Stop when we find a match
1085
ITool[] tools = getFilteredTools();
1086
for (int i=0; i<targetToolIds.length; i++) {
1087
String targetToolId = targetToolIds[i];
1088
for (int j=0; j<tools.length; j++) {
1089
ITool targetTool = tools[j];
1090
ITool tool = targetTool;
1092
if (targetToolId.equals(tool.getId())) {
1095
tool = tool.getSuperClass();
1096
} while (tool != null);
1103
* @see org.eclipse.cdt.managedbuilder.core.IConfiguration#setToolCommand(org.eclipse.cdt.managedbuilder.core.ITool, java.lang.String)
1105
public String getToolCommand(ITool tool) {
1106
// TODO: Do we need to verify that the tool is part of the configuration?
1107
return tool.getToolCommand();
1111
* @see org.eclipse.cdt.managedbuilder.core.IConfiguration#setToolCommand(org.eclipse.cdt.managedbuilder.core.ITool, java.lang.String)
1113
public void setToolCommand(ITool tool, String command) {
1114
// TODO: Do we need to verify that the tool is part of the configuration?
1115
tool.setToolCommand(command);
1119
* @see org.eclipse.cdt.core.build.managed.IConfiguration#setOption(org.eclipse.cdt.core.build.managed.IOption, boolean)
1121
public IOption setOption(IHoldsOptions holder, IOption option, boolean value) throws BuildException {
1122
return getRootFolderInfo().setOption(holder, option, value);
1126
* @see org.eclipse.cdt.core.build.managed.IConfiguration#setOption(org.eclipse.cdt.core.build.managed.IOption, java.lang.String)
1128
public IOption setOption(IHoldsOptions holder, IOption option, String value) throws BuildException {
1129
return getRootFolderInfo().setOption(holder, option, value);
1133
* @see org.eclipse.cdt.core.build.managed.IConfiguration#setOption(org.eclipse.cdt.core.build.managed.IOption, java.lang.String[])
1135
public IOption setOption(IHoldsOptions holder, IOption option, String[] value) throws BuildException {
1136
return getRootFolderInfo().setOption(holder, option, value);
1140
* Adds the Resource Configuration to the Resource Configuration list and map
1144
void addResourceConfiguration(IResourceInfo resConfig) {
1145
if(resConfig.getPath().segmentCount() == 0)
1146
rootFolderInfo = (FolderInfo)resConfig;
1147
rcInfos.addResourceInfo(resConfig);
1149
// rebuildNeeded = true;
1152
public void removeResourceConfiguration(IResourceInfo resConfig) {
1153
ManagedBuildManager.performValueHandlerEvent(resConfig,
1154
IManagedOptionValueHandler.EVENT_CLOSE);
1155
ITool tools[] = resConfig.getTools();
1156
rcInfos.removeResourceInfo(resConfig.getPath());
1157
((ResourceInfo)resConfig).removed();
1158
BuildSettingsUtil.disconnectDepentents(this, tools);
1160
rebuildNeeded = true;
1163
* M O D E L A T T R I B U T E A C C E S S O R S
1167
* @see org.eclipse.cdt.core.build.managed.IConfiguration#getName()
1169
public String getName() {
1170
return (name == null && parent != null) ? parent.getName() : name;
1174
* @see org.eclipse.cdt.managedbuilder.core.IConfiguration#getArtifactExtension()
1176
public String getArtifactExtension() {
1177
String ext = getArtifactExtensionAttribute(true);
1178
return ext != null ? ext : EMPTY_STRING;
1181
public String getArtifactExtensionAttribute(boolean querySuperClass) {
1182
if (artifactExtension == null) {
1183
// Ask my parent first
1184
if (parent != null) {
1185
return parent.getArtifactExtension();
1189
return artifactExtension;
1193
* @see org.eclipse.cdt.core.build.managed.IConfiguration#getArtifactName()
1195
public String getArtifactName() {
1196
if (artifactName == null) {
1197
// If I have a parent, ask it
1198
if (parent != null) {
1199
return parent.getArtifactName();
1201
// I'm it and this is not good!
1202
return EMPTY_STRING;
1205
return artifactName;
1210
* @see org.eclipse.cdt.core.build.managed.IConfiguration#getBuildArguments()
1212
public String getBuildArguments() {
1213
IToolChain tc = getToolChain();
1214
IBuilder builder = tc.getBuilder();
1215
if (builder != null) {
1216
return builder.getArguments();
1218
return new String("-k"); //$NON-NLS-1$
1222
* @see org.eclipse.cdt.core.build.managed.IConfiguration#getBuildCommand()
1224
public String getBuildCommand() {
1225
IToolChain tc = getToolChain();
1226
IBuilder builder = tc.getBuilder();
1227
if (builder != null) {
1228
return builder.getCommand();
1230
return new String("make"); //$NON-NLS-1$
1236
* @see org.eclipse.cdt.core.build.managed.IConfiguration#getPrebuildStep()
1238
public String getPrebuildStep() {
1239
if (prebuildStep == null) {
1240
// If I have a parent, ask it
1241
if (parent != null) {
1242
return parent.getPrebuildStep();
1245
return EMPTY_STRING;
1248
return prebuildStep;
1255
* @see org.eclipse.cdt.core.build.managed.IConfiguration#getPostbuildStep()
1257
public String getPostbuildStep() {
1258
if (postbuildStep == null) {
1259
// If I have a parent, ask it
1260
if (parent != null) {
1261
return parent.getPostbuildStep();
1264
return EMPTY_STRING;
1267
return postbuildStep;
1274
* @see org.eclipse.cdt.core.build.managed.IConfiguration#getPreannouncebuildStep()
1276
public String getPreannouncebuildStep() {
1277
if (preannouncebuildStep == null) {
1278
// If I have a parent, ask it
1279
if (parent != null) {
1280
return parent.getPreannouncebuildStep();
1283
return EMPTY_STRING;
1286
return preannouncebuildStep;
1293
* @see org.eclipse.cdt.core.build.managed.IConfiguration#getPostannouncebuildStep()
1295
public String getPostannouncebuildStep() {
1296
if (postannouncebuildStep == null) {
1297
// If I have a parent, ask it
1298
if (parent != null) {
1299
return parent.getPostannouncebuildStep();
1302
return EMPTY_STRING;
1305
return postannouncebuildStep;
1312
* @see org.eclipse.cdt.core.build.managed.IConfiguration#getCleanCommand()
1314
public String getCleanCommand() {
1315
// Return the command used to remove files
1316
if (cleanCommand == null) {
1317
if (parent != null) {
1318
return parent.getCleanCommand();
1320
// User forgot to specify it. Guess based on OS.
1321
if (Platform.getOS().equals(Platform.OS_WIN32)) {
1322
return new String("del"); //$NON-NLS-1$
1324
return new String("rm"); //$NON-NLS-1$
1328
// This was spec'd in the manifest
1329
return cleanCommand;
1334
* @see org.eclipse.cdt.core.build.managed.IConfiguration#getDescription()
1336
public String getDescription() {
1337
if (description == null) {
1338
// If I have a parent, ask it
1339
if (parent != null) {
1340
return parent.getDescription();
1343
return EMPTY_STRING;
1353
* @see org.eclipse.cdt.managedbuilder.core.IConfiguration#getErrorParserIds()
1355
public String getErrorParserIds() {
1356
if (errorParserIds != null) {
1357
return errorParserIds;
1359
// If I have a parent, ask it
1360
String errorParsers = null;
1361
if (parent != null) {
1362
errorParsers = parent.getErrorParserIds();
1364
// If no error parsers are specified by the configuration, the default
1366
// the error parsers from the tool-chain
1368
if (errorParsers == null && rootFolderInfo != null) {
1369
errorParsers = rootFolderInfo.getErrorParserIds();
1371
return errorParsers;
1374
public String getErrorParserIdsAttribute() {
1375
if (errorParserIds != null) {
1376
return errorParserIds;
1378
// If I have a parent, ask it
1379
String errorParsers = null;
1380
if (parent != null) {
1381
errorParsers = ((Configuration)parent).getErrorParserIdsAttribute();
1384
return errorParsers;
1388
* @see org.eclipse.cdt.managedbuilder.core.IConfiguration#getErrorParserList()
1390
public String[] getErrorParserList() {
1391
Set<String> set = contributeErrorParsers(null, true);
1393
String result[] = new String[set.size()];
1394
set.toArray(result);
1397
return CCorePlugin.getDefault().getAllErrorParsersIDs();
1400
public Set<String> contributeErrorParsers(Set<String> set, boolean includeChildren) {
1401
String parserIDs = getErrorParserIdsAttribute();
1402
if (parserIDs != null){
1404
set = new LinkedHashSet<String>();
1405
if(parserIDs.length() != 0) {
1406
StringTokenizer tok = new StringTokenizer(parserIDs, ";"); //$NON-NLS-1$
1407
while (tok.hasMoreElements()) {
1408
set.add(tok.nextToken());
1413
if(includeChildren){
1414
IResourceInfo[] rcInfos = getResourceInfos();
1415
for(int i = 0; i < rcInfos.length; i++){
1416
ResourceInfo rcInfo = (ResourceInfo)rcInfos[i];
1417
set = rcInfo.contributeErrorParsers(set);
1424
* @see org.eclipse.cdt.managedbuilder.core.IConfiguration#setArtifactExtension(java.lang.String)
1426
public void setArtifactExtension(String extension) {
1427
if (extension == null && artifactExtension == null) return;
1428
if (artifactExtension == null || extension == null || !artifactExtension.equals(extension)) {
1429
artifactExtension = extension;
1430
// rebuildNeeded = true;
1431
if(!isExtensionElement()){
1432
ITool tool = calculateTargetTool();
1434
tool.setRebuildState(true);
1436
setRebuildState(true);
1440
// exportArtifactInfo();
1445
* @see org.eclipse.cdt.core.build.managed.IConfiguration#setArtifactName(java.lang.String)
1447
public void setArtifactName(String name) {
1448
if (name == null && artifactName == null) return;
1449
if (artifactName == null || name == null || !artifactName.equals(name)) {
1450
artifactName = name;
1451
if(!isExtensionElement()){
1452
ITool tool = calculateTargetTool();
1454
tool.setRebuildState(true);
1456
setRebuildState(true);
1459
// rebuildNeeded = true;
1461
// exportArtifactInfo();
1467
* @see org.eclipse.cdt.managedbuilder.core.IConfiguration#setErrorParserIds()
1469
public void setErrorParserIds(String ids) {
1470
String currentIds = getErrorParserIds();
1471
if (ids == null && currentIds == null) return;
1472
if (currentIds == null || ids == null || !(currentIds.equals(ids))) {
1473
errorParserIds = ids;
1479
* @see org.eclipse.cdt.managedbuilder.core.IConfiguration#setCleanCommand()
1481
public void setCleanCommand(String command) {
1482
if (command == null && cleanCommand == null) return;
1483
if (cleanCommand == null || command == null || !cleanCommand.equals(command)) {
1484
cleanCommand = command;
1490
* @see org.eclipse.cdt.core.build.managed.IConfiguration#setDescription(java.lang.String)
1492
public void setDescription(String description) {
1493
if (description == null && this.description == null) return;
1494
if (this.description == null || description == null || !description.equals(this.description)) {
1495
this.description = description;
1501
* @see org.eclipse.cdt.managedbuilder.core.IConfiguration#setBuildArguments()
1503
public void setBuildArguments(String makeArgs) {
1504
IToolChain tc = getToolChain();
1505
IBuilder builder = tc.getBuilder();
1506
if(makeArgs == null){ //resetting the build arguments
1507
if(!builder.isExtensionElement()){
1508
builder.setArguments(makeArgs);
1509
// rebuildNeeded = true;
1511
}else if(!makeArgs.equals(builder.getArguments())){
1512
if (builder.isExtensionElement()) {
1513
String subId = ManagedBuildManager.calculateChildId(builder.getId(), null);
1514
String builderName = builder.getName() + "." + getName(); //$NON-NLS-1$
1515
builder = getToolChain().createBuilder(builder, subId, builderName, false);
1517
builder.setArguments(makeArgs);
1518
// rebuildNeeded = true;
1523
* @see org.eclipse.cdt.managedbuilder.core.IConfiguration#setBuildCommand()
1525
public void setBuildCommand(String command) {
1526
IToolChain tc = getToolChain();
1527
IBuilder builder = tc.getBuilder();
1528
if(command == null){ //resetting the build command
1529
if(!builder.isExtensionElement()){
1530
builder.setCommand(command);
1531
// rebuildNeeded = true;
1533
} else if(!command.equals(builder.getCommand())){
1534
if (builder.isExtensionElement()) {
1535
String subId = ManagedBuildManager.calculateChildId(builder.getId(), null);
1536
String builderName = builder.getName() + "." + getName(); //$NON-NLS-1$
1537
builder = getToolChain().createBuilder(builder, subId, builderName, false);
1539
builder.setCommand(command);
1540
// rebuildNeeded = true;
1545
* @see org.eclipse.cdt.core.build.managed.IConfiguration#setPrebuildStep(java.lang.String)
1547
public void setPrebuildStep(String step) {
1548
if (step == null && prebuildStep == null) return;
1549
if (prebuildStep == null || step == null || !prebuildStep.equals(step)) {
1550
prebuildStep = step;
1551
// rebuildNeeded = true;
1558
* @see org.eclipse.cdt.core.build.managed.IConfiguration#setPostbuildStep(java.lang.String)
1560
public void setPostbuildStep(String step) {
1561
if (step == null && postbuildStep == null) return;
1562
if (postbuildStep == null || step == null || !postbuildStep.equals(step)) {
1563
postbuildStep = step;
1564
// rebuildNeeded = true;
1570
* @see org.eclipse.cdt.core.build.managed.IConfiguration#setPreannouncebuildStep(java.lang.String)
1572
public void setPreannouncebuildStep(String announceStep) {
1573
if (announceStep == null && preannouncebuildStep == null) return;
1574
if (preannouncebuildStep == null || announceStep == null || !preannouncebuildStep.equals(announceStep)) {
1575
preannouncebuildStep = announceStep;
1576
// rebuildNeeded = true;
1582
* @see org.eclipse.cdt.core.build.managed.IConfiguration#setPostannouncebuildStep(java.lang.String)
1584
public void setPostannouncebuildStep(String announceStep) {
1585
if (announceStep == null && postannouncebuildStep == null) return;
1586
if (postannouncebuildStep == null || announceStep == null || !postannouncebuildStep.equals(announceStep)) {
1587
postannouncebuildStep = announceStep;
1588
// rebuildNeeded = true;
1594
* @see org.eclipse.cdt.managedbuilder.core.IConfiguration#isSupported()
1596
public boolean isSupported(){
1597
IFolderInfo foInfo = getRootFolderInfo();
1599
return foInfo.isSupported();
1604
* @see org.eclipse.cdt.managedbuilder.core.IConfiguration#isHeaderFile(java.lang.String)
1606
public boolean isHeaderFile(String ext) {
1607
return getRootFolderInfo().isHeaderFile(ext);
1611
* O B J E C T S T A T E M A I N T E N A N C E
1615
* @see org.eclipse.cdt.managedbuilder.core.IConfiguration#isExtensionElement()
1617
public boolean isExtensionElement() {
1618
return isExtensionConfig;
1622
* @see org.eclipse.cdt.managedbuilder.core.IConfiguration#isDirty()
1624
public boolean isDirty() {
1625
// This shouldn't be called for an extension configuration
1626
if (isExtensionConfig) return false;
1628
// If I need saving, just say yes
1629
if (isDirty) return true;
1631
// Otherwise see if any children need saving
1632
IResourceInfo infos[] = rcInfos.getResourceInfos();
1634
for(int i = 0; i < infos.length; i++){
1635
if(infos[i].isDirty())
1642
* @see org.eclipse.cdt.managedbuilder.core.IConfiguration#needsRebuild()
1644
public boolean needsRebuild() {
1645
return needsRebuild(true);
1648
public boolean needsFullRebuild() {
1649
return needsRebuild(false);
1652
public boolean needsRebuild(boolean checkChildren) {
1653
boolean needRebuild = rebuildNeeded || resourceChangesRequireRebuild();
1655
if(needRebuild || !checkChildren)
1658
IResourceInfo infos[] = rcInfos.getResourceInfos();
1660
for(int i = 0; i < infos.length; i++){
1661
if(infos[i].needsRebuild())
1669
* @see org.eclipse.cdt.managedbuilder.core.IConfiguration#setDirty(boolean)
1671
public void setDirty(boolean isDirty) {
1672
// Override the dirty flag
1673
this.isDirty = isDirty;
1674
// Propagate "false" to the children
1676
IResourceInfo infos[] = rcInfos.getResourceInfos();
1678
for(int i = 0; i < infos.length; i++){
1679
infos[i].setDirty(false);
1685
* @see org.eclipse.cdt.managedbuilder.core.IConfiguration#setRebuildState(boolean)
1687
public void setRebuildState(boolean rebuild) {
1688
if(isExtensionElement() && rebuild)
1691
if(rebuildNeeded != rebuild){
1692
rebuildNeeded = rebuild;
1697
setResourceChangeState(0);
1699
IResourceInfo infos[] = rcInfos.getResourceInfos();
1701
for(int i = 0; i < infos.length; i++){
1702
infos[i].setRebuildState(false);
1708
* @see org.eclipse.cdt.managedbuilder.core.IConfiguration#hasOverriddenBuildCommand()
1710
public boolean hasOverriddenBuildCommand() {
1711
IBuilder builder = getToolChain().getBuilder();
1712
if (builder != null) {
1713
IBuilder superB = builder.getSuperClass();
1714
if (superB != null) {
1715
String command = builder.getCommand();
1716
if (command != null) {
1717
String superC = superB.getCommand();
1718
if (superC != null) {
1719
if (!command.equals(superC)) {
1724
String args = builder.getArguments();
1726
String superA = superB.getArguments();
1727
if (superA != null) {
1728
if (!args.equals(superA)) {
1738
public void resolveReferences() {
1742
// call resolve references on any children
1743
ResourceInfo infos[] = (ResourceInfo[])rcInfos.getResourceInfos(ResourceInfo.class);
1745
for(int i = 0; i < infos.length; i++){
1746
infos[i].resolveReferences();
1749
if (parentId != null) {
1750
// Lookup the parent configuration by ID
1751
parent = ManagedBuildManager.getExtensionConfiguration(parentId);
1758
* Reset the configuration's, tools', options
1760
public void reset() {
1761
((FolderInfo)getRootFolderInfo()).resetOptionSettings();
1765
* Create a resource configuration object for the passed-in file
1767
public IResourceConfiguration createResourceConfiguration(IFile file)
1769
return createFileInfo(file.getFullPath().removeFirstSegments(1));
1773
public IFileInfo createFileInfo(IPath path){
1774
String resourceName = path.lastSegment();
1775
String id = ManagedBuildManager.calculateChildId(getId(), path.toString());
1776
return createFileInfo(path, id, resourceName);
1779
public IFileInfo createFileInfo(IPath path, String id, String name){
1780
IResourceInfo info = getResourceInfo(path, false);
1781
IFileInfo fileInfo = null;
1782
if(info instanceof IFileInfo){
1783
fileInfo = (IFileInfo)info;
1784
} else if (info instanceof IFolderInfo){
1785
IFolderInfo base = (IFolderInfo)info;
1786
fileInfo = createFileInfo(path, base, null, id, name);
1791
public IFileInfo createFileInfo(IPath path, IFolderInfo base, ITool baseTool, String id, String name){
1792
if(base.getPath().equals(path))
1795
IFileInfo fileInfo = new ResourceConfiguration((FolderInfo)base, baseTool, id, name, path);
1796
addResourceConfiguration(fileInfo);
1797
ManagedBuildManager.performValueHandlerEvent(fileInfo, IManagedOptionValueHandler.EVENT_OPEN);
1802
public IFileInfo createFileInfo(IPath path, IFileInfo base, String id, String name){
1803
if(base.getPath().equals(path))
1806
IFileInfo fileInfo = new ResourceConfiguration((ResourceConfiguration)base, path, id, name);
1807
addResourceConfiguration(fileInfo);
1808
ManagedBuildManager.performValueHandlerEvent(fileInfo, IManagedOptionValueHandler.EVENT_OPEN);
1814
* @see org.eclipse.cdt.managedbuilder.core.IConfiguration#getEnvironmentVariableSupplier()
1816
public IConfigurationEnvironmentVariableSupplier getEnvironmentVariableSupplier(){
1817
IToolChain toolChain = getToolChain();
1818
if(toolChain != null)
1819
return toolChain.getEnvironmentVariableSupplier();
1824
* @return Returns the version.
1826
public PluginVersionIdentifier getVersion() {
1827
if ( version == null) {
1828
if ( rootFolderInfo.getToolChain() != null) {
1829
return rootFolderInfo.getToolChain().getVersion();
1835
public void setVersion(PluginVersionIdentifier version) {
1840
* @see org.eclipse.cdt.managedbuilder.core.IConfiguration#getBuildMacroSupplier()
1842
public IConfigurationBuildMacroSupplier getBuildMacroSupplier(){
1843
IToolChain toolChain = getToolChain();
1844
if(toolChain != null)
1845
return toolChain.getBuildMacroSupplier();
1851
* @see org.eclipse.cdt.managedbuilder.core.IConfiguration#isTemporary()
1853
public boolean isTemporary(){
1858
* @see org.eclipse.cdt.managedbuilder.internal.core.BuildObject#updateManagedBuildRevision(java.lang.String)
1860
public void updateManagedBuildRevision(String revision){
1861
super.updateManagedBuildRevision(revision);
1863
ResourceInfo infos[] = (ResourceInfo[])rcInfos.getResourceInfos(ResourceInfo.class);
1865
for(int i = 0; i < infos.length; i++){
1866
infos[i].updateManagedBuildRevision(revision);
1870
public void setParent(IConfiguration parent) {
1871
if ( this.parent != parent) {
1872
this.parent = parent;
1873
if (!isExtensionElement())
1878
public ITool calculateTargetTool(){
1879
ITool tool = getTargetTool();
1882
tool = getToolFromOutputExtension(getArtifactExtension());
1886
IConfiguration extCfg;
1888
extCfg != null && !extCfg.isExtensionElement();
1889
extCfg = extCfg.getParent()){
1893
tool = getToolFromOutputExtension(extCfg.getArtifactExtension());
1900
public ITool getToolFromOutputExtension(String extension) {
1901
return getRootFolderInfo().getToolFromOutputExtension(extension);
1904
public ITool getToolFromInputExtension(String sourceExtension) {
1905
return getRootFolderInfo().getToolFromInputExtension(sourceExtension);
1909
* The resource delta passed to the builder is not always up-to-date
1910
* for the given configuration because between two builds of the same configuration
1911
* any number of other configuration builds may occur
1912
* that is why we need to keep some information regarding what happened
1913
* with the resource tree between the two configuration builds
1915
* The trivial approach implemented currently is to hold
1916
* the general information of whether some resources were
1917
* removed,changed,etc. and detect whether the rebuild is needed
1918
* based upon this information
1920
* This method adds the resource change state for the configuration
1921
* specifying the resource change type performed on the project
1922
* reported while building another configuration
1923
* The method is not exported to the public API since delta handling
1924
* mechanism will likely to be changed in the future
1926
* In the future we might implement some more smart mechanism
1927
* for tracking delta, e.g calculate the pre-cinfiguration resource delta, etc.
1930
public void addResourceChangeState(int state){
1931
setResourceChangeState(state | resourceChangeState);
1934
private void setResourceChangeState(int state){
1935
if(resourceChangeState != state){
1936
resourceChangeState = state;
1937
saveResourceChangeState();
1941
private boolean resourceChangesRequireRebuild(){
1942
return isInternalBuilderEnabled() ?
1943
resourceChangeState != 0 :
1944
(resourceChangeState & IResourceDelta.REMOVED) == IResourceDelta.REMOVED;
1947
private void saveRebuildState(){
1948
PropertyManager.getInstance().setProperty(this, REBUILD_STATE, Boolean.toString(rebuildNeeded));
1951
private void saveResourceChangeState(){
1952
PropertyManager.getInstance().setProperty(this, RC_CHANGE_STATE, Integer.toString(resourceChangeState));
1956
* Internal Builder state API
1957
* NOTE: this is a temporary API
1958
* In the future we are going present the Internal Builder
1959
* as a special Builder object of the tool-chain and implement the internal
1960
* builder enabling/disabling as the Builder substitution functionality
1964
/* public void setInternalBuilderBoolean(boolean value, String pref) {
1965
Preferences prefs = getPreferences(INTERNAL_BUILDER);
1967
prefs.putBoolean(pref, value);
1970
} catch (BackingStoreException e) {}
1974
/* public boolean getInternalBuilderBoolean(String pref, boolean defaultValue) {
1975
Preferences prefs = getPreferences(INTERNAL_BUILDER);
1976
return prefs != null ?
1977
prefs.getBoolean(pref, false) : defaultValue;
1981
* this method is used for enabling/disabling the internal builder
1982
* for the given configuration
1984
* @param enable boolean
1986
public void enableInternalBuilder(boolean enable){
1987
if(enable == isInternalBuilderEnabled())
1990
IBuilder builder = getBuilderForInternalBuilderEnablement(enable, true);
1991
if(builder != null){
1993
savePrevBuilderId(getBuilder());
1996
changeBuilder(builder,
1997
ManagedBuildManager.calculateChildId(builder.getId(), null),
2003
setManagedBuildOn(true);
2004
} catch (BuildException e) {
2010
public boolean canEnableInternalBuilder(boolean enable){
2011
return getBuilderForInternalBuilderEnablement(enable, true) != null;
2014
private IBuilder getBuilderForInternalBuilderEnablement(boolean enable, boolean checkCompatibility){
2015
IBuilder newBuilder = null;
2017
if(supportsBuild(true, false)){
2018
IBuilder b = ManagedBuildManager.getInternalBuilder();
2020
if(!checkCompatibility || isBuilderCompatible(b))
2025
String id = getPrevBuilderId();
2027
IBuilder b = ManagedBuildManager.getExtensionBuilder(id);
2029
if(!checkCompatibility || isBuilderCompatible(b))
2033
if(newBuilder == null){
2034
for(IToolChain tc = getToolChain(); tc != null; tc = tc.getSuperClass()){
2035
IBuilder b = tc.getBuilder();
2036
if(b.isInternalBuilder())
2039
for(;b != null && !b.isExtensionElement(); b = b.getSuperClass());
2042
if(!checkCompatibility || isBuilderCompatible(b)){
2050
// if(newBuilder == null){
2051
// IBuilder builders[] = ManagedBuildManager.getRealBuilders();
2052
// IBuilder tmpB = null;
2053
// for(int i = 0; i < builders.length; i++){
2054
// IBuilder b = builders[i];
2055
// if(b.isInternalBuilder())
2059
// if(isBuilderCompatible(b)){
2062
// } else if(!checkCompatibility){
2067
// if(newBuilder == null){
2069
// newBuilder = tmpB;
2078
private void savePrevBuilderId(IBuilder builder){
2079
IBuilder b = builder;
2080
for(;b != null && !b.isExtensionElement(); b = b.getSuperClass());
2085
ToolChain tc = (ToolChain)getToolChain();
2087
tc.setNonInternalBuilderId(b.getId());
2090
private String getPrevBuilderId(){
2091
ToolChain tc = (ToolChain)getToolChain();
2093
return tc.getNonInternalBuilderId();
2098
* returns whether the internal builder is enabled
2101
public boolean isInternalBuilderEnabled(){
2102
return getBuilder().isInternalBuilder();
2107
* sets the Internal Builder mode
2109
* @param ignore if true, internal builder will ignore
2110
* build errors while building,
2111
* otherwise it will stop at the first build error
2113
public void setInternalBuilderIgnoreErr(boolean ignore){
2115
getEditableBuilder().setStopOnError(!ignore);
2116
} catch (CoreException e) {
2121
* returns the Internal Builder mode
2122
* if true, internal builder will ignore build errors while building,
2123
* otherwise it will stop at the first build error
2127
public boolean getInternalBuilderIgnoreErr(){
2128
return !getBuilder().isStopOnError();
2133
* sets the Internal Builder Parallel mode
2135
* @param parallel if true, internal builder will use parallel mode
2137
public void setInternalBuilderParallel(boolean parallel){
2138
if(getInternalBuilderParallel() == parallel)
2142
getEditableBuilder().setParallelBuildOn(parallel);
2143
} catch (CoreException e) {
2148
* returns the Internal Builder parallel mode
2149
* if true, internal builder will work in parallel mode
2150
* otherwise it will use only one thread
2154
public boolean getInternalBuilderParallel(){
2155
return getBuilder().isParallelBuildOn();
2159
* @param parallel if true, internal builder will use parallel mode
2161
public void setParallelDef(boolean parallel_def){
2162
if(getParallelDef() == parallel_def)
2165
int num = getParallelNumber();
2167
setParallelNumber(-num);
2170
setParallelNumber(-1);
2172
setParallelNumber(1);
2180
public boolean getParallelDef(){
2181
int num = getBuilder().getParallelizationNum();
2187
* sets number of Parallel threads
2191
public void setParallelNumber(int n){
2193
getEditableBuilder().setParallelizationNum(n);
2194
} catch (CoreException e) {
2199
* returns number of Parallel threads
2203
public int getParallelNumber(){
2204
return getBuilder().getParallelizationNum();
2207
private Preferences getPreferences(String name){
2211
IProject project = (IProject)getOwner();
2213
if(project == null || !project.exists() || !project.isOpen())
2216
Preferences prefs = new ProjectScope(project).getNode(ManagedBuilderCorePlugin.getUniqueIdentifier());
2218
prefs = prefs.node(getId());
2219
if(prefs != null && name != null)
2220
prefs = prefs.node(name);
2225
public IResourceInfo[] getResourceInfos() {
2226
return rcInfos.getResourceInfos();
2229
public IResourceInfo getResourceInfo(IPath path, boolean exactPath) {
2230
return rcInfos.getResourceInfo(path, exactPath);
2233
public IResourceInfo getResourceInfoById(String id) {
2234
IResourceInfo infos[] = rcInfos.getResourceInfos();
2235
for(int i = 0; i < infos.length; i++){
2236
if(id.equals(infos[i].getId()))
2242
public IFolderInfo getRootFolderInfo() {
2243
return rootFolderInfo;
2246
ResourceInfoContainer getRcInfoContainer(IResourceInfo rcInfo){
2247
PathSettingsContainer cr = pathSettings.getChildContainer(rcInfo.getPath(), true, true);
2248
return new ResourceInfoContainer(cr, false);
2251
public CConfigurationData getConfigurationData(){
2255
public void removeResourceInfo(IPath path) {
2256
IResourceInfo info = getResourceInfo(path, true);
2258
removeResourceConfiguration(info);
2261
public IFolderInfo createFolderInfo(IPath path) {
2262
String resourceName = path.lastSegment();
2263
String id = ManagedBuildManager.calculateChildId(getId(), path.toString());
2264
return createFolderInfo(path, id, resourceName);
2267
public IFolderInfo createFolderInfo(IPath path, String id, String name) {
2268
IResourceInfo info = getResourceInfo(path, false);
2269
IFolderInfo folderInfo = null;
2270
if(info instanceof IFileInfo){
2272
} else if (info instanceof IFolderInfo){
2273
IFolderInfo base = (IFolderInfo)info;
2274
folderInfo = createFolderInfo(path, base, id, name);
2279
public IFolderInfo createFolderInfo(IPath path, IFolderInfo base, String id, String name) {
2280
if(base.getPath().equals(path))
2283
FolderInfo folderInfo = new FolderInfo((FolderInfo)base, id, name, path);
2284
addResourceConfiguration(folderInfo);
2285
folderInfo.propertiesChanged();
2286
ManagedBuildManager.performValueHandlerEvent(folderInfo, IManagedOptionValueHandler.EVENT_OPEN);
2291
public ICSourceEntry[] getSourceEntries() {
2292
if(sourceEntries == null || sourceEntries.length == 0){
2293
if(parent != null && sourceEntries == null)
2294
return parent.getSourceEntries();
2295
return new ICSourceEntry[]{new CSourceEntry(Path.EMPTY, null, ICSettingEntry.VALUE_WORKSPACE_PATH | ICSettingEntry.RESOLVED)}; //$NON-NLS-1$
2298
return (ICSourceEntry[])sourceEntries.clone();
2301
public void setSourceEntries(ICSourceEntry[] entries) {
2302
setSourceEntries(entries, true);
2305
public void setSourceEntries(ICSourceEntry[] entries, boolean setRebuildState) {
2306
if(Arrays.equals(getSourceEntries(), entries))
2308
sourceEntries = entries != null ? (ICSourceEntry[])entries.clone() : null;
2309
// for(int i = 0; i < sourcePaths.length; i++){
2310
// sourcePaths[i] = sourcePaths[i].makeRelative();
2312
exportArtifactInfo();
2313
if(setRebuildState){
2315
setRebuildState(true);
2319
public void setErrorParserAttribute(String[] ids) {
2321
errorParserIds = null;
2322
} else if(ids.length == 0){
2323
errorParserIds = EMPTY_STRING;
2325
StringBuffer buf = new StringBuffer();
2327
for(int i = 1; i < ids.length; i++){
2328
buf.append(";").append(ids[i]); //$NON-NLS-1$
2330
errorParserIds = buf.toString();
2334
public void setErrorParserList(String[] ids) {
2337
resetErrorParsers();
2339
resetErrorParsers();
2340
Set<String> oldSet = contributeErrorParsers(null, true);
2341
if(oldSet != null) {
2342
oldSet.removeAll(Arrays.asList(ids));
2343
removeErrorParsers(oldSet);
2345
setErrorParserAttribute(ids);
2349
public void resetErrorParsers(){
2350
errorParserIds = null;
2351
IResourceInfo rcInfos[] = getResourceInfos();
2352
for(int i = 0; i < rcInfos.length; i++){
2353
ResourceInfo rcInfo = (ResourceInfo)rcInfos[i];
2354
rcInfo.resetErrorParsers();
2358
void removeErrorParsers(Set<String> set){
2359
Set<String> oldSet = contributeErrorParsers(null, false);
2361
oldSet = new LinkedHashSet<String>();
2363
oldSet.removeAll(set);
2364
setErrorParserAttribute((String[])oldSet.toArray(new String[oldSet.size()]));
2366
IResourceInfo rcInfos[] = getResourceInfos();
2367
for(int i = 0; i < rcInfos.length; i++){
2368
ResourceInfo rcInfo = (ResourceInfo)rcInfos[i];
2369
rcInfo.removeErrorParsers(set);
2373
public CBuildData getBuildData() {
2374
return getEditableBuilder().getBuildData();
2377
public IBuilder getEditableBuilder(){
2378
IToolChain tc = getToolChain();
2379
IBuilder builder = tc.getBuilder();
2380
if(builder.isExtensionElement()){
2381
String subId = ManagedBuildManager.calculateChildId(builder.getId(), null);
2382
String builderName = builder.getName() + "." + getName(); //$NON-NLS-1$
2383
builder = getToolChain().createBuilder(builder, subId, builderName, false);
2388
public IBuilder getBuilder(){
2389
return getToolChain().getBuilder();
2392
public String getOutputPrefix(String outputExtension) {
2393
// Treat null extensions as empty string
2394
String ext = outputExtension == null ? new String() : outputExtension;
2396
// Get all the tools for the current config
2397
String flags = new String();
2398
ITool[] tools = getFilteredTools();
2399
for (int index = 0; index < tools.length; index++) {
2400
ITool tool = tools[index];
2401
if (tool.producesFileType(ext)) {
2402
flags = tool.getOutputPrefix();
2408
public ICConfigurationDescription getConfigurationDescription(){
2412
public void setConfigurationDescription(ICConfigurationDescription cfgDes){
2416
public IBuildObjectProperties getBuildProperties() {
2417
if(buildProperties == null){
2418
BuildObjectProperties parentProps = findBuildProperties();
2419
if(parentProps != null)
2420
buildProperties = new BuildObjectProperties(parentProps, this, this);
2422
buildProperties = new BuildObjectProperties(this, this);
2424
return buildProperties;
2427
private BuildObjectProperties findBuildProperties(){
2428
if(buildProperties == null){
2430
return ((Configuration)parent).findBuildProperties();
2434
return buildProperties;
2437
public boolean supportsType(IBuildPropertyType type) {
2438
return supportsType(type.getId());
2441
public boolean supportsValue(IBuildPropertyType type,
2442
IBuildPropertyValue value) {
2443
return supportsValue(type.getId(), value.getId());
2446
public void propertiesChanged() {
2447
if(isExtensionConfig)
2450
BooleanExpressionApplicabilityCalculator calculator = getBooleanExpressionCalculator();
2451
if(calculator != null)
2452
calculator.adjustConfiguration(this, false);
2454
IResourceInfo infos[] = getResourceInfos();
2455
for(int i = 0; i < infos.length; i++){
2456
((ResourceInfo)infos[i]).propertiesChanged();
2460
public BooleanExpressionApplicabilityCalculator getBooleanExpressionCalculator(){
2461
if(booleanExpressionCalculator == null){
2463
return ((Configuration)parent).getBooleanExpressionCalculator();
2466
return booleanExpressionCalculator;
2469
public boolean isSystemObject() {
2473
if(getProjectType() != null)
2474
return getProjectType().isSystemObject();
2479
public String getOutputExtension(String resourceExtension) {
2480
return getRootFolderInfo().getOutputExtension(resourceExtension);
2483
public String getOutputFlag(String outputExt) {
2484
// Treat null extension as an empty string
2485
String ext = outputExt == null ? new String() : outputExt;
2487
// Get all the tools for the current config
2488
String flags = new String();
2489
ITool[] tools = getFilteredTools();
2490
for (int index = 0; index < tools.length; index++) {
2491
ITool tool = tools[index];
2493
if (tool.producesFileType(ext)) {
2494
flags = tool.getOutputFlag();
2500
public IManagedCommandLineInfo generateToolCommandLineInfo( String sourceExtension, String[] flags,
2501
String outputFlag, String outputPrefix, String outputName, String[] inputResources, IPath inputLocation, IPath outputLocation ){
2502
ITool[] tools = getFilteredTools();
2503
for (int index = 0; index < tools.length; index++) {
2504
ITool tool = tools[index];
2505
if (tool.buildsFileType(sourceExtension)) {
2506
String cmd = tool.getToolCommand();
2507
//try to resolve the build macros in the tool command
2509
String resolvedCommand = null;
2511
if ((inputLocation != null && inputLocation.toString().indexOf(" ") != -1) || //$NON-NLS-1$
2512
(outputLocation != null && outputLocation.toString().indexOf(" ") != -1) ) //$NON-NLS-1$
2514
resolvedCommand = ManagedBuildManager
2515
.getBuildMacroProvider().resolveValue(
2519
IBuildMacroProvider.CONTEXT_FILE,
2520
new FileContextData(inputLocation,
2521
outputLocation, null,
2526
resolvedCommand = ManagedBuildManager
2527
.getBuildMacroProvider()
2528
.resolveValueToMakefileFormat(
2532
IBuildMacroProvider.CONTEXT_FILE,
2533
new FileContextData(inputLocation,
2534
outputLocation, null,
2537
if((resolvedCommand = resolvedCommand.trim()).length() > 0)
2538
cmd = resolvedCommand;
2540
} catch (BuildMacroException e){
2543
IManagedCommandLineGenerator gen = tool.getCommandLineGenerator();
2544
return gen.generateCommandLineInfo( tool, cmd,
2545
flags, outputFlag, outputPrefix, outputName, inputResources,
2546
tool.getCommandLinePattern() );
2552
public String[] getUserObjects(String extension) {
2553
Vector objs = new Vector();
2554
ITool tool = calculateTargetTool();
2556
tool = getToolFromOutputExtension(extension);
2559
IOption[] opts = tool.getOptions();
2560
// Look for the user object option type
2561
for (int i = 0; i < opts.length; i++) {
2562
IOption option = opts[i];
2564
if (option.getValueType() == IOption.OBJECTS) {
2565
String unresolved[] = option.getUserObjects();
2566
if(unresolved != null && unresolved.length > 0){
2567
for(int k = 0; k < unresolved.length; k++){
2569
String resolved[] = ManagedBuildManager.getBuildMacroProvider().resolveStringListValueToMakefileFormat(
2573
IBuildMacroProvider.CONTEXT_OPTION,
2574
new OptionContextData(option, tool));
2575
if(resolved != null && resolved.length > 0)
2576
objs.addAll(Arrays.asList(resolved));
2577
} catch (BuildMacroException e) {
2578
// TODO: report error
2584
} catch (BuildException e) {
2585
// TODO: report error
2590
return (String[])objs.toArray(new String[objs.size()]);
2593
public String[] getLibs(String extension) {
2594
Vector libs = new Vector();
2595
ITool tool = calculateTargetTool();
2597
tool = getToolFromOutputExtension(extension);
2600
IOption[] opts = tool.getOptions();
2601
// Look for the lib option type
2602
for (int i = 0; i < opts.length; i++) {
2603
IOption option = opts[i];
2605
if (option.getValueType() == IOption.LIBRARIES) {
2607
// check to see if the option has an applicability calculator
2608
IOptionApplicability applicabilitytCalculator = option.getApplicabilityCalculator();
2610
if (applicabilitytCalculator == null
2611
|| applicabilitytCalculator.isOptionUsedInCommandLine(this, tool, option)) {
2612
String command = option.getCommand();
2613
String[] allLibs = option.getLibraries();
2614
for (int j = 0; j < allLibs.length; j++)
2617
String resolved[] = ManagedBuildManager.getBuildMacroProvider().resolveStringListValueToMakefileFormat(
2621
IBuildMacroProvider.CONTEXT_OPTION,
2622
new OptionContextData(option, tool));
2623
if(resolved != null && resolved.length > 0){
2624
for(int k = 0; k < resolved.length; k++){
2625
String string = resolved[k];
2626
if(string.length() > 0)
2627
libs.add(command + string);
2630
} catch (BuildMacroException e) {
2631
// TODO: report error
2638
} catch (BuildException e) {
2639
// TODO: report error
2644
return (String[])libs.toArray(new String[libs.size()]);
2647
public boolean buildsFileType(String srcExt) {
2648
return getRootFolderInfo().buildsFileType(srcExt);
2651
public void exportArtifactInfo(){
2652
if(isExtensionConfig)
2655
IBuildObjectProperties props = getBuildProperties();
2656
IBuildProperty prop = props.getProperty(ManagedBuildManager.BUILD_ARTEFACT_TYPE_PROPERTY_ID);
2658
String valueId = prop.getValue().getId();
2659
if(ManagedBuildManager.BUILD_ARTEFACT_TYPE_PROPERTY_SHAREDLIB.equals(valueId)
2660
|| ManagedBuildManager.BUILD_ARTEFACT_TYPE_PROPERTY_STATICLIB.equals(valueId)){
2661
ICConfigurationDescription des = ManagedBuildManager.getDescriptionForConfiguration(this);
2662
if(des != null && !des.isReadOnly()){
2663
ICOutputEntry entries[] = getConfigurationData().getBuildData().getOutputDirectories();
2664
IPath path = getOwner().getFullPath();
2666
List list = new ArrayList(entries.length + 1);
2668
list.add(new CIncludePathEntry(path.toString(), ICLanguageSettingEntry.VALUE_WORKSPACE_PATH));
2670
entries = CDataUtil.resolveEntries(entries, des);
2671
for(int i = 0; i < entries.length; i++){
2672
ICOutputEntry out = entries[i];
2673
String value = out.getValue();
2675
IPath p = new Path(value);
2677
value = getOwner().getFullPath().append(value).toString();
2679
ICLibraryPathEntry lib = new CLibraryPathEntry(value, out.getFlags() & (~ICSettingEntry.RESOLVED));
2683
des.createExternalSetting(null, null, null, (ICLanguageSettingEntry[])list.toArray(new ICLanguageSettingEntry[list.size()]));
2689
public boolean supportsBuild(boolean managed) {
2690
return supportsBuild(managed, true);
2693
public boolean supportsBuild(boolean managed, boolean checkBuilder) {
2694
IResourceInfo[] rcs = getResourceInfos();
2695
for(int i = 0; i < rcs.length; i++){
2696
if(!rcs[i].supportsBuild(managed))
2701
IBuilder builder = getBuilder();
2702
if(builder != null && !builder.supportsBuild(managed))
2709
public boolean supportsType(String typeId) {
2710
SupportedProperties props = findSupportedProperties();
2711
boolean supports = false;
2713
supports = props.supportsType(typeId);
2717
supports = ((ToolChain)getToolChain()).supportsType(typeId);
2722
public boolean supportsValue(String typeId, String valueId) {
2723
SupportedProperties props = findSupportedProperties();
2724
boolean supports = false;
2726
supports = props.supportsValue(typeId, valueId);
2730
supports = ((ToolChain)getToolChain()).supportsValue(typeId, valueId);
2735
private SupportedProperties findSupportedProperties(){
2736
if(supportedProperties == null){
2738
return ((Configuration)parent).findSupportedProperties();
2741
return supportedProperties;
2744
private void loadProperties(IManagedConfigElement el){
2745
supportedProperties = new SupportedProperties(el);
2748
public String[] getRequiredTypeIds() {
2749
SupportedProperties props = findSupportedProperties();
2750
List list = new ArrayList();
2752
list.addAll(Arrays.asList(props.getRequiredTypeIds()));
2755
list.addAll(Arrays.asList(((ToolChain)getToolChain()).getRequiredTypeIds()));
2757
return (String[])list.toArray(new String[list.size()]);
2760
public String[] getSupportedTypeIds() {
2761
SupportedProperties props = findSupportedProperties();
2762
List list = new ArrayList();
2764
list.addAll(Arrays.asList(props.getSupportedTypeIds()));
2767
list.addAll(Arrays.asList(((ToolChain)getToolChain()).getSupportedTypeIds()));
2769
return (String[])list.toArray(new String[list.size()]);
2772
public String[] getSupportedValueIds(String typeId) {
2773
SupportedProperties props = findSupportedProperties();
2774
List list = new ArrayList();
2776
list.addAll(Arrays.asList(props.getSupportedValueIds(typeId)));
2779
list.addAll(Arrays.asList(((ToolChain)getToolChain()).getSupportedValueIds(typeId)));
2781
return (String[])list.toArray(new String[list.size()]);
2784
public boolean requiresType(String typeId) {
2785
SupportedProperties props = findSupportedProperties();
2786
boolean requires = false;
2788
requires = props.requiresType(typeId);
2792
requires = ((ToolChain)getToolChain()).requiresType(typeId);
2797
public boolean isManagedBuildOn() {
2798
return getBuilder().isManagedBuildOn();
2801
public void setManagedBuildOn(boolean on) throws BuildException {
2803
getEditableBuilder().setManagedBuildOn(on);
2804
} catch (CoreException e) {
2805
throw new BuildException(e.getLocalizedMessage());
2809
public void changeBuilder(IBuilder newBuilder, String id, String name){
2810
changeBuilder(newBuilder, id, name, false);
2813
public void changeBuilder(IBuilder newBuilder, String id, String name, boolean allBuildSettings){
2814
ToolChain tc = (ToolChain)getToolChain();
2815
Builder cur = (Builder)getEditableBuilder();
2816
Builder newCfgBuilder = null;
2817
if(newBuilder.getParent() == tc){
2818
newCfgBuilder = (Builder)newBuilder;
2820
IBuilder curReal = ManagedBuildManager.getRealBuilder(cur);
2821
IBuilder newReal = ManagedBuildManager.getRealBuilder(newBuilder);
2822
if(newReal != curReal){
2823
IBuilder extBuilder = newBuilder;
2824
for(;extBuilder != null && !extBuilder.isExtensionElement(); extBuilder = extBuilder.getSuperClass());
2825
if(extBuilder == null)
2826
extBuilder = newBuilder;
2828
newCfgBuilder = new Builder(tc, extBuilder, id, name, false);
2829
newCfgBuilder.copySettings(cur, allBuildSettings);
2833
if(newCfgBuilder != null){
2834
tc.setBuilder(newCfgBuilder);
2838
public boolean isBuilderCompatible(IBuilder builder){
2839
return builder.supportsBuild(isManagedBuildOn());
2842
ITool findToolById(String id){
2843
IResourceInfo[] rcInfos = getResourceInfos();
2845
for(int i = 0; i < rcInfos.length; i++){
2846
ResourceInfo info = (ResourceInfo)rcInfos[i];
2847
tool = info.getToolById(id);
2854
void resolveProjectReferences(boolean onLoad){
2855
IResourceInfo[] rcInfos = getResourceInfos();
2856
for(int i = 0; i < rcInfos.length; i++){
2857
ResourceInfo info = (ResourceInfo)rcInfos[i];
2858
info.resolveProjectReferences(onLoad);
2862
public boolean isPerRcTypeDiscovery(){
2863
ToolChain tc = (ToolChain)getRootFolderInfo().getToolChain();
2864
return tc.isPerRcTypeDiscovery();
2867
public void setPerRcTypeDiscovery(boolean on){
2868
ToolChain tc = (ToolChain)getRootFolderInfo().getToolChain();
2869
tc.setPerRcTypeDiscovery(on);
2872
// public IScannerConfigBuilderInfo2 getScannerConfigInfo(){
2873
// ToolChain tc = (ToolChain)getRootFolderInfo().getToolChain();
2874
// return tc.getScannerConfigBuilderInfo();
2877
// public IScannerConfigBuilderInfo2 setScannerConfigInfo(IScannerConfigBuilderInfo2 info){
2878
// ToolChain tc = (ToolChain)getRootFolderInfo().getToolChain();
2879
// return tc.setScannerConfigBuilderInfo(info);
2882
public PathInfoCache setDiscoveredPathInfo(PathInfoCache info){
2883
ToolChain tc = (ToolChain)getRootFolderInfo().getToolChain();
2884
return tc.setDiscoveredPathInfo(info);
2887
public PathInfoCache getDiscoveredPathInfo(){
2888
ToolChain tc = (ToolChain)getRootFolderInfo().getToolChain();
2889
return tc.getDiscoveredPathInfo();
2892
public String getDiscoveryProfileId(){
2893
ToolChain tc = (ToolChain)getRootFolderInfo().getToolChain();
2894
return tc.getScannerConfigDiscoveryProfileId();
2897
public PathInfoCache clearDiscoveredPathInfo(){
2898
ToolChain tc = (ToolChain)getRootFolderInfo().getToolChain();
2899
return tc.clearDiscoveredPathInfo();
2902
public ICfgScannerConfigBuilderInfo2Set getCfgScannerConfigInfo(){
2903
return cfgScannerInfo;
2906
public void setCfgScannerConfigInfo(ICfgScannerConfigBuilderInfo2Set info){
2907
cfgScannerInfo = info;
2910
public void clearCachedData(){
2911
cfgScannerInfo = null;
2914
public boolean isPreference(){
2915
return isPreferenceConfig;
2918
public IBuildPropertyValue getBuildArtefactType() {
2919
IBuildObjectProperties props = findBuildProperties();
2921
IBuildProperty prop = props.getProperty(ManagedBuildManager.BUILD_ARTEFACT_TYPE_PROPERTY_ID);
2923
return prop.getValue();
2928
public void setBuildArtefactType(String id) throws BuildException {
2929
IBuildObjectProperties props = getBuildProperties();
2931
props.setProperty(ManagedBuildManager.BUILD_ARTEFACT_TYPE_PROPERTY_ID, id);
2932
} catch (CoreException e){
2933
throw new BuildException(e.getLocalizedMessage());
2937
boolean isExcluded(IPath path){
2938
// if(path.segmentCount() == 0)
2940
ICSourceEntry[] entries = getSourceEntries();
2941
return CDataUtil.isExcluded(path, entries);
2944
void setExcluded(IPath path, boolean isFolder, boolean excluded){
2945
// if(path.segmentCount() == 0)
2947
if(excludeList == null) {
2948
ICSourceEntry[] newEntries = getUpdatedEntries(path, isFolder, excluded);
2949
if(newEntries != null)
2950
setSourceEntries(newEntries, false);
2953
excludeList.add(path);
2957
private ICSourceEntry[] getUpdatedEntries(IPath path, boolean isFolder, boolean excluded){
2959
ICSourceEntry[] entries = getSourceEntries();
2960
return CDataUtil.setExcluded(path, isFolder, excluded, entries, false);
2961
} catch (CoreException e) {
2962
ManagedBuilderCorePlugin.log(e);
2967
boolean canExclude(IPath path, boolean isFolder, boolean excluded){
2968
if(excludeList == null) {
2969
ICSourceEntry[] newEntries = getUpdatedEntries(path, isFolder, excluded);
2970
return newEntries != null;
2973
excludeList.add(path);
2978
public IRealBuildObjectAssociation getExtensionObject() {
2979
return isExtensionConfig ? this : (Configuration)getParent();
2982
public IRealBuildObjectAssociation[] getIdenticBuildObjects() {
2983
return new Configuration[]{(Configuration)getExtensionObject()};
2986
public IRealBuildObjectAssociation getRealBuildObject() {
2987
return getExtensionObject();
2990
public IRealBuildObjectAssociation getSuperClassObject() {
2991
return (IRealBuildObjectAssociation)getParent();
2994
public int getType() {
2995
return OBJECT_CONFIGURATION;
2998
public boolean isRealBuildObject() {
2999
return getRealBuildObject() == this;
3002
public String getUniqueRealName() {
3006
public boolean isExtensionBuildObject() {
3007
return isExtensionElement();