Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[cdt-patch] Fix for bug 42522

Hi All,
A quick fix for bug 42522. The builder now properly refreshes the files in 
a project after build. Grubby details are in the change log.

Sean Evoy
Rational Software - IBM Software Group
Ottawa, Ontario, Canada

Index: ChangeLog
===================================================================
RCS file: /home/tools/org.eclipse.cdt.managedbuilder.core/ChangeLog,v
retrieving revision 1.7
diff -u -r1.7 ChangeLog
--- ChangeLog	26 Sep 2003 17:53:45 -0000	1.7
+++ ChangeLog	29 Sep 2003 00:02:46 -0000
@@ -1,4 +1,36 @@
 2003-09-25 Sean Evoy
+	A patch to resolve the problem with refreshing the project after a build, or
+	bug 42522 if you care about those sorts of things. The managed make builder was
+	calling refresh at inside a bad if statement. I corrected that and projects 
+	refresh correctly. Of course, if you have the wrong binary parser selected you are
+	hosed. You will also notice that the string constants have been changed to 
+	resolve to a different name. The standard builder uses this name and I wanted 
+	to minimize the possibility of problems later.
+	* src/org/eclipse/cdt/managedbuilder/internal/core/GeneratedMakefileBuilder.java
+	
+	Prepended "Managed" to the externalized string identifiers to avoid future overlap 
+	with the standard build system. Had to update the makefile generator to use the 
+	new identifiers.
+	* src/org/eclipse/cdt/managedbuilder/internal/core/PluginResources.properties
+	*  src/org/eclipse/cdt/managedbuilder/internal/core/MakefileGenerator.java
+	
+	Changed the signature of the 'getMakeArguments' to return a string instead of an 
+	array so the builder can invoke make with the user-specified args. I also changed 
+	the logic of the getMakeCommand method in the implementor so that it only returns 
+	a string containing the command itself.
+	* src/org/eclipse/cdt/managedbuilder/core/IManagedBuildInfo.java
+	* src/org/eclipse/cdt/managedbuilder/internal/core/ManagedBuildInfo.java
+
+	Explicitly trim all arrays to size before converting them to String[] for Options 
+	and Tools.
+	*src/org/eclipse/cdt/managedbuilder/internal/core/Option.java
+	* src/org/eclipse/cdt/managedbuilder/internal/core/Tool.java
+	
+	Fixed a missing bit of logic in the Configuration when a user-object option is 
+	deleted. Now the build model really does get rid of the the value.
+	* src/org/eclipse/cdt/managedbuilder/internal/core/Configuration.java
+	
+2003-09-25 Sean Evoy
 	This patch contains a lot of changes needed to implement fixes for 42648 and 
 	43122. 
 
Index: src/org/eclipse/cdt/managedbuilder/core/IManagedBuildInfo.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IManagedBuildInfo.java,v
retrieving revision 1.3
diff -u -r1.3 IManagedBuildInfo.java
--- src/org/eclipse/cdt/managedbuilder/core/IManagedBuildInfo.java	26 Sep 2003 19:54:24 -0000	1.3
+++ src/org/eclipse/cdt/managedbuilder/core/IManagedBuildInfo.java	29 Sep 2003 00:02:47 -0000
@@ -150,13 +150,13 @@
 	public String[] getLibsForTarget(String extension);
 
 	/**
-	 * Answers a string array containing the arguments to be passed to
-	 * make. For example, if the user has selected a build that stops
-	 * at the first error, the array would contain {"k"}.
+	 * Answers a <code>String</code> containing the arguments to be passed to make. 
+	 * For example, if the user has selected a build that keeps going on error, the 
+	 * answer would contain {"-k"}.
 	 * 
-	 * @return
+	 * @return String
 	 */
-	public String[] getMakeArguments();
+	public String getMakeArguments();
 
 	/**
 	 * Answers a <code>String</code> containing the make command invocation 
Index: src/org/eclipse/cdt/managedbuilder/internal/core/Configuration.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Configuration.java,v
retrieving revision 1.2
diff -u -r1.2 Configuration.java
--- src/org/eclipse/cdt/managedbuilder/internal/core/Configuration.java	26 Sep 2003 00:20:12 -0000	1.2
+++ src/org/eclipse/cdt/managedbuilder/internal/core/Configuration.java	29 Sep 2003 00:02:47 -0000
@@ -352,6 +352,9 @@
 			case IOption.LIBRARIES :
 				oldValue = option.getLibraries();
 				break;
+			case IOption.OBJECTS :
+				oldValue = option.getUserObjects();
+				break;
 			default :
 				oldValue = new String[0];
 				break;
Index: src/org/eclipse/cdt/managedbuilder/internal/core/GeneratedMakefileBuilder.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/GeneratedMakefileBuilder.java,v
retrieving revision 1.3
diff -u -r1.3 GeneratedMakefileBuilder.java
--- src/org/eclipse/cdt/managedbuilder/internal/core/GeneratedMakefileBuilder.java	22 Sep 2003 02:32:08 -0000	1.3
+++ src/org/eclipse/cdt/managedbuilder/internal/core/GeneratedMakefileBuilder.java	29 Sep 2003 00:02:47 -0000
@@ -14,6 +14,7 @@
 import java.io.IOException;
 import java.io.OutputStream;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Enumeration;
 import java.util.List;
 import java.util.Map;
@@ -46,14 +47,17 @@
 
 public class GeneratedMakefileBuilder extends ACBuilder {
 	// String constants
-	private static final String MESSAGE = "MakeBuilder.message";	//$NON-NLS-1$
+	private static final String MESSAGE = "ManagedMakeBuilder.message";	//$NON-NLS-1$
 	private static final String BUILD_ERROR = MESSAGE + ".error";	//$NON-NLS-1$
+	private static final String REFRESH_ERROR = BUILD_ERROR + ".refresh";	//$NON-NLS-1$
 	private static final String BUILD_FINISHED = MESSAGE + ".finished";	//$NON-NLS-1$
 	private static final String INCREMENTAL = MESSAGE + ".incremental";	//$NON-NLS-1$
 	private static final String MAKE = MESSAGE + ".make";	//$NON-NLS-1$
 	private static final String REBUILD = MESSAGE + ".rebuild";	//$NON-NLS-1$
 	private static final String START = MESSAGE + ".starting";	//$NON-NLS-1$
-
+	private static final String REFRESH = MESSAGE + ".updating";	//$NON-NLS-1$
+	private static final String MARKERS = MESSAGE + ".creating.markers";	//$NON-NLS-1$
+	
 	// Status codes
 	public static final int EMPTY_PROJECT_BUILD_ERROR = 1;
 
@@ -85,7 +89,7 @@
 	 * 
 	 */
 	public GeneratedMakefileBuilder() {
-		super();
+
 	}
 
 	/* (non-Javadoc)
@@ -102,6 +106,9 @@
 		if (kind == IncrementalProjectBuilder.FULL_BUILD || info.isDirty()) {
 			fullBuild(monitor, info);
 		}
+		else if (kind == IncrementalProjectBuilder.AUTO_BUILD && info.isDirty()) {
+			fullBuild(monitor, info);
+		}
 		else {
 			// Create a delta visitor to make sure we should be rebuilding
 			ResourceDeltaVisitor visitor = new ResourceDeltaVisitor();
@@ -118,9 +125,6 @@
 		}
 		info.setDirty(false);
 		
-		// Checking to see if the user cancelled the build
-		checkCancel(monitor);
-
 		// Ask build mechanism to compute deltas for project dependencies next time
 		return getProject().getReferencedProjects();
 	}
@@ -191,7 +195,6 @@
 		
 		// Now call make
 		invokeMake(true, topBuildDir.removeFirstSegments(1), info, monitor);
-		
 		monitor.worked(1);		
 	}
 
@@ -282,132 +285,128 @@
 	}
 
 	protected void invokeMake(boolean fullBuild, IPath buildDir, IManagedBuildInfo info, IProgressMonitor monitor) {
-		boolean isCanceled = false;
+		// Get the project and make sure there's a monitor to cancel the build
 		IProject currentProject = getProject();
-		SubProgressMonitor subMonitor = null;
 		if (monitor == null) {
 			monitor = new NullProgressMonitor();
 		}
 
-		// Flag to the user that make is about to be called
-		IPath makeCommand = new Path(info.getMakeCommand()); 
-		String[] msgs = new String[2];
-		msgs[0] = info.getMakeCommand();
-		msgs[1] = currentProject.getName();
-		String statusMsg = ManagedBuilderCorePlugin.getFormattedString(MAKE, msgs);
-		if (statusMsg != null) {
-			monitor.subTask(statusMsg);
-		}
-
-		// Get a build console for the project
-		IConsole console = null;
-		ConsoleOutputStream consoleOutStream = null;
-		IWorkspace workspace = null;
-		IMarker[] markers = null;
 		try {
-			console = CCorePlugin.getDefault().getConsole();
-			console.start(currentProject);
-			consoleOutStream = console.getOutputStream();
-
-			// Remove all markers for this project
-			workspace = currentProject.getWorkspace();
-			markers = currentProject.findMarkers(ICModelMarker.C_MODEL_PROBLEM_MARKER, true, IResource.DEPTH_INFINITE);
-			if (markers != null) {
-				workspace.deleteMarkers(markers);
-			}
-		} catch (CoreException e) {
-		}
-
-		IPath workingDirectory = getWorkingDirectory().append(buildDir);
+			// Flag to the user that make is about to be called
+			IPath makeCommand = new Path(info.getMakeCommand()); 
+			if (makeCommand != null) {
+				String[] msgs = new String[2];
+				msgs[0] = makeCommand.toString();
+				msgs[1] = currentProject.getName();
+				monitor.beginTask(ManagedBuilderCorePlugin.getFormattedString(MAKE, msgs), IProgressMonitor.UNKNOWN);
+
+				// Get a build console for the project
+				IConsole console = CCorePlugin.getDefault().getConsole();
+				console.start(currentProject);
+				ConsoleOutputStream consoleOutStream = console.getOutputStream();
+	
+				// Remove all markers for this project
+				removeAllMarkers(currentProject);
 
-		// Get the arguments to be passed to make from build model
-		String[] makeTargets = getMakeTargets(fullBuild);
-		
-		// Get a launcher for the make command
-		String errMsg = null;
-		CommandLauncher launcher = new CommandLauncher();
-		launcher.showCommand(true);
-
-		// Set the environmennt, some scripts may need the CWD var to be set.
-		Properties props = launcher.getEnvironment();
-		props.put("CWD", workingDirectory.toOSString());
-		props.put("PWD", workingDirectory.toOSString());
-		String[] env = null;
-		ArrayList envList = new ArrayList();
-		Enumeration names = props.propertyNames();
-		if (names != null) {
-			while (names.hasMoreElements()) {
-				String key = (String) names.nextElement();
-				envList.add(key + "=" + props.getProperty(key));
-			}
-			env = (String[]) envList.toArray(new String[envList.size()]);
-		}
-		
-		// Hook up an error parser
-		ErrorParserManager epm = new ErrorParserManager(this);
-		epm.setOutputStream(consoleOutStream);
-		OutputStream stdout = epm.getOutputStream();
-		OutputStream stderr = epm.getOutputStream();
-		
-		// Launch make
-		Process proc = launcher.execute(makeCommand, makeTargets, env, workingDirectory);
-		if (proc != null) {
-			try {
-				// Close the input of the Process explicitely.
-				// We will never write to it.
-				proc.getOutputStream().close();
-			} catch (IOException e) {
-			}
-			subMonitor = new SubProgressMonitor(monitor, IProgressMonitor.UNKNOWN);
-			if (launcher.waitAndRead(stdout, stderr, subMonitor) != CommandLauncher.OK) {
-				errMsg = launcher.getErrorMessage();
+				IPath workingDirectory = getWorkingDirectory().append(buildDir);
+	
+				// Get the arguments to be passed to make from build model
+				ArrayList makeArgs = new ArrayList();
+				makeArgs.add(info.getMakeArguments());
+				makeArgs.addAll(Arrays.asList(getMakeTargets(fullBuild)));
+				String[] makeTargets = (String[]) makeArgs.toArray(new String[makeArgs.size()]);
 			
-				isCanceled = monitor.isCanceled();
-				monitor.setCanceled(false);
-				subMonitor = new SubProgressMonitor(monitor, IProgressMonitor.UNKNOWN);
-				subMonitor.subTask("Refresh From Local");
-
-				try {
-					currentProject.refreshLocal(IResource.DEPTH_INFINITE, subMonitor);
-				} catch (CoreException e) {
+				// Get a launcher for the make command
+				String errMsg = null;
+				CommandLauncher launcher = new CommandLauncher();
+				launcher.showCommand(true);
+	
+				// Set the environmennt, some scripts may need the CWD var to be set.
+				Properties props = launcher.getEnvironment();
+				props.put("CWD", workingDirectory.toOSString());	//$NON-NLS-1$
+				props.put("PWD", workingDirectory.toOSString());	//$NON-NLS-1$
+				String[] env = null;
+				ArrayList envList = new ArrayList();
+				Enumeration names = props.propertyNames();
+				if (names != null) {
+					while (names.hasMoreElements()) {
+						String key = (String) names.nextElement();
+						envList.add(key + "=" + props.getProperty(key)); //$NON-NLS-1$
+					}
+					env = (String[]) envList.toArray(new String[envList.size()]);
 				}
-
-				subMonitor = new SubProgressMonitor(monitor, IProgressMonitor.UNKNOWN);
-				subMonitor.subTask("Parsing");
-			} else {
-					errMsg = launcher.getErrorMessage();
-			}
 			
+				// Hook up an error parser
+				ErrorParserManager epm = new ErrorParserManager(this);
+				epm.setOutputStream(consoleOutStream);
+				OutputStream stdout = epm.getOutputStream();
+				OutputStream stderr = epm.getOutputStream();
 			
-			// Report either the success or failure of our mission
-			StringBuffer buf = new StringBuffer();
-			if (errMsg != null && errMsg.length() > 0) {
-				String errorDesc = ManagedBuilderCorePlugin.getResourceString(BUILD_ERROR);
-				buf.append(errorDesc);
-				buf.append(System.getProperty("line.separator", "\n"));
-				buf.append("(").append(errMsg).append(")");
-			}
-			else {
-				// Report a successful build
-				String successMsg = ManagedBuilderCorePlugin.getFormattedString(BUILD_FINISHED, currentProject.getName());
-				buf.append(successMsg);
-				buf.append(System.getProperty("line.separator", "\n"));
-			}
-			// Write your message on the pavement
-			try {
+				// Launch make
+				Process proc = launcher.execute(makeCommand, makeTargets, env, workingDirectory);
+				if (proc != null) {
+					try {
+						// Close the input of the process since we will never write to it
+						proc.getOutputStream().close();
+					} catch (IOException e) {
+					}
+				
+					if (launcher.waitAndRead(stdout, stderr, new SubProgressMonitor(monitor, IProgressMonitor.UNKNOWN)) != CommandLauncher.OK) { 
+						errMsg = launcher.getErrorMessage();
+					}
+				
+					// Force a resync of the project without allowing the user to cancel.
+					// This is probably unkind, but short of this there is no way to insure
+					// the UI is up-to-date with the build results
+					monitor.subTask(ManagedBuilderCorePlugin.getResourceString(REFRESH));
+					try {
+						currentProject.refreshLocal(IResource.DEPTH_INFINITE, null);
+					} catch (CoreException e) {
+						monitor.subTask(ManagedBuilderCorePlugin.getResourceString(REFRESH_ERROR));
+					}
+				} else {
+					errMsg = launcher.getErrorMessage();
+				}
+				
+				// Report either the success or failure of our mission
+				StringBuffer buf = new StringBuffer();
+				if (errMsg != null && errMsg.length() > 0) {
+					String errorDesc = ManagedBuilderCorePlugin.getResourceString(BUILD_ERROR);
+					buf.append(errorDesc);
+					buf.append(System.getProperty("line.separator", "\n"));
+					buf.append("(").append(errMsg).append(")");
+				} else {
+					// Report a successful build
+					String successMsg = ManagedBuilderCorePlugin.getFormattedString(BUILD_FINISHED, currentProject.getName());
+					buf.append(successMsg);
+					buf.append(System.getProperty("line.separator", "\n"));
+				}
+
+				// Write message on the console
 				consoleOutStream.write(buf.toString().getBytes());
 				consoleOutStream.flush();
 				stdout.close();
 				stderr.close();				
-			} catch (IOException e) {
+
+				monitor.subTask(ManagedBuilderCorePlugin.getResourceString(MARKERS)); //$NON-NLS-1$
+				epm.reportProblems();
 			}
+		} catch (Exception e) {
+			CCorePlugin.log(e);
+			forgetLastBuiltState();
+		} finally {
+			monitor.done();
+		}
+	}
 
-			epm.reportProblems();
+	private void removeAllMarkers(IProject project) throws CoreException {
+		IWorkspace workspace = project.getWorkspace();
 
-			subMonitor.done();
-			monitor.setCanceled(isCanceled);
+		// remove all markers
+		IMarker[] markers = project.findMarkers(ICModelMarker.C_MODEL_PROBLEM_MARKER, true, IResource.DEPTH_INFINITE);
+		if (markers != null) {
+			workspace.deleteMarkers(markers);
 		}
-		monitor.done();
 	}
 
 }
Index: src/org/eclipse/cdt/managedbuilder/internal/core/MakefileGenerator.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/MakefileGenerator.java,v
retrieving revision 1.5
diff -u -r1.5 MakefileGenerator.java
--- src/org/eclipse/cdt/managedbuilder/internal/core/MakefileGenerator.java	26 Sep 2003 19:54:24 -0000	1.5
+++ src/org/eclipse/cdt/managedbuilder/internal/core/MakefileGenerator.java	29 Sep 2003 00:02:47 -0000
@@ -51,9 +51,9 @@
 
 public class MakefileGenerator {
 	// String constants for messages
-	private static final String MESSAGE = "MakeBuilder.message";	//$NON-NLS-1$
+	private static final String MESSAGE = "ManagedMakeBuilder.message";	//$NON-NLS-1$
 	private static final String BUILD_ERROR = MESSAGE + ".error";	//$NON-NLS-1$
-	private static final String COMMENT = "MakeBuilder.comment";	//$NON-NLS-1$
+	private static final String COMMENT = "ManagedMakeBuilder.comment";	//$NON-NLS-1$
 	private static final String MOD_LIST = COMMENT + ".module.list";	//$NON-NLS-1$	
 	private static final String SRC_LISTS = COMMENT + ".source.list";	//$NON-NLS-1$	
 	private static final String MOD_RULES = COMMENT + ".build.rule";	//$NON-NLS-1$	
@@ -462,7 +462,12 @@
 		}
 
 		// Write out the all target first in case someone just runs make
-		buffer.append("all: deps" + WHITESPACE + outputPrefix + target + NEWLINE);
+		// 	all: targ_<target_name> [deps] 
+		String defaultTarget = "all:";
+		if (deps.length > 0) {
+			defaultTarget += WHITESPACE + "deps";
+		}
+		buffer.append(defaultTarget + WHITESPACE + outputPrefix + target + NEWLINE);
 		buffer.append(NEWLINE);
 
 		/*
@@ -472,30 +477,32 @@
 		 * 		<cd <Proj_Dep_1/build_dir>; $(MAKE) [clean all | all]> 
 		 */
 		List managedProjectOutputs = new ArrayList();
-		buffer.append("deps:" + NEWLINE);
-		if (deps != null) {
-			for (int i = 0; i < deps.length; i++) {
-				IProject dep = deps[i];
-				String buildDir = dep.getLocation().toString();
-				if (ManagedBuildManager.manages(dep)) {
-					// Add the current configuration to the makefile path
-					IManagedBuildInfo depInfo = ManagedBuildManager.getBuildInfo(dep);
-					buildDir += SEPARATOR + depInfo.getConfigurationName();
+		if (deps.length > 0) { 
+			buffer.append("deps:" + NEWLINE);
+			if (deps != null) {
+				for (int i = 0; i < deps.length; i++) {
+					IProject dep = deps[i];
+					String buildDir = dep.getLocation().toString();
+					if (ManagedBuildManager.manages(dep)) {
+						// Add the current configuration to the makefile path
+						IManagedBuildInfo depInfo = ManagedBuildManager.getBuildInfo(dep);
+						buildDir += SEPARATOR + depInfo.getConfigurationName();
 					
-					// Extract the build artifact to add to the dependency list
-					String depTarget = depInfo.getBuildArtifactName();
-					String depExt = (new Path(depTarget)).getFileExtension();
-					String depPrefix = depInfo.getOutputPrefix(depExt);
-					managedProjectOutputs.add(buildDir + SEPARATOR + depPrefix + depTarget);
+						// Extract the build artifact to add to the dependency list
+						String depTarget = depInfo.getBuildArtifactName();
+						String depExt = (new Path(depTarget)).getFileExtension();
+						String depPrefix = depInfo.getOutputPrefix(depExt);
+						managedProjectOutputs.add(buildDir + SEPARATOR + depPrefix + depTarget);
+					}
+					buffer.append(TAB + "cd" + WHITESPACE + buildDir + SEMI_COLON + WHITESPACE + "$(MAKE) " + targets + NEWLINE);
 				}
-				buffer.append(TAB + "cd" + WHITESPACE + buildDir + SEMI_COLON + WHITESPACE + "$(MAKE) " + targets + NEWLINE);
 			}
+			buffer.append(NEWLINE);
 		}
-		buffer.append(NEWLINE);
 
 		/*
 		 * Write out the target rule as:
-		 * <prefix><target>.<extension>: $(OBJS) [<dep_proj_1_output> ... <dep_proj_n_output>]
+		 * targ_<prefix><target>.<extension>: $(OBJS) [<dep_proj_1_output> ... <dep_proj_n_output>]
 		 * 		$(BUILD_TOOL) $(FLAGS) $(OUTPUT_FLAG) $@ $(OBJS) $(USER_OBJS) $(LIB_DEPS)
 		 */
 		//
Index: src/org/eclipse/cdt/managedbuilder/internal/core/ManagedBuildInfo.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ManagedBuildInfo.java,v
retrieving revision 1.4
diff -u -r1.4 ManagedBuildInfo.java
--- src/org/eclipse/cdt/managedbuilder/internal/core/ManagedBuildInfo.java	26 Sep 2003 19:54:24 -0000	1.4
+++ src/org/eclipse/cdt/managedbuilder/internal/core/ManagedBuildInfo.java	29 Sep 2003 00:02:47 -0000
@@ -148,6 +148,7 @@
 			IConfiguration configuration = configs[i];
 			configNames.add(configuration.getName());
 		}
+		configNames.trimToSize();
 		return (String[])configNames.toArray(new String[configNames.size()]);
 	}
 
@@ -350,11 +351,29 @@
 	/* (non-Javadoc)
 	 * @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#getMakeArguments()
 	 */
-	public String[] getMakeArguments() {
-		// TODO Stop hard-coding this
-		String[] args = {""}; 
-
-		return args;
+	public String getMakeArguments() {
+		String arguments = new String();		
+		
+		// The make command may or may not have any flags
+		ITarget target = getDefaultTarget();
+		String command = target.getMakeCommand();
+		
+		// If it does, the flags will be everything between the '-' and the next space
+		int indexOfArgs = command.indexOf('-');
+		if (indexOfArgs != - 1) {
+			try {
+				String argsAndTargs = command.substring(indexOfArgs);
+				int indexOfTargs = argsAndTargs.indexOf(' ');
+				arguments = (indexOfTargs != -1) ? 
+							argsAndTargs.substring(0, indexOfTargs) : 
+							argsAndTargs;
+				// Make sure the arg list does not contain f or C
+				
+			} catch (IndexOutOfBoundsException e) {
+			}
+		}
+		
+		return arguments.trim();
 	}
 
 	/* (non-Javadoc)
@@ -364,7 +383,15 @@
 		String command = new String();
 		ITarget target = getDefaultTarget();
 		command = target.getMakeCommand();
-		return command;
+		
+		// There may actually be arguments, so just get everything up to the first '-'
+		int indexOfArgs = command.indexOf('-');
+		if (indexOfArgs != -1) {
+			// Return ecverything up to the first argument as the command
+			return command.substring(0, indexOfArgs).trim();
+		} else {
+			return command.trim();
+		}
 	}
 
 	/* (non-Javadoc)
@@ -427,6 +454,7 @@
 	public IResource getOwner() {
 		return owner;
 	}
+	
 	/* (non-Javadoc)
 	 * @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#getTarget(org.eclipse.cdt.core.build.managed.IConfiguration)
 	 */
Index: src/org/eclipse/cdt/managedbuilder/internal/core/Option.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Option.java,v
retrieving revision 1.2
diff -u -r1.2 Option.java
--- src/org/eclipse/cdt/managedbuilder/internal/core/Option.java	26 Sep 2003 19:54:24 -0000	1.2
+++ src/org/eclipse/cdt/managedbuilder/internal/core/Option.java	29 Sep 2003 00:02:47 -0000
@@ -180,10 +180,13 @@
 		if (valueType != PREPROCESSOR_SYMBOLS) {
 			throw new BuildException("bad value type");
 		}
-		List v = (List)value;
-		return v != null
-			? (String[])v.toArray(new String[v.size()])
-			: EMPTY_STRING_ARRAY;
+		ArrayList v = (ArrayList)value;
+		if (v == null) {
+			return EMPTY_STRING_ARRAY;
+		} else {
+			v.trimToSize();
+			return (String[]) v.toArray(new String[v.size()]);
+		}
 	}
 
 	/* (non-Javadoc)
@@ -201,10 +204,13 @@
 		if (valueType != INCLUDE_PATH) {
 			throw new BuildException("bad value type");
 		}
-		List v = (List)value;
-		return v != null
-			? (String[])v.toArray(new String[v.size()])
-			: EMPTY_STRING_ARRAY;
+		ArrayList v = (ArrayList)value;
+		if (v == null) {
+			return EMPTY_STRING_ARRAY;
+		} else {
+			v.trimToSize();
+			return (String[]) v.toArray(new String[v.size()]);
+		}
 	}
 
 	/* (non-Javadoc)
@@ -214,10 +220,13 @@
 		if (valueType != LIBRARIES) {
 			throw new BuildException("bad value type");
 		}
-		List v = (List)value;
-		return v != null
-			? (String[])v.toArray(new String[v.size()])
-			: EMPTY_STRING_ARRAY;
+		ArrayList v = (ArrayList)value;
+		if (v == null) {
+			return EMPTY_STRING_ARRAY;
+		} else {
+			v.trimToSize();
+			return (String[]) v.toArray(new String[v.size()]);
+		}
 	}
 
 	/* (non-Javadoc)
@@ -237,10 +246,13 @@
 		if (valueType != STRING_LIST) {
 			throw new BuildException("bad value type");
 		}
-		List v = (List)value;
-		return v != null
-			? (String[])v.toArray(new String[v.size()])
-			: EMPTY_STRING_ARRAY;
+		ArrayList v = (ArrayList)value;
+		if (v == null) {
+			return EMPTY_STRING_ARRAY;
+		} else {
+			v.trimToSize();
+			return (String[]) v.toArray(new String[v.size()]);
+		}
 	}
 
 	/* (non-Javadoc)
@@ -268,10 +280,13 @@
 			throw new BuildException("bad value type");
 		}
 		// This is the right puppy, so return its list value
-		List v = (List)value;
-		return v != null
-			? (String[])v.toArray(new String[v.size()])
-			: EMPTY_STRING_ARRAY;
+		ArrayList v = (ArrayList)value;
+		if (v == null) {
+			return EMPTY_STRING_ARRAY;
+		} else {
+			v.trimToSize();
+			return (String[]) v.toArray(new String[v.size()]);
+		}
 	}
 
 	/* (non-Javadoc)
Index: src/org/eclipse/cdt/managedbuilder/internal/core/PluginResources.properties
===================================================================
RCS file: /home/tools/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/PluginResources.properties,v
retrieving revision 1.1
diff -u -r1.1 PluginResources.properties
--- src/org/eclipse/cdt/managedbuilder/internal/core/PluginResources.properties	15 Sep 2003 20:44:24 -0000	1.1
+++ src/org/eclipse/cdt/managedbuilder/internal/core/PluginResources.properties	29 Sep 2003 00:02:47 -0000
@@ -10,15 +10,18 @@
 ##########################################################################
 
 # Generated makefile builder messages
-MakeBuilder.message.starting = Starting the build for project {0}
-MakeBuilder.message.rebuild = Regenerating makefiles for project {0}
-MakeBuilder.message.incremental = Updating makefiles for project {0}
-MakeBuilder.message.make = Calling {0} for project {1}
-MakeBuilder.message.error = Build error
-MakeBuilder.message.finished = Build complete for project {0}
-MakeBuilder.comment.module.list = # Every subdirectory with source files must be described here
-MakeBuilder.comment.source.list = # Each subdirectory must contribute its source files here
-MakeBuilder.comment.build.rule = # Each subdirectory must supply rules for building sources it contributes
-MakeBuilder.comment.module.make.includes = # Include the makefiles for each source subdirectory
-MakeBuilder.comment.module.dep.includes = # Include automatically-generated dependency list:
-MakeBuilder.comment.autodeps = # Automatically-generated dependency list:
+ManagedMakeBuilder.message.starting = Starting the build for project {0}
+ManagedMakeBuilder.message.rebuild = Regenerating makefiles for project {0}
+ManagedMakeBuilder.message.incremental = Updating makefiles for project {0}
+ManagedMakeBuilder.message.updating = Updating project files...
+ManagedMakeBuilder.message.make = Calling {0} for project {1}
+ManagedMakeBuilder.message.creating.markers = Generating markers...
+ManagedMakeBuilder.message.error = Build error
+ManagedMakeBuilder.message.error.refresh = Error refreshing project. 
+ManagedMakeBuilder.message.finished = Build complete for project {0}
+ManagedMakeBuilder.comment.module.list = # Every subdirectory with source files must be described here
+ManagedMakeBuilder.comment.source.list = # Each subdirectory must contribute its source files here
+ManagedMakeBuilder.comment.build.rule = # Each subdirectory must supply rules for building sources it contributes
+ManagedMakeBuilder.comment.module.make.includes = # Include the makefiles for each source subdirectory
+ManagedMakeBuilder.comment.module.dep.includes = # Include automatically-generated dependency list:
+ManagedMakeBuilder.comment.autodeps = # Automatically-generated dependency list:
Index: src/org/eclipse/cdt/managedbuilder/internal/core/Tool.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Tool.java,v
retrieving revision 1.1
diff -u -r1.1 Tool.java
--- src/org/eclipse/cdt/managedbuilder/internal/core/Tool.java	15 Sep 2003 20:44:24 -0000	1.1
+++ src/org/eclipse/cdt/managedbuilder/internal/core/Tool.java	29 Sep 2003 00:02:47 -0000
@@ -196,14 +196,14 @@
 	 * @see org.eclipse.cdt.core.build.managed.ITool#getOutputFlag()
 	 */
 	public String getOutputFlag() {
-		return outputFlag == null ? new String() : outputFlag;
+		return outputFlag == null ? new String() : outputFlag.trim();
 	}
 
 	/* (non-Javadoc)
 	 * @see org.eclipse.cdt.core.build.managed.ITool#getOutputPrefix()
 	 */
 	public String getOutputPrefix() {
-		return outputPrefix == null ? new String() : outputPrefix;
+		return outputPrefix == null ? new String() : outputPrefix.trim();
 	}
 
 	/* (non-Javadoc)
@@ -228,7 +228,7 @@
 	 * @see org.eclipse.cdt.core.build.managed.ITool#getToolCommand()
 	 */
 	public String getToolCommand() {
-		return command;
+		return command.trim();
 	}
 
 	/* (non-Javadoc)
@@ -294,7 +294,7 @@
 
 		}
 
-		return buf.toString();
+		return buf.toString().trim();
 	}
 
 	/* (non-Javadoc)
@@ -317,7 +317,7 @@
 		}
 
 		IOption[] allOptions = tool.getOptions();
-		List myOptions = new ArrayList();
+		ArrayList myOptions = new ArrayList();
 			
 		for (int i = 0; i < allOptions.length; ++i) {
 			IOption option = allOptions[i];
@@ -325,6 +325,7 @@
 				myOptions.add(option);
 		}
 
+		myOptions.trimToSize();
 		return (IOption[])myOptions.toArray(new IOption[myOptions.size()]);
 	}
 

Back to the top