--- com.redhat.eclipse.cdt.autotools/src/com/redhat/eclipse/cdt/autotools/AutotoolsMakefileBuilder.java.fix 2006-08-08 14:47:55.000000000 -0400
+++ com.redhat.eclipse.cdt.autotools/src/com/redhat/eclipse/cdt/autotools/AutotoolsMakefileBuilder.java 2006-08-08 14:48:25.000000000 -0400
@@ -18,12 +18,19 @@ import java.util.Vector;
import org.eclipse.cdt.make.core.IMakeBuilderInfo;
import org.eclipse.cdt.make.core.MakeCorePlugin;
+import org.eclipse.cdt.managedbuilder.core.IConfiguration;
+import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
+import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
+import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
+import org.eclipse.cdt.managedbuilder.core.ManagedCProjectNature;
import org.eclipse.cdt.managedbuilder.internal.core.GeneratedMakefileBuilder;
+import org.eclipse.cdt.managedbuilder.internal.core.ManagedBuildInfo;
import org.eclipse.core.resources.ICommand;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IProjectDescription;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
/**
* This is the incremental builder associated with a managed build project. It dynamically
@@ -34,6 +41,8 @@ import org.eclipse.core.runtime.IProgres
public class AutotoolsMakefileBuilder extends GeneratedMakefileBuilder {
public static final String BUILDER_NAME = "genmakebuilder"; //$NON-NLS-1$
public static final String BUILDER_ID = AutotoolsPlugin.getUniqueIdentifier() + "." + BUILDER_NAME; //$NON-NLS-1$
+ public static final String MANAGED_BUILDER_ID = ManagedBuilderCorePlugin.getUniqueIdentifier() + "." + BUILDER_NAME; //$NON-NLS-1$
+ public static final String AUTOTOOLS_CONFIG_ID = AutotoolsPlugin.getUniqueIdentifier() + ".configuration1"; //$NON-NLS-1$
private IMakeBuilderInfo info;
@@ -46,16 +55,21 @@ public class AutotoolsMakefileBuilder ex
IProjectDescription description = project.getDescription();
ICommand[] commands = description.getBuildSpec();
- // TODO Remove this when the new StandardBuild nature adds the cbuilder
+ // TODO Remove the cbuilder check when the new StandardBuild nature adds the cbuilder
for (int i = 0; i < commands.length; i++) {
ICommand command = commands[i];
- if (command.getBuilderName().equals("org.eclipse.cdt.core.cbuilder")) { //$NON-NLS-1$
+ String builderName = command.getBuilderName();
+ // If there is a ManagedMake makefile generator, remove it as it will
+ // cause an additional build "all" to occur when we are making any target.
+ if (builderName.equals("org.eclipse.cdt.core.cbuilder") ||
+ builderName.equals(MANAGED_BUILDER_ID)) { //$NON-NLS-1$
// Remove the command
Vector vec = new Vector(Arrays.asList(commands));
vec.removeElementAt(i);
vec.trimToSize();
ICommand[] tempCommands = (ICommand[]) vec.toArray(new ICommand[commands.length-1]);
description.setBuildSpec(tempCommands);
+ project.setDescription(description, null);
break;
}
}
@@ -84,12 +98,18 @@ public class AutotoolsMakefileBuilder ex
public static boolean hasTargetBuilder(IProject project) {
try {
- IProjectDescription description = project.getDescription();
- ICommand[] commands = description.getBuildSpec();
- // See if the builder is already there
-
- for (int i = 0; i < commands.length; ++i) {
- if (commands[i].getBuilderName().equals(BUILDER_ID)) {
+ // When a project is converted to an Autotools project, we
+ // replace the ManagedMake builder with a special one that
+ // handles MakeTargets. If a project is brought into Eclipse and
+ // uses the New Project Wizard to create a ManagedMake project that
+ // is of type: Autotools, this added step is not done. If we know
+ // we have an Autotools project from the configuration id, then
+ // we should add the builder now and return true.
+ if (project.getNature(ManagedCProjectNature.MNG_NATURE_ID) != null) {
+ IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(project);
+ IConfiguration config = info.getDefaultConfiguration();
+ if (config.getParent().getId().equals(AUTOTOOLS_CONFIG_ID)) {
+ addAutotoolsBuilder(project, new NullProgressMonitor());
return true;
}
}