summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBaltasar Belyavsky2012-05-25 23:42:45 (EDT)
committerAndrew Gvozdev2012-05-26 02:01:05 (EDT)
commit22d7ec958f7120bec546aa0c773576f9c4fb8edf (patch)
treebb466d41ac2c4a3fefdce425467a386ecc737360
parent7381c59620c1d618cfecfa7092802d5cc1f0fa35 (diff)
downloadorg.eclipse.cdt-22d7ec958f7120bec546aa0c773576f9c4fb8edf.zip
org.eclipse.cdt-22d7ec958f7120bec546aa0c773576f9c4fb8edf.tar.gz
org.eclipse.cdt-22d7ec958f7120bec546aa0c773576f9c4fb8edf.tar.bz2
bug 378927: Internal builder seems broken
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/BuilderFactory.java43
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/dataprovider/ConfigurationDataProvider.java42
2 files changed, 85 insertions, 0 deletions
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/BuilderFactory.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/BuilderFactory.java
index bd0fd00..196a94e 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/BuilderFactory.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/BuilderFactory.java
@@ -26,6 +26,7 @@ import org.eclipse.cdt.managedbuilder.core.IManagedProject;
import org.eclipse.cdt.managedbuilder.core.IToolChain;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
+import org.eclipse.cdt.managedbuilder.core.ManagedCProjectNature;
import org.eclipse.core.resources.ICommand;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IProjectDescription;
@@ -433,4 +434,46 @@ public class BuilderFactory {
return EMPTY_BUILDERS_ARRAY;
}
+ public static int applyBuilder(IProjectDescription eDes, IBuilder builder){
+ return applyBuilder(eDes, CommonBuilder.BUILDER_ID, builder);
+ }
+
+ public static final int CMD_UNDEFINED = -1;
+ public static final int NO_CHANGES = 0;
+ public static final int CMD_CHANGED = 1;
+
+ private static int applyBuilder(IProjectDescription eDes, String eBuilderId, IBuilder builder){
+ ICommand cmd = ManagedCProjectNature.getBuildSpec(eDes, eBuilderId);
+ if(cmd == null)
+ return CMD_UNDEFINED;
+
+ if(applyBuilder(cmd, builder)){
+ ManagedCProjectNature.setBuildSpec(eDes, cmd);
+ return CMD_CHANGED;
+ }
+ return NO_CHANGES;
+ }
+
+ private static boolean applyBuilder(ICommand cmd, IBuilder builder) {
+ boolean changesMade = false;
+
+ if(cmd.isBuilding(IncrementalProjectBuilder.AUTO_BUILD) != builder.isAutoBuildEnable()) {
+ cmd.setBuilding(IncrementalProjectBuilder.AUTO_BUILD, builder.isAutoBuildEnable());
+ changesMade = true;
+ }
+ if(cmd.isBuilding(IncrementalProjectBuilder.FULL_BUILD) != builder.isFullBuildEnabled()) {
+ cmd.setBuilding(IncrementalProjectBuilder.FULL_BUILD, builder.isFullBuildEnabled());
+ changesMade = true;
+ }
+ if(cmd.isBuilding(IncrementalProjectBuilder.INCREMENTAL_BUILD) != builder.isIncrementalBuildEnabled()) {
+ cmd.setBuilding(IncrementalProjectBuilder.INCREMENTAL_BUILD, builder.isIncrementalBuildEnabled());
+ changesMade = true;
+ }
+ if(cmd.isBuilding(IncrementalProjectBuilder.CLEAN_BUILD) != builder.isCleanBuildEnabled()) {
+ cmd.setBuilding(IncrementalProjectBuilder.CLEAN_BUILD, builder.isCleanBuildEnabled());
+ changesMade = true;
+ }
+ return changesMade;
+ }
+
}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/dataprovider/ConfigurationDataProvider.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/dataprovider/ConfigurationDataProvider.java
index eae4fbf..2e198a9 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/dataprovider/ConfigurationDataProvider.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/dataprovider/ConfigurationDataProvider.java
@@ -34,6 +34,7 @@ import org.eclipse.cdt.core.settings.model.IModificationContext;
import org.eclipse.cdt.core.settings.model.extension.CConfigurationData;
import org.eclipse.cdt.core.settings.model.extension.CConfigurationDataProvider;
import org.eclipse.cdt.managedbuilder.core.BuildException;
+import org.eclipse.cdt.managedbuilder.core.IBuilder;
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
import org.eclipse.cdt.managedbuilder.core.IFolderInfo;
import org.eclipse.cdt.managedbuilder.core.IInputType;
@@ -47,6 +48,7 @@ import org.eclipse.cdt.managedbuilder.core.IToolChain;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
import org.eclipse.cdt.managedbuilder.internal.core.Builder;
+import org.eclipse.cdt.managedbuilder.internal.core.BuilderFactory;
import org.eclipse.cdt.managedbuilder.internal.core.Configuration;
import org.eclipse.cdt.managedbuilder.internal.core.ISettingsChangeListener;
import org.eclipse.cdt.managedbuilder.internal.core.InputType;
@@ -57,6 +59,7 @@ import org.eclipse.cdt.managedbuilder.internal.core.SettingsChangeEvent;
import org.eclipse.cdt.managedbuilder.internal.core.Tool;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IProjectDescription;
+import org.eclipse.core.resources.IWorkspaceRunnable;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.QualifiedName;
@@ -85,6 +88,28 @@ public class ConfigurationDataProvider extends CConfigurationDataProvider implem
}
}
+ private static class DesApplyRunnable implements IWorkspaceRunnable {
+ IBuilder fBuilder;
+ IProject fProject;
+
+ DesApplyRunnable(IProject project, IBuilder builder){
+ fProject = project;
+ fBuilder = builder;
+ }
+
+ @Override
+ public void run(IProgressMonitor monitor) throws CoreException {
+ try {
+ IProjectDescription eDes = fProject.getDescription();
+ if(BuilderFactory.applyBuilder(eDes, fBuilder) == BuilderFactory.CMD_CHANGED) {
+ fProject.setDescription(eDes, monitor);
+ }
+ } catch (Exception e){
+ ManagedBuilderCorePlugin.log(e);
+ }
+ }
+
+ }
static BuildConfigurationData writeConfiguration(ICConfigurationDescription cfgDescription,
BuildConfigurationData base) throws CoreException {
BuildConfigurationData appliedCfg = base;
@@ -159,6 +184,23 @@ public class ConfigurationDataProvider extends CConfigurationDataProvider implem
setPersistedFlag(cfgDescription);
cacheNaturesIdsUsedOnCache(cfgDescription);
}
+
+ if(cfgDescription.isActive()){
+ IConfiguration cfg = appliedCfg.getConfiguration();
+ IBuilder builder = cfg.getEditableBuilder();
+ IProject project = context.getProject();
+ IProjectDescription eDes = context.getEclipseProjectDescription();
+ switch(BuilderFactory.applyBuilder(eDes, builder)){
+ case BuilderFactory.CMD_UNDEFINED:
+ IWorkspaceRunnable applyR = new DesApplyRunnable(project, builder);
+ context.addWorkspaceRunnable(applyR);
+ break;
+ case BuilderFactory.CMD_CHANGED:
+ context.setEclipseProjectDescription(eDes);
+ break;
+ }
+ }
+
return appliedCfg;
}