Blob Blame History Raw
--- com.redhat.eclipse.cdt.autotools/src/com/redhat/eclipse/cdt/autotools/actions/BuildSpecial.java.fix	2006-08-21 17:06:01.000000000 -0400
+++ com.redhat.eclipse.cdt.autotools/src/com/redhat/eclipse/cdt/autotools/actions/BuildSpecial.java	2006-08-21 17:06:22.000000000 -0400
@@ -3,9 +3,13 @@ package com.redhat.eclipse.cdt.autotools
 import org.eclipse.cdt.make.core.IMakeTarget;
 import org.eclipse.cdt.make.ui.MakeLabelProvider;
 import org.eclipse.cdt.make.ui.TargetBuild;
+import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
+import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
 import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IProject;
 import org.eclipse.core.runtime.CoreException;
 import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.NullProgressMonitor;
 import org.eclipse.core.runtime.QualifiedName;
 import org.eclipse.jface.action.IAction;
 import org.eclipse.jface.window.Window;
@@ -13,6 +17,7 @@ import org.eclipse.ui.IWorkbenchWindowAc
 import org.eclipse.ui.dialogs.ElementListSelectionDialog;
 
 import com.redhat.eclipse.cdt.autotools.AutotoolsPlugin;
+import com.redhat.eclipse.cdt.autotools.MakeGenerator;
 
 /**
  * Our sample action implements workbench action delegate.
@@ -42,7 +47,19 @@ public class BuildSpecial extends Abstra
 		if (container != null) {
 			ElementListSelectionDialog dialog = new ElementListSelectionDialog(getShell(), new MakeLabelProvider());
 			try {
-				dialog.setElements(AutotoolsPlugin.getDefault().getTargetManager().getTargets(container));
+				// Get the targets listed for the top-level makefile.  If none
+				// exist, we may not have a makefile yet so we should attempt to
+				// generate the makefile via configuration.
+				IMakeTarget[] targets = AutotoolsPlugin.getDefault().getTargetManager().getTargets(container);
+				if (targets.length == 0) {
+					IProject project = container.getProject();
+					IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(project);
+					MakeGenerator generator = new MakeGenerator();
+					generator.initialize(project, info, new NullProgressMonitor());
+					generator.regenerateMakefiles();
+				}
+				targets = AutotoolsPlugin.getDefault().getTargetManager().getTargets(container);
+				dialog.setElements(targets);
 			} catch (CoreException e) {
 				// TODO Auto-generated catch block
 				e.printStackTrace();
--- com.redhat.eclipse.cdt.autotools/src/com/redhat/eclipse/cdt/autotools/MakeGenerator.java.fix	2006-08-21 17:01:14.000000000 -0400
+++ com.redhat.eclipse.cdt.autotools/src/com/redhat/eclipse/cdt/autotools/MakeGenerator.java	2006-08-21 17:01:44.000000000 -0400
@@ -1,8 +1,15 @@
 package com.redhat.eclipse.cdt.autotools;
 
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
 import java.io.ByteArrayInputStream;
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import java.io.EOFException;
 import java.io.File;
+import java.io.FileInputStream;
 import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
 import java.io.FileReader;
 import java.io.IOException;
 import java.io.OutputStream;
@@ -53,6 +60,8 @@ public class MakeGenerator implements IM
 	public final String AUTOGEN_SH = "autogen.sh";
 
 	public final String CONFIGURE = "configure";
+	
+	public final String SETTINGS_FILE_NAME = ".cdtconfigure";
 
 	private IProject project;
 
@@ -244,6 +253,7 @@ public class MakeGenerator implements IM
 	public MultiStatus regenerateMakefiles() throws CoreException {
 		MultiStatus status;
 		boolean ok = true;
+		boolean needFullConfigure = true;
 
 		// See if the user has cancelled the build
 		checkCancel();
@@ -292,8 +302,40 @@ public class MakeGenerator implements IM
 			IPath configfile = getProjectLocation().append(buildDir).append(
 					CONFIG_STATUS);
 			IFile configStatus = root.getFileForLocation(configfile);
-
-			if (configStatus != null && configStatus.exists()) {
+			IPath configSettingsPath = getProjectLocation().append(SETTINGS_FILE_NAME);
+			IFile configSettings = root.getFileForLocation(configSettingsPath);
+			String[] configArgs = getConfigArgs();
+
+			// We need to figure out if the end-user has changed the configuration
+			// settings.  In such a case, we need to reconfigure from scratch
+			// regardless of whether config.status exists or not.
+			// We figure this out by saving the configuration settings to
+			// a special file and reading/comparing whenever we are asked to build.
+			if (configSettings.exists()) {
+				int i = 0;
+				needFullConfigure = false;
+				IPath settingsPath = project.getLocation().append(SETTINGS_FILE_NAME);
+				try {
+					File f = new File(settingsPath.toOSString());
+					DataInputStream settings = new DataInputStream(
+							new BufferedInputStream(new FileInputStream(f)));
+					while (i < configArgs.length) {
+						String s = settings.readUTF();
+						if (!s.equals(configArgs[i])) {
+							i = configArgs.length;
+							needFullConfigure = true;
+						}
+						++i;
+					}
+					if (settings.available() > 0)
+						needFullConfigure = true;
+				} catch (EOFException e) {
+					needFullConfigure = true;
+				} catch (IOException e) {
+					needFullConfigure = true;
+				}
+			}
+			if (!needFullConfigure && configStatus != null && configStatus.exists()) {
 				ok = runCommand(configfile, project.getLocation().append(
 						buildDir), null, "Running config.status");
 			}
@@ -302,10 +344,13 @@ public class MakeGenerator implements IM
 				ok = runCommand(project.getLocation().append(
 						info.getToolForConfiguration("status")), project
 						.getLocation().append(buildDir),
-						getConfigArgs(), "Generating Makefile");
+						configArgs, "Generating Makefile");
 				File makefileFile = project.getLocation().append(buildDir)
 						.append("Makefile").toFile();
 				addMakeTargetsToManager(makefileFile);
+				// TODO: should we do something special if configure doesn't
+				// return ok?
+				saveConfigArgs(configArgs);
 			}
 			// If no configure, run autogen.sh
 			else if (autogenExists()) {
@@ -359,6 +404,21 @@ public class MakeGenerator implements IM
 		return autogenCommand.toFile().exists();
 	}
 	
+	private void saveConfigArgs(String[] args) {
+		IPath settingsPath = project.getLocation().append(SETTINGS_FILE_NAME);
+		try {
+			File f = new File(settingsPath.toOSString());
+			DataOutputStream settings = new DataOutputStream(
+					new BufferedOutputStream(new FileOutputStream(f)));
+			for (int i = 0; i < args.length; ++i) {
+				settings.writeUTF(args[i]);
+			}
+			settings.close();
+		} catch (IOException e) {
+			/* What should we do?  */
+		}
+	}
+	
 	private String[] getConfigArgs() throws BuildException {
 		// Get the arguments to be passed to config from build model
 		ITool tool = info.getToolFromOutputExtension("status");
@@ -376,15 +436,17 @@ public class MakeGenerator implements IM
 					value = value.trim();
 					boolean finished = false;
 					int lastIndex = value.indexOf("--");
-					while (!finished) {
-						int index = value.indexOf("--",lastIndex+2);
-						if (index != -1) {
-							String previous = value.substring(lastIndex, index).trim();
-							configArgs.add(previous);
-							value = value.substring(index);
-						} else {
-							configArgs.add(value);
-							finished = true;
+					if (lastIndex != -1) {
+						while (!finished) {
+							int index = value.indexOf("--",lastIndex+2);
+							if (index != -1) {
+								String previous = value.substring(lastIndex, index).trim();
+								configArgs.add(previous);
+								value = value.substring(index);
+							} else {
+								configArgs.add(value);
+								finished = true;
+							}
 						}
 					}
 				}
--- com.redhat.eclipse.cdt.autotools/ChangeLog.fix	2006-08-21 16:58:28.000000000 -0400
+++ com.redhat.eclipse.cdt.autotools/ChangeLog	2006-08-21 17:00:46.000000000 -0400
@@ -0,0 +1,31 @@
+2006-08-21  Jeff Johnston  <jjohnstn@redhat.com>
+
+	* src/com/redhat/eclipse/cdt/autotools/actions/BuildSpecial.java (run): If
+	there are no targets yet (i.e. no makefile), try and regenerate the makefile.
+	* src/com/redhat/eclipse/cdt/autotools/MakeGenerator.java (getConfigArgs): 
+	Make sure there is an "other" string to process rather than adding
+	an empty argument.
+
+2006-08-16  Jeff Johnston  <jjohnstn@redhat.com>
+
+	* src/com/redhat/eclipse/cdt/autotools/MakeGenerator.java (regenerateMakefiles): 
+	Add logic to check if the configuration arguments have changed since the last
+	configuration and reconfigure if they have.
+	(saveConfigArgs): New method.
+
+2006-08-03  Jeff Johnston  <jjohnstn@redhat.com>
+
+	* src/com/redhat/eclipse/cdt/autotools/AutotoolsMakefileBuilder.java (addAutotoolsBuilder):
+	Check for ManagedMake's genmakebuilder and remove if found.
+	(hasTargetBuilder): Look for Autotools default configuration and if found,
+	add the Autotools Makefile builder.
+
+2006-07-31  Jeff Johnston  <jjohnstn@redhat.com>
+
+	* src/com/redhat/eclipse/cdt/autotools/ui/LibHover.java (getLibHoverDocs): New
+	method which replaces buildDocPath and fetches libhover base data file from
+	the plugin's jar.
+	* src/com/redhat/eclipse/cdt/autotools/ui/LibHover.java (buildDocPath): Replaced
+	by getLibHoverDocs.  Change all callers.
+	* src/com/redhat/eclipse/cdt/autotools/ui/LibHover.java (getDocument): Removed.
+