diff --git a/build/org.eclipse.cdt.autotools-feature/feature.xml b/build/org.eclipse.cdt.autotools-feature/feature.xml
index cb3d48ad844..4cf9823fcc7 100644
--- a/build/org.eclipse.cdt.autotools-feature/feature.xml
+++ b/build/org.eclipse.cdt.autotools-feature/feature.xml
@@ -63,5 +63,12 @@
download-size="0"
install-size="0"
version="0.0.0"/>
+
+
diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/MakeBuilder.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/MakeBuilder.java
index 79a7880705b..87465d3896a 100644
--- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/MakeBuilder.java
+++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/MakeBuilder.java
@@ -15,30 +15,24 @@
package org.eclipse.cdt.make.core;
import java.io.IOException;
-import java.io.OutputStream;
import java.net.URI;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Set;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.CommandLauncher;
import org.eclipse.cdt.core.ErrorParserManager;
import org.eclipse.cdt.core.ICommandLauncher;
-import org.eclipse.cdt.core.model.ICModelMarker;
+import org.eclipse.cdt.core.IConsoleParser;
import org.eclipse.cdt.core.resources.ACBuilder;
import org.eclipse.cdt.core.resources.IConsole;
-import org.eclipse.cdt.core.resources.RefreshScopeManager;
-import org.eclipse.cdt.internal.core.ConsoleOutputSniffer;
+import org.eclipse.cdt.internal.core.BuildRunnerHelper;
+import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoConsoleParser;
import org.eclipse.cdt.make.internal.core.MakeMessages;
-import org.eclipse.cdt.make.internal.core.StreamMonitor;
import org.eclipse.cdt.make.internal.core.scannerconfig.ScannerInfoConsoleParserFactory;
import org.eclipse.cdt.utils.CommandLineUtil;
-import org.eclipse.cdt.utils.EFSExtensionManager;
-import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IResourceDelta;
@@ -53,8 +47,6 @@ import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.OperationCanceledException;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.QualifiedName;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.SubProgressMonitor;
import org.eclipse.core.runtime.jobs.ISchedulingRule;
@@ -65,8 +57,10 @@ import org.eclipse.core.runtime.jobs.Job;
* @noinstantiate This class is not intended to be instantiated by clients.
*/
public class MakeBuilder extends ACBuilder {
-
public final static String BUILDER_ID = MakeCorePlugin.getUniqueIdentifier() + ".makeBuilder"; //$NON-NLS-1$
+ private static final int MONITOR_SCALE = 100;
+
+ private BuildRunnerHelper buildRunnerHelper = null;
public MakeBuilder() {
}
@@ -146,132 +140,112 @@ public class MakeBuilder extends ACBuilder {
}
}
+ /**
+ * Run build command.
+ *
+ * @param kind - kind of build, constant defined by {@link IncrementalProjectBuilder}
+ * @param info - builder info
+ * @param monitor - progress monitor in the initial state where {@link IProgressMonitor#beginTask(String, int)}
+ * has not been called yet.
+ * @return {@code true} if the build purpose is to clean, {@code false} otherwise.
+ */
protected boolean invokeMake(int kind, IMakeBuilderInfo info, IProgressMonitor monitor) {
boolean isClean = false;
- IProject currProject = getProject();
-
- if (monitor == null) {
- monitor = new NullProgressMonitor();
- }
- monitor.beginTask(MakeMessages.getString("MakeBuilder.Invoking_Make_Builder") + currProject.getName(), 100); //$NON-NLS-1$
+ IProject project = getProject();
+ buildRunnerHelper = new BuildRunnerHelper(project);
try {
+ if (monitor == null) {
+ monitor = new NullProgressMonitor();
+ }
+ monitor.beginTask(MakeMessages.getString("MakeBuilder.Invoking_Make_Builder") + project.getName(), 3 * MONITOR_SCALE); //$NON-NLS-1$
+
IPath buildCommand = info.getBuildCommand();
if (buildCommand != null) {
IConsole console = CCorePlugin.getDefault().getConsole();
- console.start(currProject);
+ console.start(project);
- OutputStream cos = console.getOutputStream();
-
- // remove all markers for this project
- removeAllMarkers(currProject);
-
- URI workingDirectoryURI = MakeBuilderUtil.getBuildDirectoryURI(currProject, info);
- final String pathFromURI = EFSExtensionManager.getDefault().getPathFromURI(workingDirectoryURI);
- if(pathFromURI == null) {
- throw new CoreException(new Status(IStatus.ERROR, MakeCorePlugin.PLUGIN_ID, MakeMessages.getString("MakeBuilder.ErrorWorkingDirectory"), null)); //$NON-NLS-1$
- }
-
- IPath workingDirectory = new Path(pathFromURI);
+ // Prepare launch parameters for BuildRunnerHelper
+ ICommandLauncher launcher = new CommandLauncher();
String[] targets = getTargets(kind, info);
if (targets.length != 0 && targets[targets.length - 1].equals(info.getCleanBuildTarget()))
isClean = true;
- String errMsg = null;
- ICommandLauncher launcher = new CommandLauncher();
- launcher.setProject(currProject);
- // Print the command for visual interaction.
- launcher.showCommand(true);
+ String[] args = getCommandArguments(info, targets);
- // Set the environment
- HashMap envMap = new HashMap();
- if (info.appendEnvironment()) {
- @SuppressWarnings({"unchecked", "rawtypes"})
- Map env = (Map)launcher.getEnvironment();
- envMap.putAll(env);
- }
- // Add variables from build info
- envMap.putAll(info.getExpandedEnvironment());
- List strings= new ArrayList(envMap.size());
- Set> entrySet = envMap.entrySet();
- for (Entry entry : entrySet) {
- StringBuffer buffer= new StringBuffer(entry.getKey());
- buffer.append('=').append(entry.getValue());
- strings.add(buffer.toString());
- }
- String[] env = strings.toArray(new String[strings.size()]);
- String[] buildArguments = targets;
- if (info.isDefaultBuildCmd()) {
- if (!info.isStopOnError()) {
- buildArguments = new String[targets.length + 1];
- buildArguments[0] = "-k"; //$NON-NLS-1$
- System.arraycopy(targets, 0, buildArguments, 1, targets.length);
- }
- } else {
- String args = info.getBuildArguments();
- if (args != null && !args.equals("")) { //$NON-NLS-1$
- String[] newArgs = makeArray(args);
- buildArguments = new String[targets.length + newArgs.length];
- System.arraycopy(newArgs, 0, buildArguments, 0, newArgs.length);
- System.arraycopy(targets, 0, buildArguments, newArgs.length, targets.length);
- }
- }
-// MakeRecon recon = new MakeRecon(buildCommand, buildArguments, env, workingDirectory, makeMonitor, cos);
-// recon.invokeMakeRecon();
-// cos = recon;
- QualifiedName qName = new QualifiedName(MakeCorePlugin.getUniqueIdentifier(), "progressMonitor"); //$NON-NLS-1$
- Integer last = (Integer)getProject().getSessionProperty(qName);
- if (last == null) {
- last = new Integer(100);
- }
- ErrorParserManager epm = new ErrorParserManager(getProject(), workingDirectoryURI, this, info.getErrorParsers());
- epm.setOutputStream(cos);
- StreamMonitor streamMon = new StreamMonitor(new SubProgressMonitor(monitor, 100), epm, last.intValue());
- OutputStream stdout = streamMon;
- OutputStream stderr = streamMon;
- // Sniff console output for scanner info
- ConsoleOutputSniffer sniffer = ScannerInfoConsoleParserFactory.getMakeBuilderOutputSniffer(
- stdout, stderr, getProject(), workingDirectory, null, this, null);
- OutputStream consoleOut = (sniffer == null ? stdout : sniffer.getOutputStream());
- OutputStream consoleErr = (sniffer == null ? stderr : sniffer.getErrorStream());
- Process p = launcher.execute(buildCommand, buildArguments, env, workingDirectory, monitor);
- if (p != null) {
- try {
- // Close the input of the Process explicitly.
- // We will never write to it.
- p.getOutputStream().close();
- } catch (IOException e) {
- }
- // Before launching give visual cues via the monitor
- monitor.subTask(MakeMessages.getString("MakeBuilder.Invoking_Command") + launcher.getCommandLine()); //$NON-NLS-1$
- if (launcher.waitAndRead(consoleOut, consoleErr, new SubProgressMonitor(monitor, 0))
- != ICommandLauncher.OK)
- errMsg = launcher.getErrorMessage();
- monitor.subTask(MakeMessages.getString("MakeBuilder.Updating_project")); //$NON-NLS-1$
- refreshProject(currProject);
- } else {
- errMsg = launcher.getErrorMessage();
- }
- getProject().setSessionProperty(qName, !monitor.isCanceled() && !isClean ? new Integer(streamMon.getWorkDone()) : null);
+ URI workingDirectoryURI = MakeBuilderUtil.getBuildDirectoryURI(project, info);
- if (errMsg != null) {
- consoleErr.write((errMsg + '\n').getBytes());
+ HashMap envMap = getEnvironment(launcher, info);
+ String[] envp = BuildRunnerHelper.envMapToEnvp(envMap);
+
+ String[] errorParsers = info.getErrorParsers();
+ ErrorParserManager epm = new ErrorParserManager(getProject(), workingDirectoryURI, this, errorParsers);
+
+ List parsers = new ArrayList();
+ IScannerInfoConsoleParser parserSD = ScannerInfoConsoleParserFactory.getScannerInfoConsoleParser(project, workingDirectoryURI, this);
+ parsers.add(parserSD);
+
+ buildRunnerHelper.setLaunchParameters(launcher, buildCommand, args, workingDirectoryURI, envp);
+ buildRunnerHelper.prepareStreams(epm, parsers, console, new SubProgressMonitor(monitor, 1 * MONITOR_SCALE, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK));
+
+ buildRunnerHelper.removeOldMarkers(project, new SubProgressMonitor(monitor, 1 * MONITOR_SCALE, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK));
+
+ buildRunnerHelper.greeting(kind);
+ int state = buildRunnerHelper.build(new SubProgressMonitor(monitor, 1 * MONITOR_SCALE, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK));
+ buildRunnerHelper.close();
+ buildRunnerHelper.goodbye();
+
+ if (state != ICommandLauncher.ILLEGAL_COMMAND) {
+ refreshProject(project);
}
-
- stdout.close();
- stderr.close();
-
- consoleOut.close();
- consoleErr.close();
- cos.close();
+ } else {
+ String msg = MakeMessages.getFormattedString("MakeBuilder.message.undefined.build.command", project.getName()); //$NON-NLS-1$
+ throw new CoreException(new Status(IStatus.ERROR, MakeCorePlugin.PLUGIN_ID, msg, new Exception()));
}
} catch (Exception e) {
MakeCorePlugin.log(e);
} finally {
+ try {
+ buildRunnerHelper.close();
+ } catch (IOException e) {
+ MakeCorePlugin.log(e);
+ }
monitor.done();
}
- return (isClean);
+ return isClean;
+ }
+
+ private HashMap getEnvironment(ICommandLauncher launcher, IMakeBuilderInfo info)
+ throws CoreException {
+ HashMap envMap = new HashMap();
+ if (info.appendEnvironment()) {
+ @SuppressWarnings({"unchecked", "rawtypes"})
+ Map env = (Map)launcher.getEnvironment();
+ envMap.putAll(env);
+ }
+ envMap.putAll(info.getExpandedEnvironment());
+ return envMap;
+ }
+
+ private String[] getCommandArguments(IMakeBuilderInfo info, String[] targets) {
+ String[] args = targets;
+ if (info.isDefaultBuildCmd()) {
+ if (!info.isStopOnError()) {
+ args = new String[targets.length + 1];
+ args[0] = "-k"; //$NON-NLS-1$
+ System.arraycopy(targets, 0, args, 1, targets.length);
+ }
+ } else {
+ String argsStr = info.getBuildArguments();
+ if (argsStr != null && !argsStr.equals("")) { //$NON-NLS-1$
+ String[] newArgs = makeArray(argsStr);
+ args = new String[targets.length + newArgs.length];
+ System.arraycopy(newArgs, 0, args, 0, newArgs.length);
+ System.arraycopy(targets, 0, args, newArgs.length, targets.length);
+ }
+ }
+ return args;
}
/**
@@ -281,18 +255,8 @@ public class MakeBuilder extends ACBuilder {
* @since 6.0
*/
protected void refreshProject(IProject project) {
- try {
- // Do not allow the cancel of the refresh, since the builder is external
- // to Eclipse, files may have been created/modified and we will be out-of-sync.
- // The caveat is for huge projects, it may take sometimes at every build.
- // project.refreshLocal(IResource.DEPTH_INFINITE, null);
-
- // use the refresh scope manager to refresh
- RefreshScopeManager refreshManager = RefreshScopeManager.getInstance();
- IWorkspaceRunnable runnable = refreshManager.getRefreshRunnable(project);
- ResourcesPlugin.getWorkspace().run(runnable, null, IWorkspace.AVOID_UPDATE, null);
- } catch (CoreException e) {
- MakeCorePlugin.log(e);
+ if (buildRunnerHelper != null) {
+ buildRunnerHelper.refreshProject(null);
}
}
@@ -339,14 +303,4 @@ public class MakeBuilder extends ACBuilder {
private String[] makeArray(String string) {
return CommandLineUtil.argumentsToArray(string);
}
-
- private void removeAllMarkers(IProject currProject) throws CoreException {
- IWorkspace workspace = currProject.getWorkspace();
-
- // remove all markers
- IMarker[] markers = currProject.findMarkers(ICModelMarker.C_MODEL_PROBLEM_MARKER, true, IResource.DEPTH_INFINITE);
- if (markers != null) {
- workspace.deleteMarkers(markers);
- }
- }
}
diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/MakeMessages.properties b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/MakeMessages.properties
index 7509f90aa47..5673ce0ea8e 100644
--- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/MakeMessages.properties
+++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/MakeMessages.properties
@@ -14,10 +14,8 @@ AbstractGCCBOPConsoleParser_EnteringDirectory=Entering directory
AbstractGCCBOPConsoleParser_LeavingDirectory=Leaving directory
MakeBuilder.Invoking_Make_Builder=Invoking Make Builder...
-MakeBuilder.Invoking_Command=Invoking Command:
-MakeBuilder.Updating_project=Updating project...
-MakeBuilder.Creating_Markers=Generating markers...
-MakeBuilder.ErrorWorkingDirectory=Error determining working directory.
+MakeBuilder.message.error.build = Internal error building project {0}
+MakeBuilder.message.undefined.build.command = Build command is null for project {0}
BuildInfoFactory.Missing_Builder=Missing Builder:
@@ -37,12 +35,7 @@ ScannerConfigInfoFactory.Missing_Builder=Missing Builder:
ExternalScannerInfoProvider.Console_Name=CDT Built-in Specs Console, {0}
ExternalScannerInfoProvider.Reading_Specs=Reading specs ...
-ExternalScannerInfoProvider.Invoking_Command=Invoking Command:
-ExternalScannerInfoProvider.Parsing_Output=Parsing output ...
-ExternalScannerInfoProvider.Creating_Markers=Generating markers ...
-ExternalScannerInfoProvider.Provider_Error=Warning: Error launching external scanner info generator ({0})
-ExternalScannerInfoProvider.Working_Directory=Working directory: {0}
-ExternalScannerInfoProvider.Program_Not_In_Path=Program ''{0}'' is not found in $PATH
+ExternalScannerInfoProvider.Greeting=Scanner Discovery of compiler built-in settings for project {0}
ScannerInfoCollector.Processing=Processing discovered scanner configuration ...
ScannerInfoCollector.Updating=Updating Scanner Configuration for project
diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/StreamMonitor.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/StreamMonitor.java
index ef7363695bb..dde487ec6b9 100644
--- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/StreamMonitor.java
+++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/StreamMonitor.java
@@ -10,97 +10,18 @@
*******************************************************************************/
package org.eclipse.cdt.make.internal.core;
-import java.io.IOException;
import java.io.OutputStream;
import org.eclipse.core.runtime.IProgressMonitor;
-public class StreamMonitor extends OutputStream {
-
- IProgressMonitor monitor;
- OutputStream console;
- public final int fTotalWork;
- private int halfWay;
- private int currentIncrement = 2;
- private int nextProgress = currentIncrement;
- private int worked = 0;
-
+/**
+ *
+ * @deprecated as of CDT 8.1. Use org.eclipse.cdt.internal.core.StreamMonitor
+ *
+ */
+@Deprecated
+public class StreamMonitor extends org.eclipse.cdt.internal.core.StreamMonitor {
public StreamMonitor(IProgressMonitor mon, OutputStream cos, int totalWork) {
- monitor = mon;
- console = cos;
- fTotalWork = totalWork;
- halfWay = fTotalWork / 2;
- monitor.beginTask("", fTotalWork); //$NON-NLS-1$
- }
-
- private void progressUpdate() {
- if (--nextProgress <= 0) {
- //we have exhausted the current increment, so report progress
- if (fTotalWork > worked) {
- monitor.worked(1);
- }
- worked++;
- if (worked >= halfWay) {
- //we have passed the current halfway point, so double the
- //increment and reset the halfway point.
- currentIncrement *= 2;
- halfWay += (fTotalWork - halfWay) / 2;
- }
- //reset the progress counter to another full increment
- nextProgress = currentIncrement;
- }
- }
- /**
- * @see java.io.OutputStream#close()
- */
- @Override
- public void close() throws IOException {
- if (console != null) {
- console.close();
- }
- monitor.done();
- }
-
- /**
- * @see java.io.OutputStream#flush()
- */
- @Override
- public void flush() throws IOException {
- if (console != null) {
- console.flush();
- }
- }
-
- /**
- * @see java.io.OutputStream#write(int)
- */
- @Override
- public synchronized void write(int b) throws IOException {
- if (console != null) {
- console.write(b);
- }
- progressUpdate();
- }
-
- /**
- * @see java.io.OutputStream#write(byte[], int, int)
- */
- @Override
- public synchronized void write(byte[] b, int off, int len) throws IOException {
- if (b == null) {
- throw new NullPointerException();
- } else if (off != 0 || (len < 0) || (len > b.length)) {
- throw new IndexOutOfBoundsException();
- } else if (len == 0) {
- return;
- }
- if (console != null) {
- console.write(b, off, len);
- }
- progressUpdate();
- }
-
- public int getWorkDone() {
- return worked;
+ super(mon, cos, totalWork);
}
}
diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/ScannerInfoConsoleParserFactory.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/ScannerInfoConsoleParserFactory.java
index 0bd3ebaf6b6..f1f2b9ddd4e 100644
--- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/ScannerInfoConsoleParserFactory.java
+++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/ScannerInfoConsoleParserFactory.java
@@ -4,7 +4,7 @@
* 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:
* IBM - Initial API and implementation
* Tianchao Li (tianchao.li@gmail.com) - arbitrary build directory (bug #136136)
@@ -12,6 +12,7 @@
package org.eclipse.cdt.make.internal.core.scannerconfig;
import java.io.OutputStream;
+import java.net.URI;
import org.eclipse.cdt.core.IMarkerGenerator;
import org.eclipse.cdt.internal.core.ConsoleOutputSniffer;
@@ -23,15 +24,18 @@ import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector;
import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoConsoleParser;
import org.eclipse.cdt.make.core.scannerconfig.InfoContext;
import org.eclipse.cdt.make.internal.core.scannerconfig2.SCProfileInstance;
+import org.eclipse.cdt.make.internal.core.scannerconfig2.ScannerConfigProfile;
import org.eclipse.cdt.make.internal.core.scannerconfig2.ScannerConfigProfileManager;
+import org.eclipse.cdt.utils.EFSExtensionManager;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
/**
* A factory that creates a ConsoleOutputStreamSniffer,
* ScannerInfoConsoleParser and optionally a ScannerInfoConsoleParserUtility.
- *
+ *
* @author vhirsl
*/
public class ScannerInfoConsoleParserFactory {
@@ -64,14 +68,14 @@ public class ScannerInfoConsoleParserFactory {
IScannerInfoCollector collector,
IMarkerGenerator markerGenerator) {
if (scBuildInfo.isProviderOutputParserEnabled(providerId)) {
- // get the ESIProvider console parser
+ // get the ESIProvider console parser
SCProfileInstance profileInstance = ScannerConfigProfileManager.getInstance().
getSCProfileInstance(currentProject, context, scBuildInfo.getSelectedProfileId());
IScannerInfoConsoleParser clParser = profileInstance.createExternalScannerInfoParser(providerId);
IPath buildDirectory = MakeBuilderUtil.getBuildDirectory(currentProject, MakeBuilder.BUILDER_ID);
clParser.startup(currentProject, buildDirectory, collector, markerGenerator);
// create an output stream sniffer
- return new ConsoleOutputSniffer(outputStream, errorStream, new
+ return new ConsoleOutputSniffer(outputStream, errorStream, new
IScannerInfoConsoleParser[] {clParser});
}
return null;
@@ -86,9 +90,9 @@ public class ScannerInfoConsoleParserFactory {
OutputStream errorStream,
IProject currentProject,
IPath workingDirectory,
- IScannerConfigBuilderInfo2 scBuildInfo,
+ IScannerConfigBuilderInfo2 scBuildInfo,
IMarkerGenerator markerGenerator,
- IScannerInfoCollector collector) {
+ IScannerInfoCollector collector) {
return getMakeBuilderOutputSniffer(outputStream, errorStream, currentProject, new InfoContext(currentProject), workingDirectory, scBuildInfo, markerGenerator, collector);
}
@@ -99,48 +103,90 @@ public class ScannerInfoConsoleParserFactory {
public static ConsoleOutputSniffer getMakeBuilderOutputSniffer(
OutputStream outputStream,
OutputStream errorStream,
- IProject currentProject,
- InfoContext context,
+ IProject project,
+ InfoContext infoContext,
IPath workingDirectory,
- IScannerConfigBuilderInfo2 scBuildInfo,
+ IScannerConfigBuilderInfo2 info2,
IMarkerGenerator markerGenerator,
- IScannerInfoCollector collector) {
+ IScannerInfoCollector collector) {
+
+ IScannerInfoConsoleParser parser = getScannerInfoConsoleParserInternal(project, infoContext, workingDirectory, info2, markerGenerator, collector);
+ if (parser != null) {
+ // create an output stream sniffer
+ return new ConsoleOutputSniffer(outputStream, errorStream, new IScannerInfoConsoleParser[] {parser});
+
+ }
+ return null;
+ }
+
+ private static IScannerInfoConsoleParser getScannerInfoConsoleParserInternal(IProject project, InfoContext infoContext, IPath workingDirectory,
+ IScannerConfigBuilderInfo2 info2, IMarkerGenerator markerGenerator, IScannerInfoCollector collector) {
+
+ IScannerInfoConsoleParser parser = null;
// try {
// get the SC builder settings
/*if (currentProject.hasNature(ScannerConfigNature.NATURE_ID))*/ {
- if (scBuildInfo == null) {
- try {
- IScannerConfigBuilderInfo2Set container = ScannerConfigProfileManager.
- createScannerConfigBuildInfo2Set(currentProject);
- scBuildInfo = container.getInfo(context);
- }
- catch (CoreException e) {
- // builder not installed or disabled
- }
- }
- if (scBuildInfo != null &&
- scBuildInfo.isAutoDiscoveryEnabled() &&
- scBuildInfo.isBuildOutputParserEnabled()) {
- // get the make builder console parser
- SCProfileInstance profileInstance = ScannerConfigProfileManager.getInstance().
- getSCProfileInstance(currentProject, context, scBuildInfo.getSelectedProfileId());
- IScannerInfoConsoleParser clParser = profileInstance.createBuildOutputParser();
- if (collector == null) {
- collector = profileInstance.getScannerInfoCollector();
- }
- if(clParser != null){
- clParser.startup(currentProject, workingDirectory, collector,
- scBuildInfo.isProblemReportingEnabled() ? markerGenerator : null);
- // create an output stream sniffer
- return new ConsoleOutputSniffer(outputStream, errorStream, new
- IScannerInfoConsoleParser[] {clParser});
- }
+ if (info2 == null) {
+ try {
+ IScannerConfigBuilderInfo2Set container = ScannerConfigProfileManager.createScannerConfigBuildInfo2Set(project);
+ info2 = container.getInfo(infoContext);
+ } catch (CoreException e) {
+ // builder not installed or disabled
+ }
+ }
+ if (info2 != null && info2.isAutoDiscoveryEnabled() && info2.isBuildOutputParserEnabled()) {
+ String id = info2.getSelectedProfileId();
+
+ // get the make builder console parser
+ SCProfileInstance profileInstance = ScannerConfigProfileManager.getInstance().getSCProfileInstance(project, infoContext, id);
+ parser = profileInstance.createBuildOutputParser();
+ if (parser != null){
+ if (collector == null) {
+ collector = profileInstance.getScannerInfoCollector();
+ }
+ parser.startup(project, workingDirectory, collector, info2.isProblemReportingEnabled() ? markerGenerator : null);
+ }
}
}
-// }
+// }
// catch (CoreException e) {
// MakeCorePlugin.log(e.getStatus());
// }
- return null;
+
+ return parser;
+ }
+
+ public static IScannerInfoConsoleParser getScannerInfoConsoleParser(IProject project, URI workingDirectoryURI, IMarkerGenerator markerGenerator) {
+ String pathFromURI = EFSExtensionManager.getDefault().getPathFromURI(workingDirectoryURI);
+ if(pathFromURI == null) {
+ // fallback to CWD
+ pathFromURI = System.getProperty("user.dir"); //$NON-NLS-1$
+ }
+ return getScannerInfoConsoleParserInternal(project, new InfoContext(project), new Path(pathFromURI), null, markerGenerator, null);
+ }
+
+ // TODO - perhaps this be unified with the other one?
+ public static IScannerInfoConsoleParser getScannerInfoConsoleParser(IProject project, InfoContext infoContext, IPath workingDirectory,
+ IScannerConfigBuilderInfo2 info2, IMarkerGenerator markerGenerator, IScannerInfoCollector collector) {
+
+ IScannerInfoConsoleParser parser = null;
+ if (info2 != null && info2.isAutoDiscoveryEnabled() && info2.isBuildOutputParserEnabled()) {
+ String id = info2.getSelectedProfileId();
+ ScannerConfigProfile profile = ScannerConfigProfileManager.getInstance().getSCProfileConfiguration(id);
+ if(profile.getBuildOutputProviderElement() != null){
+ // get the make builder console parser
+ SCProfileInstance profileInstance = ScannerConfigProfileManager.getInstance().getSCProfileInstance(project, infoContext, id);
+ parser = profileInstance.createBuildOutputParser();
+ if(parser != null){
+ if (collector == null) {
+ collector = profileInstance.getScannerInfoCollector();
+ }
+ parser.startup(project, workingDirectory, collector, info2.isProblemReportingEnabled() ? markerGenerator : null);
+ }
+
+ }
+ }
+
+ return parser;
}
}
diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/gnu/GCCSpecsConsoleParser.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/gnu/GCCSpecsConsoleParser.java
index bd42c16fd97..30ea92422bf 100644
--- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/gnu/GCCSpecsConsoleParser.java
+++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/gnu/GCCSpecsConsoleParser.java
@@ -44,10 +44,7 @@ public class GCCSpecsConsoleParser implements IScannerInfoConsoleParser {
protected List symbols = new ArrayList();
protected List includes = new ArrayList();
- /* (non-Javadoc)
- * @see org.eclipse.cdt.make.core.scannerconfig.IScannerInfoConsoleParser#startup(org.eclipse.core.resources.IProject, org.eclipse.core.runtime.IPath, org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector, org.eclipse.cdt.core.IMarkerGenerator)
- */
- @Override
+ @Override
public void startup(IProject project, IPath workingDirectory, IScannerInfoCollector collector, IMarkerGenerator markerGenerator) {
this.fProject = project;
this.fCollector = collector;
@@ -58,21 +55,24 @@ public class GCCSpecsConsoleParser implements IScannerInfoConsoleParser {
*/
@Override
public boolean processLine(String line) {
- boolean rc = false;
- line= line.trim();
TraceUtil.outputTrace("GCCSpecsConsoleParser parsing line: [", line, "]"); //$NON-NLS-1$ //$NON-NLS-2$
+ line= line.trim();
+ if (line.length() == 0) {
+ return false;
+ }
+
// contribution of -dD option
if (line.startsWith(DEFINE)) {
String[] defineParts = line.split("\\s+", 3); //$NON-NLS-1$
if (defineParts[0].equals(DEFINE)) {
- if (defineParts[1].indexOf('(') >= 0) {
- // #define __X__(P1, P2) __Y__(P1, P2)
- // Enclose matching parentheses pairs
- // in the macro name if they are present
- int i = line.indexOf(')'); // macro definition itself can have only one pair of brackets
+ if (defineParts[1].indexOf('(') >= 0) {
+ // #define __X__(P1, P2) __Y__(P1, P2)
+ // Enclose matching parentheses pairs
+ // in the macro name if they are present
+ int i = line.indexOf(')'); // macro definition itself can have only one pair of brackets
- // i now marks the space between the name and definition
+ // i now marks the space between the name and definition
if (i > 0) {
int start = line.indexOf(defineParts[1]); // start of definition
defineParts[1] = line.substring(start, i + 1);
@@ -82,18 +82,18 @@ public class GCCSpecsConsoleParser implements IScannerInfoConsoleParser {
} else {
MakeCorePlugin.log(new Exception("GCCSpecsConsoleParser ERROR: Unmatched brackets: ["+ line+ "]")); //$NON-NLS-1$ //$NON-NLS-2$
}
- }
+ }
- // Now defineParts[1] is the symbol name, and [2] is the definition
- String symbol = null;
- if (defineParts.length > 1) {
- symbol = defineParts[1] + "="; //$NON-NLS-1$
- if (defineParts.length > 2) {
- symbol += defineParts[2];
- }
- if (!symbols.contains(symbol)) {
- symbols.add(symbol);
- }
+ // Now defineParts[1] is the symbol name, and [2] is the definition
+ String symbol = null;
+ if (defineParts.length > 1) {
+ symbol = defineParts[1] + "="; //$NON-NLS-1$
+ if (defineParts.length > 2) {
+ symbol += defineParts[2];
+ }
+ if (!symbols.contains(symbol)) {
+ symbols.add(symbol);
+ }
}
}
}
@@ -109,7 +109,7 @@ public class GCCSpecsConsoleParser implements IScannerInfoConsoleParser {
includes.add(line);
}
- return rc;
+ return false;
}
/* (non-Javadoc)
diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/DefaultRunSIProvider.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/DefaultRunSIProvider.java
index 19123121aa0..a88e64bb236 100644
--- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/DefaultRunSIProvider.java
+++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/DefaultRunSIProvider.java
@@ -12,7 +12,6 @@
package org.eclipse.cdt.make.internal.core.scannerconfig2;
import java.io.IOException;
-import java.io.OutputStream;
import java.net.URI;
import java.util.ArrayList;
import java.util.Enumeration;
@@ -24,7 +23,7 @@ import org.eclipse.cdt.core.ErrorParserManager;
import org.eclipse.cdt.core.ICommandLauncher;
import org.eclipse.cdt.core.model.ILanguage;
import org.eclipse.cdt.core.resources.IConsole;
-import org.eclipse.cdt.internal.core.ConsoleOutputSniffer;
+import org.eclipse.cdt.internal.core.BuildRunnerHelper;
import org.eclipse.cdt.make.core.MakeBuilder;
import org.eclipse.cdt.make.core.MakeBuilderUtil;
import org.eclipse.cdt.make.core.MakeCorePlugin;
@@ -33,9 +32,7 @@ import org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo2;
import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector;
import org.eclipse.cdt.make.core.scannerconfig.InfoContext;
import org.eclipse.cdt.make.internal.core.MakeMessages;
-import org.eclipse.cdt.make.internal.core.StreamMonitor;
import org.eclipse.cdt.make.internal.core.scannerconfig.ScannerConfigUtil;
-import org.eclipse.cdt.make.internal.core.scannerconfig.ScannerInfoConsoleParserFactory;
import org.eclipse.cdt.utils.EFSExtensionManager;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
@@ -56,7 +53,7 @@ import org.osgi.service.prefs.BackingStoreException;
public class DefaultRunSIProvider implements IExternalScannerInfoProvider {
private static final String GMAKE_ERROR_PARSER_ID = "org.eclipse.cdt.core.GmakeErrorParser"; //$NON-NLS-1$
private static final String PREF_CONSOLE_ENABLED = "org.eclipse.cdt.make.core.scanner.discovery.console.enabled"; //$NON-NLS-1$
- private static final String NEWLINE = System.getProperty("line.separator", "\n"); //$NON-NLS-1$ //$NON-NLS-2$
+ private static final int MONITOR_SCALE = 100;
protected IResource resource;
protected String providerId;
@@ -90,17 +87,20 @@ public class DefaultRunSIProvider implements IExternalScannerInfoProvider {
this.buildInfo = buildInfo;
this.collector = collector;
- IProject currentProject = resource.getProject();
- // call a subclass to initialize protected fields
- if (!initialize()) {
- return false;
- }
- if (monitor == null) {
- monitor = new NullProgressMonitor();
- }
- monitor.beginTask(MakeMessages.getString("ExternalScannerInfoProvider.Reading_Specs"), 100); //$NON-NLS-1$
+ IProject project = resource.getProject();
+ BuildRunnerHelper buildRunnerHelper = new BuildRunnerHelper(project);
try {
+ if (monitor == null) {
+ monitor = new NullProgressMonitor();
+ }
+ monitor.beginTask(MakeMessages.getString("ExternalScannerInfoProvider.Reading_Specs"), 2 * MONITOR_SCALE); //$NON-NLS-1$
+
+ // call a subclass to initialize protected fields
+ if (!initialize()) {
+ return false;
+ }
+
ILanguage language = context.getLanguage();
IConsole console;
if (language!=null && isConsoleEnabled()) {
@@ -111,64 +111,34 @@ public class DefaultRunSIProvider implements IExternalScannerInfoProvider {
// that looks in extension points registry and won't find the id
console = CCorePlugin.getDefault().getConsole(MakeCorePlugin.PLUGIN_ID + ".console.hidden"); //$NON-NLS-1$
}
- console.start(currentProject);
- OutputStream cos = console.getOutputStream();
+ console.start(project);
- // Before launching give visual cues via the monitor
- monitor.subTask(MakeMessages.getString("ExternalScannerInfoProvider.Reading_Specs")); //$NON-NLS-1$
-
- String errMsg = null;
ICommandLauncher launcher = new CommandLauncher();
- launcher.setProject(currentProject);
- // Print the command for visual interaction.
- launcher.showCommand(true);
+ launcher.setProject(project);
String[] comandLineOptions = getCommandLineOptions();
IPath program = getCommandToLaunch();
- String params = coligate(comandLineOptions);
+ URI workingDirectoryURI = MakeBuilderUtil.getBuildDirectoryURI(project, MakeBuilder.BUILDER_ID);
+ String[] envp = setEnvironment(launcher, env);
- monitor.subTask(MakeMessages.getString("ExternalScannerInfoProvider.Invoking_Command") //$NON-NLS-1$
- + program + params);
+ ErrorParserManager epm = new ErrorParserManager(project, markerGenerator, new String[] {GMAKE_ERROR_PARSER_ID});
- ErrorParserManager epm = new ErrorParserManager(currentProject, markerGenerator, new String[] {GMAKE_ERROR_PARSER_ID});
- epm.setOutputStream(cos);
- StreamMonitor streamMon = new StreamMonitor(new SubProgressMonitor(monitor, 70), epm, 100);
- OutputStream stdout = streamMon;
- OutputStream stderr = streamMon;
+ buildRunnerHelper.setLaunchParameters(launcher, program, comandLineOptions, workingDirectoryURI, envp );
+ buildRunnerHelper.prepareStreams(epm, null, console, new SubProgressMonitor(monitor, 1 * MONITOR_SCALE, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK));
- ConsoleOutputSniffer sniffer = ScannerInfoConsoleParserFactory.getESIProviderOutputSniffer(
- stdout, stderr, currentProject, context, providerId, buildInfo, collector, markerGenerator);
- OutputStream consoleOut = (sniffer == null ? cos : sniffer.getOutputStream());
- OutputStream consoleErr = (sniffer == null ? cos : sniffer.getErrorStream());
- Process p = launcher.execute(program, comandLineOptions, setEnvironment(launcher, env), fWorkingDirectory, monitor);
- if (p != null) {
- try {
- // Close the input of the Process explicitly.
- // We will never write to it.
- p.getOutputStream().close();
- } catch (IOException e) {
- }
- if (launcher.waitAndRead(consoleOut, consoleErr, new SubProgressMonitor(monitor, 0)) != ICommandLauncher.OK) {
- errMsg = launcher.getErrorMessage();
- }
- monitor.subTask(MakeMessages.getString("ExternalScannerInfoProvider.Parsing_Output")); //$NON-NLS-1$
- } else {
- errMsg = launcher.getErrorMessage();
- }
+ buildRunnerHelper.greeting(MakeMessages.getFormattedString("ExternalScannerInfoProvider.Greeting", project.getName())); //$NON-NLS-1$
+ buildRunnerHelper.build(new SubProgressMonitor(monitor, 1 * MONITOR_SCALE, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK));
+ buildRunnerHelper.close();
+ buildRunnerHelper.goodbye();
- if (errMsg != null) {
- printLine(consoleErr, errMsg);
- printLine(consoleErr, MakeMessages.getFormattedString("ExternalScannerInfoProvider.Provider_Error", program + params) + NEWLINE); //$NON-NLS-1$
- }
-
- consoleOut.close();
- consoleErr.close();
- cos.close();
- }
- catch (Exception e) {
+ } catch (Exception e) {
MakeCorePlugin.log(e);
- }
- finally {
+ } finally {
+ try {
+ buildRunnerHelper.close();
+ } catch (IOException e) {
+ MakeCorePlugin.log(e);
+ }
monitor.done();
}
return true;
@@ -185,11 +155,6 @@ public class DefaultRunSIProvider implements IExternalScannerInfoProvider {
buildInfo.isUseDefaultProviderCommand(providerId));
}
- private void printLine(OutputStream stream, String msg) throws IOException {
- stream.write((msg + NEWLINE).getBytes());
- stream.flush();
- }
-
/**
* Initialization of protected fields.
* Subclasses are most likely to override default implementation.
@@ -223,16 +188,6 @@ public class DefaultRunSIProvider implements IExternalScannerInfoProvider {
return fCompileArguments;
}
- private String coligate(String[] array) {
- StringBuffer sb = new StringBuffer(128);
- for (int i = 0; i < array.length; ++i) {
- sb.append(' ');
- sb.append(array[i]);
- }
- String ca = sb.toString();
- return ca;
- }
-
private Properties getEnvMap(ICommandLauncher launcher, Properties initialEnv) {
// Set the environmennt, some scripts may need the CWD var to be set.
Properties props = initialEnv != null ? initialEnv : launcher.getEnvironment();
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/AbstractBuildRunner.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/AbstractBuildRunner.java
index d387f1ee47b..d3ae5ce2ef8 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/AbstractBuildRunner.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/AbstractBuildRunner.java
@@ -20,7 +20,7 @@ import org.eclipse.core.runtime.IProgressMonitor;
/**
* Interface implemented by toolchain integrators to perform the actual build.
- *
+ *
* @author Doug Schaefer
* @since 8.0
*/
@@ -29,12 +29,13 @@ public abstract class AbstractBuildRunner {
/**
* Perform the build.
*
- * @param kind kind from the IncrementalProjectBuilder
- * @param project project being built
- * @param configuration configuration being built
- * @param console console to use for build output
- * @param markerGenerator generator to add markers for build problems
- * @param monitor progress monitor
+ * @param kind - kind from the IncrementalProjectBuilder
+ * @param project - project being built
+ * @param configuration - configuration being built
+ * @param console - console to use for build output
+ * @param markerGenerator - generator to add markers for build problems
+ * @param monitor - progress monitor in the initial state where {@link IProgressMonitor#beginTask(String, int)}
+ * has not been called yet.
* @throws CoreException standard core exception if something goes wrong
*/
public abstract boolean invokeBuild(int kind, IProject project, IConfiguration configuration,
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ExternalBuildRunner.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ExternalBuildRunner.java
index 5a2c2dafbbf..a20b6bd08f4 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ExternalBuildRunner.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ExternalBuildRunner.java
@@ -1,18 +1,18 @@
/*******************************************************************************
- * Copyright (c) 2010, 2011 Wind River Systems and others.
+ * Copyright (c) 2010, 2012 Wind River Systems 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:
- * Wind River Systems - Initial API and implementation
- * James Blackburn (Broadcom Corp.)
+ * Wind River Systems - Initial API and implementation
+ * James Blackburn (Broadcom Corp.)
+ * Andrew Gvozdev
*******************************************************************************/
package org.eclipse.cdt.managedbuilder.core;
import java.io.IOException;
-import java.io.OutputStream;
import java.net.URI;
import java.util.ArrayList;
import java.util.HashMap;
@@ -26,41 +26,29 @@ import org.eclipse.cdt.build.internal.core.scannerconfig2.CfgScannerConfigProfil
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.ErrorParserManager;
import org.eclipse.cdt.core.ICommandLauncher;
+import org.eclipse.cdt.core.IConsoleParser;
import org.eclipse.cdt.core.IMarkerGenerator;
import org.eclipse.cdt.core.envvar.IEnvironmentVariable;
import org.eclipse.cdt.core.envvar.IEnvironmentVariableManager;
-import org.eclipse.cdt.core.model.ICModelMarker;
import org.eclipse.cdt.core.resources.IConsole;
-import org.eclipse.cdt.core.resources.RefreshScopeManager;
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
-import org.eclipse.cdt.internal.core.ConsoleOutputSniffer;
+import org.eclipse.cdt.internal.core.BuildRunnerHelper;
import org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo2;
-import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector;
import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoConsoleParser;
-import org.eclipse.cdt.make.core.scannerconfig.InfoContext;
-import org.eclipse.cdt.make.internal.core.scannerconfig2.SCProfileInstance;
-import org.eclipse.cdt.make.internal.core.scannerconfig2.ScannerConfigProfile;
-import org.eclipse.cdt.make.internal.core.scannerconfig2.ScannerConfigProfileManager;
+import org.eclipse.cdt.make.internal.core.scannerconfig.ScannerInfoConsoleParserFactory;
import org.eclipse.cdt.managedbuilder.internal.core.ManagedMakeMessages;
import org.eclipse.cdt.managedbuilder.macros.BuildMacroException;
import org.eclipse.cdt.managedbuilder.macros.IBuildMacroProvider;
-import org.eclipse.cdt.newmake.internal.core.StreamMonitor;
import org.eclipse.cdt.utils.CommandLineUtil;
import org.eclipse.cdt.utils.EFSExtensionManager;
-import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IWorkspace;
-import org.eclipse.core.resources.IWorkspaceRunnable;
import org.eclipse.core.resources.IncrementalProjectBuilder;
-import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.QualifiedName;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.SubProgressMonitor;
@@ -69,13 +57,7 @@ import org.eclipse.core.runtime.SubProgressMonitor;
* @since 8.0
*/
public class ExternalBuildRunner extends AbstractBuildRunner {
-
- private static final String TYPE_CLEAN = "ManagedMakeBuilder.type.clean"; //$NON-NLS-1$
- private static final String TYPE_INC = "ManagedMakeBuider.type.incremental"; //$NON-NLS-1$
- private static final String CONSOLE_HEADER = "ManagedMakeBuilder.message.console.header"; //$NON-NLS-1$
- private static final String WARNING_UNSUPPORTED_CONFIGURATION = "ManagedMakeBuilder.warning.unsupported.configuration"; //$NON-NLS-1$
- private static final String NEWLINE = System.getProperty("line.separator", "\n"); //$NON-NLS-1$ //$NON-NLS-2$
- private static final String PATH_ENV = "PATH"; //$NON-NLS-1$
+ private static final int MONITOR_SCALE = 100;
@Override
public boolean invokeBuild(int kind, IProject project, IConfiguration configuration,
@@ -88,156 +70,79 @@ public class ExternalBuildRunner extends AbstractBuildRunner {
protected boolean invokeExternalBuild(int kind, IProject project, IConfiguration configuration,
IBuilder builder, IConsole console, IMarkerGenerator markerGenerator,
IncrementalProjectBuilder projectBuilder, IProgressMonitor monitor) throws CoreException {
+
boolean isClean = false;
- if (monitor == null) {
- monitor = new NullProgressMonitor();
- }
- monitor.beginTask(ManagedMakeMessages.getResourceString("MakeBuilder.Invoking_Make_Builder") + project.getName(), 100); //$NON-NLS-1$
-
+ BuildRunnerHelper buildRunnerHelper = new BuildRunnerHelper(project);
try {
+ if (monitor == null) {
+ monitor = new NullProgressMonitor();
+ }
+ monitor.beginTask(ManagedMakeMessages.getResourceString("MakeBuilder.Invoking_Make_Builder") + project.getName(), 4 * MONITOR_SCALE); //$NON-NLS-1$
+
IPath buildCommand = builder.getBuildCommand();
if (buildCommand != null) {
- OutputStream cos = console.getOutputStream();
- StringBuffer buf = new StringBuffer();
+ String cfgName = configuration.getName();
+ String toolchainName = configuration.getToolChain().getName();
+ boolean isSupported = configuration.isSupported();
- String[] consoleHeader = new String[3];
- switch (kind) {
- case IncrementalProjectBuilder.FULL_BUILD:
- case IncrementalProjectBuilder.INCREMENTAL_BUILD:
- case IncrementalProjectBuilder.AUTO_BUILD:
- consoleHeader[0] = ManagedMakeMessages.getResourceString(TYPE_INC);
- break;
- case IncrementalProjectBuilder.CLEAN_BUILD:
- consoleHeader[0] = ManagedMakeMessages.getResourceString(TYPE_CLEAN);
- break;
- }
-
- consoleHeader[1] = configuration.getName();
- consoleHeader[2] = project.getName();
- buf.append(NEWLINE);
- buf.append(ManagedMakeMessages.getFormattedString(CONSOLE_HEADER, consoleHeader)).append(NEWLINE);
- buf.append(NEWLINE);
-
- if(!configuration.isSupported()){
- String unsupportedToolchainMsg = ManagedMakeMessages.getFormattedString(WARNING_UNSUPPORTED_CONFIGURATION,
- new String[] { configuration.getName(), configuration.getToolChain().getName() });
- buf.append(unsupportedToolchainMsg).append(NEWLINE);
- buf.append(NEWLINE);
- }
- cos.write(buf.toString().getBytes());
- cos.flush();
-
- // remove all markers for this project
- IWorkspace workspace = project.getWorkspace();
- IMarker[] markers = project.findMarkers(ICModelMarker.C_MODEL_PROBLEM_MARKER, true, IResource.DEPTH_INFINITE);
- if (markers != null)
- workspace.deleteMarkers(markers);
-
- URI workingDirectoryURI = ManagedBuildManager.getBuildLocationURI(configuration, builder);
- final String pathFromURI = EFSExtensionManager.getDefault().getPathFromURI(workingDirectoryURI);
- if(pathFromURI == null) {
- throw new CoreException(new Status(IStatus.ERROR, ManagedBuilderCorePlugin.PLUGIN_ID, ManagedMakeMessages.getString("ManagedMakeBuilder.message.error"), null)); //$NON-NLS-1$
- }
-
- IPath workingDirectory = new Path(pathFromURI);
+ ICommandLauncher launcher = builder.getCommandLauncher();
String[] targets = getTargets(kind, builder);
if (targets.length != 0 && targets[targets.length - 1].equals(builder.getCleanBuildTarget()))
isClean = true;
- String errMsg = null;
- ICommandLauncher launcher = builder.getCommandLauncher();
- launcher.setProject(project);
- // Print the command for visual interaction.
- launcher.showCommand(true);
+ String[] args = getCommandArguments(builder, targets);
+
+ URI workingDirectoryURI = ManagedBuildManager.getBuildLocationURI(configuration, builder);
- // Set the environment
Map envMap = getEnvironment(builder);
- String[] env = getEnvStrings(envMap);
- String[] buildArguments = targets;
+ String[] envp = BuildRunnerHelper.envMapToEnvp(envMap);
- String[] newArgs = CommandLineUtil.argumentsToArray(builder.getBuildArguments());
- buildArguments = new String[targets.length + newArgs.length];
- System.arraycopy(newArgs, 0, buildArguments, 0, newArgs.length);
- System.arraycopy(targets, 0, buildArguments, newArgs.length, targets.length);
+ String[] errorParsers = builder.getErrorParsers();
+ ErrorParserManager epm = new ErrorParserManager(project, workingDirectoryURI, markerGenerator, errorParsers);
- QualifiedName qName = new QualifiedName(ManagedBuilderCorePlugin.getUniqueIdentifier(), "progressMonitor"); //$NON-NLS-1$
- Integer last = (Integer)project.getSessionProperty(qName);
- if (last == null) {
- last = new Integer(100);
+ List parsers = new ArrayList();
+ collectScannerInfoConsoleParsers(project, configuration, workingDirectoryURI, markerGenerator, parsers);
+
+ buildRunnerHelper.setLaunchParameters(launcher, buildCommand, args, workingDirectoryURI, envp);
+ buildRunnerHelper.prepareStreams(epm, parsers, console, new SubProgressMonitor(monitor, 1 * MONITOR_SCALE));
+
+ buildRunnerHelper.removeOldMarkers(project, new SubProgressMonitor(monitor, 1 * MONITOR_SCALE, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK));
+
+ buildRunnerHelper.greeting(kind, cfgName, toolchainName, isSupported);
+ int state = buildRunnerHelper.build(new SubProgressMonitor(monitor, 1 * MONITOR_SCALE, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK));
+ buildRunnerHelper.close();
+ buildRunnerHelper.goodbye();
+
+ if (state != ICommandLauncher.ILLEGAL_COMMAND) {
+ buildRunnerHelper.refreshProject(new SubProgressMonitor(monitor, 1 * MONITOR_SCALE, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK));
}
- ErrorParserManager epm = new ErrorParserManager(project, workingDirectoryURI, markerGenerator, builder.getErrorParsers());
- epm.setOutputStream(cos);
- StreamMonitor streamMon = new StreamMonitor(new SubProgressMonitor(monitor, 100), epm, last.intValue());
- OutputStream stdout = streamMon;
- OutputStream stderr = streamMon;
-
- // Sniff console output for scanner info
- ConsoleOutputSniffer sniffer = createBuildOutputSniffer(stdout, stderr, project, configuration, workingDirectory, markerGenerator, null);
- OutputStream consoleOut = (sniffer == null ? stdout : sniffer.getOutputStream());
- OutputStream consoleErr = (sniffer == null ? stderr : sniffer.getErrorStream());
- Process p = launcher.execute(buildCommand, buildArguments, env, workingDirectory, monitor);
- if (p != null) {
- try {
- // Close the input of the Process explicitly.
- // We will never write to it.
- p.getOutputStream().close();
- } catch (IOException e) {
- }
- // Before launching give visual cues via the monitor
- monitor.subTask(ManagedMakeMessages.getResourceString("MakeBuilder.Invoking_Command") + launcher.getCommandLine()); //$NON-NLS-1$
- if (launcher.waitAndRead(consoleOut, consoleErr, new SubProgressMonitor(monitor, 0))
- != ICommandLauncher.OK)
- errMsg = launcher.getErrorMessage();
- monitor.subTask(ManagedMakeMessages.getResourceString("MakeBuilder.Updating_project")); //$NON-NLS-1$
-
- try {
- // Do not allow the cancel of the refresh, since the builder is external
- // to Eclipse, files may have been created/modified and we will be out-of-sync.
- // The caveat is for huge projects, it may take sometimes at every build.
-
- // TODO should only refresh output folders
- //project.refreshLocal(IResource.DEPTH_INFINITE, null);
-
- // use the refresh scope manager to refresh
- RefreshScopeManager refreshManager = RefreshScopeManager.getInstance();
- IWorkspaceRunnable runnable = refreshManager.getRefreshRunnable(project);
- ResourcesPlugin.getWorkspace().run(runnable, null, IWorkspace.AVOID_UPDATE, null);
- } catch (CoreException e) {
- }
- } else {
- errMsg = launcher.getErrorMessage();
- }
- project.setSessionProperty(qName, !monitor.isCanceled() && !isClean ? new Integer(streamMon.getWorkDone()) : null);
-
- if (errMsg != null) {
- consoleErr.write(errMsg.getBytes());
- consoleErr.flush();
- }
-
- buf = new StringBuffer(NEWLINE);
- buf.append(ManagedMakeMessages.getResourceString("ManagedMakeBuilder.message.build.finished")).append(NEWLINE); //$NON-NLS-1$
- consoleOut.write(buf.toString().getBytes());
-
- stdout.close();
- stderr.close();
-
- monitor.subTask(ManagedMakeMessages.getResourceString("MakeBuilder.Creating_Markers")); //$NON-NLS-1$
- consoleOut.close();
- consoleErr.close();
- cos.close();
+ } else {
+ String msg = ManagedMakeMessages.getFormattedString("ManagedMakeBuilder.message.undefined.build.command", builder.getId()); //$NON-NLS-1$
+ throw new CoreException(new Status(IStatus.ERROR, ManagedBuilderCorePlugin.PLUGIN_ID, msg, new Exception()));
}
} catch (Exception e) {
- ManagedBuilderCorePlugin.log(e);
- throw new CoreException(new Status(IStatus.ERROR,
- ManagedBuilderCorePlugin.getUniqueIdentifier(),
- e.getLocalizedMessage(),
- e));
+ String msg = ManagedMakeMessages.getFormattedString("ManagedMakeBuilder.message.error.build", //$NON-NLS-1$
+ new String[] { project.getName(), configuration.getName() });
+ throw new CoreException(new Status(IStatus.ERROR, ManagedBuilderCorePlugin.PLUGIN_ID, msg, e));
} finally {
+ try {
+ buildRunnerHelper.close();
+ } catch (IOException e) {
+ ManagedBuilderCorePlugin.log(e);
+ }
monitor.done();
}
- return (isClean);
+ return isClean;
+ }
+
+ private String[] getCommandArguments(IBuilder builder, String[] targets) {
+ String[] builderArgs = CommandLineUtil.argumentsToArray(builder.getBuildArguments());
+ String[] args = new String[targets.length + builderArgs.length];
+ System.arraycopy(builderArgs, 0, args, 0, builderArgs.length);
+ System.arraycopy(targets, 0, args, builderArgs.length, targets.length);
+ return args;
}
protected String[] getTargets(int kind, IBuilder builder) {
@@ -301,6 +206,7 @@ public class ExternalBuildRunner extends AbstractBuildRunner {
return envMap;
}
+ @Deprecated
protected static String[] getEnvStrings(Map env) {
// Convert into env strings
List strings= new ArrayList(env.size());
@@ -313,16 +219,19 @@ public class ExternalBuildRunner extends AbstractBuildRunner {
return strings.toArray(new String[strings.size()]);
}
- private ConsoleOutputSniffer createBuildOutputSniffer(OutputStream outputStream,
- OutputStream errorStream,
- IProject project,
- IConfiguration cfg,
- IPath workingDirectory,
- IMarkerGenerator markerGenerator,
- IScannerInfoCollector collector){
+ private static void collectScannerInfoConsoleParsers(IProject project, IConfiguration cfg, URI workingDirectoryURI,
+ IMarkerGenerator markerGenerator, List parsers) {
ICfgScannerConfigBuilderInfo2Set container = CfgScannerConfigProfileManager.getCfgScannerConfigBuildInfo(cfg);
Map map = container.getInfoMap();
- List clParserList = new ArrayList();
+
+ String pathFromURI = EFSExtensionManager.getDefault().getPathFromURI(workingDirectoryURI);
+ if(pathFromURI == null) {
+ // fallback to CWD
+ pathFromURI = System.getProperty("user.dir"); //$NON-NLS-1$
+ }
+ IPath workingDirectory = new Path(pathFromURI);
+
+ int oldSize = parsers.size();
if(container.isPerRcTypeDiscovery()){
for (IResourceInfo rcInfo : cfg.getResourceInfos()) {
@@ -337,66 +246,34 @@ public class ExternalBuildRunner extends AbstractBuildRunner {
if(types.length != 0){
for (IInputType type : types) {
- CfgInfoContext c = new CfgInfoContext(rcInfo, tool, type);
- contributeToConsoleParserList(project, map, c, workingDirectory, markerGenerator, collector, clParserList);
+ CfgInfoContext context = new CfgInfoContext(rcInfo, tool, type);
+ IScannerInfoConsoleParser parser = getScannerInfoConsoleParser(project, map, context, workingDirectory, markerGenerator);
+ if (parser != null) {
+ parsers.add(parser);
+ }
}
} else {
- CfgInfoContext c = new CfgInfoContext(rcInfo, tool, null);
- contributeToConsoleParserList(project, map, c, workingDirectory, markerGenerator, collector, clParserList);
+ CfgInfoContext context = new CfgInfoContext(rcInfo, tool, null);
+ IScannerInfoConsoleParser parser = getScannerInfoConsoleParser(project, map, context, workingDirectory, markerGenerator);
+ if (parser != null) {
+ parsers.add(parser);
+ }
}
}
}
}
- if(clParserList.size() == 0){
- contributeToConsoleParserList(project, map, new CfgInfoContext(cfg), workingDirectory, markerGenerator, collector, clParserList);
- }
-
- if(clParserList.size() != 0){
- return new ConsoleOutputSniffer(outputStream, errorStream,
- clParserList.toArray(new IScannerInfoConsoleParser[clParserList.size()]));
- }
-
- return null;
- }
-
- private boolean contributeToConsoleParserList(
- IProject project,
- Map map,
- CfgInfoContext context,
- IPath workingDirectory,
- IMarkerGenerator markerGenerator,
- IScannerInfoCollector collector,
- List parserList){
- IScannerConfigBuilderInfo2 info = map.get(context);
- InfoContext ic = context.toInfoContext();
- boolean added = false;
- if (info != null &&
- info.isAutoDiscoveryEnabled() &&
- info.isBuildOutputParserEnabled()) {
-
- String id = info.getSelectedProfileId();
- ScannerConfigProfile profile = ScannerConfigProfileManager.getInstance().getSCProfileConfiguration(id);
- if(profile.getBuildOutputProviderElement() != null){
- // get the make builder console parser
- SCProfileInstance profileInstance = ScannerConfigProfileManager.getInstance().
- getSCProfileInstance(project, ic, id);
-
- IScannerInfoConsoleParser clParser = profileInstance.createBuildOutputParser();
- if (collector == null) {
- collector = profileInstance.getScannerInfoCollector();
- }
- if(clParser != null){
- clParser.startup(project, workingDirectory, collector,
- info.isProblemReportingEnabled() ? markerGenerator : null);
- parserList.add(clParser);
- added = true;
- }
-
+ if(parsers.size() == oldSize){
+ CfgInfoContext context = new CfgInfoContext(cfg);
+ IScannerInfoConsoleParser parser = getScannerInfoConsoleParser(project, map, context, workingDirectory, markerGenerator);
+ if (parser != null) {
+ parsers.add(parser);
}
}
-
- return added;
}
+ private static IScannerInfoConsoleParser getScannerInfoConsoleParser(IProject project, Map map,
+ CfgInfoContext context, IPath workingDirectory, IMarkerGenerator markerGenerator) {
+ return ScannerInfoConsoleParserFactory.getScannerInfoConsoleParser(project, context.toInfoContext(), workingDirectory, map.get(context), markerGenerator, null);
+ }
}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/InternalBuildRunner.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/InternalBuildRunner.java
index f50ce9993aa..f12791bdc30 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/InternalBuildRunner.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/InternalBuildRunner.java
@@ -13,74 +13,56 @@ package org.eclipse.cdt.managedbuilder.core;
import java.io.IOException;
import java.io.OutputStream;
+import java.net.URI;
-import org.eclipse.cdt.core.ConsoleOutputStream;
import org.eclipse.cdt.core.ErrorParserManager;
+import org.eclipse.cdt.core.ICommandLauncher;
import org.eclipse.cdt.core.IMarkerGenerator;
-import org.eclipse.cdt.core.model.ICModelMarker;
import org.eclipse.cdt.core.resources.IConsole;
+import org.eclipse.cdt.internal.core.BuildRunnerHelper;
import org.eclipse.cdt.managedbuilder.buildmodel.BuildDescriptionManager;
import org.eclipse.cdt.managedbuilder.buildmodel.IBuildDescription;
import org.eclipse.cdt.managedbuilder.internal.buildmodel.BuildStateManager;
import org.eclipse.cdt.managedbuilder.internal.buildmodel.DescriptionBuilder;
-import org.eclipse.cdt.managedbuilder.internal.buildmodel.IBuildModelBuilder;
import org.eclipse.cdt.managedbuilder.internal.buildmodel.IConfigurationBuildState;
import org.eclipse.cdt.managedbuilder.internal.buildmodel.IProjectBuildState;
import org.eclipse.cdt.managedbuilder.internal.buildmodel.ParallelBuilder;
import org.eclipse.cdt.managedbuilder.internal.core.ManagedMakeMessages;
-import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IResourceDelta;
-import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.IncrementalProjectBuilder;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.SubProgressMonitor;
/**
* The build runner for the internal builder.
- *
+ *
* @author dschaefer
* @since 8.0
*/
public class InternalBuildRunner extends AbstractBuildRunner {
-
- private static final String INTERNAL_BUILDER = "ManagedMakeBuilder.message.internal.builder"; //$NON-NLS-1$
- private static final String TYPE_INC = "ManagedMakeBuider.type.incremental"; //$NON-NLS-1$
- private static final String TYPE_REBUILD = "ManagedMakeBuider.type.rebuild"; //$NON-NLS-1$
- private static final String CONSOLE_HEADER = "ManagedMakeBuilder.message.console.header"; //$NON-NLS-1$
- private static final String INTERNAL_BUILDER_HEADER_NOTE = "ManagedMakeBuilder.message.internal.builder.header.note"; //$NON-NLS-1$
- private static final String WARNING_UNSUPPORTED_CONFIGURATION = "ManagedMakeBuilder.warning.unsupported.configuration"; //$NON-NLS-1$
- private static final String BUILD_FINISHED = "ManagedMakeBuilder.message.finished"; //$NON-NLS-1$
- private static final String BUILD_CANCELLED = "ManagedMakeBuilder.message.cancelled"; //$NON-NLS-1$
- private static final String BUILD_FINISHED_WITH_ERRS = "ManagedMakeBuilder.message.finished.with.errs"; //$NON-NLS-1$
- private static final String BUILD_STOPPED_ERR = "ManagedMakeBuilder.message.stopped.error"; //$NON-NLS-1$
- private static final String BUILD_FAILED_ERR = "ManagedMakeBuilder.message.internal.builder.error"; //$NON-NLS-1$
- private static final String MARKERS = "ManagedMakeBuilder.message.creating.markers"; //$NON-NLS-1$
- private static final String NOTHING_BUILT = "ManagedMakeBuilder.message.no.build"; //$NON-NLS-1$
- private static final String BUILD_ERROR = "ManagedMakeBuilder.message.error"; //$NON-NLS-1$
+ private static final int MONITOR_SCALE = 100;
@Override
public boolean invokeBuild(int kind, IProject project, IConfiguration configuration,
IBuilder builder, IConsole console, IMarkerGenerator markerGenerator,
IncrementalProjectBuilder projectBuilder, IProgressMonitor monitor) throws CoreException {
- boolean isParallel = builder.getParallelizationNum() > 1;
-// boolean buildIncrementaly = true;
- boolean resumeOnErr = !builder.isStopOnError();
- // Get the project and make sure there's a monitor to cancel the build
- if (monitor == null) {
- monitor = new NullProgressMonitor();
- }
+ BuildRunnerHelper buildRunnerHelper = new BuildRunnerHelper(project);
- String[] msgs = new String[2];
- msgs[0] = ManagedMakeMessages.getResourceString(INTERNAL_BUILDER);
- msgs[1] = project.getName();
-
- ConsoleOutputStream consoleOutStream = null;
- OutputStream epmOutputStream = null;
try {
+ if (monitor == null) {
+ monitor = new NullProgressMonitor();
+ }
+ monitor.beginTask("", 3 * MONITOR_SCALE); //$NON-NLS-1$
+
+ boolean isParallel = builder.getParallelizationNum() > 1;
+ boolean resumeOnErr = !builder.isStopOnError();
+
int flags = 0;
IResourceDelta delta = projectBuilder.getDelta(project);
BuildStateManager bsMngr = BuildStateManager.getInstance();
@@ -88,155 +70,78 @@ public class InternalBuildRunner extends AbstractBuildRunner {
IConfigurationBuildState cBS = pBS.getConfigurationBuildState(configuration.getId(), true);
// if(delta != null){
- flags = BuildDescriptionManager.REBUILD | BuildDescriptionManager.REMOVED | BuildDescriptionManager.DEPS;
+ flags = BuildDescriptionManager.REBUILD | BuildDescriptionManager.REMOVED | BuildDescriptionManager.DEPS;
// delta = getDelta(currentProject);
// }
boolean buildIncrementaly = delta != null;
- // Get a build console for the project
- StringBuffer buf = new StringBuffer();
- consoleOutStream = console.getOutputStream();
- String[] consoleHeader = new String[3];
- if(buildIncrementaly)
- consoleHeader[0] = ManagedMakeMessages.getResourceString(TYPE_INC);
- else
- consoleHeader[0] = ManagedMakeMessages.getResourceString(TYPE_REBUILD);
+ // Prepare launch parameters for BuildRunnerHelper
+ String cfgName = configuration.getName();
+ String toolchainName = configuration.getToolChain().getName();
+ boolean isConfigurationSupported = configuration.isSupported();
- consoleHeader[1] = configuration.getName();
- consoleHeader[2] = project.getName();
- buf.append(System.getProperty("line.separator", "\n")); //$NON-NLS-1$ //$NON-NLS-2$
- buf.append(ManagedMakeMessages.getFormattedString(CONSOLE_HEADER, consoleHeader));
- buf.append(System.getProperty("line.separator", "\n")); //$NON-NLS-1$ //$NON-NLS-2$
- buf.append(System.getProperty("line.separator", "\n")); //$NON-NLS-1$ //$NON-NLS-2$
+ URI workingDirectoryURI = ManagedBuildManager.getBuildLocationURI(configuration, builder);
- buf.append(ManagedMakeMessages.getResourceString(INTERNAL_BUILDER_HEADER_NOTE));
- buf.append("\n"); //$NON-NLS-1$
+ String[] errorParsers = builder.getErrorParsers();
+ ErrorParserManager epm = new ErrorParserManager(project, workingDirectoryURI, markerGenerator, errorParsers);
- if(!configuration.isSupported()){
- buf.append(ManagedMakeMessages.getFormattedString(WARNING_UNSUPPORTED_CONFIGURATION,
- new String[] { configuration.getName(), configuration.getToolChain().getName()}));
- buf.append(System.getProperty("line.separator", "\n")); //$NON-NLS-1$ //$NON-NLS-2$
- buf.append(System.getProperty("line.separator", "\n")); //$NON-NLS-1$ //$NON-NLS-2$
- }
- consoleOutStream.write(buf.toString().getBytes());
- consoleOutStream.flush();
+ buildRunnerHelper.prepareStreams(epm, null, console, new SubProgressMonitor(monitor, 1 * MONITOR_SCALE));
IBuildDescription des = BuildDescriptionManager.createBuildDescription(configuration, cBS, delta, flags);
-
DescriptionBuilder dBuilder = null;
- if (!isParallel)
+ if (!isParallel) {
dBuilder = new DescriptionBuilder(des, buildIncrementaly, resumeOnErr, cBS);
-
- if(isParallel || dBuilder.getNumCommands() > 0) {
- // Remove all markers for this project
- IWorkspace workspace = project.getWorkspace();
- IMarker[] markers = project.findMarkers(ICModelMarker.C_MODEL_PROBLEM_MARKER, true, IResource.DEPTH_INFINITE);
- if (markers != null)
- workspace.deleteMarkers(markers);
-
- // Hook up an error parser manager
- String[] errorParsers = builder.getErrorParsers();
- ErrorParserManager epm = new ErrorParserManager(project, des.getDefaultBuildDirLocationURI(), markerGenerator, errorParsers);
- epm.setOutputStream(consoleOutStream);
- // This variable is necessary to ensure that the EPM stream stay open
- // until we explicitly close it. See bug#123302.
- epmOutputStream = epm.getOutputStream();
-
- int status = 0;
-
- long t1 = System.currentTimeMillis();
- if (isParallel)
- status = ParallelBuilder.build(des, null, null, epmOutputStream, epmOutputStream, monitor, resumeOnErr, buildIncrementaly);
- else
- status = dBuilder.build(epmOutputStream, epmOutputStream, monitor);
- long t2 = System.currentTimeMillis();
-
- // Report either the success or failure of our mission
- buf = new StringBuffer();
-
- switch(status){
- case IBuildModelBuilder.STATUS_OK:
- buf.append(ManagedMakeMessages
- .getFormattedString(BUILD_FINISHED,
- project.getName()));
- break;
- case IBuildModelBuilder.STATUS_CANCELLED:
- buf.append(ManagedMakeMessages
- .getResourceString(BUILD_CANCELLED));
- break;
- case IBuildModelBuilder.STATUS_ERROR_BUILD:
- String msg = resumeOnErr ?
- ManagedMakeMessages.getResourceString(BUILD_FINISHED_WITH_ERRS) :
- ManagedMakeMessages.getResourceString(BUILD_STOPPED_ERR);
- buf.append(msg);
- break;
- case IBuildModelBuilder.STATUS_ERROR_LAUNCH:
- default:
- buf.append(ManagedMakeMessages.getResourceString(BUILD_FAILED_ERR));
- break;
+ if (dBuilder.getNumCommands() <= 0) {
+ buildRunnerHelper.printLine(ManagedMakeMessages.getFormattedString("ManagedMakeBuilder.message.no.build", project.getName())); //$NON-NLS-1$
+ return false;
}
- buf.append(System.getProperty("line.separator", "\n")); //$NON-NLS-1$//$NON-NLS-2$
+ }
- // Report time and number of threads used
- buf.append(ManagedMakeMessages.getFormattedString("CommonBuilder.6", Integer.toString((int)(t2 - t1)))); //$NON-NLS-1$
-// buf.append(t2 - t1);
-// buf.append(" ms. ");
- if (isParallel) {
- buf.append(ManagedMakeMessages.getFormattedString("CommonBuilder.7", Integer.toString(ParallelBuilder.lastThreadsUsed))); //$NON-NLS-1$
-// buf.append(ParallelBuilder.lastThreadsUsed);
- }
- buf.append(System.getProperty("line.separator", "\n")); //$NON-NLS-1$ //$NON-NLS-2$
- // Write message on the console
- consoleOutStream.write(buf.toString().getBytes());
- consoleOutStream.flush();
- epmOutputStream.close();
- epmOutputStream = null;
- // Generate any error markers that the build has discovered
- monitor.subTask(ManagedMakeMessages.getResourceString(MARKERS));
+ buildRunnerHelper.removeOldMarkers(project, new SubProgressMonitor(monitor, 1 * MONITOR_SCALE, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK));
- bsMngr.setProjectBuildState(project, pBS);
+ if (buildIncrementaly) {
+ buildRunnerHelper.greeting(IncrementalProjectBuilder.INCREMENTAL_BUILD, cfgName, toolchainName, isConfigurationSupported);
} else {
- buf = new StringBuffer();
- buf.append(ManagedMakeMessages.getFormattedString(NOTHING_BUILT, project.getName()));
- buf.append(System.getProperty("line.separator", "\n")); //$NON-NLS-1$//$NON-NLS-2$
- consoleOutStream.write(buf.toString().getBytes());
- consoleOutStream.flush();
+ buildRunnerHelper.greeting(ManagedMakeMessages.getResourceString("ManagedMakeBuider.type.rebuild"), cfgName, toolchainName, isConfigurationSupported); //$NON-NLS-1$
+ }
+ buildRunnerHelper.printLine(ManagedMakeMessages.getResourceString("ManagedMakeBuilder.message.internal.builder.header.note")); //$NON-NLS-1$
+
+ OutputStream stdout = buildRunnerHelper.getOutputStream();
+ OutputStream stderr = buildRunnerHelper.getErrorStream();
+
+ int status;
+ if (dBuilder != null) {
+ status = dBuilder.build(stdout, stderr, new SubProgressMonitor(monitor, 1 * MONITOR_SCALE, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK));
+ } else {
+ status = ParallelBuilder.build(des, null, null, stdout, stderr, new SubProgressMonitor(monitor, 1 * MONITOR_SCALE, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK), resumeOnErr, buildIncrementaly);
+ buildRunnerHelper.printLine(ManagedMakeMessages.getFormattedString("CommonBuilder.7", Integer.toString(ParallelBuilder.lastThreadsUsed))); //$NON-NLS-1$
+ }
+
+ bsMngr.setProjectBuildState(project, pBS);
+
+ buildRunnerHelper.close();
+ buildRunnerHelper.goodbye();
+
+ if (status != ICommandLauncher.ILLEGAL_COMMAND) {
+ buildRunnerHelper.refreshProject(monitor);
}
} catch (Exception e) {
- if(consoleOutStream != null){
- StringBuffer buf = new StringBuffer();
- String errorDesc = ManagedMakeMessages
- .getResourceString(BUILD_ERROR);
- buf.append(errorDesc);
- buf.append(System.getProperty("line.separator", "\n")); //$NON-NLS-1$//$NON-NLS-2$
- buf.append(e.getLocalizedMessage());
- buf.append(System.getProperty("line.separator", "\n")); //$NON-NLS-1$//$NON-NLS-2$
-
- try {
- consoleOutStream.write(buf.toString().getBytes());
- consoleOutStream.flush();
- } catch (IOException e1) {
- }
- }
projectBuilder.forgetLastBuiltState();
+
+ String msg = ManagedMakeMessages.getFormattedString("ManagedMakeBuilder.message.error.build", //$NON-NLS-1$
+ new String[] { project.getName(), configuration.getName() });
+ throw new CoreException(new Status(IStatus.ERROR, ManagedBuilderCorePlugin.PLUGIN_ID, msg, e));
} finally {
- if(epmOutputStream != null){
- try {
- epmOutputStream.close();
- } catch (IOException e) {
- }
- }
- if(consoleOutStream != null){
- try {
- consoleOutStream.close();
- } catch (IOException e) {
- }
+ try {
+ buildRunnerHelper.close();
+ } catch (IOException e) {
+ ManagedBuilderCorePlugin.log(e);
}
monitor.done();
}
+
return false;
}
-
}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/buildmodel/CommandBuilder.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/buildmodel/CommandBuilder.java
index f4fbfd0244a..712027a2a1d 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/buildmodel/CommandBuilder.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/buildmodel/CommandBuilder.java
@@ -21,8 +21,13 @@ import java.util.Set;
import org.eclipse.cdt.core.CommandLauncher;
import org.eclipse.cdt.core.ICommandLauncher;
import org.eclipse.cdt.managedbuilder.buildmodel.IBuildCommand;
+import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
+import org.eclipse.cdt.managedbuilder.internal.core.ManagedMakeMessages;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.SubProgressMonitor;
/**
@@ -36,7 +41,6 @@ import org.eclipse.core.runtime.SubProgressMonitor;
*
*/
public class CommandBuilder implements IBuildModelBuilder {
- private static final String PATH_ENV = "PATH"; //$NON-NLS-1$
private static final String NEWLINE = System.getProperty("line.separator", "\n"); //$NON-NLS-1$ //$NON-NLS-2$
private IBuildCommand fCmd;
@@ -84,67 +88,57 @@ public class CommandBuilder implements IBuildModelBuilder {
return new OutputStreamWrapper(out);
}
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.internal.builddescription.IBuildDescriptionBuilder#build(java.io.OutputStream, java.io.OutputStream, org.eclipse.core.runtime.IProgressMonitor)
- */
@Override
- public int build(OutputStream out, OutputStream err, IProgressMonitor monitor){
- //TODO: should we display the command line here?
- monitor.beginTask("", getNumCommands()); //$NON-NLS-1$
- monitor.subTask(""/*getCommandLine()*/); //$NON-NLS-1$
-
- ICommandLauncher launcher = createLauncher();
- int status = STATUS_OK;
-
- launcher.showCommand(true);
+ public int build(OutputStream out, OutputStream err, IProgressMonitor monitor) {
+ int status = STATUS_ERROR_LAUNCH;
try {
- fProcess = launcher.execute(fCmd.getCommand(), fCmd.getArgs(), mapToStringArray(fCmd.getEnvironment()), fCmd.getCWD(), monitor);
- } catch (CoreException e1) {
- // TODO Auto-generated catch block
- if(DbgUtil.DEBUG)
- DbgUtil.trace("Error launching command: " + e1.getMessage()); //$NON-NLS-1$
- monitor.done();
- return STATUS_ERROR_LAUNCH;
- }
-
- int st = ICommandLauncher.ILLEGAL_COMMAND;
- if (fProcess != null) {
- try {
- // Close the input of the process since we will never write to it
- fProcess.getOutputStream().close();
- } catch (IOException e) {
+ if (monitor == null) {
+ monitor = new NullProgressMonitor();
+ }
+ monitor.beginTask("", getNumCommands()); //$NON-NLS-1$
+ monitor.subTask(ManagedMakeMessages.getResourceString("MakeBuilder.Invoking_Command") + getCommandLine()); //$NON-NLS-1$
+
+ ICommandLauncher launcher = createLauncher();
+ launcher.showCommand(true);
+
+ fProcess = launcher.execute(fCmd.getCommand(), fCmd.getArgs(), mapToStringArray(fCmd.getEnvironment()), fCmd.getCWD(), monitor);
+ if (fProcess != null) {
+ try {
+ // Close the input of the process since we will never write to it
+ fProcess.getOutputStream().close();
+ } catch (IOException e) {
+ }
+
+ // Wrapping out and err streams to avoid their closure
+ int st = launcher.waitAndRead(wrap(out), wrap(err), new SubProgressMonitor(monitor, getNumCommands()));
+ switch (st) {
+ case ICommandLauncher.OK:
+ // assuming that compiler returns error code after compilation errors
+ status = fProcess.exitValue() == 0 ? STATUS_OK : STATUS_ERROR_BUILD;
+ break;
+ case ICommandLauncher.COMMAND_CANCELED:
+ status = STATUS_CANCELLED;
+ break;
+ case ICommandLauncher.ILLEGAL_COMMAND:
+ default:
+ status = STATUS_ERROR_LAUNCH;
+ break;
+ }
}
- //wrapping out and err streams to avoid their closure
- st = launcher.waitAndRead(wrap(out), wrap(err),
- new SubProgressMonitor(monitor, getNumCommands()));
- }
- switch(st){
- case ICommandLauncher.OK:
- if(fProcess.exitValue() != 0)
- status = STATUS_ERROR_BUILD;
- break;
- case ICommandLauncher.COMMAND_CANCELED:
- status = STATUS_CANCELLED;
fErrMsg = launcher.getErrorMessage();
- if(DbgUtil.DEBUG)
- DbgUtil.trace("command cancelled: " + fErrMsg); //$NON-NLS-1$
-
- printMessage(fErrMsg, out);
- break;
- case ICommandLauncher.ILLEGAL_COMMAND:
- default:
+ if (fErrMsg != null && !fErrMsg.isEmpty()) {
+ printMessage(fErrMsg, err);
+ }
+ } catch (CoreException e) {
+ ManagedBuilderCorePlugin.log(new Status(IStatus.ERROR, ManagedBuilderCorePlugin.PLUGIN_ID,
+ "Error launching command [" + fCmd.getCommand() + "]", e)); //$NON-NLS-1$ //$NON-NLS-2$
status = STATUS_ERROR_LAUNCH;
- fErrMsg = launcher.getErrorMessage();
- if(DbgUtil.DEBUG)
- DbgUtil.trace("error launching the command: " + fErrMsg); //$NON-NLS-1$
-
- printMessage(fErrMsg, out);
- break;
+ } finally {
+ monitor.done();
}
- monitor.done();
return status;
}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/CommonBuilder.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/CommonBuilder.java
index e1f9d58adae..8a5565604c1 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/CommonBuilder.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/CommonBuilder.java
@@ -15,6 +15,8 @@
package org.eclipse.cdt.managedbuilder.internal.core;
import java.io.IOException;
+import java.io.OutputStream;
+import java.net.URI;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
@@ -25,12 +27,15 @@ import java.util.Set;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.ConsoleOutputStream;
+import org.eclipse.cdt.core.ErrorParserManager;
+import org.eclipse.cdt.core.ICommandLauncher;
import org.eclipse.cdt.core.ProblemMarkerInfo;
import org.eclipse.cdt.core.model.CoreModel;
import org.eclipse.cdt.core.resources.ACBuilder;
import org.eclipse.cdt.core.resources.IConsole;
import org.eclipse.cdt.core.settings.model.ICProjectDescription;
import org.eclipse.cdt.core.settings.model.util.ListComparator;
+import org.eclipse.cdt.internal.core.BuildRunnerHelper;
import org.eclipse.cdt.managedbuilder.buildmodel.BuildDescriptionManager;
import org.eclipse.cdt.managedbuilder.buildmodel.IBuildDescription;
import org.eclipse.cdt.managedbuilder.buildmodel.IBuildStep;
@@ -76,14 +81,11 @@ import org.eclipse.core.runtime.jobs.Job;
public class CommonBuilder extends ACBuilder {
public final static String BUILDER_ID = ManagedBuilderCorePlugin.getUniqueIdentifier() + ".genmakebuilder"; //$NON-NLS-1$
- private static final String BUILD_FINISHED = "ManagedMakeBuilder.message.finished"; //$NON-NLS-1$
- private static final String CONSOLE_HEADER = "ManagedMakeBuilder.message.console.header"; //$NON-NLS-1$
private static final String ERROR_HEADER = "GeneratedmakefileBuilder error ["; //$NON-NLS-1$
private static final String NEWLINE = System.getProperty("line.separator"); //$NON-NLS-1$
private static final String TRACE_FOOTER = "]: "; //$NON-NLS-1$
private static final String TRACE_HEADER = "GeneratedmakefileBuilder trace ["; //$NON-NLS-1$
- private static final String TYPE_CLEAN = "ManagedMakeBuilder.type.clean"; //$NON-NLS-1$
- private static final String TYPE_INC = "ManagedMakeBuider.type.incremental"; //$NON-NLS-1$
+ private static final int MONITOR_SCALE = 100;
public static boolean VERBOSE = false;
private static CfgBuildSet fBuildSet = new CfgBuildSet();
@@ -805,7 +807,7 @@ public class CommonBuilder extends ACBuilder {
String configName = bInfo.getConfiguration().getName();
String projName = bInfo.getProject().getName();
if (buildType == FULL_BUILD || buildType == INCREMENTAL_BUILD) {
- consoleHeader[0] = ManagedMakeMessages.getResourceString(TYPE_INC);
+ consoleHeader[0] = ManagedMakeMessages.getResourceString("ManagedMakeBuider.type.incremental"); //$NON-NLS-1$
} else {
consoleHeader[0] = new String();
outputError(projName, "The given build type is not supported in this context"); //$NON-NLS-1$
@@ -813,7 +815,7 @@ public class CommonBuilder extends ACBuilder {
consoleHeader[1] = configName;
consoleHeader[2] = projName;
buf.append(System.getProperty("line.separator", "\n")); //$NON-NLS-1$ //$NON-NLS-2$
- buf.append(ManagedMakeMessages.getFormattedString(CONSOLE_HEADER, consoleHeader));
+ buf.append(ManagedMakeMessages.getFormattedString("ManagedMakeBuilder.message.console.header", consoleHeader)); //$NON-NLS-1$
buf.append(System.getProperty("line.separator", "\n")); //$NON-NLS-1$ //$NON-NLS-2$
buf.append(System.getProperty("line.separator", "\n")); //$NON-NLS-1$ //$NON-NLS-2$
buf.append(status.getMessage());
@@ -1166,73 +1168,82 @@ public class CommonBuilder extends ACBuilder {
protected void cleanWithInternalBuilder(CfgBuildInfo bInfo, IProgressMonitor monitor) throws CoreException {
// referencedProjects = getProject().getReferencedProjects();
- IProject curProject = bInfo.getProject();
- outputTrace(curProject.getName(), "Clean build with Internal Builder requested"); //$NON-NLS-1$
- IConfiguration cfg = bInfo.getConfiguration();
+ IProject project = bInfo.getProject();
+ outputTrace(project.getName(), "Clean build with Internal Builder requested"); //$NON-NLS-1$
+ IConfiguration configuration = bInfo.getConfiguration();
int flags = BuildDescriptionManager.DEPFILES;
- BuildDescription des = (BuildDescription)BuildDescriptionManager.createBuildDescription(cfg, null, null, flags);
+ BuildDescription des = (BuildDescription)BuildDescriptionManager.createBuildDescription(configuration, null, null, flags);
IBuildStep cleanStep = des.getCleanStep();
StepBuilder sBuilder = new StepBuilder(cleanStep, null, null);
+ BuildRunnerHelper buildRunnerHelper = new BuildRunnerHelper(project);
try {
- // try the brute force approach first
- StringBuffer buf = new StringBuffer();
- // write to the console
-//
-// IConsole console = CCorePlugin.getDefault().getConsole();
-// console.start(getProject());
- IConsole console = bInfo.getConsole();
- ConsoleOutputStream consoleOutStream = console.getOutputStream();
- String[] consoleHeader = new String[3];
- consoleHeader[0] = ManagedMakeMessages.getResourceString(TYPE_CLEAN);
- consoleHeader[1] = cfg.getName();
- consoleHeader[2] = curProject.getName();
- buf.append(System.getProperty("line.separator", "\n")); //$NON-NLS-1$ //$NON-NLS-2$
- buf.append(ManagedMakeMessages.getFormattedString(CONSOLE_HEADER, consoleHeader));
- buf.append(System.getProperty("line.separator", "\n")); //$NON-NLS-1$ //$NON-NLS-2$
- consoleOutStream.write(buf.toString().getBytes());
- consoleOutStream.flush();
- buf = new StringBuffer();
- int result = sBuilder.build(consoleOutStream, consoleOutStream, monitor);
- //Throw a core exception indicating that the clean command failed
- if(result == IBuildModelBuilder.STATUS_ERROR_LAUNCH)
- {
- try {
- consoleOutStream.close();
- } catch (IOException e) {
- }
- Status status = new Status(IStatus.INFO, ManagedBuilderCorePlugin.getUniqueIdentifier(),
- "Failed to exec delete command"); //$NON-NLS-1$
- throw new CoreException(status);
+ if (monitor == null) {
+ monitor = new NullProgressMonitor();
}
- // Report a successful clean
- String successMsg = ManagedMakeMessages.getFormattedString(BUILD_FINISHED, curProject.getName());
- buf.append(successMsg);
- buf.append(System.getProperty("line.separator", "\n")); //$NON-NLS-1$//$NON-NLS-2$
- consoleOutStream.write(buf.toString().getBytes());
- consoleOutStream.flush();
- consoleOutStream.close();
- curProject.refreshLocal(IResource.DEPTH_INFINITE, null);
- } catch (IOException io) {} // Ignore console failures...
+ monitor.beginTask("", 2 * MONITOR_SCALE); //$NON-NLS-1$
+
+ IConsole console = bInfo.getConsole();
+
+ IBuilder builder = bInfo.getBuilder();
+ String[] errorParsers = builder.getErrorParsers();
+ URI workingDirectoryURI = ManagedBuildManager.getBuildLocationURI(configuration, builder);
+ ErrorParserManager epm = new ErrorParserManager(project, workingDirectoryURI, this, errorParsers);
+
+ buildRunnerHelper.prepareStreams(epm, null, console, new SubProgressMonitor(monitor, 1 * MONITOR_SCALE));
+ OutputStream stdout = buildRunnerHelper.getOutputStream();
+ OutputStream stderr = buildRunnerHelper.getErrorStream();
+
+ String cfgName = configuration.getName();
+ String toolchainName = configuration.getToolChain().getName();
+ boolean isConfigurationSupported = configuration.isSupported();
+
+ buildRunnerHelper.greeting(CLEAN_BUILD, cfgName, toolchainName, isConfigurationSupported);
+ int status = sBuilder.build(stdout, stderr, new SubProgressMonitor(monitor, 1 * MONITOR_SCALE));
+ buildRunnerHelper.close();
+ buildRunnerHelper.goodbye();
+
+ if (status != ICommandLauncher.ILLEGAL_COMMAND) {
+ buildRunnerHelper.refreshProject(monitor);
+ }
+
+ //Throw a core exception indicating that the clean command failed
+ if(status == IBuildModelBuilder.STATUS_ERROR_LAUNCH)
+ {
+ Status st = new Status(IStatus.INFO, ManagedBuilderCorePlugin.PLUGIN_ID, "Failed to execute delete command"); //$NON-NLS-1$
+ throw new CoreException(st);
+ }
+ } catch (Exception e) {
+ String msg = ManagedMakeMessages.getFormattedString("ManagedMakeBuilder.message.error.build", //$NON-NLS-1$
+ new String[] { project.getName(), configuration.getName() });
+ throw new CoreException(new Status(IStatus.ERROR, ManagedBuilderCorePlugin.PLUGIN_ID, msg, e));
+ } finally {
+ try {
+ buildRunnerHelper.close();
+ } catch (IOException e) {
+ ManagedBuilderCorePlugin.log(e);
+ }
+ monitor.done();
+ }
}
protected void cleanProgrammatically(CfgBuildInfo bInfo, IProgressMonitor monitor) throws CoreException {
// referencedProjects = getProject().getReferencedProjects();
- IProject curProject = bInfo.getProject();
- outputTrace(curProject.getName(), "Clean build requested"); //$NON-NLS-1$
+ IProject project = bInfo.getProject();
+ outputTrace(project.getName(), "Clean build requested"); //$NON-NLS-1$
IBuilder builder = bInfo.getBuilder();
- IConfiguration cfg = bInfo.getConfiguration();
- IPath buildPath = ManagedBuildManager.getBuildFullPath(cfg, builder);
+ IConfiguration configuration = bInfo.getConfiguration();
+ IPath buildPath = ManagedBuildManager.getBuildFullPath(configuration, builder);
if(buildPath == null){
throw new CoreException(new Status(IStatus.ERROR,
ManagedBuilderCorePlugin.getUniqueIdentifier(),
ManagedMakeMessages.getResourceString("CommonBuilder.0"))); //$NON-NLS-1$
}
- IPath projectFullPath = curProject.getFullPath();
+ IPath projectFullPath = project.getFullPath();
if(!projectFullPath.isPrefixOf(buildPath)){
throw new CoreException(new Status(IStatus.ERROR,
ManagedBuilderCorePlugin.getUniqueIdentifier(),
@@ -1255,37 +1266,47 @@ public class CommonBuilder extends ACBuilder {
ManagedBuilderCorePlugin.getUniqueIdentifier(),
ManagedMakeMessages.getResourceString("CommonBuilder.13"))); //$NON-NLS-1$
}
- String status;
- try {
- // try the brute force approach first
- status = ManagedMakeMessages.getFormattedString("ManagedMakeBuilder.message.clean.deleting.output", buildDir.getName()); //$NON-NLS-1$
- monitor.subTask(status);
- workspace.delete(new IResource[]{buildDir}, true, monitor);
- StringBuffer buf = new StringBuffer();
- // write to the console
-//
-// IConsole console = CCorePlugin.getDefault().getConsole();
-// console.start(getProject());
- IConsole console = bInfo.getConsole();
- ConsoleOutputStream consoleOutStream = console.getOutputStream();
- String[] consoleHeader = new String[3];
- consoleHeader[0] = ManagedMakeMessages.getResourceString(TYPE_CLEAN);
- consoleHeader[1] = cfg.getName();
- consoleHeader[2] = curProject.getName();
- buf.append(System.getProperty("line.separator", "\n")); //$NON-NLS-1$ //$NON-NLS-2$
- buf.append(ManagedMakeMessages.getFormattedString(CONSOLE_HEADER, consoleHeader));
- buf.append(System.getProperty("line.separator", "\n")); //$NON-NLS-1$ //$NON-NLS-2$
- consoleOutStream.write(buf.toString().getBytes());
- consoleOutStream.flush();
- buf = new StringBuffer();
- // Report a successful clean
- String successMsg = ManagedMakeMessages.getFormattedString(BUILD_FINISHED, curProject.getName());
- buf.append(successMsg);
- buf.append(System.getProperty("line.separator", "\n")); //$NON-NLS-1$//$NON-NLS-2$
- consoleOutStream.write(buf.toString().getBytes());
- consoleOutStream.flush();
- consoleOutStream.close();
- } catch (IOException io) {} // Ignore console failures...
+
+ BuildRunnerHelper buildRunnerHelper = new BuildRunnerHelper(project);
+ try {
+ if (monitor == null) {
+ monitor = new NullProgressMonitor();
+ }
+ monitor.beginTask("", 2 * MONITOR_SCALE); //$NON-NLS-1$
+
+ // try the brute force approach first
+ String status = ManagedMakeMessages.getFormattedString("ManagedMakeBuilder.message.clean.deleting.output", buildDir.getName()); //$NON-NLS-1$
+ monitor.subTask(status);
+
+ IConsole console = bInfo.getConsole();
+
+ String[] errorParsers = builder.getErrorParsers();
+ URI workingDirectoryURI = ManagedBuildManager.getBuildLocationURI(configuration, builder);
+ ErrorParserManager epm = new ErrorParserManager(project, workingDirectoryURI, this, errorParsers);
+
+ buildRunnerHelper.prepareStreams(epm, null, console, new SubProgressMonitor(monitor, 1 * MONITOR_SCALE));
+
+ String cfgName = configuration.getName();
+ String toolchainName = configuration.getToolChain().getName();
+ boolean isConfigurationSupported = configuration.isSupported();
+
+ buildRunnerHelper.greeting(CLEAN_BUILD, cfgName, toolchainName, isConfigurationSupported);
+ workspace.delete(new IResource[]{buildDir}, true, new SubProgressMonitor(monitor, 1 * MONITOR_SCALE));
+ buildRunnerHelper.close();
+ buildRunnerHelper.goodbye();
+
+ } catch (Exception e) {
+ String msg = ManagedMakeMessages.getFormattedString("ManagedMakeBuilder.message.error.build", //$NON-NLS-1$
+ new String[] { project.getName(), configuration.getName() });
+ throw new CoreException(new Status(IStatus.ERROR, ManagedBuilderCorePlugin.PLUGIN_ID, msg, e));
+ } finally {
+ try {
+ buildRunnerHelper.close();
+ } catch (IOException e) {
+ ManagedBuilderCorePlugin.log(e);
+ }
+ monitor.done();
+ }
}
}
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 1650ca25c24..6c55b220bee 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
@@ -15,6 +15,7 @@ import java.io.OutputStream;
import java.net.URI;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
@@ -31,6 +32,7 @@ import org.eclipse.cdt.core.model.ICModelMarker;
import org.eclipse.cdt.core.resources.ACBuilder;
import org.eclipse.cdt.core.resources.IConsole;
import org.eclipse.cdt.core.resources.RefreshScopeManager;
+import org.eclipse.cdt.internal.core.BuildRunnerHelper;
import org.eclipse.cdt.managedbuilder.buildmodel.BuildDescriptionManager;
import org.eclipse.cdt.managedbuilder.buildmodel.IBuildDescription;
import org.eclipse.cdt.managedbuilder.buildmodel.IBuildIOType;
@@ -307,6 +309,7 @@ public class GeneratedMakefileBuilder extends ACBuilder {
private static final String INTERNAL_BUILDER_HEADER_NOTE = "ManagedMakeBuilder.message.internal.builder.header.note"; //$NON-NLS-1$
private static final String TYPE_REBUILD = "ManagedMakeBuider.type.rebuild"; //$NON-NLS-1$
private static final String INTERNAL_BUILDER = "ManagedMakeBuilder.message.internal.builder"; //$NON-NLS-1$
+ private static final int MONITOR_SCALE = 100;
public static boolean VERBOSE = false;
// Local variables
@@ -314,7 +317,6 @@ public class GeneratedMakefileBuilder extends ACBuilder {
protected IProject[] referencedProjects;
protected List resourcesToBuild;
private IConsole console;
- private ConsoleOutputStream consoleOutStream;
public static void outputTrace(String resourceName, String message) {
if (VERBOSE) {
System.out.println(TRACE_HEADER + resourceName + TRACE_FOOTER + message + NEWLINE);
@@ -864,7 +866,7 @@ public class GeneratedMakefileBuilder extends ACBuilder {
*/
protected void invokeMake(int buildType, IPath buildDir, IManagedBuildInfo info, IManagedBuilderMakefileGenerator generator, IProgressMonitor monitor) {
// Get the project and make sure there's a monitor to cancel the build
- IProject currentProject = getProject();
+ IProject project = getProject();
if (monitor == null) {
monitor = new NullProgressMonitor();
}
@@ -879,7 +881,7 @@ public class GeneratedMakefileBuilder extends ACBuilder {
IPath workingDirectory = new Path(pathFromURI);
- IWorkspace workspace = currentProject.getWorkspace();
+ IWorkspace workspace = project.getWorkspace();
if (workspace == null) {
return;
}
@@ -910,13 +912,13 @@ public class GeneratedMakefileBuilder extends ACBuilder {
IPath makeCommand = new Path(makeCmd);
String[] msgs = new String[2];
msgs[0] = makeCommand.toString();
- msgs[1] = currentProject.getName();
+ msgs[1] = project.getName();
monitor.subTask(ManagedMakeMessages.getFormattedString(MAKE, msgs));
// Get a build console for the project
StringBuffer buf = new StringBuffer();
IConsole console = CCorePlugin.getDefault().getConsole();
- console.start(currentProject);
+ console.start(project);
ConsoleOutputStream consoleOutStream = console.getOutputStream();
String[] consoleHeader = new String[3];
switch (buildType) {
@@ -930,7 +932,7 @@ public class GeneratedMakefileBuilder extends ACBuilder {
}
consoleHeader[1] = info.getConfigurationName();
- consoleHeader[2] = currentProject.getName();
+ consoleHeader[2] = project.getName();
buf.append(NEWLINE);
buf.append(ManagedMakeMessages.getFormattedString(CONSOLE_HEADER, consoleHeader)).append(NEWLINE);
buf.append(NEWLINE);
@@ -945,24 +947,24 @@ public class GeneratedMakefileBuilder extends ACBuilder {
consoleOutStream.flush();
// Remove all markers for this project
- removeAllMarkers(currentProject);
+ removeAllMarkers(project);
// Get a launcher for the make command
String errMsg = null;
IBuilder builder = info.getDefaultConfiguration().getBuilder();
ICommandLauncher launcher = builder.getCommandLauncher();
- launcher.setProject(currentProject);
+ launcher.setProject(project);
launcher.showCommand(true);
// Set the environmennt
IBuildEnvironmentVariable variables[] = ManagedBuildManager.getEnvironmentVariableProvider().getVariables(cfg,true,true);
- String[] env = null;
+ String[] envp = null;
ArrayList envList = new ArrayList();
if (variables != null) {
for(int i = 0; i < variables.length; i++){
envList.add(variables[i].getName() + "=" + variables[i].getValue()); //$NON-NLS-1$
}
- env = envList.toArray(new String[envList.size()]);
+ envp = envList.toArray(new String[envList.size()]);
}
// Hook up an error parser manager
@@ -1014,7 +1016,7 @@ public class GeneratedMakefileBuilder extends ACBuilder {
premakeArgs.add("-q"); //$NON-NLS-1$
premakeArgs.add("main-build"); //$NON-NLS-1$
premakeTargets = premakeArgs.toArray(new String[premakeArgs.size()]);
- proc = launcher.execute(makeCommand, premakeTargets, env, workingDirectory, monitor);
+ proc = launcher.execute(makeCommand, premakeTargets, envp, workingDirectory, monitor);
if (proc != null) {
try {
// Close the input of the process since we will never write to it
@@ -1041,7 +1043,7 @@ public class GeneratedMakefileBuilder extends ACBuilder {
// If the status value returned from "make -q" is 0, then the build state is up-to-date
isuptodate = true;
// Report that the build was up to date, and thus nothing needs to be built
- String uptodateMsg = ManagedMakeMessages.getFormattedString(NOTHING_BUILT, currentProject.getName());
+ String uptodateMsg = ManagedMakeMessages.getFormattedString(NOTHING_BUILT, project.getName());
buf = new StringBuffer();
buf.append(NEWLINE);
buf.append(uptodateMsg).append(NEWLINE);
@@ -1080,7 +1082,7 @@ public class GeneratedMakefileBuilder extends ACBuilder {
// Launch make - main invocation
if (!isuptodate) {
- proc = launcher.execute(makeCommand, makeTargets, env, workingDirectory, monitor);
+ proc = launcher.execute(makeCommand, makeTargets, envp, workingDirectory, monitor);
if (proc != null) {
try {
// Close the input of the process since we will never write to it
@@ -1112,7 +1114,7 @@ public class GeneratedMakefileBuilder extends ACBuilder {
// use the refresh scope manager to refresh
RefreshScopeManager refreshManager = RefreshScopeManager.getInstance();
- IWorkspaceRunnable runnable = refreshManager.getRefreshRunnable(currentProject);
+ IWorkspaceRunnable runnable = refreshManager.getRefreshRunnable(project);
ResourcesPlugin.getWorkspace().run(runnable, null, IWorkspace.AVOID_UPDATE, null);
} catch (CoreException e) {
monitor.subTask(ManagedMakeMessages
@@ -1129,7 +1131,7 @@ public class GeneratedMakefileBuilder extends ACBuilder {
} else {
// Report a successful build
String successMsg = ManagedMakeMessages.getFormattedString(BUILD_FINISHED,
- currentProject.getName());
+ project.getName());
buf.append(successMsg).append(NEWLINE);
}
@@ -1367,330 +1369,280 @@ public class GeneratedMakefileBuilder extends ACBuilder {
}
}
- /**
- * Called to invoke the MBS Internal Builder for building the given resources in
- * the given configuration
- *
- * This method is considered experimental. Clients implementing this API should expect
- * possible changes in the API.
- *
- * @param resourcesToBuild resources to be built
- * @param cfg configuration to be built
- * @param buildIncrementaly if true, incremental build will be performed,
- * only files that need rebuild will be built.
- * If false, full rebuild will be performed
- * @param resumeOnErr if true, build will continue in case of error while building.
- * If false the build will stop on the first error
- * @param monitor Progress monitor. For every resource built this monitor will consume one unit of work.
- */
- public void invokeInternalBuilder(IResource[] resourcesToBuild, IConfiguration cfg,
- boolean buildIncrementaly,
- boolean resumeOnErr,
- boolean initNewConsole,
- boolean printFinishedMessage,
- IProgressMonitor monitor) {
+ private Map> arrangeFilesByProject(List files) {
+ Map> projectMap = new HashMap>();
+ for (IFile file : files) {
+ IProject project = file.getProject();
+ List filesInProject = projectMap.get(project);
+ if (filesInProject == null) {
+ filesInProject = new ArrayList();
+ projectMap.put(project, filesInProject);
+ }
+ filesInProject.add(file);
+ }
+ return projectMap;
+ }
- OutputStream epmOutputStream = null;
- // Get the project and make sure there's a monitor to cancel the build
- IProject currentProject = cfg.getOwner().getProject();
+ /**
+ * Called to invoke the MBS Internal Builder for building the given resources
+ *
+ * @param files - list of files to build.
+ * @param monitor - progress monitor to report progress to user.
+ * @return status of the operation. Can be {@link Status#OK_STATUS} or
+ * {@link Status#CANCEL_STATUS}.
+ */
+ public IStatus invokeInternalBuilder(List files, IProgressMonitor monitor) {
+ // Make sure there's a monitor to cancel the build
if (monitor == null) {
monitor = new NullProgressMonitor();
}
try {
- int flags = 0;
- IResourceDelta delta = null;
+ Map> projectMap = arrangeFilesByProject(files);
+ monitor.beginTask("", projectMap.size() * MONITOR_SCALE); //$NON-NLS-1$
- if(buildIncrementaly){
- flags = BuildDescriptionManager.REBUILD | BuildDescriptionManager.REMOVED | BuildDescriptionManager.DEPS;
- delta = getDelta(currentProject);
+ for (List filesInProject : projectMap.values()) {
+ IProject project = filesInProject.get(0).getProject();
+ monitor.subTask(ManagedMakeMessages.getFormattedString("GeneratedMakefileBuilder.buildingProject", project.getName())); //$NON-NLS-1$
+ invokeInternalBuilderForOneProject(filesInProject, new SubProgressMonitor(monitor, 1 * MONITOR_SCALE, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK));
}
+ } finally {
+ if (monitor.isCanceled()) {
+ return Status.CANCEL_STATUS;
+ }
+ monitor.done();
+ }
+ return Status.OK_STATUS;
+ }
+ private void invokeInternalBuilderForOneProject(List files, IProgressMonitor monitor) {
+ IProject project = files.get(0).getProject();
+ BuildRunnerHelper buildRunnerHelper = new BuildRunnerHelper(project);
- String[] msgs = new String[2];
- msgs[0] = ManagedMakeMessages.getResourceString(INTERNAL_BUILDER);
- msgs[1] = currentProject.getName();
+ try {
+ monitor.beginTask(ManagedMakeMessages.getFormattedString("GeneratedMakefileBuilder.buildingProject", project.getName()) + ':', files.size() * MONITOR_SCALE); //$NON-NLS-1$
- if(initNewConsole)
- initNewBuildConsole(currentProject);
+ // Get a build console for the project
+ console = CCorePlugin.getDefault().getConsole();
+ console.start(project);
- StringBuffer buf = new StringBuffer();
+ IManagedBuildInfo buildInfo = ManagedBuildManager.getBuildInfo(project);
+ IConfiguration configuration = buildInfo.getDefaultConfiguration();
- if (initNewConsole) {
- String msg;
- if (buildIncrementaly) {
- msg = ManagedMakeMessages.getResourceString("GeneratedMakefileBuilder.buildSelectedIncremental"); //$NON-NLS-1$
- } else {
- msg = ManagedMakeMessages.getResourceString("GeneratedMakefileBuilder.buildSelectedRebuild"); //$NON-NLS-1$
+ String cfgName = configuration.getName();
+ String toolchainName = configuration.getToolChain().getName();
+ boolean isSupported = configuration.isSupported();
+
+ IBuildDescription des = BuildDescriptionManager.createBuildDescription(configuration, null, 0);
+
+ String[] errorParsers = configuration.getErrorParserList();
+ ErrorParserManager epm = new ErrorParserManager(project, des.getDefaultBuildDirLocationURI(), this, errorParsers);
+
+ buildRunnerHelper.prepareStreams(epm, null, console, new SubProgressMonitor(monitor, 1 * MONITOR_SCALE));
+ OutputStream stdout = buildRunnerHelper.getOutputStream();
+ OutputStream stderr = buildRunnerHelper.getErrorStream();
+
+ buildRunnerHelper.greeting(ManagedMakeMessages.getResourceString("BuildFilesAction.buildingSelectedFiles"), cfgName, toolchainName, isSupported); //$NON-NLS-1$
+ buildRunnerHelper.printLine(ManagedMakeMessages.getResourceString("ManagedMakeBuilder.message.internal.builder.header.note")); //$NON-NLS-1$
+
+ // Build artifacts for each file in the project
+ for (IFile file : files) {
+ if (monitor.isCanceled()) {
+ break;
}
-
- buf.append(msg).append(NEWLINE);
- buf.append(NEWLINE);
-
- buf.append(ManagedMakeMessages.getResourceString(INTERNAL_BUILDER_HEADER_NOTE)).append(NEWLINE);
- }
-
- if(!cfg.isSupported()){
- String msg = ManagedMakeMessages.getFormattedString(WARNING_UNSUPPORTED_CONFIGURATION,new String[] {cfg.getName(),cfg.getToolChain().getName()});
- buf.append(msg).append(NEWLINE);
- buf.append(NEWLINE);
- }
- consoleOutStream.write(buf.toString().getBytes());
- consoleOutStream.flush();
-
- // Remove all markers for this project
- // TODO remove only necessary markers
- removeAllMarkers(currentProject);
-
- IBuildDescription des = BuildDescriptionManager.createBuildDescription(cfg, delta, flags);
-
- // Hook up an error parser manager
- String[] errorParsers = cfg.getErrorParserList();
- ErrorParserManager epm = new ErrorParserManager(currentProject, des.getDefaultBuildDirLocationURI(), this, errorParsers);
- epm.setOutputStream(consoleOutStream);
- // This variable is necessary to ensure that the EPM stream stay open
- // until we explicitly close it. See bug#123302.
- epmOutputStream = epm.getOutputStream();
-
- boolean errorsFound = false;
-
- doneBuild: for (int k = 0; k < resourcesToBuild.length; k++) {
- IBuildResource buildResource = des
- .getBuildResource(resourcesToBuild[k]);
-
-// step collector
- Set dependentSteps = new HashSet();
-
-// get dependent IO types
- IBuildIOType depTypes[] = buildResource.getDependentIOTypes();
-
-// iterate through each type and add the step the type belongs to to the collector
- for(int j = 0; j < depTypes.length; j++){
- IBuildIOType type = depTypes[j];
- if(type != null && type.getStep() != null)
- dependentSteps.add(type.getStep());
- }
-
- monitor.subTask(ManagedMakeMessages.getResourceString("GeneratedMakefileBuilder.buildingFile") + resourcesToBuild[k].getProjectRelativePath()); //$NON-NLS-1$
-
- // iterate through all build steps
- Iterator stepIter = dependentSteps.iterator();
-
- while(stepIter.hasNext())
- {
- IBuildStep step = stepIter.next();
-
- StepBuilder stepBuilder = new StepBuilder(step, null);
-
- int status = stepBuilder.build(epmOutputStream, epmOutputStream, new SubProgressMonitor(monitor, 1, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK));
-
- // Refresh the output resource without allowing the user to cancel.
- // This is probably unkind, but short of this there is no way to ensure
- // the UI is up-to-date with the build results
- IBuildIOType[] outputIOTypes = step.getOutputIOTypes();
-
- for(int j = 0; j < outputIOTypes.length; j++ )
- {
- IBuildResource[] resources = outputIOTypes[j].getResources();
-
- for(int i = 0; i < resources.length; i++)
- {
- IFile file = currentProject.getFile(resources[i].getLocation());
- file.refreshLocal(IResource.DEPTH_INFINITE, null);
- }
- }
-
- // check status
-
- switch (status) {
- case IBuildModelBuilder.STATUS_OK:
- // don't print anything if the step was successful,
- // since the build might not be done as a whole
- break;
- case IBuildModelBuilder.STATUS_CANCELLED:
- buf.append(ManagedMakeMessages
- .getResourceString(BUILD_CANCELLED));
- break doneBuild;
- case IBuildModelBuilder.STATUS_ERROR_BUILD:
- errorsFound = true;
- if (!resumeOnErr) {
- buf.append(ManagedMakeMessages
- .getResourceString(BUILD_STOPPED_ERR));
- break doneBuild;
- }
- break;
- case IBuildModelBuilder.STATUS_ERROR_LAUNCH:
- default:
- buf.append(ManagedMakeMessages
- .getResourceString(BUILD_FAILED_ERR));
- break doneBuild;
- }
- }
-
-
- }
-
- // check status
- // Report either the success or failure of our mission
- buf = new StringBuffer();
-
- buf.append(NEWLINE);
-
- if (printFinishedMessage) {
- if (errorsFound) {
- buf.append(ManagedMakeMessages.getResourceString(BUILD_FAILED_ERR));
- } else {
- buf.append(ManagedMakeMessages.getResourceString("GeneratedMakefileBuilder.buildResourcesFinished")); //$NON-NLS-1$
- }
- }
-
- // Write message on the console
- consoleOutStream.write(buf.toString().getBytes());
- consoleOutStream.flush();
-
- // Generate any error markers that the build has discovered
- addBuilderMarkers(epm);
- } catch (Exception e) {
- if(consoleOutStream != null){
- StringBuffer buf = new StringBuffer();
- String errorDesc = ManagedMakeMessages.getResourceString(BUILD_ERROR);
- buf.append(errorDesc).append(NEWLINE);
- buf.append("(").append(e.getLocalizedMessage()).append(")").append(NEWLINE); //$NON-NLS-1$ //$NON-NLS-2$
+ String filePath = file.getProjectRelativePath().toString();
try {
- consoleOutStream.write(buf.toString().getBytes());
- consoleOutStream.flush();
- } catch (IOException e1) {
+ IBuildResource buildResource = des.getBuildResource(file);
+
+ Set dependentSteps = new HashSet();
+ IBuildIOType depTypes[] = buildResource.getDependentIOTypes();
+ for (IBuildIOType btype : depTypes) {
+ if(btype != null && btype.getStep() != null)
+ dependentSteps.add(btype.getStep());
+ }
+
+ SubProgressMonitor monitor2 = new SubProgressMonitor(monitor, 1 * MONITOR_SCALE, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK);
+ try {
+ monitor2.beginTask("", (1 + dependentSteps.size()) * MONITOR_SCALE); //$NON-NLS-1$
+
+ // Remove problem markers for the file
+ monitor2.subTask(ManagedMakeMessages.getFormattedString("GeneratedMakefileBuilder.removingResourceMarkers", filePath)); //$NON-NLS-1$
+ buildRunnerHelper.removeOldMarkers(file, new SubProgressMonitor(monitor2, 1 * MONITOR_SCALE, SubProgressMonitor.SUPPRESS_SUBTASK_LABEL));
+
+ // Build dependent steps
+ for (IBuildStep step : dependentSteps) {
+ if (monitor2.isCanceled()) {
+ break;
+ }
+
+ monitor2.subTask(filePath);
+ StepBuilder stepBuilder = new StepBuilder(step, null);
+ stepBuilder.build(stdout, stderr, new SubProgressMonitor(monitor2, 1 * MONITOR_SCALE, SubProgressMonitor.SUPPRESS_SUBTASK_LABEL));
+
+ monitor2.subTask(ManagedMakeMessages.getFormattedString("GeneratedMakefileBuilder.refreshingArtifacts", filePath)); //$NON-NLS-1$
+ IBuildIOType[] outputIOTypes = step.getOutputIOTypes();
+ for (IBuildIOType type : outputIOTypes) {
+ for (IBuildResource outResource : type.getResources()) {
+ IFile outFile = project.getFile(outResource.getLocation());
+ // Refresh the output resource without allowing the user to cancel.
+ outFile.refreshLocal(IResource.DEPTH_INFINITE, null);
+ }
+ }
+ }
+ } finally {
+ monitor2.done();
+ }
+
+ } catch (Exception e) {
+ ManagedBuilderCorePlugin.log(new CoreException(new Status(IStatus.ERROR, ManagedBuilderCorePlugin.PLUGIN_ID, "CDT Build Error", e))); //$NON-NLS-1$
}
+
}
+ buildRunnerHelper.close();
+ buildRunnerHelper.goodbye();
+
+ } catch (Exception e) {
+ ManagedBuilderCorePlugin.log(new CoreException(new Status(IStatus.ERROR, ManagedBuilderCorePlugin.PLUGIN_ID, "CDT Build Error", e))); //$NON-NLS-1$
forgetLastBuiltState();
} finally {
- if(epmOutputStream != null){
- try {
- epmOutputStream.close();
- } catch (IOException e) {
- }
- }
- if(consoleOutStream != null){
- try {
- consoleOutStream.close();
- } catch (IOException e) {
- }
- }
getGenerationProblems().clear();
+ try {
+ buildRunnerHelper.close();
+ } catch (IOException e) {
+ ManagedBuilderCorePlugin.log(new CoreException(new Status(IStatus.ERROR, ManagedBuilderCorePlugin.PLUGIN_ID, "CDT Build Error", e))); //$NON-NLS-1$
+ }
monitor.done();
}
}
- private void removeAllMarkers(IFile file) {
- IMarker[] markers;
+ public IStatus cleanFiles(List files, IProgressMonitor monitor) {
+ // Make sure there's a monitor to cancel the build
+ if (monitor == null) {
+ monitor = new NullProgressMonitor();
+ }
+
try {
- markers = file.findMarkers(
- ICModelMarker.C_MODEL_PROBLEM_MARKER, true,
- IResource.DEPTH_INFINITE);
- } catch (CoreException e) {
- // Handled just about every case in the sanity check
- return;
- }
- if (markers != null) {
- try {
- file.getWorkspace().deleteMarkers(markers);
- } catch (CoreException e) {
- // The only situation that might cause this is some sort of
- // resource change event
- return;
+ Map> projectMap = arrangeFilesByProject(files);
+ monitor.beginTask("", projectMap.size() * MONITOR_SCALE); //$NON-NLS-1$
+
+ for (List filesInProject : projectMap.values()) {
+ IProject project = filesInProject.get(0).getProject();
+ monitor.subTask(ManagedMakeMessages.getFormattedString("GeneratedMakefileBuilder.cleaningProject", project.getName())); //$NON-NLS-1$
+ cleanFilesForOneProject(filesInProject, new SubProgressMonitor(monitor, 1 * MONITOR_SCALE, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK));
}
+ } finally {
+ if (monitor.isCanceled()) {
+ return Status.CANCEL_STATUS;
+ }
+ monitor.done();
}
+ return Status.OK_STATUS;
}
- public void cleanFile(IFile file, IProgressMonitor monitor) {
-
- monitor.subTask(ManagedMakeMessages.getResourceString("GeneratedMakefileBuilder.0") //$NON-NLS-1$
- + file.getProjectRelativePath());
-
- // remove all markers on the file
- removeAllMarkers(file);
-
- IProject currentProject = file.getProject();
-
- IManagedBuildInfo info = ManagedBuildManager
- .getBuildInfo(currentProject);
-
- // if we have no info then don't do anything
- if (info == null) {
- // monitor.worked(1);
- return;
-
- }
-
- IConfiguration cfg = info.getDefaultConfiguration();
-
- // figure out the output file for this file
-// IPath sourcePath = file.getProjectRelativePath();
-
- int flags = BuildDescriptionManager.REBUILD | BuildDescriptionManager.REMOVED;
- IResourceDelta delta = getDelta(currentProject);
+ public void cleanFilesForOneProject(List files, IProgressMonitor monitor) {
+ IProject project = files.get(0).getProject();
+ BuildRunnerHelper buildRunnerHelper = new BuildRunnerHelper(project);
+ int countDeleted = 0;
try {
- IBuildDescription des = BuildDescriptionManager
- .createBuildDescription(cfg, delta, flags);
+ monitor.beginTask(ManagedMakeMessages.getFormattedString("GeneratedMakefileBuilder.cleaningProject", project.getName()) + ':', files.size() * MONITOR_SCALE); //$NON-NLS-1$
- IBuildResource buildResource = des.getBuildResource(file);
+ // Get a build console for the project
+ console = CCorePlugin.getDefault().getConsole();
+ console.start(project);
+ IManagedBuildInfo buildInfo = ManagedBuildManager.getBuildInfo(project);
+ IConfiguration configuration = buildInfo.getDefaultConfiguration();
- if (buildResource != null) {
+ String cfgName = configuration.getName();
+ String toolchainName = configuration.getToolChain().getName();
+ boolean isSupported = configuration.isSupported();
- // step collector
- Set dependentSteps = new HashSet();
+ int flags = BuildDescriptionManager.REBUILD | BuildDescriptionManager.REMOVED;
+ IResourceDelta delta = getDelta(project);
- // get dependent IO types
- IBuildIOType depTypes[] = buildResource.getDependentIOTypes();
+ IBuildDescription des = BuildDescriptionManager.createBuildDescription(configuration, delta, flags);
- // iterate through each type and add the step the type belongs
- // to to
- // the collector
- for (int j = 0; j < depTypes.length; j++) {
- IBuildIOType type = depTypes[j];
- if (type != null && type.getStep() != null)
- dependentSteps.add(type.getStep());
+ String[] errorParsers = configuration.getErrorParserList();
+ ErrorParserManager epm = new ErrorParserManager(project, des.getDefaultBuildDirLocationURI(), this, errorParsers);
+ buildRunnerHelper.prepareStreams(epm, null , console, new SubProgressMonitor(monitor, 1 * MONITOR_SCALE));
+
+ buildRunnerHelper.greeting(ManagedMakeMessages.getResourceString("CleanFilesAction.cleanSelectedFiles"), cfgName, toolchainName, isSupported); //$NON-NLS-1$
+ buildRunnerHelper.printLine(ManagedMakeMessages.getResourceString("ManagedMakeBuilder.message.internal.builder.header.note")); //$NON-NLS-1$
+
+ for (IFile file : files) {
+ if (monitor.isCanceled()) {
+ break;
}
+ String filePath = file.getProjectRelativePath().toString();
- // iterate through all build steps
- Iterator stepIter = dependentSteps.iterator();
+ try {
+ IBuildResource buildResource = des.getBuildResource(file);
+ if (buildResource != null) {
+ Set dependentSteps = new HashSet();
+ IBuildIOType depTypes[] = buildResource.getDependentIOTypes();
+ for (IBuildIOType btype : depTypes) {
+ if (btype != null && btype.getStep() != null)
+ dependentSteps.add(btype.getStep());
+ }
- while (stepIter.hasNext()) {
- IBuildStep step = stepIter.next();
+ SubProgressMonitor monitor2 = new SubProgressMonitor(monitor, 1 * MONITOR_SCALE, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK);
+ try {
+ monitor2.beginTask("", (1 + dependentSteps.size()) * MONITOR_SCALE); //$NON-NLS-1$
- // Delete the output resources
- IBuildIOType[] outputIOTypes = step.getOutputIOTypes();
+ // Remove problem markers for the file
+ monitor2.subTask(ManagedMakeMessages.getFormattedString("GeneratedMakefileBuilder.removingResourceMarkers", filePath)); //$NON-NLS-1$
+ buildRunnerHelper.removeOldMarkers(file, new SubProgressMonitor(monitor2, 1 * MONITOR_SCALE, SubProgressMonitor.SUPPRESS_SUBTASK_LABEL));
- for (int j = 0; j < outputIOTypes.length; j++) {
- IBuildResource[] resources = outputIOTypes[j].getResources();
+ // iterate through all build steps
+ for (IBuildStep step : dependentSteps) {
+ if (monitor2.isCanceled()) {
+ break;
+ }
- for (int i = 0; i < resources.length; i++) {
- IResource outputFile = currentProject.findMember(resources[i]
- .getFullPath().removeFirstSegments(1)); // strip project name
+ monitor2.subTask(filePath);
+ // Delete the output resources
+ IBuildIOType[] outputIOTypes = step.getOutputIOTypes();
- if (outputFile != null)
- outputFile.delete(true, new SubProgressMonitor(monitor, 1));
+ for (IBuildIOType ioType : outputIOTypes) {
+ for (IBuildResource rc : ioType.getResources()) {
+ IResource outputFile = project.findMember(rc.getFullPath().removeFirstSegments(1)); // strip project name
+ if (outputFile != null) {
+ outputFile.delete(true, null);
+ countDeleted++;
+ buildRunnerHelper.printLine(ManagedMakeMessages.getFormattedString("GeneratedMakefileBuilder.fileDeleted", //$NON-NLS-1$
+ outputFile.getProjectRelativePath().toString()));
+ }
+ }
+ }
+
+ monitor2.worked(1 * MONITOR_SCALE);
+ }
+ } finally {
+ monitor2.done();
}
}
-
+ } catch (Exception e) {
+ ManagedBuilderCorePlugin.log(new CoreException(new Status(IStatus.ERROR, ManagedBuilderCorePlugin.PLUGIN_ID, "CDT Build Error", e))); //$NON-NLS-1$
}
+
}
+ if (countDeleted == 0) {
+ buildRunnerHelper.printLine(ManagedMakeMessages.getResourceString("GeneratedMakefileBuilder.nothingToClean")); //$NON-NLS-1$
+ }
+ buildRunnerHelper.close();
+ buildRunnerHelper.goodbye();
- } catch (CoreException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
+ } catch (Exception e) {
+ ManagedBuilderCorePlugin.log(new CoreException(new Status(IStatus.ERROR, ManagedBuilderCorePlugin.PLUGIN_ID, "CDT Build Error", e))); //$NON-NLS-1$
+ } finally {
+ try {
+ buildRunnerHelper.close();
+ } catch (IOException e) {
+ ManagedBuilderCorePlugin.log(new CoreException(new Status(IStatus.ERROR, ManagedBuilderCorePlugin.PLUGIN_ID, "CDT Build Error", e))); //$NON-NLS-1$
+ }
+ monitor.done();
}
-
- }
-
-
- private void initNewBuildConsole(IProject currentProject) throws CoreException {
- // Get a build console for the project
- console = CCorePlugin.getDefault().getConsole();
- console.start(currentProject);
- consoleOutStream = console.getOutputStream();
}
}
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 abadc94b1c7..83ee8b40fa1 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
@@ -21,10 +21,11 @@ ManagedMakeBuilder.message.regen.deps = Regenerating dependency files for {0}
ManagedMakeBuilder.message.updating.deps = Updating dependency files for {0}
ManagedMakeBuilder.message.creating.markers = Generating markers...
ManagedMakeBuilder.message.console.header = **** {0} of configuration {1} for project {2} ****
-ManagedMakeBuilder.message.internal.builder.header.note = **** Internal Builder is used for build ****
-ManagedMakeBuilder.message.no.build = Nothing to build for {0}
-ManagedMakeBuilder.message.error = Build error
-ManagedMakeBuilder.message.error.refresh = Error refreshing project
+ManagedMakeBuilder.message.internal.builder.header.note = Info: Internal Builder is used for build
+ManagedMakeBuilder.message.no.build = Info: Nothing to build for {0}
+ManagedMakeBuilder.message.error = Internal error during build, see eclipse error log.
+ManagedMakeBuilder.message.error.build = Internal error building project {0} configuration {1}
+ManagedMakeBuilder.message.undefined.build.command = Build command is null for builder {0}
ManagedMakeBuilder.message.finished = Build complete for project {0}
ManagedMakeBuilder.message.cancelled = Build cancelled
ManagedMakeBuilder.message.finished.with.errs = Build completed with errors
@@ -117,7 +118,6 @@ BuildMacroStatus.status.macro.undefined=Macro {0} is undefined
BuildFilesAction.buildingSelectedFiles=Building Selected Files
BuildDescriptionGnuMakefileGenerator.0=IO exception occurred:
BuildDescriptionGnuMakefileGenerator.1=IO exception occurred:
-BuildFilesAction.buildSelectedFile=Build the selected file.
BuildMacroStatus.status.reference.eachother=Macros {0} and {1} reference each other
BuildMacroStatus.status.reference.incorrect=Macro {0} reference is incorrect
BuildMacroStatus.status.macro.not.string=Macro {0} is not of String type
@@ -130,15 +130,14 @@ BuildInfoFactory.Missing_Builder=Missing Builder:
ResourceChangeHandler.buildInfoSerializationJob=Build Info Serialization
#ManagedBuilderCorePlugin messages
-GeneratedMakefileBuilder.buildResourcesFinished=Build of selected resources is complete.
-GeneratedMakefileBuilder.buildSelectedIncremental=Building selected file(s) incrementally
-GeneratedMakefileBuilder.buildSelectedRebuild=Rebuilding selected file(s)
-GeneratedMakefileBuilder.buildingFile=Building file
+GeneratedMakefileBuilder.buildingProject=Building project {0}
+GeneratedMakefileBuilder.cleaningProject=Cleaning project {0}
+GeneratedMakefileBuilder.removingResourceMarkers=Removing problem markers for {0}
+GeneratedMakefileBuilder.refreshingArtifacts=Refreshing build artefacts for {0}
+GeneratedMakefileBuilder.fileDeleted={0} deleted.
+GeneratedMakefileBuilder.nothingToClean=Nothing to clean.
GenerateMakefileWithBuildDescription.0=info is null
GenerateMakefileWithBuildDescription.1=cfg is null
-GeneratedMakefileBuilder.0=Cleaning output file(s) for
-BuildFilesAction.building=Building
-BuildFilesAction.buildFiles=Build File(s)
ManagedBuilderCorePlugin.resourceChangeHandlingInitializationJob=Initializing Resource Change Handling
#Internal Builder messages
@@ -146,7 +145,7 @@ InternalBuilder.msg.header=Internal Builder: {0}
InternalBuilder.nothing.todo=Nothing to be done for project {0}
CfgScannerConfigUtil_ErrorNotSupported=Only type {0} is supported in this method.
CleanFilesAction.cleanFiles=Clean File(s)
-CleanFilesAction.cleanSelectedFiles=Clean the selected file(s).
+CleanFilesAction.cleanSelectedFiles=Cleaning Selected Files
CleanFilesAction.cleaningFiles=Cleaning files
BuilderFactory.1=can not find builder with the specified id
FolderInfo.4=converter invocation failed
@@ -156,7 +155,7 @@ GnuLinkOutputNameProvider.0=tool parent must be one of configuration, toolchain,
CommonBuilder.1=customized builder created for builder that does not support customization
CommonBuilder.2=request for building non active configuration for the builder that does not support this
CommonBuilder.6=Time consumed: {0} ms.
-CommonBuilder.7=Parallel threads used: {0}
+CommonBuilder.7=Info: Parallel threads used: {0}
CommonBuilder.0=can not clean programmatically: build workspace path is not specified
CommonBuilder.16=can not clean programmatically: build workspace path is not the project path
CommonBuilder.12=can not clean programmatically: build workspace path is not folder
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/newmake/internal/core/StreamMonitor.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/newmake/internal/core/StreamMonitor.java
index ed578a8a63c..f139d67f758 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/newmake/internal/core/StreamMonitor.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/newmake/internal/core/StreamMonitor.java
@@ -10,97 +10,18 @@
*******************************************************************************/
package org.eclipse.cdt.newmake.internal.core;
-import java.io.IOException;
import java.io.OutputStream;
import org.eclipse.core.runtime.IProgressMonitor;
-public class StreamMonitor extends OutputStream {
-
- IProgressMonitor monitor;
- OutputStream console;
- public final int fTotalWork;
- private int halfWay;
- private int currentIncrement = 2;
- private int nextProgress = currentIncrement;
- private int worked = 0;
-
+/**
+*
+* @deprecated as of CDT 8.1. Use org.eclipse.cdt.internal.core.StreamMonitor
+*
+*/
+@Deprecated
+public class StreamMonitor extends org.eclipse.cdt.internal.core.StreamMonitor {
public StreamMonitor(IProgressMonitor mon, OutputStream cos, int totalWork) {
- monitor = mon;
- console = cos;
- fTotalWork = totalWork;
- halfWay = fTotalWork / 2;
- monitor.beginTask("", fTotalWork); //$NON-NLS-1$
- }
-
- private void progressUpdate() {
- if (--nextProgress <= 0) {
- //we have exhausted the current increment, so report progress
- if (fTotalWork > worked) {
- monitor.worked(1);
- }
- worked++;
- if (worked >= halfWay) {
- //we have passed the current halfway point, so double the
- //increment and reset the halfway point.
- currentIncrement *= 2;
- halfWay += (fTotalWork - halfWay) / 2;
- }
- //reset the progress counter to another full increment
- nextProgress = currentIncrement;
- }
- }
- /**
- * @see java.io.OutputStream#close()
- */
- @Override
- public void close() throws IOException {
- if (console != null) {
- console.close();
- }
- monitor.done();
- }
-
- /**
- * @see java.io.OutputStream#flush()
- */
- @Override
- public void flush() throws IOException {
- if (console != null) {
- console.flush();
- }
- }
-
- /**
- * @see java.io.OutputStream#write(int)
- */
- @Override
- public synchronized void write(int b) throws IOException {
- if (console != null) {
- console.write(b);
- }
- progressUpdate();
- }
-
- /**
- * @see java.io.OutputStream#write(byte[], int, int)
- */
- @Override
- public synchronized void write(byte[] b, int off, int len) throws IOException {
- if (b == null) {
- throw new NullPointerException();
- } else if (off != 0 || (len < 0) || (len > b.length)) {
- throw new IndexOutOfBoundsException();
- } else if (len == 0) {
- return;
- }
- if (console != null) {
- console.write(b, off, len);
- }
- progressUpdate();
- }
-
- public int getWorkDone() {
- return worked;
+ super(mon, cos, totalWork);
}
}
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/actions/BuildFilesAction.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/actions/BuildFilesAction.java
index 3da83ce2984..6983bcc43c6 100644
--- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/actions/BuildFilesAction.java
+++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/actions/BuildFilesAction.java
@@ -31,7 +31,6 @@ import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Preferences;
-import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.viewers.ISelection;
@@ -192,10 +191,7 @@ public class BuildFilesAction extends ActionDelegate implements
private final List files;
BuildFilesJob(List filesToBuild) {
- super(
- ManagedMakeMessages
- .getResourceString("BuildFilesAction.buildingSelectedFiles")); //$NON-NLS-1$
-
+ super(ManagedMakeMessages.getResourceString("BuildFilesAction.buildingSelectedFiles")); //$NON-NLS-1$
files = filesToBuild;
}
@@ -204,43 +200,8 @@ public class BuildFilesAction extends ActionDelegate implements
*/
@Override
protected IStatus run(IProgressMonitor monitor) {
-
- Iterator iterator = files.iterator();
-
GeneratedMakefileBuilder builder = new GeneratedMakefileBuilder();
-
- monitor
- .beginTask(
- ManagedMakeMessages
- .getResourceString("BuildFilesAction.building"), files.size()); //$NON-NLS-1$
-
- boolean isFirstFile = true;
-
- while (iterator.hasNext()) {
- IFile file = iterator.next();
-
- IManagedBuildInfo buildInfo = ManagedBuildManager
- .getBuildInfo(file.getProject());
-
- IResource[] resources = { file };
-
- // invoke the internal builder to do the build
- builder.invokeInternalBuilder(resources, buildInfo
- .getDefaultConfiguration(), false, false, isFirstFile,
- !iterator.hasNext(), monitor);
-
- if (isFirstFile) {
- isFirstFile = false;
- }
-
- if (monitor.isCanceled()) {
- return Status.CANCEL_STATUS;
- }
-
- }
-
- monitor.done();
- return Status.OK_STATUS;
+ return builder.invokeInternalBuilder(files, monitor);
}
/* (non-Javadoc)
@@ -260,9 +221,7 @@ public class BuildFilesAction extends ActionDelegate implements
*/
@Override
public void run(IAction action) {
-
List selectedFiles = getSelectedBuildableFiles();
-
Job buildFilesJob = new BuildFilesJob(selectedFiles);
List projects = getProjectsToBuild(selectedFiles);
@@ -277,7 +236,7 @@ public class BuildFilesAction extends ActionDelegate implements
private boolean shouldBeEnabled() {
- // fix for Bugzilla 139663
+ // fix for bug 139663
// if build automatically is turned on, then this menu should be turned off as
// it will trigger the auto build
Preferences preferences = ResourcesPlugin.getPlugin().getPluginPreferences();
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/actions/CleanFilesAction.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/actions/CleanFilesAction.java
index 49e3f420d5a..91d33ec1d8b 100644
--- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/actions/CleanFilesAction.java
+++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/actions/CleanFilesAction.java
@@ -13,7 +13,6 @@ package org.eclipse.cdt.managedbuilder.internal.ui.actions;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
-import java.util.Vector;
import org.eclipse.cdt.core.model.ITranslationUnit;
import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
@@ -26,7 +25,6 @@ import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.core.runtime.Preferences;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
@@ -184,10 +182,8 @@ public class CleanFilesAction extends ActionDelegate implements
private static final class CleanFilesJob extends Job {
private final List files;
- protected Vector> generationProblems;
-
- private CleanFilesJob(String name, List filesToBuild) {
- super(name);
+ private CleanFilesJob(List filesToBuild) {
+ super(ManagedMakeMessages.getResourceString("CleanFilesAction.cleaningFiles")); //$NON-NLS-1$
files = filesToBuild;
}
@@ -213,36 +209,9 @@ public class CleanFilesAction extends ActionDelegate implements
}
}
}
- try {
- if (files != null) {
- monitor
- .beginTask(
- ManagedMakeMessages
- .getResourceString("CleanFilesAction.cleaningFiles"), files.size()); //$NON-NLS-1$
- Iterator iterator = files.iterator();
-
- // clean each file
- while (iterator.hasNext() && !monitor.isCanceled()) {
- IFile file = iterator.next();
-
- GeneratedMakefileBuilder builder = new GeneratedMakefileBuilder();
- builder.cleanFile(file, monitor);
-
- if (monitor.isCanceled()) {
- return Status.CANCEL_STATUS;
- }
- }
-
- monitor.done();
-
- }
- } catch (OperationCanceledException e) {
- return Status.CANCEL_STATUS;
- } finally {
- monitor.done();
- }
- return Status.OK_STATUS;
+ GeneratedMakefileBuilder builder = new GeneratedMakefileBuilder();
+ return builder.cleanFiles(files, monitor);
}
@Override
@@ -258,13 +227,8 @@ public class CleanFilesAction extends ActionDelegate implements
*/
@Override
public void run(IAction action) {
-
List selectedFiles = getSelectedBuildableFiles();
-
- CleanFilesJob job = new CleanFilesJob(
- ManagedMakeMessages
- .getResourceString("CleanFilesAction.cleaningFiles"), selectedFiles); //$NON-NLS-1$
-
+ CleanFilesJob job = new CleanFilesJob(selectedFiles);
job.schedule();
}
diff --git a/build/org.eclipse.linuxtools.cdt.autotools.core/META-INF/MANIFEST.MF b/build/org.eclipse.linuxtools.cdt.autotools.core/META-INF/MANIFEST.MF
index 69cfd1fb52f..d2f08bafe87 100644
--- a/build/org.eclipse.linuxtools.cdt.autotools.core/META-INF/MANIFEST.MF
+++ b/build/org.eclipse.linuxtools.cdt.autotools.core/META-INF/MANIFEST.MF
@@ -1,6 +1,6 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
-Bundle-Name: Core
+Bundle-Name: %Bundle-Name.0
Bundle-SymbolicName: org.eclipse.linuxtools.cdt.autotools.core;singleton:=true
Bundle-Version: 2.0.0.qualifier
Bundle-Activator: org.eclipse.linuxtools.cdt.autotools.core.Activator
@@ -10,3 +10,4 @@ Require-Bundle: org.eclipse.core.runtime,
Bundle-Localization: plugin
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Bundle-Vendor: %provider
diff --git a/build/org.eclipse.linuxtools.cdt.autotools.core/plugin.properties b/build/org.eclipse.linuxtools.cdt.autotools.core/plugin.properties
index eee053af5e2..846175c02d6 100644
--- a/build/org.eclipse.linuxtools.cdt.autotools.core/plugin.properties
+++ b/build/org.eclipse.linuxtools.cdt.autotools.core/plugin.properties
@@ -1 +1,13 @@
+#################################################################################
+# Copyright (c) 2012 Red Hat, Inc.
+# 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:
+# Red Hat Incorporated - initial API and implementation
+#################################################################################
+Bundle-Name.0 = Autotools Core Plug-in (Compatibility)
+provider=Eclipse CDT
Makefile.builder.name=Autotools Makefile Generator
\ No newline at end of file
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/changegenerator/ChangeGenerator.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/changegenerator/ChangeGenerator.java
index f8a07a9b3e1..3fe59806219 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/changegenerator/ChangeGenerator.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/changegenerator/ChangeGenerator.java
@@ -345,8 +345,12 @@ public class ChangeGenerator extends ASTVisitor {
int offset = edit.getOffset();
int end = offset + edit.getLength();
int newOffset = document.getLineInformationOfOffset(offset).getOffset();
- int newEnd = endOffset(document.getLineInformationOfOffset(end));
edit = originalEdits[i];
+ int originalEnd = edit.getExclusiveEnd();
+ // Expand to the end of the line unless the end of the edit region is at
+ // the beginning of line both, before and after the change.
+ int newEnd = (originalEnd == 0 || code.charAt(originalEnd - 1) == '\n') && end == newOffset ?
+ end : endOffset(document.getLineInformationOfOffset(end));
int offsetBefore = edit.getOffset();
int newOffsetBefore = newOffset + offsetBefore - offset;
int newEndBefore = newEnd + offsetBefore + edit.getLength() - end;
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOM.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOM.java
index e507340e261..c0e9f1fede2 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOM.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOM.java
@@ -956,7 +956,8 @@ public class PDOM extends PlatformObject implements IPDOM {
CCorePlugin.log(e);
}
assert lockCount == -1;
- lastWriteAccess= System.currentTimeMillis();
+ if (!fEvent.isTrivial())
+ lastWriteAccess= System.currentTimeMillis();
final ChangeEvent event= fEvent;
fEvent= new ChangeEvent();
synchronized (mutex) {
diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/ErrorParserManager.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/ErrorParserManager.java
index 8b9c0b320b8..37777c8a269 100644
--- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/ErrorParserManager.java
+++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/ErrorParserManager.java
@@ -50,7 +50,7 @@ import org.osgi.service.prefs.BackingStoreException;
*
* @noextend This class is not intended to be subclassed by clients.
*/
-public class ErrorParserManager extends OutputStream {
+public class ErrorParserManager extends OutputStream implements IConsoleParser {
/**
* The list of error parsers stored in .project for 3.X projects
* as key/value pair with key="org.eclipse.cdt.core.errorOutputParser"
@@ -306,9 +306,11 @@ public class ErrorParserManager extends OutputStream {
}
/**
- * Parses the input and tries to generate error or warning markers
+ * Parses one line of output and generates error or warning markers.
+ * @since 5.4
*/
- private void processLine(String line) {
+ @Override
+ public boolean processLine(String line) {
String lineTrimmed = line.trim();
lineCounter++;
@@ -363,6 +365,8 @@ outer:
}
}
outputLine(line, marker);
+
+ return false;
}
/**
@@ -848,4 +852,11 @@ outer:
}
return result;
}
+
+ /**
+ * @since 5.4
+ */
+ @Override
+ public void shutdown() {
+ }
}
diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/resources/RefreshScopeManager.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/resources/RefreshScopeManager.java
index 559e3cf5999..d8941f98add 100644
--- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/resources/RefreshScopeManager.java
+++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/resources/RefreshScopeManager.java
@@ -485,12 +485,35 @@ public class RefreshScopeManager {
String configName = child.getAttribute(CONFIGURATION_ELEMENT_NAME);
loadResourceData(workspaceRoot, project, configName, child.getChildren());
}
- }
+ }
+ // else there are no children, and this is a "new" project.
+ // so initialize it.
+ if (children.length == 0) {
+ initializeConfigMap(project);
+ }
}
}
}
}
+ private void initializeConfigMap(IProject project) {
+ getProjectToConfigurationToResourcesMap();
+ HashMap>> configMap = fProjToConfToResToExcluMap.get(project);
+ if (configMap == null) {
+ configMap = new HashMap>>();
+ CProjectDescriptionManager descriptionManager = CProjectDescriptionManager.getInstance();
+ ICProjectDescription projectDescription = descriptionManager.getProjectDescription(project, false);
+ ICConfigurationDescription cfgDescs[] = projectDescription.getConfigurations();
+ for (ICConfigurationDescription cfgDesc : cfgDescs) {
+ String configName = cfgDesc.getName();
+ HashMap> resourceMap = new HashMap>();
+ resourceMap.put(project, new LinkedList());
+ configMap.put(configName, resourceMap);
+ }
+ fProjToConfToResToExcluMap.put(project,configMap);
+ }
+ }
+
/**
* @since 5.4
*/
diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/BuildRunnerHelper.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/BuildRunnerHelper.java
new file mode 100644
index 00000000000..d15fa295114
--- /dev/null
+++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/BuildRunnerHelper.java
@@ -0,0 +1,510 @@
+/*******************************************************************************
+ * Copyright (c) 2012, 2012 Andrew Gvozdev 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:
+ * Andrew Gvozdev - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.core;
+
+import java.io.Closeable;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.net.URI;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.concurrent.TimeUnit;
+
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.ErrorParserManager;
+import org.eclipse.cdt.core.ICommandLauncher;
+import org.eclipse.cdt.core.IConsoleParser;
+import org.eclipse.cdt.core.model.ICModelMarker;
+import org.eclipse.cdt.core.resources.IConsole;
+import org.eclipse.cdt.core.resources.RefreshScopeManager;
+import org.eclipse.cdt.utils.EFSExtensionManager;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.core.resources.IWorkspaceRunnable;
+import org.eclipse.core.resources.IncrementalProjectBuilder;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.QualifiedName;
+import org.eclipse.core.runtime.SubProgressMonitor;
+
+/**
+ * Helper class attempting to unify interactions with build console,
+ * such as style of console output and handling of console output parsers.
+ *
+ * As of CDT 8.1, this class is experimental, internal and work in progress.
+ * API is unstable and subject to change.
+ */
+public class BuildRunnerHelper implements Closeable {
+ private static final String PROGRESS_MONITOR_QUALIFIER = CCorePlugin.PLUGIN_ID + ".progressMonitor"; //$NON-NLS-1$
+ private static final int MONITOR_SCALE = 100;
+
+ private IProject project;
+
+ private IConsole console = null;
+ private ErrorParserManager errorParserManager = null;
+ private StreamMonitor streamMon = null;
+ private OutputStream stdout = null;
+ private OutputStream stderr = null;
+ private OutputStream consoleOut = null;
+ private OutputStream consoleInfo = null;
+
+ private long startTime = 0;
+ private long endTime = 0;
+
+ private QualifiedName progressPropertyName = null;
+
+ private ICommandLauncher launcher;
+ private IPath buildCommand;
+ private String[] args;
+ private URI workingDirectoryURI;
+ String[] envp;
+
+ private boolean isStreamsOpen = false;
+ boolean isCancelled = false;
+
+ /**
+ * Constructor.
+ */
+ public BuildRunnerHelper(IProject project) {
+ this.project = project;
+ }
+
+ /**
+ * Set parameters for the launch.
+ * @param envp - String[] array of environment variables in format "var=value" suitable for using
+ * as "envp" with Runtime.exec(String[] cmdarray, String[] envp, File dir)
+ */
+ public void setLaunchParameters(ICommandLauncher launcher, IPath buildCommand, String[] args, URI workingDirectoryURI, String[] envp) {
+ this.launcher = launcher;
+ launcher.setProject(project);
+ // Print the command for visual interaction.
+ launcher.showCommand(true);
+
+ this.buildCommand = buildCommand;
+ this.args = args;
+ this.workingDirectoryURI = workingDirectoryURI;
+ this.envp = envp;
+ }
+
+ /**
+ * Open and set up streams for use by {@link BuildRunnerHelper}.
+ * This must be followed by {@link #close()} to close the streams. Use try...finally for that.
+ *
+ * @param epm - ErrorParserManger for error parsing and coloring errors on the console
+ * @param buildOutputParsers - list of console output parsers or {@code null}.
+ * @param con - the console.
+ * @param monitor - progress monitor in the initial state where {@link IProgressMonitor#beginTask(String, int)}
+ * has not been called yet.
+ * @throws CoreException
+ */
+ public void prepareStreams(ErrorParserManager epm, List buildOutputParsers, IConsole con, IProgressMonitor monitor) throws CoreException {
+ errorParserManager = epm;
+ console = con;
+
+ // Visualize the flow of the streams:
+ //
+ // console <- EPM
+ // ^
+ // IConsoleParsers (includes EPM + other parsers)
+ // ^
+ // null <- StreamMomitor <= Sniffer <= Process (!!! the flow starts here!)
+ //
+
+ isStreamsOpen = true;
+
+ consoleOut = console.getOutputStream();
+ // stdout/stderr get to the console through ErrorParserManager
+ errorParserManager.setOutputStream(consoleOut);
+
+ List parsers = new ArrayList();
+ // Using ErrorParserManager as console parser helps to avoid intermixing buffered streams
+ // as ConsoleOutputSniffer waits for EOL to send a line to console parsers
+ // separately for each stream.
+ parsers.add(errorParserManager);
+ if (buildOutputParsers != null) {
+ parsers.addAll(buildOutputParsers);
+ }
+
+ Integer lastWork = null;
+ if (buildCommand != null) {
+ progressPropertyName = getProgressPropertyName(buildCommand, args);
+ lastWork = (Integer)project.getSessionProperty(progressPropertyName);
+ }
+ if (lastWork == null) {
+ lastWork = MONITOR_SCALE;
+ }
+
+ streamMon = new StreamMonitor(monitor, null, lastWork.intValue());
+ ConsoleOutputSniffer sniffer = new ConsoleOutputSniffer(streamMon, streamMon, parsers.toArray(new IConsoleParser[parsers.size()]));
+ stdout = sniffer.getOutputStream();
+ stderr = sniffer.getErrorStream();
+ }
+
+ /**
+ * @return the output stream to connect stdout of a process
+ */
+ public OutputStream getOutputStream() {
+ return stdout;
+ }
+
+ /**
+ * @return the output stream to connect stderr of a process
+ */
+ public OutputStream getErrorStream() {
+ return stderr;
+ }
+
+ /**
+ * Remove problem markers created for the resource by previous build.
+ *
+ * @param rc - resource to remove its markers.
+ * @param monitor - progress monitor in the initial state where {@link IProgressMonitor#beginTask(String, int)}
+ * has not been called yet.
+ * @throws CoreException
+ */
+ public void removeOldMarkers(IResource rc, IProgressMonitor monitor) throws CoreException {
+ if (monitor == null) {
+ monitor = new NullProgressMonitor();
+ }
+ try {
+ monitor.beginTask("", IProgressMonitor.UNKNOWN); //$NON-NLS-1$
+ monitor.subTask(CCorePlugin.getFormattedString("BuildRunnerHelper.removingMarkers", rc.getFullPath().toString())); //$NON-NLS-1$
+ rc.deleteMarkers(ICModelMarker.C_MODEL_PROBLEM_MARKER, false, IResource.DEPTH_INFINITE);
+ } finally {
+ monitor.done();
+ }
+ }
+
+ /**
+ * Launch build command and process console output.
+ *
+ * @param monitor - progress monitor in the initial state where {@link IProgressMonitor#beginTask(String, int)}
+ * has not been called yet.
+ * @throws CoreException
+ * @throws IOException
+ */
+ public int build(IProgressMonitor monitor) throws CoreException, IOException {
+ Assert.isNotNull(launcher, "Launch parameters must be set before calling this method"); //$NON-NLS-1$
+ Assert.isNotNull(errorParserManager, "Streams must be created and connected before calling this method"); //$NON-NLS-1$
+
+ int status = ICommandLauncher.ILLEGAL_COMMAND;
+
+ if (monitor == null) {
+ monitor = new NullProgressMonitor();
+ }
+ try {
+ monitor.beginTask("", 2 * MONITOR_SCALE); //$NON-NLS-1$
+
+ isCancelled = false;
+ String pathFromURI = EFSExtensionManager.getDefault().getPathFromURI(workingDirectoryURI);
+ if(pathFromURI == null) {
+ // fallback to CWD
+ pathFromURI = System.getProperty("user.dir"); //$NON-NLS-1$
+ }
+ IPath workingDirectory = new Path(pathFromURI);
+
+ String errMsg = null;
+ Process p = launcher.execute(buildCommand, args, envp, workingDirectory, monitor);
+ if (p != null) {
+ try {
+ // Close the input of the Process explicitly.
+ // We will never write to it.
+ p.getOutputStream().close();
+ } catch (IOException e) {
+ }
+ // Before launching give visual cues via the monitor
+ monitor.subTask(CCorePlugin.getFormattedString("BuildRunnerHelper.invokingCommand", launcher.getCommandLine())); //$NON-NLS-1$
+
+ status = launcher.waitAndRead(stdout, stderr, new SubProgressMonitor(monitor, 1 * MONITOR_SCALE));
+ if (status != ICommandLauncher.OK) {
+ errMsg = launcher.getErrorMessage();
+ }
+ } else {
+ errMsg = launcher.getErrorMessage();
+ }
+
+ if (errMsg != null && !errMsg.isEmpty()) {
+ stderr.write(errMsg.getBytes());
+ }
+
+ isCancelled = monitor.isCanceled();
+ if (!isCancelled) {
+ project.setSessionProperty(progressPropertyName, new Integer(streamMon.getWorkDone()));
+ }
+ } finally {
+ monitor.done();
+ }
+ return status;
+ }
+
+ /**
+ * Close all streams.
+ */
+ @Override
+ public void close() throws IOException {
+ if (!isStreamsOpen)
+ return;
+
+ try {
+ if (stdout != null)
+ stdout.close();
+ } catch (Exception e) {
+ CCorePlugin.log(e);
+ } finally {
+ try {
+ if (stderr != null)
+ stderr.close();
+ } catch (Exception e) {
+ CCorePlugin.log(e);
+ } finally {
+ try {
+ if (streamMon != null)
+ streamMon.close();
+ } catch (Exception e) {
+ CCorePlugin.log(e);
+ } finally {
+ try {
+ if (consoleOut != null)
+ consoleOut.close();
+ } catch (Exception e) {
+ CCorePlugin.log(e);
+ }
+ }
+ }
+ }
+ isStreamsOpen = false;
+ }
+
+ /**
+ * Refresh project in the workspace.
+ *
+ * @param monitor - progress monitor in the initial state where {@link IProgressMonitor#beginTask(String, int)}
+ * has not been called yet.
+ */
+ public void refreshProject(IProgressMonitor monitor) {
+ if (monitor == null) {
+ monitor = new NullProgressMonitor();
+ }
+ try {
+ monitor.beginTask(CCorePlugin.getResourceString("BuildRunnerHelper.updatingProject"), IProgressMonitor.UNKNOWN); //$NON-NLS-1$
+
+ // Do not allow the cancel of the refresh, since the builder is external
+ // to Eclipse, files may have been created/modified and we will be out-of-sync.
+ // The caveat is for huge projects, it may take sometimes at every build.
+ // Use the refresh scope manager to refresh
+ RefreshScopeManager refreshManager = RefreshScopeManager.getInstance();
+ IWorkspaceRunnable runnable = refreshManager.getRefreshRunnable(project);
+ ResourcesPlugin.getWorkspace().run(runnable, null, IWorkspace.AVOID_UPDATE, null);
+ } catch (CoreException e) {
+ // ignore exceptions
+ } finally {
+ monitor.done();
+ }
+ }
+
+ /**
+ * Print a standard greeting to the console.
+ * Note that start time of the build is recorded by this method.
+ *
+ * @param kind - kind of build. {@link IncrementalProjectBuilder} constants such as
+ * {@link IncrementalProjectBuilder#FULL_BUILD} should be used.
+ */
+ public void greeting(int kind) {
+ String msg = CCorePlugin.getFormattedString("BuildRunnerHelper.buildProject", //$NON-NLS-1$
+ new String[] { buildKindToString(kind), project.getName() });
+ greeting(msg);
+ }
+
+ /**
+ * Print a standard greeting to the console.
+ * Note that start time of the build is recorded by this method.
+ *
+ * @param kind - kind of build. {@link IncrementalProjectBuilder} constants such as
+ * {@link IncrementalProjectBuilder#FULL_BUILD} should be used.
+ * @param cfgName - configuration name.
+ * @param toolchainName - tool-chain name.
+ * @param isSupported - flag indicating if tool-chain is supported on the system.
+ */
+ public void greeting(int kind, String cfgName, String toolchainName, boolean isSupported) {
+ greeting(buildKindToString(kind), cfgName, toolchainName, isSupported);
+ }
+
+ /**
+ * Print a standard greeting to the console.
+ * Note that start time of the build is recorded by this method.
+ *
+ * @param kind - kind of build as a String.
+ * @param cfgName - configuration name.
+ * @param toolchainName - tool-chain name.
+ * @param isSupported - flag indicating if tool-chain is supported on the system.
+ */
+ public void greeting(String kind, String cfgName, String toolchainName, boolean isSupported) {
+ String msg = CCorePlugin.getFormattedString("BuildRunnerHelper.buildProjectConfiguration", //$NON-NLS-1$
+ new String[] { kind, cfgName, project.getName() });
+ greeting(msg);
+
+ if (!isSupported ){
+ String errMsg = CCorePlugin.getFormattedString("BuildRunnerHelper.unsupportedConfiguration", //$NON-NLS-1$
+ new String[] { cfgName, toolchainName });
+ printLine(errMsg);
+ }
+ }
+
+ /**
+ * Print the specified greeting to the console.
+ * Note that start time of the build is recorded by this method.
+ */
+ public void greeting(String msg) {
+ startTime = System.currentTimeMillis();
+ toConsole(BuildRunnerHelper.timestamp(startTime) + "**** " + msg + " ****"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ /**
+ * Print a standard footer to the console.
+ * That prints duration of the build determined by start time recorded in {@link #greeting(String)}.
+ *
+ *
Important: {@link #close()} the streams BEFORE calling this method to properly flush all outputs
+ */
+ public void goodbye() {
+ Assert.isTrue(startTime != 0, "Start time must be set before calling this method"); //$NON-NLS-1$
+ Assert.isTrue(!isStreamsOpen, "Close streams before calling this method."); //$NON-NLS-1$
+
+ endTime = System.currentTimeMillis();
+ String duration = durationToString(endTime - startTime);
+ String msg = isCancelled ? CCorePlugin.getFormattedString("BuildRunnerHelper.buildCancelled", duration) //$NON-NLS-1$
+ : CCorePlugin.getFormattedString("BuildRunnerHelper.buildFinished", duration); //$NON-NLS-1$
+ String goodbye = '\n' + timestamp(endTime) + msg + '\n';
+ toConsole(goodbye);
+ }
+
+ /**
+ * Print the given message to the console.
+ * @param msg - message to print.
+ */
+ public void printLine(String msg) {
+ Assert.isNotNull(errorParserManager, "Streams must be created and connected before calling this method"); //$NON-NLS-1$
+ errorParserManager.processLine(msg);
+ }
+
+ /**
+ * Print a message to the console info output. Note that this message is colored
+ * with the color assigned to "Info" stream.
+ * @param msg - message to print.
+ */
+ private void toConsole(String msg) {
+ Assert.isNotNull(console, "Streams must be created and connected before calling this method"); //$NON-NLS-1$
+ try {
+ if (consoleInfo == null) {
+ consoleInfo = console.getInfoStream();
+ }
+ consoleInfo.write((msg+"\n").getBytes()); //$NON-NLS-1$
+ } catch (Exception e) {
+ CCorePlugin.log(e);
+ }
+ }
+
+ /**
+ * Qualified name to keep previous value of build duration in project session properties.
+ */
+ private static QualifiedName getProgressPropertyName(IPath buildCommand, String[] args) {
+ String name = buildCommand.toString();
+ if (args != null) {
+ for (String arg : args) {
+ name = name + ' ' + arg;
+ }
+ }
+ return new QualifiedName(PROGRESS_MONITOR_QUALIFIER, name);
+ }
+
+ /**
+ * Convert map of environment variables to array of "var=value"
+ *
+ * @param envMap - map of environment variables
+ * @return String array of environment variables in format "var=value" suitable for using
+ * as "envp" with Runtime.exec(String[] cmdarray, String[] envp, File dir)
+ */
+ public static String[] envMapToEnvp(Map envMap) {
+ // Convert into env strings
+ List strings= new ArrayList(envMap.size());
+ for (Entry entry : envMap.entrySet()) {
+ StringBuffer buffer= new StringBuffer(entry.getKey());
+ buffer.append('=').append(entry.getValue());
+ strings.add(buffer.toString());
+ }
+
+ return strings.toArray(new String[strings.size()]);
+ }
+
+ /**
+ * Convert duration to human friendly format.
+ */
+ @SuppressWarnings("nls")
+ private static String durationToString(long duration) {
+ String result = "";
+ long days = TimeUnit.MILLISECONDS.toDays(duration);
+ if (days > 0) {
+ result += days + "d,";
+ }
+ long hours = TimeUnit.MILLISECONDS.toHours(duration) % 24;
+ if (hours > 0) {
+ result += hours + "h:";
+ }
+ long minutes = TimeUnit.MILLISECONDS.toMinutes(duration) % 60;
+ if (minutes > 0) {
+ result += minutes + "m:";
+ }
+ long seconds = TimeUnit.MILLISECONDS.toSeconds(duration) % 60;
+ if (seconds > 0) {
+ result += seconds + "s.";
+ }
+ long milliseconds = TimeUnit.MILLISECONDS.toMillis(duration) % 1000;
+ result += milliseconds + "ms";
+
+ return result;
+ }
+
+ /**
+ * Supply timestamp to prefix informational messages.
+ */
+ @SuppressWarnings("nls")
+ private static String timestamp(long time) {
+ return new SimpleDateFormat("HH:mm:ss").format(new Date(time)) + " ";
+ }
+
+ /**
+ * Convert build kind to human friendly format.
+ */
+ private static String buildKindToString(int kind) {
+ switch (kind) {
+ case IncrementalProjectBuilder.FULL_BUILD:
+ return CCorePlugin.getResourceString("BuildRunnerHelper.build"); //$NON-NLS-1$
+ case IncrementalProjectBuilder.INCREMENTAL_BUILD:
+ return CCorePlugin.getResourceString("BuildRunnerHelper.incrementalBuild"); //$NON-NLS-1$
+ case IncrementalProjectBuilder.AUTO_BUILD:
+ return CCorePlugin.getResourceString("BuildRunnerHelper.autoBuild"); //$NON-NLS-1$
+ case IncrementalProjectBuilder.CLEAN_BUILD:
+ return CCorePlugin.getResourceString("BuildRunnerHelper.cleanBuild"); //$NON-NLS-1$
+ default:
+ return CCorePlugin.getResourceString("BuildRunnerHelper.build"); //$NON-NLS-1$
+ }
+ }
+}
diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/CCorePluginResources.properties b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/CCorePluginResources.properties
index cfcf1d84e09..36637f2d9e6 100644
--- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/CCorePluginResources.properties
+++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/CCorePluginResources.properties
@@ -90,3 +90,16 @@ CConfigBasedDescriptorManager.3=Failed to create descriptor
CConfigBasedDescriptorManager.4=error: read-only configuration can not be used for CDescriptor
CConfigBasedDescriptorManager.5=the project does not contain valid configurations
CCorePlugin.startupJob=CDT Startup
+
+BuildRunnerHelper.unsupportedConfiguration=Info: Configuration "{0}" uses tool-chain "{1}" that is unsupported on this system, attempting to build anyway.
+BuildRunnerHelper.removingMarkers=Removing problem markers for {0}
+BuildRunnerHelper.invokingCommand=Invoking Command: {0}
+BuildRunnerHelper.updatingProject=Updating project...
+BuildRunnerHelper.buildProject={0} of project {1}
+BuildRunnerHelper.buildProjectConfiguration={0} of configuration {1} for project {2}
+BuildRunnerHelper.buildFinished=Build Finished (took {0})
+BuildRunnerHelper.buildCancelled=Build Cancelled (took {0})
+BuildRunnerHelper.build=Build
+BuildRunnerHelper.incrementalBuild=Incremental Build
+BuildRunnerHelper.autoBuild=Auto Build
+BuildRunnerHelper.cleanBuild=Clean-only build
diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/ConsoleOutputSniffer.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/ConsoleOutputSniffer.java
index aa357dd991a..e2dde57209a 100644
--- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/ConsoleOutputSniffer.java
+++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/ConsoleOutputSniffer.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2008 IBM Corporation and others.
+ * Copyright (c) 2004, 2012 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
@@ -18,149 +18,138 @@ import org.eclipse.cdt.core.IConsoleParser;
/**
* Intercepts an output to console and forwards it to console parsers for processing
- *
- * @author vhirsl
*/
public class ConsoleOutputSniffer {
- /*
- * Private class to sniffer the output stream for this snifffer.
- */
- private class ConsoleOutputStream extends OutputStream {
- // Stream's private buffer for the stream's read contents.
- private StringBuffer currentLine = new StringBuffer();
- private OutputStream outputStream = null;
-
+ /**
+ * Private class to sniff the output stream for this sniffer.
+ */
+ private class ConsoleOutputStream extends OutputStream {
+ // Stream's private buffer for the stream's read contents.
+ private StringBuffer currentLine = new StringBuffer();
+ private OutputStream outputStream = null;
+
public ConsoleOutputStream(OutputStream outputStream) {
this.outputStream = outputStream;
}
- /* (non-Javadoc)
- * @see java.io.OutputStream#write(int)
- */
- @Override
+ @Override
public void write(int b) throws IOException {
- currentLine.append((char) b);
- checkLine(false);
+ currentLine.append((char) b);
+ checkLine(false);
- // Continue writing the bytes to the console's output.
- if (outputStream != null) {
- outputStream.write(b);
- }
- }
-
- /* (non-Javadoc)
- * @see java.io.OutputStream#write(byte[], int, int)
- */
- @Override
+ // Continue writing the bytes to the console's output.
+ if (outputStream != null) {
+ outputStream.write(b);
+ }
+ }
+
+ @Override
public void write(byte[] b, int off, int len) throws IOException {
- if (b == null) {
- throw new NullPointerException();
- } else if (off != 0 || (len < 0) || (len > b.length)) {
- throw new IndexOutOfBoundsException();
- } else if (len == 0) {
- return;
- }
- currentLine.append(new String(b, 0, len));
- checkLine(false);
-
- // Continue writing the bytes to the console's output.
- if (outputStream != null)
- outputStream.write(b, off, len);
- }
-
- /* (non-Javadoc)
- * @see java.io.OutputStream#close()
- */
- @Override
+ if (b == null) {
+ throw new NullPointerException();
+ } else if (off != 0 || (len < 0) || (len > b.length)) {
+ throw new IndexOutOfBoundsException();
+ } else if (len == 0) {
+ return;
+ }
+ currentLine.append(new String(b, 0, len));
+ checkLine(false);
+
+ // Continue writing the bytes to the console's output.
+ if (outputStream != null)
+ outputStream.write(b, off, len);
+ }
+
+ @Override
public void close() throws IOException {
- checkLine(true);
- closeConsoleOutputStream();
- }
-
- /* (non-Javadoc)
- * @see java.io.OutputStream#flush()
- */
- @Override
+ checkLine(true);
+ closeConsoleOutputStream();
+ }
+
+ @Override
public void flush() throws IOException {
- if (outputStream != null) {
- outputStream.flush();
- }
- }
+ if (outputStream != null) {
+ outputStream.flush();
+ }
+ }
- /*
- * Checks to see if the already read input constitutes
- * a complete line (e.g. does the sniffing). If so, then
- * send it to processLine.
- *
- * @param flush
- */
- private void checkLine(boolean flush) {
- String buffer = currentLine.toString();
- int i = 0;
- while ((i = buffer.indexOf('\n')) != -1) {
- // get rid of any trailing whitespace but keep leading whitespaces (bug 199245)
- int end= i;
- while(end > 0 && buffer.charAt(end-1) <= ' ') { // see String.trim()
- end--;
- }
- if (end > 0) {
- String line = buffer.substring(0, end);
- processLine(line);
- }
- buffer = buffer.substring(i + 1); // skip the \n and advance
- }
- currentLine.setLength(0);
- if (flush) {
- if (buffer.length() > 0) {
- processLine(buffer);
- }
- } else {
- currentLine.append(buffer);
- }
- }
+ /**
+ * Checks to see if the already read input constitutes
+ * a complete line (e.g. does the sniffing). If so, then
+ * send it to processLine.
+ *
+ * @param flush
+ */
+ private void checkLine(boolean flush) {
+ if (currentLine.length() == 0) {
+ return;
+ }
+
+ String buffer = currentLine.toString();
+ int i = 0;
+ while ((i = buffer.indexOf('\n')) != -1) {
+ int eol = i;
+ if (i > 0 && buffer.charAt(i-1) == '\r') {
+ // also get rid of trailing \r in case of Windows line delimiter "\r\n"
+ eol = i - 1;
+ }
+ String line = buffer.substring(0, eol);
+ processLine(line);
+
+ buffer = buffer.substring(i + 1); // skip the \n and advance
+ }
+ currentLine.setLength(0);
+ if (flush) {
+ if (buffer.length() > 0) {
+ processLine(buffer);
+ }
+ } else {
+ currentLine.append(buffer);
+ }
+ }
+
+ } // end ConsoleOutputStream class
- } // end ConsoleOutputStream class
-
private int nOpens = 0;
private OutputStream consoleOutputStream;
private OutputStream consoleErrorStream;
private IConsoleParser[] parsers;
-
+
public ConsoleOutputSniffer(IConsoleParser[] parsers) {
this.parsers = parsers;
}
-
+
public ConsoleOutputSniffer(OutputStream outputStream, OutputStream errorStream, IConsoleParser[] parsers) {
this(parsers);
this.consoleOutputStream = outputStream;
this.consoleErrorStream = errorStream;
}
-
+
/**
* Returns an output stream that will be sniffed.
* This stream should be hooked up so the command
* output stream goes into here.
*/
public OutputStream getOutputStream() {
- incNOpens();
- return new ConsoleOutputStream(consoleOutputStream);
+ incNOpens();
+ return new ConsoleOutputStream(consoleOutputStream);
}
-
+
/**
* Returns an error stream that will be sniffed.
* This stream should be hooked up so the command
* error stream goes into here.
*/
public OutputStream getErrorStream() {
- incNOpens();
- return new ConsoleOutputStream(consoleErrorStream);
+ incNOpens();
+ return new ConsoleOutputStream(consoleErrorStream);
}
-
+
private synchronized void incNOpens() {
- nOpens++;
+ nOpens++;
}
-
+
/*
*/
public synchronized void closeConsoleOutputStream() throws IOException {
@@ -170,10 +159,10 @@ public class ConsoleOutputSniffer {
}
}
}
-
+
/*
* Processes the line by passing the line to the parsers.
- *
+ *
* @param line
*/
private synchronized void processLine(String line) {
@@ -181,5 +170,5 @@ public class ConsoleOutputSniffer {
parsers[i].processLine(line);
}
}
-
+
}
diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/StreamMonitor.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/StreamMonitor.java
new file mode 100644
index 00000000000..26796c8ad91
--- /dev/null
+++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/StreamMonitor.java
@@ -0,0 +1,109 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2010 QNX Software Systems 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:
+ * QNX Software Systems - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.core;
+
+import java.io.IOException;
+import java.io.OutputStream;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+
+/**
+ * Helper class to report progress of the build via {@link IProgressMonitor}
+ */
+public class StreamMonitor extends OutputStream {
+
+ private IProgressMonitor monitor;
+ private OutputStream console;
+ private final int fTotalWork;
+ private int halfWay;
+ private int currentIncrement = 2;
+ private int nextProgress = currentIncrement;
+ private int worked = 0;
+
+ public StreamMonitor(IProgressMonitor mon, OutputStream cos, int totalWork) {
+ monitor = mon;
+ console = cos;
+ fTotalWork = totalWork;
+ halfWay = fTotalWork / 2;
+ monitor.beginTask("", fTotalWork); //$NON-NLS-1$
+ }
+
+ private void progressUpdate() {
+ if (--nextProgress <= 0) {
+ //we have exhausted the current increment, so report progress
+ if (fTotalWork > worked) {
+ monitor.worked(1);
+ }
+ worked++;
+ if (worked >= halfWay) {
+ //we have passed the current halfway point, so double the
+ //increment and reset the halfway point.
+ currentIncrement *= 2;
+ halfWay += (fTotalWork - halfWay) / 2;
+ }
+ //reset the progress counter to another full increment
+ nextProgress = currentIncrement;
+ }
+ }
+ /**
+ * @see java.io.OutputStream#close()
+ */
+ @Override
+ public void close() throws IOException {
+ if (console != null) {
+ console.close();
+ }
+ monitor.done();
+ }
+
+ /**
+ * @see java.io.OutputStream#flush()
+ */
+ @Override
+ public void flush() throws IOException {
+ if (console != null) {
+ console.flush();
+ }
+ }
+
+ /**
+ * @see java.io.OutputStream#write(int)
+ */
+ @Override
+ public synchronized void write(int b) throws IOException {
+ if (console != null) {
+ console.write(b);
+ }
+ progressUpdate();
+ }
+
+ /**
+ * @see java.io.OutputStream#write(byte[], int, int)
+ */
+ @Override
+ public synchronized void write(byte[] b, int off, int len) throws IOException {
+ if (b == null) {
+ throw new NullPointerException();
+ } else if (off != 0 || (len < 0) || (len > b.length)) {
+ throw new IndexOutOfBoundsException();
+ } else if (len == 0) {
+ return;
+ }
+ if (console != null) {
+ console.write(b, off, len);
+ }
+ progressUpdate();
+ }
+
+ public int getWorkDone() {
+ return worked;
+ }
+}
diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/RefactoringTestBase.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/RefactoringTestBase.java
index 6963b4af42b..9741fc6801e 100644
--- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/RefactoringTestBase.java
+++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/RefactoringTestBase.java
@@ -101,9 +101,11 @@ public abstract class RefactoringTestBase extends BaseTestCase {
BufferedReader reader = new BufferedReader(new StringReader(contents.toString()));
String line;
while ((line = reader.readLine()) != null) {
+ String trimmedLine = line.trim();
if (testFile == null) {
- testFile = new TestSourceFile(line.trim());
- } else if (isResultDelimiter(line.trim())) {
+ assertTrue("Invalid file name \"" + trimmedLine + "\"", trimmedLine.matches("^(\\w+/)*\\w+\\.\\w+$"));
+ testFile = new TestSourceFile(trimmedLine);
+ } else if (isResultDelimiter(trimmedLine)) {
expectedResult = true;
} else if (expectedResult) {
testFile.addLineToExpectedSource(line);
diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/extractfunction/ExtractFunctionRefactoringTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/extractfunction/ExtractFunctionRefactoringTest.java
index 471a174916f..10910d20611 100644
--- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/extractfunction/ExtractFunctionRefactoringTest.java
+++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/extractfunction/ExtractFunctionRefactoringTest.java
@@ -274,6 +274,41 @@ public class ExtractFunctionRefactoringTest extends RefactoringTestBase {
assertRefactoringSuccess();
}
+ //main.cpp
+ //class A {
+ //public:
+ // explicit A(const char*);
+ // void m1() const;
+ // void m2() const;
+ //};
+ //
+ //void main() {
+ // /*$*/A a("");
+ // a.m1();/*$$*/
+ // A b(a); // nonstandard indent to check that it is preserved
+ //}
+ //====================
+ //class A {
+ //public:
+ // explicit A(const char*);
+ // void m1() const;
+ // void m2() const;
+ //};
+ //
+ //A extracted() {
+ // A a("");
+ // a.m1();
+ // return a;
+ //}
+ //
+ //void main() {
+ // A a = extracted();
+ // A b(a); // nonstandard indent to check that it is preserved
+ //}
+ public void testLocalVariableDeclaration_3() throws Exception {
+ assertRefactoringSuccess();
+ }
+
//A.h
//#ifndef A_H_
//#define A_H_
diff --git a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/opentype/ElementSelectionDialog.java b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/opentype/ElementSelectionDialog.java
index 196e17a5b75..a99d230af20 100644
--- a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/opentype/ElementSelectionDialog.java
+++ b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/opentype/ElementSelectionDialog.java
@@ -336,11 +336,6 @@ public class ElementSelectionDialog extends TypeSelectionDialog {
return types.toArray(new ITypeInfo[types.size()]);
}
- @Override
- protected final void setListElements(Object[] elements) {
- super.setListElements(elements);
- }
-
/**
* @deprecated Unsupported
*/
@@ -350,6 +345,14 @@ public class ElementSelectionDialog extends TypeSelectionDialog {
throw new UnsupportedOperationException();
}
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.dialogs.AbstractElementListSelectionDialog#handleElementsChanged()
+ */
+ @Override
+ protected void handleElementsChanged() {
+ updateOkState();
+ }
+
@Override
protected void handleEmptyList() {
updateOkState();
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/refactoring/code/flow/FlowAnalyzer.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/refactoring/code/flow/FlowAnalyzer.java
index abb635e644b..b5a8f2304af 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/refactoring/code/flow/FlowAnalyzer.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/refactoring/code/flow/FlowAnalyzer.java
@@ -911,8 +911,11 @@ abstract class FlowAnalyzer extends ASTGenericVisitor {
if (binding instanceof IVariable) {
IVariable variable= (IVariable) binding;
if (!(variable instanceof IField)) {
- int accessMode = CPPVariableReadWriteFlags.getReadWriteFlags(node);
- setFlowInfo(node, new LocalFlowInfo(variable, accessMode, fFlowContext));
+ int index = fFlowContext.getIndexFromLocal(variable);
+ if (index >= 0) {
+ int accessMode = CPPVariableReadWriteFlags.getReadWriteFlags(node);
+ setFlowInfo(node, new LocalFlowInfo(variable, index, accessMode, fFlowContext));
+ }
}
}
return PROCESS_SKIP;
@@ -957,7 +960,7 @@ abstract class FlowAnalyzer extends ASTGenericVisitor {
return leave((ICASTDesignatedInitializer) node);
} else if (node instanceof IASTInitializerList) {
return leave((ICPPASTConstructorChainInitializer) node);
- } else if (node instanceof IASTInitializerList) {
+ } else if (node instanceof ICPPASTConstructorInitializer) {
return leave((ICPPASTConstructorInitializer) node);
}
return PROCESS_SKIP;
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/refactoring/code/flow/LocalFlowInfo.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/refactoring/code/flow/LocalFlowInfo.java
index 8bbbb4945c6..4cd924edcc9 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/refactoring/code/flow/LocalFlowInfo.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/refactoring/code/flow/LocalFlowInfo.java
@@ -16,11 +16,11 @@ import org.eclipse.cdt.core.dom.ast.IVariable;
class LocalFlowInfo extends FlowInfo {
private final int fVariableIndex;
- public LocalFlowInfo(IVariable binding, int localAccessMode, FlowContext context) {
+ public LocalFlowInfo(IVariable binding, int variableIndex, int localAccessMode, FlowContext context) {
super(NO_RETURN);
- fVariableIndex= context.getIndexFromLocal(binding);
- if (fVariableIndex < 0)
- throw new IllegalStateException("Invalid local variable \"" + binding.getName() + "\" for the context."); //$NON-NLS-1$ //$NON-NLS-2$
+ if (variableIndex < 0)
+ throw new IllegalArgumentException("Invalid index for local variable \"" + binding.getName()); //$NON-NLS-1$
+ fVariableIndex= variableIndex;
if (context.considerAccessMode()) {
createAccessModeArray(context);
context.manageLocal(binding);
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/CRefactoring.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/CRefactoring.java
index 798ddf66a29..b93cefc2e78 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/CRefactoring.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/CRefactoring.java
@@ -132,16 +132,16 @@ public abstract class CRefactoring extends Refactoring {
public RefactoringStatus checkInitialConditions(IProgressMonitor pm)
throws CoreException, OperationCanceledException {
SubMonitor sm = SubMonitor.convert(pm, 10);
- sm.subTask(Messages.Refactoring_PM_LoadTU);
- if (isProgressMonitorCanceld(sm, initStatus)) {
+ if (isProgressMonitorCanceled(sm, initStatus)) {
return initStatus;
}
+ sm.subTask(Messages.Refactoring_PM_LoadTU);
IASTTranslationUnit ast = getAST(tu, sm);
if (ast == null) {
initStatus.addError(NLS.bind(Messages.Refactoring_ParsingError, tu.getPath()));
return initStatus;
}
- if (isProgressMonitorCanceld(sm, initStatus)) {
+ if (isProgressMonitorCanceled(sm, initStatus)) {
return initStatus;
}
sm.subTask(Messages.Refactoring_PM_CheckTU);
@@ -152,7 +152,7 @@ public abstract class CRefactoring extends Refactoring {
return initStatus;
}
- protected static boolean isProgressMonitorCanceld(IProgressMonitor sm, RefactoringStatus status) {
+ protected static boolean isProgressMonitorCanceled(IProgressMonitor sm, RefactoringStatus status) {
if (sm.isCanceled()) {
status.addFatalError(Messages.Refactoring_CanceledByUser);
return true;
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/NameInformation.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/NameInformation.java
index 8859680deed..68f2fa4d808 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/NameInformation.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/NameInformation.java
@@ -278,6 +278,7 @@ public class NameInformation {
if (!isWriteAccess) {
indirection = Indirection.REFERENCE;
}
+ // TODO(sprigogin): Verify availability of the copy ctor before passing by value
} else {
indirection = Indirection.POINTER;
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/ExtractFunctionRefactoring.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/ExtractFunctionRefactoring.java
index 6e294bdc6b0..ef15e271284 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/ExtractFunctionRefactoring.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/ExtractFunctionRefactoring.java
@@ -173,7 +173,7 @@ public class ExtractFunctionRefactoring extends CRefactoring {
nodeFactory = ast.getASTNodeFactory();
container = findExtractableNodes();
- if (isProgressMonitorCanceld(sm, initStatus))
+ if (isProgressMonitorCanceled(sm, initStatus))
return initStatus;
if (container.isEmpty()) {
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractlocalvariable/ExtractLocalVariableRefactoring.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractlocalvariable/ExtractLocalVariableRefactoring.java
index f2fff7c0092..37fd2cb8c18 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractlocalvariable/ExtractLocalVariableRefactoring.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractlocalvariable/ExtractLocalVariableRefactoring.java
@@ -114,7 +114,7 @@ public class ExtractLocalVariableRefactoring extends CRefactoring {
}
sm.worked(1);
- if (isProgressMonitorCanceld(sm, initStatus))
+ if (isProgressMonitorCanceled(sm, initStatus))
return initStatus;
boolean oneMarked = selectedRegion != null && isOneMarked(container.getNodesToWrite(), selectedRegion);
@@ -125,7 +125,7 @@ public class ExtractLocalVariableRefactoring extends CRefactoring {
}
sm.worked(1);
- if (isProgressMonitorCanceld(sm, initStatus))
+ if (isProgressMonitorCanceled(sm, initStatus))
return initStatus;
sm.worked(1);
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/hidemethod/HideMethodRefactoring.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/hidemethod/HideMethodRefactoring.java
index 18d8d571577..6a588328ed7 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/hidemethod/HideMethodRefactoring.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/hidemethod/HideMethodRefactoring.java
@@ -93,7 +93,7 @@ public class HideMethodRefactoring extends CRefactoring {
return initStatus;
}
- if (isProgressMonitorCanceld(sm, initStatus))
+ if (isProgressMonitorCanceled(sm, initStatus))
return initStatus;
List names = findAllMarkedNames();
@@ -118,7 +118,7 @@ public class HideMethodRefactoring extends CRefactoring {
return initStatus;
}
- if (isProgressMonitorCanceld(sm, initStatus))
+ if (isProgressMonitorCanceled(sm, initStatus))
return initStatus;
if (methodDeclaration instanceof IASTFunctionDefinition) {
IASTDeclarator declarator = ((IASTFunctionDefinition) methodDeclaration).getDeclarator();
diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/AddWatchpointDialog.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/AddWatchpointDialog.java
new file mode 100644
index 00000000000..f7c4231a94e
--- /dev/null
+++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/AddWatchpointDialog.java
@@ -0,0 +1,29 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Wind River Systems 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:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.debug.internal.ui.actions;
+
+import org.eclipse.cdt.debug.core.cdi.model.ICDIMemorySpaceManagement;
+import org.eclipse.swt.widgets.Shell;
+
+/**
+ * This class was moved to the org.eclipse.cdt.debug.internal.ui.actions.breakpoints
+ * package. This class is left here for backward compatibility for extenders that
+ * reference this internal class (see Bug 374983).
+ *
+ * @deprecated Replaced by opening a properties dialog on a new breakpoint.
+ */
+public class AddWatchpointDialog extends org.eclipse.cdt.debug.internal.ui.actions.breakpoints.AddWatchpointDialog {
+
+ public AddWatchpointDialog( Shell parentShell, ICDIMemorySpaceManagement memMgmt ) {
+ super(parentShell, memMgmt);
+ }
+
+}
diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/breakpoints/CToggleMethodBreakpointActionDelegate.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/breakpoints/CToggleMethodBreakpointActionDelegate.java
index 85c8d914694..37aa40ad275 100644
--- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/breakpoints/CToggleMethodBreakpointActionDelegate.java
+++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/breakpoints/CToggleMethodBreakpointActionDelegate.java
@@ -37,9 +37,9 @@ public class CToggleMethodBreakpointActionDelegate extends CToggleBreakpointObje
{
if ((event.stateMask & SWT.MOD1) != 0 &&
target instanceof IToggleBreakpointsTargetCExtension &&
- ((IToggleBreakpointsTargetCExtension)target).canCreateLineBreakpointsInteractive(part, selection))
+ ((IToggleBreakpointsTargetCExtension)target).canCreateFunctionBreakpointInteractive(part, selection))
{
- ((IToggleBreakpointsTargetCExtension)target).createLineBreakpointsInteractive(part, selection);
+ ((IToggleBreakpointsTargetCExtension)target).createFunctionBreakpointInteractive(part, selection);
}
else {
target.toggleMethodBreakpoints(part, selection);
diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.multicorevisualizer.ui/src/org/eclipse/cdt/dsf/gdb/multicorevisualizer/internal/ui/view/MulticoreVisualizer.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.multicorevisualizer.ui/src/org/eclipse/cdt/dsf/gdb/multicorevisualizer/internal/ui/view/MulticoreVisualizer.java
index 0b9d2188815..2aca3f6ad35 100755
--- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.multicorevisualizer.ui/src/org/eclipse/cdt/dsf/gdb/multicorevisualizer/internal/ui/view/MulticoreVisualizer.java
+++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.multicorevisualizer.ui/src/org/eclipse/cdt/dsf/gdb/multicorevisualizer/internal/ui/view/MulticoreVisualizer.java
@@ -33,8 +33,8 @@ import org.eclipse.cdt.dsf.gdb.multicorevisualizer.internal.utils.DSFDebugModel;
import org.eclipse.cdt.dsf.gdb.multicorevisualizer.internal.utils.DSFDebugModelListener;
import org.eclipse.cdt.dsf.gdb.multicorevisualizer.internal.utils.DSFSessionState;
import org.eclipse.cdt.dsf.gdb.multicorevisualizer.internal.utils.DebugViewUtils;
-import org.eclipse.cdt.dsf.gdb.service.IGDBHardware.ICPUDMContext;
-import org.eclipse.cdt.dsf.gdb.service.IGDBHardware.ICoreDMContext;
+import org.eclipse.cdt.dsf.gdb.service.IGDBHardwareAndOS.ICPUDMContext;
+import org.eclipse.cdt.dsf.gdb.service.IGDBHardwareAndOS.ICoreDMContext;
import org.eclipse.cdt.dsf.mi.service.IMIExecutionDMContext;
import org.eclipse.cdt.dsf.mi.service.IMIProcessDMContext;
import org.eclipse.cdt.dsf.ui.viewmodel.datamodel.IDMVMContext;
diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.multicorevisualizer.ui/src/org/eclipse/cdt/dsf/gdb/multicorevisualizer/internal/utils/DSFDebugModel.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.multicorevisualizer.ui/src/org/eclipse/cdt/dsf/gdb/multicorevisualizer/internal/utils/DSFDebugModel.java
index 101673d3b91..d7b65a1020e 100644
--- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.multicorevisualizer.ui/src/org/eclipse/cdt/dsf/gdb/multicorevisualizer/internal/utils/DSFDebugModel.java
+++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.multicorevisualizer.ui/src/org/eclipse/cdt/dsf/gdb/multicorevisualizer/internal/utils/DSFDebugModel.java
@@ -30,10 +30,10 @@ import org.eclipse.cdt.dsf.debug.service.IRunControl.StateChangeReason;
import org.eclipse.cdt.dsf.debug.service.command.ICommandControlService;
import org.eclipse.cdt.dsf.debug.service.command.ICommandControlService.ICommandControlDMContext;
import org.eclipse.cdt.dsf.gdb.multicorevisualizer.internal.ui.model.VisualizerExecutionState;
-import org.eclipse.cdt.dsf.gdb.service.IGDBHardware;
-import org.eclipse.cdt.dsf.gdb.service.IGDBHardware.ICPUDMContext;
-import org.eclipse.cdt.dsf.gdb.service.IGDBHardware.ICoreDMContext;
-import org.eclipse.cdt.dsf.gdb.service.IGDBHardware.IHardwareTargetDMContext;
+import org.eclipse.cdt.dsf.gdb.service.IGDBHardwareAndOS;
+import org.eclipse.cdt.dsf.gdb.service.IGDBHardwareAndOS.ICPUDMContext;
+import org.eclipse.cdt.dsf.gdb.service.IGDBHardwareAndOS.ICoreDMContext;
+import org.eclipse.cdt.dsf.gdb.service.IGDBHardwareAndOS.IHardwareTargetDMContext;
import org.eclipse.cdt.dsf.gdb.service.IGDBProcesses.IGdbThreadDMData;
import org.eclipse.cdt.dsf.mi.service.IMIExecutionDMContext;
@@ -61,7 +61,7 @@ public class DSFDebugModel {
final Object arg)
{
ICommandControlService controlService = sessionState.getService(ICommandControlService.class);
- IGDBHardware hwService = sessionState.getService(IGDBHardware.class);
+ IGDBHardwareAndOS hwService = sessionState.getService(IGDBHardwareAndOS.class);
if (controlService == null || hwService == null) {
listener.getCPUsDone(null, arg);
return;
@@ -99,7 +99,7 @@ public class DSFDebugModel {
final DSFDebugModelListener listener,
final Object arg)
{
- IGDBHardware hwService = sessionState.getService(IGDBHardware.class);
+ IGDBHardwareAndOS hwService = sessionState.getService(IGDBHardwareAndOS.class);
if (hwService == null) {
listener.getCoresDone(cpuContext, null, arg);
return;
diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.multicorevisualizer.ui/src/org/eclipse/cdt/dsf/gdb/multicorevisualizer/internal/utils/DSFDebugModelListener.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.multicorevisualizer.ui/src/org/eclipse/cdt/dsf/gdb/multicorevisualizer/internal/utils/DSFDebugModelListener.java
index ccc0eed5fb8..f55a2594d9a 100644
--- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.multicorevisualizer.ui/src/org/eclipse/cdt/dsf/gdb/multicorevisualizer/internal/utils/DSFDebugModelListener.java
+++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.multicorevisualizer.ui/src/org/eclipse/cdt/dsf/gdb/multicorevisualizer/internal/utils/DSFDebugModelListener.java
@@ -15,8 +15,8 @@ package org.eclipse.cdt.dsf.gdb.multicorevisualizer.internal.utils;
import org.eclipse.cdt.dsf.datamodel.IDMContext;
import org.eclipse.cdt.dsf.debug.service.IProcesses.IThreadDMData;
import org.eclipse.cdt.dsf.gdb.multicorevisualizer.internal.ui.model.VisualizerExecutionState;
-import org.eclipse.cdt.dsf.gdb.service.IGDBHardware.ICPUDMContext;
-import org.eclipse.cdt.dsf.gdb.service.IGDBHardware.ICoreDMContext;
+import org.eclipse.cdt.dsf.gdb.service.IGDBHardwareAndOS.ICPUDMContext;
+import org.eclipse.cdt.dsf.gdb.service.IGDBHardwareAndOS.ICoreDMContext;
import org.eclipse.cdt.dsf.mi.service.IMIExecutionDMContext;
/** Interface for classes that interact with DSFDebugModel.
diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/ProcessPrompter.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/ProcessPrompter.java
index 764b2409a07..8df673aa10c 100644
--- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/ProcessPrompter.java
+++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/ProcessPrompter.java
@@ -97,6 +97,12 @@ public class ProcessPrompter implements IStatusHandler {
// we will get confused when using path.lastSegment(), so,
// let's only keep the name to be sure
String name = info.getName();
+ if (name == null || name.isEmpty()) {
+ // Skip elements that have no name
+ // Bug 374823
+ return null;
+ }
+
name = name.split("\\s", 2)[0]; //$NON-NLS-1$
IPath path = new Path(name);
diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/internal/CoreList.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/internal/CoreList.java
index 55007d29bb0..0b2f5dfdbca 100644
--- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/internal/CoreList.java
+++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/internal/CoreList.java
@@ -51,40 +51,43 @@ public class CoreList {
Vector coreInfo = new Vector();
BufferedReader reader = null;
try {
+ String processorId = null;
String physicalId = null;
- String coreId = null;
- String cpuCores = null;
Reader r = new InputStreamReader(new FileInputStream(cpuInfo));
reader = new BufferedReader(r);
String line;
while ((line = reader.readLine()) != null) {
line = line.trim();
- if (line.startsWith("physical id")) { //$NON-NLS-1$
+ if (line.startsWith("processor")) { //$NON-NLS-1$
+ if (processorId != null) {
+ // We are already at the next 'processor' entry, without
+ // having found the 'physical id' entry. This means
+ // there is a single physical CPU.
+ physicalId = "0"; //$NON-NLS-1$
+
+ coreInfo.add(new CoreInfo(processorId, physicalId));
+ processorId = null;
+ }
+ // Found the processor id of this core, so store it temporarily
+ processorId = line.split(":")[1].trim(); //$NON-NLS-1$
+ } else if (line.startsWith("physical id")) { //$NON-NLS-1$
// Found the physical id of this core, so store it temporarily
+
+ assert physicalId == null;
physicalId = line.split(":")[1].trim(); //$NON-NLS-1$
- } else if (line.startsWith("core id")) { //$NON-NLS-1$
- // Found core id of this core which come after the entry
- // for physical id, so we have both now.
- coreId = line.split(":")[1].trim(); //$NON-NLS-1$
- } else if (line.startsWith("cpu cores")) { //$NON-NLS-1$
- // Found CPU core count which comes after the entry
- // for core id, so we have all three by now.
- cpuCores = line.split(":")[1].trim(); //$NON-NLS-1$
-
- int cid = Integer.parseInt(coreId);
- int pid = Integer.parseInt(physicalId);
- int cores_per_pid = Integer.parseInt(cpuCores);
- String absoluteCoreID = Integer.toString(cid + pid * cores_per_pid);
-
- coreInfo.add(new CoreInfo(absoluteCoreID, physicalId));
+
+ coreInfo.add(new CoreInfo(processorId, physicalId));
// Get ready to look for the next core.
+ processorId = null;
physicalId = null;
- coreId = null;
- cpuCores = null;
}
- }
+ }
+ if (processorId != null) {
+ // This will happen when there is no 'physical id' field
+ coreInfo.add(new CoreInfo(processorId, "0")); //$NON-NLS-1$
+ }
} catch (IOException e) {
} finally {
try {
diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/ServicesLaunchSequence.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/ServicesLaunchSequence.java
index 22ffdf57f92..ad15fc60642 100644
--- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/ServicesLaunchSequence.java
+++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/ServicesLaunchSequence.java
@@ -29,7 +29,7 @@ import org.eclipse.cdt.dsf.debug.service.ISourceLookup;
import org.eclipse.cdt.dsf.debug.service.ISourceLookup.ISourceLookupDMContext;
import org.eclipse.cdt.dsf.debug.service.IStack;
import org.eclipse.cdt.dsf.debug.service.command.ICommandControlService;
-import org.eclipse.cdt.dsf.gdb.service.IGDBHardware;
+import org.eclipse.cdt.dsf.gdb.service.IGDBHardwareAndOS;
import org.eclipse.cdt.dsf.gdb.service.IGDBTraceControl;
import org.eclipse.cdt.dsf.mi.service.CSourceLookup;
import org.eclipse.cdt.dsf.mi.service.IMIBackend;
@@ -62,7 +62,7 @@ public class ServicesLaunchSequence extends Sequence {
},
new Step() { @Override
public void execute(RequestMonitor requestMonitor) {
- IGDBHardware hwService = fLaunch.getServiceFactory().createService(IGDBHardware.class, fSession, fLaunch.getLaunchConfiguration());
+ IGDBHardwareAndOS hwService = fLaunch.getServiceFactory().createService(IGDBHardwareAndOS.class, fSession, fLaunch.getLaunchConfiguration());
hwService.initialize(requestMonitor);
}},
new Step() { @Override
diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBHardware.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBHardwareAndOS.java
similarity index 98%
rename from dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBHardware.java
rename to dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBHardwareAndOS.java
index 48d0a69d9ce..fb848126623 100644
--- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBHardware.java
+++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBHardwareAndOS.java
@@ -60,13 +60,13 @@ import org.eclipse.core.runtime.Status;
import org.osgi.framework.BundleContext;
/**
- * This class implements the IGDBHardware interface which gives access
+ * This class implements the {@link IGDBHardwareAndOS} interface which gives access
* to hardware information about the target.
*
* @since 4.1
*/
@SuppressWarnings("restriction")
-public class GDBHardware extends AbstractDsfService implements IGDBHardware, ICachingService {
+public class GDBHardwareAndOS extends AbstractDsfService implements IGDBHardwareAndOS, ICachingService {
@Immutable
protected static class GDBCPUDMC extends AbstractDMContext
@@ -171,7 +171,7 @@ public class GDBHardware extends AbstractDsfService implements IGDBHardware, ICa
// Bug 374293
private boolean fSessionInitializationComplete;
- public GDBHardware(DsfSession session) {
+ public GDBHardwareAndOS(DsfSession session) {
super(session);
}
@@ -216,8 +216,8 @@ public class GDBHardware extends AbstractDsfService implements IGDBHardware, ICa
getSession().addServiceEventListener(this, null);
// Register this service.
- register(new String[] { IGDBHardware.class.getName(),
- GDBHardware.class.getName() },
+ register(new String[] { IGDBHardwareAndOS.class.getName(),
+ GDBHardwareAndOS.class.getName() },
new Hashtable());
requestMonitor.done();
diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GdbDebugServicesFactory.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GdbDebugServicesFactory.java
index 7d6c78fcee7..a419748ed67 100644
--- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GdbDebugServicesFactory.java
+++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GdbDebugServicesFactory.java
@@ -96,10 +96,10 @@ public class GdbDebugServicesFactory extends AbstractDsfDebugServicesFactory {
return (V)createTraceControlService(session, (ILaunchConfiguration)arg);
}
}
- } else if (IGDBHardware.class.isAssignableFrom(clazz)) {
+ } else if (IGDBHardwareAndOS.class.isAssignableFrom(clazz)) {
for (Object arg : optionalArguments) {
if (arg instanceof ILaunchConfiguration) {
- return (V)createHardwareService(session, (ILaunchConfiguration)arg);
+ return (V)createHardwareAndOSService(session, (ILaunchConfiguration)arg);
}
}
}
@@ -223,7 +223,7 @@ public class GdbDebugServicesFactory extends AbstractDsfDebugServicesFactory {
}
/** @since 4.1 */
- protected IGDBHardware createHardwareService(DsfSession session, ILaunchConfiguration config) {
- return new GDBHardware(session);
+ protected IGDBHardwareAndOS createHardwareAndOSService(DsfSession session, ILaunchConfiguration config) {
+ return new GDBHardwareAndOS(session);
}
}
diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/IGDBHardware.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/IGDBHardwareAndOS.java
similarity index 98%
rename from dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/IGDBHardware.java
rename to dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/IGDBHardwareAndOS.java
index 205d38ebadd..b3035e8e59e 100644
--- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/IGDBHardware.java
+++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/IGDBHardwareAndOS.java
@@ -25,7 +25,7 @@ import org.eclipse.cdt.dsf.service.IDsfService;
*
* @since 4.1
*/
-public interface IGDBHardware extends IDsfService {
+public interface IGDBHardwareAndOS extends IDsfService {
/**
* The physical target that has CPUs and Cores.
diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/command/GDBControlDMContext.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/command/GDBControlDMContext.java
index 546e1a094d2..bd1b0f3ba0e 100644
--- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/command/GDBControlDMContext.java
+++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/command/GDBControlDMContext.java
@@ -15,7 +15,7 @@ package org.eclipse.cdt.dsf.gdb.service.command;
import org.eclipse.cdt.dsf.debug.service.IModules.ISymbolDMContext;
import org.eclipse.cdt.dsf.debug.service.ISignals.ISignalsDMContext;
import org.eclipse.cdt.dsf.debug.service.ISourceLookup.ISourceLookupDMContext;
-import org.eclipse.cdt.dsf.gdb.service.IGDBHardware.IHardwareTargetDMContext;
+import org.eclipse.cdt.dsf.gdb.service.IGDBHardwareAndOS.IHardwareTargetDMContext;
import org.eclipse.cdt.dsf.gdb.service.IGDBTraceControl.ITraceTargetDMContext;
import org.eclipse.cdt.dsf.mi.service.command.MIControlDMContext;
diff --git a/dsf/org.eclipse.cdt.dsf.ui/plugin.xml b/dsf/org.eclipse.cdt.dsf.ui/plugin.xml
index b3bda1e7b55..c745ce4544d 100644
--- a/dsf/org.eclipse.cdt.dsf.ui/plugin.xml
+++ b/dsf/org.eclipse.cdt.dsf.ui/plugin.xml
@@ -468,7 +468,7 @@
id="org.eclipse.cdt.dsf.debug.ui.disassemblyViewToggleBreakpointTester"
namespace="org.eclipse.cdt.dsf.debug.ui"
properties="isDisassemblyViewSupportsCBreakpoint"
- type="org.eclipse.cdt.dsf.debug.internal.ui.disassembly.DisassemblyView">
+ type="org.eclipse.cdt.dsf.debug.internal.ui.disassembly.DisassemblyPart">
-
-
diff --git a/releng/org.eclipse.cdt.repo/category.xml b/releng/org.eclipse.cdt.repo/category.xml
index 6be8d24d638..41a589de88f 100644
--- a/releng/org.eclipse.cdt.repo/category.xml
+++ b/releng/org.eclipse.cdt.repo/category.xml
@@ -56,4 +56,10 @@
+
+
+
+
+
+
diff --git a/releng/org.eclipse.cdt.sdk-feature/feature.xml b/releng/org.eclipse.cdt.sdk-feature/feature.xml
index fe5d8838bff..ac1bca3c926 100644
--- a/releng/org.eclipse.cdt.sdk-feature/feature.xml
+++ b/releng/org.eclipse.cdt.sdk-feature/feature.xml
@@ -45,10 +45,6 @@
id="org.eclipse.cdt"
version="0.0.0"/>
-
-