Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/buildmodel/BuildDescriptionManager.java2
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/buildmodel/DbgUtil.java2
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Configuration.java198
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/GeneratedMakefileBuilder.java91
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ManagedBuildInfo.java13
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ManagedProject.java3
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/PluginResources.properties1
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/PropertyManager.java372
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ResourceChangeHandler.java1
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ResourceConfiguration.java17
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Tool.java24
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ToolChain.java20
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/envvar/StoredBuildPathEnvironmentContainer.java4
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/envvar/UserDefinedEnvironmentSupplier.java8
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/macros/UserDefinedMacroSupplier.java18
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/BuildSettingsBlock.java101
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/PluginResources.properties5
17 files changed, 829 insertions, 51 deletions
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/buildmodel/BuildDescriptionManager.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/buildmodel/BuildDescriptionManager.java
index 141a9d18c2..d2abb38308 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/buildmodel/BuildDescriptionManager.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/buildmodel/BuildDescriptionManager.java
@@ -125,7 +125,7 @@ public class BuildDescriptionManager {
fVisitedSteps.add(action);
}
- if(doNext){
+ if(doNext && proceed){
IBuildStep[] nextActions = getSteps(action, !fUp);
for(int i = 0; i < nextActions.length; i++){
if(!fVisitedSteps.contains(nextActions[i])){
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/buildmodel/DbgUtil.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/buildmodel/DbgUtil.java
index c65fc7e089..f2af35a481 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/buildmodel/DbgUtil.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/buildmodel/DbgUtil.java
@@ -23,7 +23,7 @@ import org.eclipse.cdt.managedbuilder.core.ITool;
* this is the build description debug utility class
*/
public class DbgUtil {
- public static final boolean DEBUG = false;
+ public static boolean DEBUG = false;
private static PrintStream out = System.out;
public static void trace(String str){
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Configuration.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Configuration.java
index f8f1011e9e..ca079ad4ba 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Configuration.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Configuration.java
@@ -44,6 +44,7 @@ import org.eclipse.cdt.managedbuilder.macros.IConfigurationBuildMacroSupplier;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IResourceDelta;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.PluginVersionIdentifier;
@@ -80,6 +81,43 @@ public class Configuration extends BuildObject implements IConfiguration {
private boolean resolved = true;
private boolean isTemporary = false;
+ //property name for holding the rebuild state
+ private static final String REBUILD_STATE = "rebuildState"; //$NON-NLS-1$
+
+ //The resource delta passed to the builder is not always up-to-date
+ //for the given configuration because between two builds of the same configuration
+ //any number of other configuration builds may occur
+ //that is why we need to keep some information regarding what happened
+ //with the resource tree between the two configuration builds
+ //
+ //The trivial approach implemented currently is to hold
+ //the general information of whether some resources were
+ //removed,changed,etc. and detect whether the rebuild is needed
+ //based upon this information
+ //
+ //In the future we might implement some more smart mechanism
+ //for tracking delta, e.g calculate the pre-cinfiguration resource delta, etc.
+ //
+ //property for holding the resource change state
+ private static final String RC_CHANGE_STATE = "rcState"; //$NON-NLS-1$
+ //resource change state
+ private int resourceChangeState;
+
+ //Internal Builder state
+ //NOTE: these are temporary properties
+ //In the future we are going present the Internal Builder
+ //as a special Builder object of the tool-chain and implement the internal
+ //builder enabling/disabling as the Builder substitution functionality
+ //
+ //property that holds the Internal Builder enable state
+ private static final String INTERNAL_BUILDER_ENABLED = "internalBuilderOn"; //$NON-NLS-1$
+ //property that holds the internal builder mode
+ private static final String INTERNAL_BUILDER_IGNORE_ERR = "internalBuilderIgnoreErr"; //$NON-NLS-1$
+ //Internal Builder enable state
+ private boolean internalBuilderEnabled;
+ //Internal Builder mode
+ private boolean internalBuilderIgnoreErr;
+
/*
* C O N S T R U C T O R S
@@ -215,6 +253,28 @@ public class Configuration extends BuildObject implements IConfiguration {
addResourceConfiguration(resConfig);
}
}
+
+ PropertyManager mngr = PropertyManager.getInstance();
+ String rebuild = mngr.getProperty(this, REBUILD_STATE);
+ if(rebuild == null || Boolean.parseBoolean(rebuild))
+ rebuildNeeded = true;
+
+ String rcChangeState = mngr.getProperty(this, RC_CHANGE_STATE);
+ if(rcChangeState == null)
+ resourceChangeState = ~0;
+ else {
+ try {
+ resourceChangeState = Integer.parseInt(rcChangeState);
+ } catch (NumberFormatException e){
+ resourceChangeState = ~0;
+ }
+ }
+
+ internalBuilderEnabled = Boolean.parseBoolean(
+ mngr.getProperty(this, INTERNAL_BUILDER_ENABLED));
+ String tmp = mngr.getProperty(this, INTERNAL_BUILDER_IGNORE_ERR);
+ if(tmp == null || Boolean.parseBoolean(tmp))
+ internalBuilderIgnoreErr = true;
}
/**
@@ -267,6 +327,9 @@ public class Configuration extends BuildObject implements IConfiguration {
postannouncebuildStep = new String(cloneConfig.postannouncebuildStep);
}
+ internalBuilderEnabled = cloneConfig.internalBuilderEnabled;
+ internalBuilderIgnoreErr = cloneConfig.internalBuilderIgnoreErr;
+
// Clone the configuration's children
// Tool Chain
String subId;
@@ -522,6 +585,8 @@ public class Configuration extends BuildObject implements IConfiguration {
element.appendChild(resElement);
resConfig.serialize(doc, resElement);
}
+
+ PropertyManager.getInstance().serialize(this);
// I am clean now
isDirty = false;
@@ -1314,8 +1379,10 @@ public class Configuration extends BuildObject implements IConfiguration {
}
public boolean needsRebuild(boolean checkChildren) {
- if(rebuildNeeded || !checkChildren)
- return rebuildNeeded;
+ boolean needRebuild = rebuildNeeded || resourceChangesRequireRebuild();
+
+ if(needRebuild || !checkChildren)
+ return needRebuild;
if(toolChain.needsRebuild())
return true;
@@ -1365,18 +1432,25 @@ public class Configuration extends BuildObject implements IConfiguration {
if(isExtensionElement() && rebuild)
return;
- rebuildNeeded = rebuild;
+ if(rebuildNeeded != rebuild){
+ rebuildNeeded = rebuild;
+ saveRebuildState();
+ }
if(!rebuildNeeded){
+ setResourceChangeState(0);
+
toolChain.setRebuildState(false);
- for(Iterator iter = resourceConfigurationList.iterator();iter.hasNext();){
- IResourceConfiguration rcCfg = (IResourceConfiguration)iter.next();
- rcCfg.setRebuildState(false);
-
- ITool tools[] = rcCfg.getToolsToInvoke();
- for(int i = 0; i < tools.length; i++){
- tools[i].setRebuildState(false);
+ if(resourceConfigurationList != null){
+ for(Iterator iter = resourceConfigurationList.iterator();iter.hasNext();){
+ IResourceConfiguration rcCfg = (IResourceConfiguration)iter.next();
+ rcCfg.setRebuildState(false);
+
+ ITool tools[] = rcCfg.getToolsToInvoke();
+ for(int i = 0; i < tools.length; i++){
+ tools[i].setRebuildState(false);
+ }
}
}
@@ -1582,4 +1656,108 @@ public class Configuration extends BuildObject implements IConfiguration {
return tool;
}
+
+ /*
+ * The resource delta passed to the builder is not always up-to-date
+ * for the given configuration because between two builds of the same configuration
+ * any number of other configuration builds may occur
+ * that is why we need to keep some information regarding what happened
+ * with the resource tree between the two configuration builds
+ *
+ * The trivial approach implemented currently is to hold
+ * the general information of whether some resources were
+ * removed,changed,etc. and detect whether the rebuild is needed
+ * based upon this information
+ *
+ * This method adds the resource change state for the configuration
+ * specifying the resource change type performed on the project
+ * reported while building another configuration
+ * The method is not exported to the public API since delta handling
+ * mechanism will likely to be changed in the future
+ *
+ * In the future we might implement some more smart mechanism
+ * for tracking delta, e.g calculate the pre-cinfiguration resource delta, etc.
+ *
+ */
+ public void addResourceChangeState(int state){
+ setResourceChangeState(state | resourceChangeState);
+ }
+
+ private void setResourceChangeState(int state){
+ if(resourceChangeState != state){
+ resourceChangeState = state;
+ saveResourceChangeState();
+ }
+ }
+
+ private boolean resourceChangesRequireRebuild(){
+ return isInternalBuilderEnabled() ?
+ resourceChangeState != 0 :
+ (resourceChangeState & IResourceDelta.REMOVED) == IResourceDelta.REMOVED;
+ }
+
+ private void saveRebuildState(){
+ PropertyManager.getInstance().setProperty(this, REBUILD_STATE, Boolean.toString(rebuildNeeded));
+ }
+
+ private void saveResourceChangeState(){
+ PropertyManager.getInstance().setProperty(this, RC_CHANGE_STATE, Integer.toString(resourceChangeState));
+ }
+
+ /*
+ * Internal Builder state API
+ * NOTE: this is a temporary API
+ * In the future we are going present the Internal Builder
+ * as a special Builder object of the tool-chain and implement the internal
+ * builder enabling/disabling as the Builder substitution functionality
+ *
+ */
+
+ /*
+ * this method is used for enabling/disabling the internal builder
+ * for the given configuration
+ *
+ * @param enable boolean
+ */
+ public void enableInternalBuilder(boolean enable){
+ if(internalBuilderEnabled != enable){
+ internalBuilderEnabled = enable;
+ PropertyManager.getInstance().setProperty(this, INTERNAL_BUILDER_ENABLED, Boolean.toString(internalBuilderEnabled));
+ }
+ }
+
+ /*
+ * returns whether the internal builder is enabled
+ *
+ * @return boolean
+ */
+ public boolean isInternalBuilderEnabled(){
+ return internalBuilderEnabled;
+ }
+
+ /*
+ *
+ * sets the Internal Builder mode
+ *
+ * @param ignore if true, internal builder will ignore
+ * build errors while building,
+ * otherwise it will stop at the first build error
+ */
+ public void setInternalBuilderIgnoreErr(boolean ignore){
+ if(internalBuilderIgnoreErr != ignore){
+ internalBuilderIgnoreErr = ignore;
+ PropertyManager.getInstance().setProperty(this, INTERNAL_BUILDER_IGNORE_ERR, Boolean.toString(internalBuilderIgnoreErr));
+ }
+ }
+
+ /*
+ * returns the Internal Builder mode
+ * if true, internal builder will ignore build errors while building,
+ * otherwise it will stop at the first build error
+ *
+ * @return boolean
+ */
+ public boolean getInternalBuilderIgnoreErr(){
+ return internalBuilderIgnoreErr;
+ }
}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/GeneratedMakefileBuilder.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/GeneratedMakefileBuilder.java
index 283bf75941..09c94d3211 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/GeneratedMakefileBuilder.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/GeneratedMakefileBuilder.java
@@ -208,6 +208,81 @@ public class GeneratedMakefileBuilder extends ACBuilder {
}
}
+ private static class OtherConfigVerifier implements IResourceDeltaVisitor {
+ IConfiguration config;
+ IConfiguration configs[];
+ Configuration otherConfigs[];
+ int resourceChangeState;
+
+ private static final IPath[] ignoreList = {
+ new Path(".cdtproject"), //$NON-NLS-1$
+ new Path(".cproject"), //$NON-NLS-1$
+ new Path(".cdtbuild"), //$NON-NLS-1$
+ new Path(".settings"), //$NON-NLS-1$
+ };
+
+ OtherConfigVerifier(IConfiguration cfg){
+ config = cfg;
+ configs = cfg.getManagedProject().getConfigurations();
+ otherConfigs = new Configuration[configs.length - 1];
+ int counter = 0;
+ for(int i = 0; i < configs.length; i++){
+ if(configs[i] != config)
+ otherConfigs[counter++] = (Configuration)configs[i];
+ }
+ }
+
+ public boolean visit(IResourceDelta delta) throws CoreException {
+
+ IResource rc = delta.getResource();
+ if(rc.getType() == IResource.FILE){
+ if(isResourceValuable(rc))
+ resourceChangeState |= delta.getKind();
+ return false;
+ }
+ return !isGeneratedForConfig(rc, config) && isResourceValuable(rc);
+ }
+
+ public void updateOtherConfigs(IResourceDelta delta){
+ if(delta == null)
+ resourceChangeState = ~0;
+ else {
+ try {
+ delta.accept(this);
+ } catch (CoreException e) {
+ resourceChangeState = ~0;
+ }
+ }
+
+ setResourceChangeStateForOtherConfigs();
+ }
+
+ private void setResourceChangeStateForOtherConfigs(){
+ for(int i = 0; i < otherConfigs.length; i++){
+ otherConfigs[i].addResourceChangeState(resourceChangeState);
+ }
+ }
+
+ private boolean isGeneratedForConfig(IResource resource, IConfiguration cfg) {
+ // Is this a generated directory ...
+ IPath path = resource.getProjectRelativePath();
+ IPath root = new Path(cfg.getName());
+ // It is if it is a root of the resource pathname
+ if (root.isPrefixOf(path))
+ return true;
+ return false;
+ }
+
+ private boolean isResourceValuable(IResource rc){
+ IPath path = rc.getProjectRelativePath();
+ for(int i = 0; i < ignoreList.length; i++){
+ if(ignoreList[i].equals(path))
+ return false;
+ }
+ return true;
+ }
+ }
+
// String constants
private static final String BUILD_ERROR = "ManagedMakeBuilder.message.error"; //$NON-NLS-1$
private static final String BUILD_FINISHED = "ManagedMakeBuilder.message.finished"; //$NON-NLS-1$
@@ -340,18 +415,16 @@ public class GeneratedMakefileBuilder extends ACBuilder {
IConfiguration cfg = info.getDefaultConfiguration();
-// Uncomment the below code for using the Internal Builder
-// TODO: the info of what builder is to be used
-// should be held in and obtained from the Configuration
-/*
- if(true){
- invokeInternalBuilder(cfg, kind != FULL_BUILD, true, monitor);
+ updateOtherConfigs(cfg, kind);
+
+ if(((Configuration)cfg).isInternalBuilderEnabled()){
+ invokeInternalBuilder(cfg, kind != FULL_BUILD, ((Configuration)cfg).getInternalBuilderIgnoreErr(), monitor);
// Scrub the build info the project
info.setRebuildState(false);
return referencedProjects;
}
-*/
+
// Create a makefile generator for the build
IManagedBuilderMakefileGenerator generator = ManagedBuildManager.getBuildfileGenerator(info.getDefaultConfiguration());
generator.initialize(getProject(), info, monitor);
@@ -474,6 +547,10 @@ public class GeneratedMakefileBuilder extends ACBuilder {
return referencedProjects;
}
+ private void updateOtherConfigs(IConfiguration cfg, int buildKind){
+ new OtherConfigVerifier(cfg).updateOtherConfigs(buildKind == FULL_BUILD ? null : getDelta(getProject()));
+ }
+
/**
* Check whether the build has been canceled. Cancellation requests
* propagated to the caller by throwing <code>OperationCanceledException</code>.
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ManagedBuildInfo.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ManagedBuildInfo.java
index 9ad4fa2589..33bdb114a5 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ManagedBuildInfo.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ManagedBuildInfo.java
@@ -18,8 +18,6 @@ import java.util.List;
import java.util.Map;
import java.util.Vector;
-import org.eclipse.cdt.core.CCProjectNature;
-import org.eclipse.cdt.core.CProjectNature;
import org.eclipse.cdt.core.model.CModelException;
import org.eclipse.cdt.core.model.CoreModel;
import org.eclipse.cdt.core.model.ICProject;
@@ -950,8 +948,15 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
defaultConfig = configuration;
defaultConfigId = configuration.getId();
- defaultConfig.setRebuildState(true);
-
+ IProject proj = getOwner().getProject();
+ IResource cdtbuildFile = proj.findMember(ManagedBuildManager.SETTINGS_FILE_NAME);
+ if(cdtbuildFile != null){
+ try {
+ cdtbuildFile.touch(new NullProgressMonitor());
+ } catch (CoreException e) {
+ //TODO: log an error
+ }
+ }
// TODO: is this appropriate?
persistDefaultConfiguration();
}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ManagedProject.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ManagedProject.java
index bc276ea078..fad07ac222 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ManagedProject.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ManagedProject.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2005 Intel Corporation and others.
+ * Copyright (c) 2004, 2006 Intel Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -313,6 +313,7 @@ public class ManagedProject extends BuildObject implements IManagedProject {
ManagedBuildManager.performValueHandlerEvent(config,
IManagedOptionValueHandler.EVENT_CLOSE);
+ PropertyManager.getInstance().clearProperties(config);
getConfigurationList().remove(config);
getConfigurationMap().remove(removeId);
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/PluginResources.properties b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/PluginResources.properties
index 62249c1c28..7ad3ff4739 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/PluginResources.properties
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/PluginResources.properties
@@ -29,6 +29,7 @@ ManagedMakeBuilder.message.finished = Build complete for project {0}
ManagedMakeBuilder.message.cancelled = Build cancelled
ManagedMakeBuilder.message.finished.with.errs = Build completed with errors
ManagedMakeBuilder.message.internal.builder.error = Build failed: Internal builder error occured
+ManagedMakeBuilder.message.stopped.error=Build error occured, build is stopped
ManagedMakeBuilder.message.clean.deleting.output=Removing build artifacts from {0}
ManagedMakeBuilder.message.clean.build.clean=Trying a make clean in {0}
ManagedMakeBuilder.type.clean = Clean-only build
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/PropertyManager.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/PropertyManager.java
new file mode 100644
index 0000000000..abff32ce5b
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/PropertyManager.java
@@ -0,0 +1,372 @@
+/*******************************************************************************
+ * Copyright (c) 2006 Intel Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.managedbuilder.internal.core;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Properties;
+
+import org.eclipse.cdt.managedbuilder.core.IBuildObject;
+import org.eclipse.cdt.managedbuilder.core.IBuilder;
+import org.eclipse.cdt.managedbuilder.core.IConfiguration;
+import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
+import org.eclipse.cdt.managedbuilder.core.IResourceConfiguration;
+import org.eclipse.cdt.managedbuilder.core.ITool;
+import org.eclipse.cdt.managedbuilder.core.IToolChain;
+import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
+import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ProjectScope;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.QualifiedName;
+import org.osgi.service.prefs.BackingStoreException;
+import org.osgi.service.prefs.Preferences;
+
+/**
+ * This class allows specifying BuildObject-specific persisted properties
+ * The properties are stored as project preferences for now
+ *
+ */
+public class PropertyManager {
+ private static final String PROPS_PROPERTY = "properties"; //$NON-NLS-1$
+ private static final QualifiedName propsSessionProperty = new QualifiedName(ManagedBuilderCorePlugin.getUniqueIdentifier(), PROPS_PROPERTY);
+
+ private static final String NODE_NAME = "properties"; //$NON-NLS-1$
+
+ private static PropertyManager fInstance;
+
+ private PropertyManager(){
+ }
+
+ public static PropertyManager getInstance(){
+ if(fInstance == null)
+ fInstance = new PropertyManager();
+ return fInstance;
+ }
+
+ protected void setProperty(IConfiguration cfg, IBuildObject bo, String prop, String value){
+ Properties props = getProperties(cfg, bo);
+ if(props != null)
+ props.setProperty(prop, value);
+ }
+
+ protected String getProperty(IConfiguration cfg, IBuildObject bo, String prop){
+ Properties props = getProperties(cfg, bo);
+ if(props != null)
+ return props.getProperty(prop);
+ return null;
+ }
+
+ protected Properties getProperties(IConfiguration cfg, IBuildObject bo){
+ return loadProperties(cfg, bo);
+ }
+
+ protected Map getLoaddedData(IConfiguration cfg){
+ Map map = null;
+ try {
+ IProject proj = cfg.getOwner().getProject();
+ map = (Map)proj.getSessionProperty(propsSessionProperty);
+ if(map == null){
+ map = new HashMap();
+ proj.setSessionProperty(propsSessionProperty, map);
+ }
+ map = (Map)map.get(cfg.getId());
+ } catch (CoreException e) {
+ }
+ return map;
+ }
+
+ protected void clearLoaddedData(IConfiguration cfg){
+ IProject proj = cfg.getOwner().getProject();
+ try {
+ proj.setSessionProperty(propsSessionProperty, null);
+ } catch (CoreException e) {
+ }
+ }
+
+ protected Properties loadProperties(IConfiguration cfg, IBuildObject bo){
+ Map map = getData(cfg);
+
+ return getPropsFromData(map, bo);
+ }
+
+ protected Properties getPropsFromData(Map data, IBuildObject bo){
+ Object oVal = data.get(bo.getId());
+ Properties props = null;
+ if(oVal instanceof String){
+ props = stringToProps((String)oVal);
+ data.put(bo.getId(), props);
+ } else if (oVal instanceof Properties){
+ props = (Properties)oVal;
+ }
+
+ if(props == null){
+ props = new Properties();
+ data.put(bo.getId(), props);
+ }
+
+ return props;
+ }
+
+
+ protected void storeData(IConfiguration cfg){
+ Map map = getLoaddedData(cfg);
+
+ if(map != null)
+ storeData(cfg, map);
+ }
+
+ protected Properties mapToProps(Map map){
+ Properties props = null;
+ if(map != null && map.size() > 0){
+ props = new Properties();
+ for(Iterator iter = map.entrySet().iterator(); iter.hasNext();){
+ Map.Entry entry = (Map.Entry)iter.next();
+ String key = (String)entry.getKey();
+ String value = null;
+ Object oVal = entry.getValue();
+ if(oVal instanceof Properties){
+ value = propsToString((Properties)oVal);
+ } else if (oVal instanceof String){
+ value = (String)oVal;
+ }
+
+ if(key != null && value != null)
+ props.setProperty(key, value);
+ }
+ }
+
+ return props;
+ }
+
+ protected String propsToString(Properties props){
+ if(props == null || props.size() == 0)
+ return null;
+
+ ByteArrayOutputStream stream = new ByteArrayOutputStream();
+ try {
+ props.store(stream, ""); //$NON-NLS-1$
+ } catch (IOException e1) {
+ }
+
+ byte[] bytes= stream.toByteArray();
+
+ String value = null;
+ try {
+ value= new String(bytes, "UTF-8"); //$NON-NLS-1$
+ } catch (UnsupportedEncodingException e) {
+ value= new String(bytes);
+ }
+ return value;
+ }
+
+ protected Properties stringToProps(String str){
+ Properties props = null;
+ if(str != null){
+ props = new Properties();
+ byte[] bytes;
+ try {
+ bytes = str.getBytes("UTF-8"); //$NON-NLS-1$
+ } catch (UnsupportedEncodingException e) {
+ bytes = str.getBytes();
+ }
+
+ ByteArrayInputStream stream = new ByteArrayInputStream(bytes);
+ try {
+ props.load(stream);
+ } catch (IOException e) {
+ props = null;
+ }
+ }
+ return props;
+ }
+
+ protected void storeData(IConfiguration cfg, Map map){
+ String str = null;
+ Properties props = mapToProps(map);
+
+ str = propsToString(props);
+
+ storeString(cfg, str);
+ }
+
+ protected void storeString(IConfiguration cfg, String str){
+ IProject proj = cfg.getOwner().getProject();
+
+ Preferences prefs = getNode(proj);
+ if(prefs != null){
+ if(str != null)
+ prefs.put(cfg.getId(), str);
+ else
+ prefs.remove(cfg.getId());
+ try {
+ prefs.flush();
+ } catch (BackingStoreException e) {
+ }
+ }
+ }
+
+ protected String loadString(IConfiguration cfg){
+ IProject proj = cfg.getOwner().getProject();
+
+ if(proj == null || !proj.exists() || !proj.isOpen())
+ return null;
+
+ String str = null;
+ Preferences prefs = getNode(proj);
+ if(prefs != null)
+ str = prefs.get(cfg.getId(), null);
+ return str;
+ }
+
+ protected Preferences getNode(IProject project){
+ Preferences prefs = new ProjectScope(project).getNode(ManagedBuilderCorePlugin.getUniqueIdentifier());
+ if(prefs != null)
+ return prefs.node(NODE_NAME);
+ return null;
+ }
+
+
+ protected Map getData(IConfiguration cfg){
+ Map map = getLoaddedData(cfg);
+
+ if(map == null){
+ map = loadData(cfg);
+
+ setLoaddedData(cfg, map);
+ }
+
+ return map;
+ }
+
+ protected Map loadData(IConfiguration cfg){
+ Map map = null;
+ String str = loadString(cfg);
+
+ Properties props = stringToProps(str);
+
+ map = propsToMap(props);
+
+ if(map == null)
+ map = new HashMap();
+
+ return map;
+ }
+
+ protected Map propsToMap(Properties props){
+ if(props != null)
+ return new HashMap(props);
+ return null;
+ }
+
+ protected void setLoaddedData(IConfiguration cfg, Map data){
+ try {
+ IProject proj = cfg.getOwner().getProject();
+ Map map = (Map)proj.getSessionProperty(propsSessionProperty);
+ if(map == null){
+ map = new HashMap();
+ proj.setSessionProperty(propsSessionProperty, map);
+ }
+ map.put(cfg.getId(), data);
+ } catch (CoreException e) {
+ }
+ }
+
+ public void setProperty(IConfiguration cfg, String key, String value){
+ setProperty(cfg, cfg, key, value);
+ }
+
+ public void setProperty(IResourceConfiguration rcCfg, String key, String value){
+ setProperty(rcCfg.getParent(), rcCfg, key, value);
+ }
+
+ public void setProperty(IToolChain tc, String key, String value){
+ setProperty(tc.getParent(), tc, key, value);
+ }
+
+ public void setProperty(ITool tool, String key, String value){
+ setProperty(getConfiguration(tool), tool, key, value);
+ }
+
+ public void setProperty(IBuilder builder, String key, String value){
+ setProperty(getConfiguration(builder), builder, key, value);
+ }
+
+ public String getProperty(IConfiguration cfg, String key){
+ return getProperty(cfg, cfg, key);
+ }
+
+ public String getProperty(IResourceConfiguration rcCfg, String key){
+ return getProperty(rcCfg.getParent(), rcCfg, key);
+ }
+
+ public String getProperty(IToolChain tc, String key){
+ return getProperty(tc.getParent(), tc, key);
+ }
+
+ public String getProperty(ITool tool, String key){
+ return getProperty(getConfiguration(tool), tool, key);
+ }
+
+ public String getProperty(IBuilder builder, String key){
+ return getProperty(getConfiguration(builder), builder, key);
+ }
+
+ public void clearProperties(IConfiguration cfg){
+ clearLoaddedData(cfg);
+ storeData(cfg, null);
+ }
+
+ private IConfiguration getConfiguration(IBuilder builder){
+ IToolChain tc = builder.getParent();
+ if(tc != null)
+ return tc.getParent();
+ return null;
+ }
+
+ private IConfiguration getConfiguration(ITool tool){
+ IBuildObject p = tool.getParent();
+ IConfiguration cfg = null;
+ if(p instanceof IToolChain){
+ cfg = ((IToolChain)p).getParent();
+ } else if(p instanceof IResourceConfiguration){
+ cfg = ((IResourceConfiguration)p).getParent();
+ }
+ return cfg;
+ }
+
+ public void serialize(IConfiguration cfg){
+ if(cfg.isTemporary())
+ return;
+
+ storeData(cfg);
+ }
+
+ public void serialize(){
+ IProject projects[] = ResourcesPlugin.getWorkspace().getRoot().getProjects();
+ for(int i = 0; i < projects.length; i++){
+ IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(projects[i], false);
+ if(info != null && info.isValid() && info.getManagedProject() != null){
+ IConfiguration cfgs[] = info.getManagedProject().getConfigurations();
+ for(int j = 0; j < cfgs.length; j++){
+ serialize(cfgs[j]);
+ }
+ }
+ }
+ }
+
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ResourceChangeHandler.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ResourceChangeHandler.java
index 6c0a0f99fb..ec3193dceb 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ResourceChangeHandler.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ResourceChangeHandler.java
@@ -436,6 +436,7 @@ public class ResourceChangeHandler implements IResourceChangeListener, ISavePart
// No state to be saved by the plug-in, but request a
// resource delta to be used on next activation.
context.needDelta();
+ PropertyManager.getInstance().serialize();
}
/* (non-Javadoc)
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ResourceConfiguration.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ResourceConfiguration.java
index 54814e8959..dd76775c3d 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ResourceConfiguration.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ResourceConfiguration.java
@@ -38,6 +38,9 @@ public class ResourceConfiguration extends BuildObject implements IResourceConfi
private static final String EMPTY_STRING = new String();
+ //property name for holding the rebuild state
+ private static final String REBUILD_STATE = "rebuildState"; //$NON-NLS-1$
+
// Parent and children
private IConfiguration parent;
private List toolList;
@@ -112,6 +115,10 @@ public class ResourceConfiguration extends BuildObject implements IResourceConfi
addTool(tool);
}
}
+
+ String rebuild = PropertyManager.getInstance().getProperty(this, REBUILD_STATE);
+ if(rebuild == null || Boolean.parseBoolean(rebuild))
+ rebuildState = true;
}
public ResourceConfiguration(IConfiguration parent, String id, String resourceName, String path){
@@ -888,7 +895,10 @@ public class ResourceConfiguration extends BuildObject implements IResourceConfi
if(isExtensionResourceConfiguration() && rebuild)
return;
- rebuildState = rebuild;
+ if(rebuildState != rebuild){
+ rebuildState = rebuild;
+ saveRebuildState();
+ }
if(!rebuildState){
ITool tools[] = getToolsToInvoke();
@@ -898,4 +908,9 @@ public class ResourceConfiguration extends BuildObject implements IResourceConfi
}
}
+
+ private void saveRebuildState(){
+ PropertyManager.getInstance().setProperty(this, REBUILD_STATE, Boolean.toString(rebuildState));
+ }
+
}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Tool.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Tool.java
index b955d3cda9..f6277388c1 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Tool.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Tool.java
@@ -75,6 +75,9 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory {
public static final String DEFAULT_PATTERN = "${COMMAND} ${FLAGS} ${OUTPUT_FLAG}${OUTPUT_PREFIX}${OUTPUT} ${INPUTS}"; //$NON-NLS-1$
public static final String DEFAULT_CBS_PATTERN = "${COMMAND}"; //$NON-NLS-1$
+ //property name for holding the rebuild state
+ private static final String REBUILD_STATE = "rebuildState"; //$NON-NLS-1$
+
private static final String DEFAULT_SEPARATOR = ","; //$NON-NLS-1$
//private static final IOptionCategory[] EMPTY_CATEGORIES = new IOptionCategory[0];
//private static final IOption[] EMPTY_OPTIONS = new IOption[0];
@@ -291,6 +294,11 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory {
addOutputType(outputType);
}
}
+
+ String rebuild = PropertyManager.getInstance().getProperty(this, REBUILD_STATE);
+ if(rebuild == null || Boolean.parseBoolean(rebuild))
+ rebuildState = true;
+
}
/**
@@ -872,7 +880,9 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory {
// Save as URL in string form
element.setAttribute(IOptionCategory.ICON, iconPathURL.toString());
}
-
+
+ saveRebuildState();
+
// I am clean now
isDirty = false;
} catch (Exception e) {
@@ -2861,7 +2871,10 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory {
if(isExtensionElement() && rebuild)
return;
- rebuildState = rebuild;
+ if(rebuildState != rebuild){
+ rebuildState = rebuild;
+ saveRebuildState();
+ }
if(!rebuild){
super.setRebuildState(rebuild);
@@ -2881,7 +2894,10 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory {
}
}
}
-
-
}
+
+ private void saveRebuildState(){
+ PropertyManager.getInstance().setProperty(this, REBUILD_STATE, Boolean.toString(needsRebuild()));
+ }
+
}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ToolChain.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ToolChain.java
index f963c02f86..859d6da209 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ToolChain.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ToolChain.java
@@ -50,6 +50,8 @@ public class ToolChain extends HoldsOptions implements IToolChain {
private static final String EMPTY_STRING = new String();
+ private static final String REBUILD_STATE = "rebuildState"; //$NON-NLS-1$
+
private static final boolean resolvedDefault = true;
// Superclass
@@ -234,6 +236,11 @@ public class ToolChain extends HoldsOptions implements IToolChain {
}
}
+
+ String rebuild = PropertyManager.getInstance().getProperty(this, REBUILD_STATE);
+ if(rebuild == null || Boolean.parseBoolean(rebuild))
+ rebuildState = true;
+
}
/**
@@ -683,7 +690,9 @@ public class ToolChain extends HoldsOptions implements IToolChain {
if(userDefinedEnvironment != null)
EnvironmentVariableProvider.fUserSupplier.storeEnvironment(getParent(),true);
-
+
+ saveRebuildState();
+
// I am clean now
isDirty = false;
} catch (Exception e) {
@@ -1746,9 +1755,16 @@ public class ToolChain extends HoldsOptions implements IToolChain {
if(isExtensionElement() && rebuild)
return;
- rebuildState = rebuild;
+ if(rebuildState != rebuild){
+ rebuildState = rebuild;
+ saveRebuildState();
+ }
if(!rebuild)
super.setRebuildState(rebuild);
}
+
+ private void saveRebuildState(){
+ PropertyManager.getInstance().setProperty(this, REBUILD_STATE, Boolean.toString(needsRebuild()));
+ }
}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/envvar/StoredBuildPathEnvironmentContainer.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/envvar/StoredBuildPathEnvironmentContainer.java
index 5f606b1954..25f19f5e70 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/envvar/StoredBuildPathEnvironmentContainer.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/envvar/StoredBuildPathEnvironmentContainer.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005 Intel Corporation and others.
+ * Copyright (c) 2005, 2006 Intel Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -118,7 +118,7 @@ public class StoredBuildPathEnvironmentContainer extends
}
boolean changed = env.isChanged();
env.setChanged(false);
- if(changed)
+ if(changed && !configuration.isTemporary())
try{
storeEnvironment(env,configuration,false);
}catch(CoreException e){
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/envvar/UserDefinedEnvironmentSupplier.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/envvar/UserDefinedEnvironmentSupplier.java
index 614bbcadfa..047b9d312f 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/envvar/UserDefinedEnvironmentSupplier.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/envvar/UserDefinedEnvironmentSupplier.java
@@ -235,8 +235,10 @@ public class UserDefinedEnvironmentSupplier extends
if(env == null)
return null;
IBuildEnvironmentVariable var = env.createVariable(name,value,op,delimiter);
- if(env.isChanged())
+ if(env.isChanged()){
setRebuildStateForContext(context);
+ env.setChanged(false);
+ }
return var;
}
@@ -265,8 +267,10 @@ public class UserDefinedEnvironmentSupplier extends
return;
env.setVariales(vars);
- if(env.isChanged())
+ if(env.isChanged()){
setRebuildStateForContext(context);
+ env.setChanged(false);
+ }
}
protected void setRebuildStateForContext(Object context){
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/macros/UserDefinedMacroSupplier.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/macros/UserDefinedMacroSupplier.java
index 0ec62d2c11..cc1771bef4 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/macros/UserDefinedMacroSupplier.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/macros/UserDefinedMacroSupplier.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005 Intel Corporation and others.
+ * Copyright (c) 2005, 2006 Intel Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -152,8 +152,10 @@ public class UserDefinedMacroSupplier implements IBuildMacroSupplier {
return null;
IBuildMacro macro = macros.createMacro(macroName,type,value);
- if(macros.isChanged())
+ if(macros.isChanged()){
setRebuildStateForContext(contextType, contextData);
+ macros.setChanged(false);
+ }
return macro;
@@ -171,8 +173,10 @@ public class UserDefinedMacroSupplier implements IBuildMacroSupplier {
return null;
IBuildMacro macro = macros.createMacro(macroName,type,value);
- if(macros.isChanged())
+ if(macros.isChanged()){
setRebuildStateForContext(contextType, contextData);
+ macros.setChanged(false);
+ }
return macro;
@@ -189,8 +193,10 @@ public class UserDefinedMacroSupplier implements IBuildMacroSupplier {
return null;
IBuildMacro macro = macros.createMacro(copy);
- if(macros.isChanged())
+ if(macros.isChanged()){
setRebuildStateForContext(contextType, contextData);
+ macros.setChanged(false);
+ }
return macro;
}
@@ -221,8 +227,10 @@ public class UserDefinedMacroSupplier implements IBuildMacroSupplier {
return;
macros.setMacros(m);
- if(macros.isChanged())
+ if(macros.isChanged()){
setRebuildStateForContext(contextType, contextData);
+ macros.setChanged(false);
+ }
}
/*
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/BuildSettingsBlock.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/BuildSettingsBlock.java
index e4872ef1cc..a44998b3f3 100644
--- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/BuildSettingsBlock.java
+++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/BuildSettingsBlock.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2002, 2005 IBM Corporation and others.
+ * Copyright (c) 2002, 2006 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -16,15 +16,14 @@ import java.util.regex.Pattern;
import org.eclipse.cdt.managedbuilder.core.IBuilder;
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
-import org.eclipse.cdt.managedbuilder.core.IToolChain;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
+import org.eclipse.cdt.managedbuilder.internal.core.Configuration;
import org.eclipse.cdt.managedbuilder.internal.macros.BuildMacroProvider;
import org.eclipse.cdt.managedbuilder.ui.properties.BuildPropertyPage;
import org.eclipse.cdt.ui.dialogs.AbstractCOptionPage;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.swt.SWT;
import org.eclipse.swt.accessibility.AccessibleAdapter;
@@ -41,7 +40,6 @@ import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
public class BuildSettingsBlock extends AbstractCOptionPage {
@@ -58,8 +56,12 @@ public class BuildSettingsBlock extends AbstractCOptionPage {
private static final String OUTPUT_EXT = LABEL + ".output.extension"; //$NON-NLS-1$
private static final String OUTPUT_NAME = LABEL + ".output.name"; //$NON-NLS-1$
private static final String MACROS_GROUP = LABEL + ".macros.group"; //$NON-NLS-1$
- private static final String PACROS_EXPAND_BTN = LABEL + ".macros.expand"; //$NON-NLS-1$
-
+ private static final String MACROS_EXPAND_BTN = LABEL + ".macros.expand"; //$NON-NLS-1$
+ private static final String INTERNAL_BUILDER_GROUP = LABEL + ".internal.builder.group"; //$NON-NLS-1$
+ private static final String INTERNAL_BUILDER_ENABLE_BTN = LABEL + ".internal.builder.enable"; //$NON-NLS-1$
+ private static final String INTERNAL_BUILDER_IGNORE_ERR_BTN = LABEL + ".internal.builder.ignore.err"; //$NON-NLS-1$
+ private static final String INTERNAL_BUILDER_EXPERIMENTAL_NOTE = LABEL + ".internal.builder.experimental.note"; //$NON-NLS-1$
+
private static final String EMPTY_STRING = new String();
/*
@@ -68,9 +70,13 @@ public class BuildSettingsBlock extends AbstractCOptionPage {
protected Text buildArtifactExt;
protected Text buildArtifactName;
protected Button makeCommandDefault;
+ protected Group makeCommandGroup;
protected Text makeCommandEntry;
protected Button buildMacrosExpand;
protected Group buildMacrosExpandGroup;
+ protected Group internalBuilderGroup;
+ protected Button internalBuilderEnable;
+ protected Button internalBuilderIgnoreErr;
/*
* Bookeeping variables
@@ -137,6 +143,9 @@ public class BuildSettingsBlock extends AbstractCOptionPage {
// Create the build macros usage configuration area
createExpandMacrosGroup(comp);
+
+ // Create the Internal Builder configuration area
+ createInternalBuilderGroup(comp);
}
/* (non-Javadoc)
@@ -210,7 +219,7 @@ public class BuildSettingsBlock extends AbstractCOptionPage {
* @param parent
*/
private void createMakeCommandGroup(Composite parent) {
- final Group makeCommandGroup = new Group(parent, SWT.NONE);
+ makeCommandGroup = new Group(parent, SWT.NONE);
makeCommandGroup.setFont(parent.getFont());
makeCommandGroup.setText(ManagedBuilderUIMessages.getResourceString(GROUP));
makeCommandGroup.setLayout(new GridLayout(1, true));
@@ -256,7 +265,7 @@ public class BuildSettingsBlock extends AbstractCOptionPage {
buildMacrosExpandGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
buildMacrosExpand = new Button(buildMacrosExpandGroup, SWT.CHECK | SWT.LEFT);
buildMacrosExpand.setFont(buildMacrosExpandGroup.getFont());
- buildMacrosExpand.setText(ManagedBuilderUIMessages.getResourceString(PACROS_EXPAND_BTN));
+ buildMacrosExpand.setText(ManagedBuilderUIMessages.getResourceString(MACROS_EXPAND_BTN));
buildMacrosExpand.setBackground(buildMacrosExpandGroup.getBackground());
buildMacrosExpand.setForeground(buildMacrosExpandGroup.getForeground());
buildMacrosExpand.addSelectionListener(new SelectionAdapter () {
@@ -278,6 +287,62 @@ public class BuildSettingsBlock extends AbstractCOptionPage {
});
}
+ /* (non-Javadoc)
+ * Creates the group containing the check-box that allow user to specify
+ * whether the environment variable macros should be expanded or kept in the makefile
+ * @param parent
+ */
+ private void createInternalBuilderGroup(Composite parent) {
+ internalBuilderGroup = new Group(parent, SWT.NONE);
+ internalBuilderGroup.setFont(parent.getFont());
+ internalBuilderGroup.setText(ManagedBuilderUIMessages.getResourceString(INTERNAL_BUILDER_GROUP));
+ internalBuilderGroup.setLayout(new GridLayout(1, true));
+ internalBuilderGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+ Label dotLabel = new Label(internalBuilderGroup, SWT.CENTER);
+ dotLabel.setFont(internalBuilderGroup.getFont());
+ dotLabel.setText(ManagedBuilderUIMessages.getResourceString(INTERNAL_BUILDER_EXPERIMENTAL_NOTE));
+
+ internalBuilderEnable = new Button(internalBuilderGroup, SWT.CHECK | SWT.LEFT);
+ internalBuilderEnable.setFont(internalBuilderGroup.getFont());
+ internalBuilderEnable.setText(ManagedBuilderUIMessages.getResourceString(INTERNAL_BUILDER_ENABLE_BTN));
+ internalBuilderEnable.setBackground(internalBuilderGroup.getBackground());
+ internalBuilderEnable.setForeground(internalBuilderGroup.getForeground());
+ internalBuilderEnable.addSelectionListener(new SelectionAdapter () {
+ public void widgetSelected(SelectionEvent e) {
+ Configuration config = (Configuration)BuildSettingsBlock.this.parent.getSelectedConfigurationClone();
+ config.enableInternalBuilder(internalBuilderEnable.getSelection());
+ setValues();
+ setDirty(true);
+ }
+ });
+ internalBuilderEnable.addDisposeListener(new DisposeListener() {
+ public void widgetDisposed(DisposeEvent event) {
+ internalBuilderEnable = null;
+ }
+ });
+
+ internalBuilderIgnoreErr = new Button(internalBuilderGroup, SWT.CHECK | SWT.LEFT);
+ internalBuilderIgnoreErr.setFont(internalBuilderGroup.getFont());
+ internalBuilderIgnoreErr.setText(ManagedBuilderUIMessages.getResourceString(INTERNAL_BUILDER_IGNORE_ERR_BTN));
+ internalBuilderIgnoreErr.setBackground(internalBuilderGroup.getBackground());
+ internalBuilderIgnoreErr.setForeground(internalBuilderGroup.getForeground());
+ internalBuilderIgnoreErr.addSelectionListener(new SelectionAdapter () {
+ public void widgetSelected(SelectionEvent e) {
+ Configuration config = (Configuration)BuildSettingsBlock.this.parent.getSelectedConfigurationClone();
+ config.setInternalBuilderIgnoreErr(internalBuilderIgnoreErr.getSelection());
+ setValues();
+ setDirty(true);
+ }
+ });
+ internalBuilderIgnoreErr.addDisposeListener(new DisposeListener() {
+ public void widgetDisposed(DisposeEvent event) {
+ internalBuilderIgnoreErr = null;
+ }
+ });
+
+ }
+
protected void initializeValues() {
setValues();
setDirty(false);
@@ -290,7 +355,7 @@ public class BuildSettingsBlock extends AbstractCOptionPage {
}
protected void setValues() {
- IConfiguration config = parent.getSelectedConfigurationClone();
+ Configuration config = (Configuration)parent.getSelectedConfigurationClone();
if(!config.getArtifactName().equals(buildArtifactName.getText()))
buildArtifactName.setText(config.getArtifactName());
@@ -312,6 +377,17 @@ public class BuildSettingsBlock extends AbstractCOptionPage {
buildMacrosExpand.setSelection(provider.areMacrosExpandedInBuildfile(config));
}
+ boolean internalBuilderOn = config.isInternalBuilderEnabled();
+ internalBuilderEnable.setSelection(internalBuilderOn);
+ internalBuilderIgnoreErr.setSelection(config.getInternalBuilderIgnoreErr());
+
+ makeCommandDefault.setEnabled(!internalBuilderOn);
+ makeCommandEntry.setEnabled(!internalBuilderOn);
+ makeCommandGroup.setEnabled(!internalBuilderOn);
+ buildMacrosExpand.setEnabled(!internalBuilderOn);
+ buildMacrosExpandGroup.setEnabled(!internalBuilderOn);
+ internalBuilderIgnoreErr.setEnabled(internalBuilderOn);
+
// setDirty(false);
}
@@ -350,8 +426,8 @@ public class BuildSettingsBlock extends AbstractCOptionPage {
* @see org.eclipse.cdt.ui.dialogs.ICOptionPage#performApply(IProgressMonitor)
*/
public void performApply(IProgressMonitor monitor) throws CoreException {
- IConfiguration selectedConfiguration = parent.getSelectedConfiguration();
- IConfiguration cloneConfig = parent.getSelectedConfigurationClone();
+ Configuration selectedConfiguration = (Configuration)parent.getSelectedConfiguration();
+ Configuration cloneConfig = (Configuration)parent.getSelectedConfigurationClone();
String buildCommand = cloneConfig.getBuildCommand();
String buildArgs = cloneConfig.getBuildArguments();
@@ -378,6 +454,9 @@ public class BuildSettingsBlock extends AbstractCOptionPage {
selectedConfiguration,
provider.areMacrosExpandedInBuildfile(cloneConfig));
+ selectedConfiguration.enableInternalBuilder(cloneConfig.isInternalBuilderEnabled());
+ selectedConfiguration.setInternalBuilderIgnoreErr(cloneConfig.getInternalBuilderIgnoreErr());
+
setDirty(false);
}
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/PluginResources.properties b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/PluginResources.properties
index 34dbbf0aa6..91d6bddf7c 100644
--- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/PluginResources.properties
+++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/PluginResources.properties
@@ -107,6 +107,11 @@ BuildSettingsBlock.defaults.title=Reset Build Settings
BuildSettingsBlock.defaults.message=This action will reset the build settings to their default settings.\n\nDo you want to proceed?
BuildSettingsBlock.label.macros.group=Build Macros usage
BuildSettingsBlock.label.macros.expand=Expand Build Environment Macros
+BuildSettingsBlock.label.internal.builder.group=Internal Builder
+BuildSettingsBlock.label.internal.builder.enable=Enable Internal Builder
+BuildSettingsBlock.label.internal.builder.ignore.err=Ignore build errorors
+BuildSettingsBlock.label.internal.builder.experimental.note=NOTE: This is experimental functionality
+
# ----------- Build Steps Block -----------
BuildStepSettingsBlock.label.Settings=Build Steps

Back to the top