1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-23 14:42:11 +02:00

Merge branch 'master' of ssh://mkhodjai@git.eclipse.org/gitroot/cdt/org.eclipse.cdt.git

This commit is contained in:
Mikhail Khodjaiants 2012-03-22 13:24:14 -04:00
commit 9e7c69f289
53 changed files with 1780 additions and 1558 deletions

View file

@ -63,5 +63,12 @@
download-size="0" download-size="0"
install-size="0" install-size="0"
version="0.0.0"/> version="0.0.0"/>
<plugin
id="org.eclipse.linuxtools.cdt.autotools.core"
download-size="0"
install-size="0"
version="0.0.0"
unpack="false"/>
</feature> </feature>

View file

@ -15,30 +15,24 @@
package org.eclipse.cdt.make.core; package org.eclipse.cdt.make.core;
import java.io.IOException; import java.io.IOException;
import java.io.OutputStream;
import java.net.URI; import java.net.URI;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.CommandLauncher; import org.eclipse.cdt.core.CommandLauncher;
import org.eclipse.cdt.core.ErrorParserManager; import org.eclipse.cdt.core.ErrorParserManager;
import org.eclipse.cdt.core.ICommandLauncher; 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.ACBuilder;
import org.eclipse.cdt.core.resources.IConsole; 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.internal.core.ConsoleOutputSniffer; import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoConsoleParser;
import org.eclipse.cdt.make.internal.core.MakeMessages; 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.make.internal.core.scannerconfig.ScannerInfoConsoleParserFactory;
import org.eclipse.cdt.utils.CommandLineUtil; 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.IProject;
import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IResourceDelta; 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.IStatus;
import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.OperationCanceledException; 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.Status;
import org.eclipse.core.runtime.SubProgressMonitor; import org.eclipse.core.runtime.SubProgressMonitor;
import org.eclipse.core.runtime.jobs.ISchedulingRule; 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. * @noinstantiate This class is not intended to be instantiated by clients.
*/ */
public class MakeBuilder extends ACBuilder { public class MakeBuilder extends ACBuilder {
public final static String BUILDER_ID = MakeCorePlugin.getUniqueIdentifier() + ".makeBuilder"; //$NON-NLS-1$ 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() { 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) { protected boolean invokeMake(int kind, IMakeBuilderInfo info, IProgressMonitor monitor) {
boolean isClean = false; boolean isClean = false;
IProject currProject = getProject(); IProject project = getProject();
buildRunnerHelper = new BuildRunnerHelper(project);
if (monitor == null) {
monitor = new NullProgressMonitor();
}
monitor.beginTask(MakeMessages.getString("MakeBuilder.Invoking_Make_Builder") + currProject.getName(), 100); //$NON-NLS-1$
try { 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(); IPath buildCommand = info.getBuildCommand();
if (buildCommand != null) { if (buildCommand != null) {
IConsole console = CCorePlugin.getDefault().getConsole(); IConsole console = CCorePlugin.getDefault().getConsole();
console.start(currProject); console.start(project);
OutputStream cos = console.getOutputStream(); // Prepare launch parameters for BuildRunnerHelper
ICommandLauncher launcher = new CommandLauncher();
// 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);
String[] targets = getTargets(kind, info); String[] targets = getTargets(kind, info);
if (targets.length != 0 && targets[targets.length - 1].equals(info.getCleanBuildTarget())) if (targets.length != 0 && targets[targets.length - 1].equals(info.getCleanBuildTarget()))
isClean = true; isClean = true;
String errMsg = null; String[] args = getCommandArguments(info, targets);
ICommandLauncher launcher = new CommandLauncher();
launcher.setProject(currProject);
// Print the command for visual interaction.
launcher.showCommand(true);
// Set the environment URI workingDirectoryURI = MakeBuilderUtil.getBuildDirectoryURI(project, info);
HashMap<String, String> envMap = new HashMap<String, String>();
if (info.appendEnvironment()) {
@SuppressWarnings({"unchecked", "rawtypes"})
Map<String, String> env = (Map)launcher.getEnvironment();
envMap.putAll(env);
}
// Add variables from build info
envMap.putAll(info.getExpandedEnvironment());
List<String> strings= new ArrayList<String>(envMap.size());
Set<Entry<String, String>> entrySet = envMap.entrySet();
for (Entry<String, String> 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);
if (errMsg != null) { HashMap<String, String> envMap = getEnvironment(launcher, info);
consoleErr.write((errMsg + '\n').getBytes()); String[] envp = BuildRunnerHelper.envMapToEnvp(envMap);
String[] errorParsers = info.getErrorParsers();
ErrorParserManager epm = new ErrorParserManager(getProject(), workingDirectoryURI, this, errorParsers);
List<IConsoleParser> parsers = new ArrayList<IConsoleParser>();
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);
} }
} else {
stdout.close(); String msg = MakeMessages.getFormattedString("MakeBuilder.message.undefined.build.command", project.getName()); //$NON-NLS-1$
stderr.close(); throw new CoreException(new Status(IStatus.ERROR, MakeCorePlugin.PLUGIN_ID, msg, new Exception()));
consoleOut.close();
consoleErr.close();
cos.close();
} }
} catch (Exception e) { } catch (Exception e) {
MakeCorePlugin.log(e); MakeCorePlugin.log(e);
} finally { } finally {
try {
buildRunnerHelper.close();
} catch (IOException e) {
MakeCorePlugin.log(e);
}
monitor.done(); monitor.done();
} }
return (isClean); return isClean;
}
private HashMap<String, String> getEnvironment(ICommandLauncher launcher, IMakeBuilderInfo info)
throws CoreException {
HashMap<String, String> envMap = new HashMap<String, String>();
if (info.appendEnvironment()) {
@SuppressWarnings({"unchecked", "rawtypes"})
Map<String, String> 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 * @since 6.0
*/ */
protected void refreshProject(IProject project) { protected void refreshProject(IProject project) {
try { if (buildRunnerHelper != null) {
// Do not allow the cancel of the refresh, since the builder is external buildRunnerHelper.refreshProject(null);
// 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);
} }
} }
@ -339,14 +303,4 @@ public class MakeBuilder extends ACBuilder {
private String[] makeArray(String string) { private String[] makeArray(String string) {
return CommandLineUtil.argumentsToArray(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);
}
}
} }

View file

@ -14,10 +14,8 @@ AbstractGCCBOPConsoleParser_EnteringDirectory=Entering directory
AbstractGCCBOPConsoleParser_LeavingDirectory=Leaving directory AbstractGCCBOPConsoleParser_LeavingDirectory=Leaving directory
MakeBuilder.Invoking_Make_Builder=Invoking Make Builder... MakeBuilder.Invoking_Make_Builder=Invoking Make Builder...
MakeBuilder.Invoking_Command=Invoking Command: MakeBuilder.message.error.build = Internal error building project {0}
MakeBuilder.Updating_project=Updating project... MakeBuilder.message.undefined.build.command = Build command is null for project {0}
MakeBuilder.Creating_Markers=Generating markers...
MakeBuilder.ErrorWorkingDirectory=Error determining working directory.
BuildInfoFactory.Missing_Builder=Missing Builder: BuildInfoFactory.Missing_Builder=Missing Builder:
@ -37,12 +35,7 @@ ScannerConfigInfoFactory.Missing_Builder=Missing Builder:
ExternalScannerInfoProvider.Console_Name=CDT Built-in Specs Console, {0} ExternalScannerInfoProvider.Console_Name=CDT Built-in Specs Console, {0}
ExternalScannerInfoProvider.Reading_Specs=Reading specs ... ExternalScannerInfoProvider.Reading_Specs=Reading specs ...
ExternalScannerInfoProvider.Invoking_Command=Invoking Command: ExternalScannerInfoProvider.Greeting=Scanner Discovery of compiler built-in settings for project {0}
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
ScannerInfoCollector.Processing=Processing discovered scanner configuration ... ScannerInfoCollector.Processing=Processing discovered scanner configuration ...
ScannerInfoCollector.Updating=Updating Scanner Configuration for project ScannerInfoCollector.Updating=Updating Scanner Configuration for project

View file

@ -10,97 +10,18 @@
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.make.internal.core; package org.eclipse.cdt.make.internal.core;
import java.io.IOException;
import java.io.OutputStream; import java.io.OutputStream;
import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IProgressMonitor;
public class StreamMonitor extends OutputStream { /**
*
IProgressMonitor monitor; * @deprecated as of CDT 8.1. Use org.eclipse.cdt.internal.core.StreamMonitor
OutputStream console; *
public final int fTotalWork; */
private int halfWay; @Deprecated
private int currentIncrement = 2; public class StreamMonitor extends org.eclipse.cdt.internal.core.StreamMonitor {
private int nextProgress = currentIncrement;
private int worked = 0;
public StreamMonitor(IProgressMonitor mon, OutputStream cos, int totalWork) { public StreamMonitor(IProgressMonitor mon, OutputStream cos, int totalWork) {
monitor = mon; super(mon, cos, totalWork);
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;
} }
} }

View file

@ -4,7 +4,7 @@
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* IBM - Initial API and implementation * IBM - Initial API and implementation
* Tianchao Li (tianchao.li@gmail.com) - arbitrary build directory (bug #136136) * Tianchao Li (tianchao.li@gmail.com) - arbitrary build directory (bug #136136)
@ -12,6 +12,7 @@
package org.eclipse.cdt.make.internal.core.scannerconfig; package org.eclipse.cdt.make.internal.core.scannerconfig;
import java.io.OutputStream; import java.io.OutputStream;
import java.net.URI;
import org.eclipse.cdt.core.IMarkerGenerator; import org.eclipse.cdt.core.IMarkerGenerator;
import org.eclipse.cdt.internal.core.ConsoleOutputSniffer; 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.IScannerInfoConsoleParser;
import org.eclipse.cdt.make.core.scannerconfig.InfoContext; 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.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.scannerconfig2.ScannerConfigProfileManager;
import org.eclipse.cdt.utils.EFSExtensionManager;
import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
/** /**
* A factory that creates a ConsoleOutputStreamSniffer, * A factory that creates a ConsoleOutputStreamSniffer,
* ScannerInfoConsoleParser and optionally a ScannerInfoConsoleParserUtility. * ScannerInfoConsoleParser and optionally a ScannerInfoConsoleParserUtility.
* *
* @author vhirsl * @author vhirsl
*/ */
public class ScannerInfoConsoleParserFactory { public class ScannerInfoConsoleParserFactory {
@ -64,14 +68,14 @@ public class ScannerInfoConsoleParserFactory {
IScannerInfoCollector collector, IScannerInfoCollector collector,
IMarkerGenerator markerGenerator) { IMarkerGenerator markerGenerator) {
if (scBuildInfo.isProviderOutputParserEnabled(providerId)) { if (scBuildInfo.isProviderOutputParserEnabled(providerId)) {
// get the ESIProvider console parser // get the ESIProvider console parser
SCProfileInstance profileInstance = ScannerConfigProfileManager.getInstance(). SCProfileInstance profileInstance = ScannerConfigProfileManager.getInstance().
getSCProfileInstance(currentProject, context, scBuildInfo.getSelectedProfileId()); getSCProfileInstance(currentProject, context, scBuildInfo.getSelectedProfileId());
IScannerInfoConsoleParser clParser = profileInstance.createExternalScannerInfoParser(providerId); IScannerInfoConsoleParser clParser = profileInstance.createExternalScannerInfoParser(providerId);
IPath buildDirectory = MakeBuilderUtil.getBuildDirectory(currentProject, MakeBuilder.BUILDER_ID); IPath buildDirectory = MakeBuilderUtil.getBuildDirectory(currentProject, MakeBuilder.BUILDER_ID);
clParser.startup(currentProject, buildDirectory, collector, markerGenerator); clParser.startup(currentProject, buildDirectory, collector, markerGenerator);
// create an output stream sniffer // create an output stream sniffer
return new ConsoleOutputSniffer(outputStream, errorStream, new return new ConsoleOutputSniffer(outputStream, errorStream, new
IScannerInfoConsoleParser[] {clParser}); IScannerInfoConsoleParser[] {clParser});
} }
return null; return null;
@ -86,9 +90,9 @@ public class ScannerInfoConsoleParserFactory {
OutputStream errorStream, OutputStream errorStream,
IProject currentProject, IProject currentProject,
IPath workingDirectory, IPath workingDirectory,
IScannerConfigBuilderInfo2 scBuildInfo, IScannerConfigBuilderInfo2 scBuildInfo,
IMarkerGenerator markerGenerator, IMarkerGenerator markerGenerator,
IScannerInfoCollector collector) { IScannerInfoCollector collector) {
return getMakeBuilderOutputSniffer(outputStream, errorStream, currentProject, new InfoContext(currentProject), workingDirectory, scBuildInfo, markerGenerator, collector); return getMakeBuilderOutputSniffer(outputStream, errorStream, currentProject, new InfoContext(currentProject), workingDirectory, scBuildInfo, markerGenerator, collector);
} }
@ -99,48 +103,90 @@ public class ScannerInfoConsoleParserFactory {
public static ConsoleOutputSniffer getMakeBuilderOutputSniffer( public static ConsoleOutputSniffer getMakeBuilderOutputSniffer(
OutputStream outputStream, OutputStream outputStream,
OutputStream errorStream, OutputStream errorStream,
IProject currentProject, IProject project,
InfoContext context, InfoContext infoContext,
IPath workingDirectory, IPath workingDirectory,
IScannerConfigBuilderInfo2 scBuildInfo, IScannerConfigBuilderInfo2 info2,
IMarkerGenerator markerGenerator, 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 { // try {
// get the SC builder settings // get the SC builder settings
/*if (currentProject.hasNature(ScannerConfigNature.NATURE_ID))*/ { /*if (currentProject.hasNature(ScannerConfigNature.NATURE_ID))*/ {
if (scBuildInfo == null) { if (info2 == null) {
try { try {
IScannerConfigBuilderInfo2Set container = ScannerConfigProfileManager. IScannerConfigBuilderInfo2Set container = ScannerConfigProfileManager.createScannerConfigBuildInfo2Set(project);
createScannerConfigBuildInfo2Set(currentProject); info2 = container.getInfo(infoContext);
scBuildInfo = container.getInfo(context); } catch (CoreException e) {
} // builder not installed or disabled
catch (CoreException e) { }
// builder not installed or disabled }
} if (info2 != null && info2.isAutoDiscoveryEnabled() && info2.isBuildOutputParserEnabled()) {
} String id = info2.getSelectedProfileId();
if (scBuildInfo != null &&
scBuildInfo.isAutoDiscoveryEnabled() && // get the make builder console parser
scBuildInfo.isBuildOutputParserEnabled()) { SCProfileInstance profileInstance = ScannerConfigProfileManager.getInstance().getSCProfileInstance(project, infoContext, id);
// get the make builder console parser parser = profileInstance.createBuildOutputParser();
SCProfileInstance profileInstance = ScannerConfigProfileManager.getInstance(). if (parser != null){
getSCProfileInstance(currentProject, context, scBuildInfo.getSelectedProfileId()); if (collector == null) {
IScannerInfoConsoleParser clParser = profileInstance.createBuildOutputParser(); collector = profileInstance.getScannerInfoCollector();
if (collector == null) { }
collector = profileInstance.getScannerInfoCollector(); parser.startup(project, workingDirectory, collector, info2.isProblemReportingEnabled() ? markerGenerator : null);
} }
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});
}
} }
} }
// } // }
// catch (CoreException e) { // catch (CoreException e) {
// MakeCorePlugin.log(e.getStatus()); // 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;
} }
} }

View file

@ -44,10 +44,7 @@ public class GCCSpecsConsoleParser implements IScannerInfoConsoleParser {
protected List<String> symbols = new ArrayList<String>(); protected List<String> symbols = new ArrayList<String>();
protected List<String> includes = new ArrayList<String>(); protected List<String> includes = new ArrayList<String>();
/* (non-Javadoc) @Override
* @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
public void startup(IProject project, IPath workingDirectory, IScannerInfoCollector collector, IMarkerGenerator markerGenerator) { public void startup(IProject project, IPath workingDirectory, IScannerInfoCollector collector, IMarkerGenerator markerGenerator) {
this.fProject = project; this.fProject = project;
this.fCollector = collector; this.fCollector = collector;
@ -58,21 +55,24 @@ public class GCCSpecsConsoleParser implements IScannerInfoConsoleParser {
*/ */
@Override @Override
public boolean processLine(String line) { public boolean processLine(String line) {
boolean rc = false;
line= line.trim();
TraceUtil.outputTrace("GCCSpecsConsoleParser parsing line: [", line, "]"); //$NON-NLS-1$ //$NON-NLS-2$ 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 // contribution of -dD option
if (line.startsWith(DEFINE)) { if (line.startsWith(DEFINE)) {
String[] defineParts = line.split("\\s+", 3); //$NON-NLS-1$ String[] defineParts = line.split("\\s+", 3); //$NON-NLS-1$
if (defineParts[0].equals(DEFINE)) { if (defineParts[0].equals(DEFINE)) {
if (defineParts[1].indexOf('(') >= 0) { if (defineParts[1].indexOf('(') >= 0) {
// #define __X__(P1, P2) __Y__(P1, P2) // #define __X__(P1, P2) __Y__(P1, P2)
// Enclose matching parentheses pairs // Enclose matching parentheses pairs
// in the macro name if they are present // in the macro name if they are present
int i = line.indexOf(')'); // macro definition itself can have only one pair of brackets 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) { if (i > 0) {
int start = line.indexOf(defineParts[1]); // start of definition int start = line.indexOf(defineParts[1]); // start of definition
defineParts[1] = line.substring(start, i + 1); defineParts[1] = line.substring(start, i + 1);
@ -82,18 +82,18 @@ public class GCCSpecsConsoleParser implements IScannerInfoConsoleParser {
} else { } else {
MakeCorePlugin.log(new Exception("GCCSpecsConsoleParser ERROR: Unmatched brackets: ["+ line+ "]")); //$NON-NLS-1$ //$NON-NLS-2$ 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 // Now defineParts[1] is the symbol name, and [2] is the definition
String symbol = null; String symbol = null;
if (defineParts.length > 1) { if (defineParts.length > 1) {
symbol = defineParts[1] + "="; //$NON-NLS-1$ symbol = defineParts[1] + "="; //$NON-NLS-1$
if (defineParts.length > 2) { if (defineParts.length > 2) {
symbol += defineParts[2]; symbol += defineParts[2];
} }
if (!symbols.contains(symbol)) { if (!symbols.contains(symbol)) {
symbols.add(symbol); symbols.add(symbol);
} }
} }
} }
} }
@ -109,7 +109,7 @@ public class GCCSpecsConsoleParser implements IScannerInfoConsoleParser {
includes.add(line); includes.add(line);
} }
return rc; return false;
} }
/* (non-Javadoc) /* (non-Javadoc)

View file

@ -12,7 +12,6 @@
package org.eclipse.cdt.make.internal.core.scannerconfig2; package org.eclipse.cdt.make.internal.core.scannerconfig2;
import java.io.IOException; import java.io.IOException;
import java.io.OutputStream;
import java.net.URI; import java.net.URI;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Enumeration; 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.ICommandLauncher;
import org.eclipse.cdt.core.model.ILanguage; import org.eclipse.cdt.core.model.ILanguage;
import org.eclipse.cdt.core.resources.IConsole; 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.MakeBuilder;
import org.eclipse.cdt.make.core.MakeBuilderUtil; import org.eclipse.cdt.make.core.MakeBuilderUtil;
import org.eclipse.cdt.make.core.MakeCorePlugin; 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.IScannerInfoCollector;
import org.eclipse.cdt.make.core.scannerconfig.InfoContext; import org.eclipse.cdt.make.core.scannerconfig.InfoContext;
import org.eclipse.cdt.make.internal.core.MakeMessages; 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.ScannerConfigUtil;
import org.eclipse.cdt.make.internal.core.scannerconfig.ScannerInfoConsoleParserFactory;
import org.eclipse.cdt.utils.EFSExtensionManager; import org.eclipse.cdt.utils.EFSExtensionManager;
import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IResource;
@ -56,7 +53,7 @@ import org.osgi.service.prefs.BackingStoreException;
public class DefaultRunSIProvider implements IExternalScannerInfoProvider { 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 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 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 IResource resource;
protected String providerId; protected String providerId;
@ -90,17 +87,20 @@ public class DefaultRunSIProvider implements IExternalScannerInfoProvider {
this.buildInfo = buildInfo; this.buildInfo = buildInfo;
this.collector = collector; this.collector = collector;
IProject currentProject = resource.getProject(); IProject project = resource.getProject();
// call a subclass to initialize protected fields BuildRunnerHelper buildRunnerHelper = new BuildRunnerHelper(project);
if (!initialize()) {
return false;
}
if (monitor == null) {
monitor = new NullProgressMonitor();
}
monitor.beginTask(MakeMessages.getString("ExternalScannerInfoProvider.Reading_Specs"), 100); //$NON-NLS-1$
try { 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(); ILanguage language = context.getLanguage();
IConsole console; IConsole console;
if (language!=null && isConsoleEnabled()) { 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 // 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 = CCorePlugin.getDefault().getConsole(MakeCorePlugin.PLUGIN_ID + ".console.hidden"); //$NON-NLS-1$
} }
console.start(currentProject); console.start(project);
OutputStream cos = console.getOutputStream();
// 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(); ICommandLauncher launcher = new CommandLauncher();
launcher.setProject(currentProject); launcher.setProject(project);
// Print the command for visual interaction.
launcher.showCommand(true);
String[] comandLineOptions = getCommandLineOptions(); String[] comandLineOptions = getCommandLineOptions();
IPath program = getCommandToLaunch(); 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$ ErrorParserManager epm = new ErrorParserManager(project, markerGenerator, new String[] {GMAKE_ERROR_PARSER_ID});
+ program + params);
ErrorParserManager epm = new ErrorParserManager(currentProject, markerGenerator, new String[] {GMAKE_ERROR_PARSER_ID}); buildRunnerHelper.setLaunchParameters(launcher, program, comandLineOptions, workingDirectoryURI, envp );
epm.setOutputStream(cos); buildRunnerHelper.prepareStreams(epm, null, console, new SubProgressMonitor(monitor, 1 * MONITOR_SCALE, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK));
StreamMonitor streamMon = new StreamMonitor(new SubProgressMonitor(monitor, 70), epm, 100);
OutputStream stdout = streamMon;
OutputStream stderr = streamMon;
ConsoleOutputSniffer sniffer = ScannerInfoConsoleParserFactory.getESIProviderOutputSniffer( buildRunnerHelper.greeting(MakeMessages.getFormattedString("ExternalScannerInfoProvider.Greeting", project.getName())); //$NON-NLS-1$
stdout, stderr, currentProject, context, providerId, buildInfo, collector, markerGenerator); buildRunnerHelper.build(new SubProgressMonitor(monitor, 1 * MONITOR_SCALE, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK));
OutputStream consoleOut = (sniffer == null ? cos : sniffer.getOutputStream()); buildRunnerHelper.close();
OutputStream consoleErr = (sniffer == null ? cos : sniffer.getErrorStream()); buildRunnerHelper.goodbye();
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();
}
if (errMsg != null) { } catch (Exception e) {
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) {
MakeCorePlugin.log(e); MakeCorePlugin.log(e);
} } finally {
finally { try {
buildRunnerHelper.close();
} catch (IOException e) {
MakeCorePlugin.log(e);
}
monitor.done(); monitor.done();
} }
return true; return true;
@ -185,11 +155,6 @@ public class DefaultRunSIProvider implements IExternalScannerInfoProvider {
buildInfo.isUseDefaultProviderCommand(providerId)); buildInfo.isUseDefaultProviderCommand(providerId));
} }
private void printLine(OutputStream stream, String msg) throws IOException {
stream.write((msg + NEWLINE).getBytes());
stream.flush();
}
/** /**
* Initialization of protected fields. * Initialization of protected fields.
* Subclasses are most likely to override default implementation. * Subclasses are most likely to override default implementation.
@ -223,16 +188,6 @@ public class DefaultRunSIProvider implements IExternalScannerInfoProvider {
return fCompileArguments; 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) { private Properties getEnvMap(ICommandLauncher launcher, Properties initialEnv) {
// Set the environmennt, some scripts may need the CWD var to be set. // Set the environmennt, some scripts may need the CWD var to be set.
Properties props = initialEnv != null ? initialEnv : launcher.getEnvironment(); Properties props = initialEnv != null ? initialEnv : launcher.getEnvironment();

View file

@ -20,7 +20,7 @@ import org.eclipse.core.runtime.IProgressMonitor;
/** /**
* Interface implemented by toolchain integrators to perform the actual build. * Interface implemented by toolchain integrators to perform the actual build.
* *
* @author Doug Schaefer * @author Doug Schaefer
* @since 8.0 * @since 8.0
*/ */
@ -29,12 +29,13 @@ public abstract class AbstractBuildRunner {
/** /**
* Perform the build. * Perform the build.
* *
* @param kind kind from the IncrementalProjectBuilder * @param kind - kind from the IncrementalProjectBuilder
* @param project project being built * @param project - project being built
* @param configuration configuration being built * @param configuration - configuration being built
* @param console console to use for build output * @param console - console to use for build output
* @param markerGenerator generator to add markers for build problems * @param markerGenerator - generator to add markers for build problems
* @param monitor progress monitor * @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 * @throws CoreException standard core exception if something goes wrong
*/ */
public abstract boolean invokeBuild(int kind, IProject project, IConfiguration configuration, public abstract boolean invokeBuild(int kind, IProject project, IConfiguration configuration,

View file

@ -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 * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* Wind River Systems - Initial API and implementation * Wind River Systems - Initial API and implementation
* James Blackburn (Broadcom Corp.) * James Blackburn (Broadcom Corp.)
* Andrew Gvozdev
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.managedbuilder.core; package org.eclipse.cdt.managedbuilder.core;
import java.io.IOException; import java.io.IOException;
import java.io.OutputStream;
import java.net.URI; import java.net.URI;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; 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.CCorePlugin;
import org.eclipse.cdt.core.ErrorParserManager; import org.eclipse.cdt.core.ErrorParserManager;
import org.eclipse.cdt.core.ICommandLauncher; import org.eclipse.cdt.core.ICommandLauncher;
import org.eclipse.cdt.core.IConsoleParser;
import org.eclipse.cdt.core.IMarkerGenerator; import org.eclipse.cdt.core.IMarkerGenerator;
import org.eclipse.cdt.core.envvar.IEnvironmentVariable; import org.eclipse.cdt.core.envvar.IEnvironmentVariable;
import org.eclipse.cdt.core.envvar.IEnvironmentVariableManager; 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.IConsole;
import org.eclipse.cdt.core.resources.RefreshScopeManager;
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription; 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.IScannerConfigBuilderInfo2;
import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector;
import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoConsoleParser; import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoConsoleParser;
import org.eclipse.cdt.make.core.scannerconfig.InfoContext; import org.eclipse.cdt.make.internal.core.scannerconfig.ScannerInfoConsoleParserFactory;
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.managedbuilder.internal.core.ManagedMakeMessages; import org.eclipse.cdt.managedbuilder.internal.core.ManagedMakeMessages;
import org.eclipse.cdt.managedbuilder.macros.BuildMacroException; import org.eclipse.cdt.managedbuilder.macros.BuildMacroException;
import org.eclipse.cdt.managedbuilder.macros.IBuildMacroProvider; 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.CommandLineUtil;
import org.eclipse.cdt.utils.EFSExtensionManager; import org.eclipse.cdt.utils.EFSExtensionManager;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IProject; 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.IncrementalProjectBuilder;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.QualifiedName;
import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.SubProgressMonitor; import org.eclipse.core.runtime.SubProgressMonitor;
@ -69,13 +57,7 @@ import org.eclipse.core.runtime.SubProgressMonitor;
* @since 8.0 * @since 8.0
*/ */
public class ExternalBuildRunner extends AbstractBuildRunner { public class ExternalBuildRunner extends AbstractBuildRunner {
private static final int MONITOR_SCALE = 100;
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$
@Override @Override
public boolean invokeBuild(int kind, IProject project, IConfiguration configuration, 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, protected boolean invokeExternalBuild(int kind, IProject project, IConfiguration configuration,
IBuilder builder, IConsole console, IMarkerGenerator markerGenerator, IBuilder builder, IConsole console, IMarkerGenerator markerGenerator,
IncrementalProjectBuilder projectBuilder, IProgressMonitor monitor) throws CoreException { IncrementalProjectBuilder projectBuilder, IProgressMonitor monitor) throws CoreException {
boolean isClean = false; boolean isClean = false;
if (monitor == null) { BuildRunnerHelper buildRunnerHelper = new BuildRunnerHelper(project);
monitor = new NullProgressMonitor();
}
monitor.beginTask(ManagedMakeMessages.getResourceString("MakeBuilder.Invoking_Make_Builder") + project.getName(), 100); //$NON-NLS-1$
try { 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(); IPath buildCommand = builder.getBuildCommand();
if (buildCommand != null) { if (buildCommand != null) {
OutputStream cos = console.getOutputStream(); String cfgName = configuration.getName();
StringBuffer buf = new StringBuffer(); String toolchainName = configuration.getToolChain().getName();
boolean isSupported = configuration.isSupported();
String[] consoleHeader = new String[3]; ICommandLauncher launcher = builder.getCommandLauncher();
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);
String[] targets = getTargets(kind, builder); String[] targets = getTargets(kind, builder);
if (targets.length != 0 && targets[targets.length - 1].equals(builder.getCleanBuildTarget())) if (targets.length != 0 && targets[targets.length - 1].equals(builder.getCleanBuildTarget()))
isClean = true; isClean = true;
String errMsg = null; String[] args = getCommandArguments(builder, targets);
ICommandLauncher launcher = builder.getCommandLauncher();
launcher.setProject(project); URI workingDirectoryURI = ManagedBuildManager.getBuildLocationURI(configuration, builder);
// Print the command for visual interaction.
launcher.showCommand(true);
// Set the environment
Map<String, String> envMap = getEnvironment(builder); Map<String, String> envMap = getEnvironment(builder);
String[] env = getEnvStrings(envMap); String[] envp = BuildRunnerHelper.envMapToEnvp(envMap);
String[] buildArguments = targets;
String[] newArgs = CommandLineUtil.argumentsToArray(builder.getBuildArguments()); String[] errorParsers = builder.getErrorParsers();
buildArguments = new String[targets.length + newArgs.length]; ErrorParserManager epm = new ErrorParserManager(project, workingDirectoryURI, markerGenerator, errorParsers);
System.arraycopy(newArgs, 0, buildArguments, 0, newArgs.length);
System.arraycopy(targets, 0, buildArguments, newArgs.length, targets.length);
QualifiedName qName = new QualifiedName(ManagedBuilderCorePlugin.getUniqueIdentifier(), "progressMonitor"); //$NON-NLS-1$ List<IConsoleParser> parsers = new ArrayList<IConsoleParser>();
Integer last = (Integer)project.getSessionProperty(qName); collectScannerInfoConsoleParsers(project, configuration, workingDirectoryURI, markerGenerator, parsers);
if (last == null) {
last = new Integer(100); 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()); } else {
epm.setOutputStream(cos); String msg = ManagedMakeMessages.getFormattedString("ManagedMakeBuilder.message.undefined.build.command", builder.getId()); //$NON-NLS-1$
StreamMonitor streamMon = new StreamMonitor(new SubProgressMonitor(monitor, 100), epm, last.intValue()); throw new CoreException(new Status(IStatus.ERROR, ManagedBuilderCorePlugin.PLUGIN_ID, msg, new Exception()));
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();
} }
} catch (Exception e) { } catch (Exception e) {
ManagedBuilderCorePlugin.log(e); String msg = ManagedMakeMessages.getFormattedString("ManagedMakeBuilder.message.error.build", //$NON-NLS-1$
throw new CoreException(new Status(IStatus.ERROR, new String[] { project.getName(), configuration.getName() });
ManagedBuilderCorePlugin.getUniqueIdentifier(), throw new CoreException(new Status(IStatus.ERROR, ManagedBuilderCorePlugin.PLUGIN_ID, msg, e));
e.getLocalizedMessage(),
e));
} finally { } finally {
try {
buildRunnerHelper.close();
} catch (IOException e) {
ManagedBuilderCorePlugin.log(e);
}
monitor.done(); 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) { protected String[] getTargets(int kind, IBuilder builder) {
@ -301,6 +206,7 @@ public class ExternalBuildRunner extends AbstractBuildRunner {
return envMap; return envMap;
} }
@Deprecated
protected static String[] getEnvStrings(Map<String, String> env) { protected static String[] getEnvStrings(Map<String, String> env) {
// Convert into env strings // Convert into env strings
List<String> strings= new ArrayList<String>(env.size()); List<String> strings= new ArrayList<String>(env.size());
@ -313,16 +219,19 @@ public class ExternalBuildRunner extends AbstractBuildRunner {
return strings.toArray(new String[strings.size()]); return strings.toArray(new String[strings.size()]);
} }
private ConsoleOutputSniffer createBuildOutputSniffer(OutputStream outputStream, private static void collectScannerInfoConsoleParsers(IProject project, IConfiguration cfg, URI workingDirectoryURI,
OutputStream errorStream, IMarkerGenerator markerGenerator, List<IConsoleParser> parsers) {
IProject project,
IConfiguration cfg,
IPath workingDirectory,
IMarkerGenerator markerGenerator,
IScannerInfoCollector collector){
ICfgScannerConfigBuilderInfo2Set container = CfgScannerConfigProfileManager.getCfgScannerConfigBuildInfo(cfg); ICfgScannerConfigBuilderInfo2Set container = CfgScannerConfigProfileManager.getCfgScannerConfigBuildInfo(cfg);
Map<CfgInfoContext, IScannerConfigBuilderInfo2> map = container.getInfoMap(); Map<CfgInfoContext, IScannerConfigBuilderInfo2> map = container.getInfoMap();
List<IScannerInfoConsoleParser> clParserList = new ArrayList<IScannerInfoConsoleParser>();
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()){ if(container.isPerRcTypeDiscovery()){
for (IResourceInfo rcInfo : cfg.getResourceInfos()) { for (IResourceInfo rcInfo : cfg.getResourceInfos()) {
@ -337,66 +246,34 @@ public class ExternalBuildRunner extends AbstractBuildRunner {
if(types.length != 0){ if(types.length != 0){
for (IInputType type : types) { for (IInputType type : types) {
CfgInfoContext c = new CfgInfoContext(rcInfo, tool, type); CfgInfoContext context = new CfgInfoContext(rcInfo, tool, type);
contributeToConsoleParserList(project, map, c, workingDirectory, markerGenerator, collector, clParserList); IScannerInfoConsoleParser parser = getScannerInfoConsoleParser(project, map, context, workingDirectory, markerGenerator);
if (parser != null) {
parsers.add(parser);
}
} }
} else { } else {
CfgInfoContext c = new CfgInfoContext(rcInfo, tool, null); CfgInfoContext context = new CfgInfoContext(rcInfo, tool, null);
contributeToConsoleParserList(project, map, c, workingDirectory, markerGenerator, collector, clParserList); IScannerInfoConsoleParser parser = getScannerInfoConsoleParser(project, map, context, workingDirectory, markerGenerator);
if (parser != null) {
parsers.add(parser);
}
} }
} }
} }
} }
if(clParserList.size() == 0){ if(parsers.size() == oldSize){
contributeToConsoleParserList(project, map, new CfgInfoContext(cfg), workingDirectory, markerGenerator, collector, clParserList); CfgInfoContext context = new CfgInfoContext(cfg);
} IScannerInfoConsoleParser parser = getScannerInfoConsoleParser(project, map, context, workingDirectory, markerGenerator);
if (parser != null) {
if(clParserList.size() != 0){ parsers.add(parser);
return new ConsoleOutputSniffer(outputStream, errorStream,
clParserList.toArray(new IScannerInfoConsoleParser[clParserList.size()]));
}
return null;
}
private boolean contributeToConsoleParserList(
IProject project,
Map<CfgInfoContext, IScannerConfigBuilderInfo2> map,
CfgInfoContext context,
IPath workingDirectory,
IMarkerGenerator markerGenerator,
IScannerInfoCollector collector,
List<IScannerInfoConsoleParser> 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;
}
} }
} }
return added;
} }
private static IScannerInfoConsoleParser getScannerInfoConsoleParser(IProject project, Map<CfgInfoContext, IScannerConfigBuilderInfo2> map,
CfgInfoContext context, IPath workingDirectory, IMarkerGenerator markerGenerator) {
return ScannerInfoConsoleParserFactory.getScannerInfoConsoleParser(project, context.toInfoContext(), workingDirectory, map.get(context), markerGenerator, null);
}
} }

View file

@ -13,74 +13,56 @@ package org.eclipse.cdt.managedbuilder.core;
import java.io.IOException; import java.io.IOException;
import java.io.OutputStream; 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.ErrorParserManager;
import org.eclipse.cdt.core.ICommandLauncher;
import org.eclipse.cdt.core.IMarkerGenerator; import org.eclipse.cdt.core.IMarkerGenerator;
import org.eclipse.cdt.core.model.ICModelMarker;
import org.eclipse.cdt.core.resources.IConsole; 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.BuildDescriptionManager;
import org.eclipse.cdt.managedbuilder.buildmodel.IBuildDescription; import org.eclipse.cdt.managedbuilder.buildmodel.IBuildDescription;
import org.eclipse.cdt.managedbuilder.internal.buildmodel.BuildStateManager; import org.eclipse.cdt.managedbuilder.internal.buildmodel.BuildStateManager;
import org.eclipse.cdt.managedbuilder.internal.buildmodel.DescriptionBuilder; 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.IConfigurationBuildState;
import org.eclipse.cdt.managedbuilder.internal.buildmodel.IProjectBuildState; import org.eclipse.cdt.managedbuilder.internal.buildmodel.IProjectBuildState;
import org.eclipse.cdt.managedbuilder.internal.buildmodel.ParallelBuilder; import org.eclipse.cdt.managedbuilder.internal.buildmodel.ParallelBuilder;
import org.eclipse.cdt.managedbuilder.internal.core.ManagedMakeMessages; 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.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IResourceDelta; import org.eclipse.core.resources.IResourceDelta;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.IncrementalProjectBuilder; import org.eclipse.core.resources.IncrementalProjectBuilder;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.NullProgressMonitor; 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. * The build runner for the internal builder.
* *
* @author dschaefer * @author dschaefer
* @since 8.0 * @since 8.0
*/ */
public class InternalBuildRunner extends AbstractBuildRunner { public class InternalBuildRunner extends AbstractBuildRunner {
private static final int MONITOR_SCALE = 100;
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$
@Override @Override
public boolean invokeBuild(int kind, IProject project, IConfiguration configuration, public boolean invokeBuild(int kind, IProject project, IConfiguration configuration,
IBuilder builder, IConsole console, IMarkerGenerator markerGenerator, IBuilder builder, IConsole console, IMarkerGenerator markerGenerator,
IncrementalProjectBuilder projectBuilder, IProgressMonitor monitor) throws CoreException { 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 BuildRunnerHelper buildRunnerHelper = new BuildRunnerHelper(project);
if (monitor == null) {
monitor = new NullProgressMonitor();
}
String[] msgs = new String[2];
msgs[0] = ManagedMakeMessages.getResourceString(INTERNAL_BUILDER);
msgs[1] = project.getName();
ConsoleOutputStream consoleOutStream = null;
OutputStream epmOutputStream = null;
try { 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; int flags = 0;
IResourceDelta delta = projectBuilder.getDelta(project); IResourceDelta delta = projectBuilder.getDelta(project);
BuildStateManager bsMngr = BuildStateManager.getInstance(); BuildStateManager bsMngr = BuildStateManager.getInstance();
@ -88,155 +70,78 @@ public class InternalBuildRunner extends AbstractBuildRunner {
IConfigurationBuildState cBS = pBS.getConfigurationBuildState(configuration.getId(), true); IConfigurationBuildState cBS = pBS.getConfigurationBuildState(configuration.getId(), true);
// if(delta != null){ // if(delta != null){
flags = BuildDescriptionManager.REBUILD | BuildDescriptionManager.REMOVED | BuildDescriptionManager.DEPS; flags = BuildDescriptionManager.REBUILD | BuildDescriptionManager.REMOVED | BuildDescriptionManager.DEPS;
// delta = getDelta(currentProject); // delta = getDelta(currentProject);
// } // }
boolean buildIncrementaly = delta != null; boolean buildIncrementaly = delta != null;
// Get a build console for the project // Prepare launch parameters for BuildRunnerHelper
StringBuffer buf = new StringBuffer(); String cfgName = configuration.getName();
consoleOutStream = console.getOutputStream(); String toolchainName = configuration.getToolChain().getName();
String[] consoleHeader = new String[3]; boolean isConfigurationSupported = configuration.isSupported();
if(buildIncrementaly)
consoleHeader[0] = ManagedMakeMessages.getResourceString(TYPE_INC);
else
consoleHeader[0] = ManagedMakeMessages.getResourceString(TYPE_REBUILD);
consoleHeader[1] = configuration.getName(); URI workingDirectoryURI = ManagedBuildManager.getBuildLocationURI(configuration, builder);
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$
buf.append(ManagedMakeMessages.getResourceString(INTERNAL_BUILDER_HEADER_NOTE)); String[] errorParsers = builder.getErrorParsers();
buf.append("\n"); //$NON-NLS-1$ ErrorParserManager epm = new ErrorParserManager(project, workingDirectoryURI, markerGenerator, errorParsers);
if(!configuration.isSupported()){ buildRunnerHelper.prepareStreams(epm, null, console, new SubProgressMonitor(monitor, 1 * MONITOR_SCALE));
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();
IBuildDescription des = BuildDescriptionManager.createBuildDescription(configuration, cBS, delta, flags); IBuildDescription des = BuildDescriptionManager.createBuildDescription(configuration, cBS, delta, flags);
DescriptionBuilder dBuilder = null; DescriptionBuilder dBuilder = null;
if (!isParallel) if (!isParallel) {
dBuilder = new DescriptionBuilder(des, buildIncrementaly, resumeOnErr, cBS); dBuilder = new DescriptionBuilder(des, buildIncrementaly, resumeOnErr, cBS);
if (dBuilder.getNumCommands() <= 0) {
if(isParallel || dBuilder.getNumCommands() > 0) { buildRunnerHelper.printLine(ManagedMakeMessages.getFormattedString("ManagedMakeBuilder.message.no.build", project.getName())); //$NON-NLS-1$
// Remove all markers for this project return false;
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;
} }
buf.append(System.getProperty("line.separator", "\n")); //$NON-NLS-1$//$NON-NLS-2$ }
// Report time and number of threads used buildRunnerHelper.removeOldMarkers(project, new SubProgressMonitor(monitor, 1 * MONITOR_SCALE, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK));
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));
bsMngr.setProjectBuildState(project, pBS); if (buildIncrementaly) {
buildRunnerHelper.greeting(IncrementalProjectBuilder.INCREMENTAL_BUILD, cfgName, toolchainName, isConfigurationSupported);
} else { } else {
buf = new StringBuffer(); buildRunnerHelper.greeting(ManagedMakeMessages.getResourceString("ManagedMakeBuider.type.rebuild"), cfgName, toolchainName, isConfigurationSupported); //$NON-NLS-1$
buf.append(ManagedMakeMessages.getFormattedString(NOTHING_BUILT, project.getName())); }
buf.append(System.getProperty("line.separator", "\n")); //$NON-NLS-1$//$NON-NLS-2$ buildRunnerHelper.printLine(ManagedMakeMessages.getResourceString("ManagedMakeBuilder.message.internal.builder.header.note")); //$NON-NLS-1$
consoleOutStream.write(buf.toString().getBytes());
consoleOutStream.flush(); 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) { } 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(); 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 { } finally {
if(epmOutputStream != null){ try {
try { buildRunnerHelper.close();
epmOutputStream.close(); } catch (IOException e) {
} catch (IOException e) { ManagedBuilderCorePlugin.log(e);
}
}
if(consoleOutStream != null){
try {
consoleOutStream.close();
} catch (IOException e) {
}
} }
monitor.done(); monitor.done();
} }
return false; return false;
} }
} }

View file

@ -21,8 +21,13 @@ import java.util.Set;
import org.eclipse.cdt.core.CommandLauncher; import org.eclipse.cdt.core.CommandLauncher;
import org.eclipse.cdt.core.ICommandLauncher; import org.eclipse.cdt.core.ICommandLauncher;
import org.eclipse.cdt.managedbuilder.buildmodel.IBuildCommand; 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.CoreException;
import org.eclipse.core.runtime.IProgressMonitor; 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; import org.eclipse.core.runtime.SubProgressMonitor;
/** /**
@ -36,7 +41,6 @@ import org.eclipse.core.runtime.SubProgressMonitor;
* *
*/ */
public class CommandBuilder implements IBuildModelBuilder { 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 static final String NEWLINE = System.getProperty("line.separator", "\n"); //$NON-NLS-1$ //$NON-NLS-2$
private IBuildCommand fCmd; private IBuildCommand fCmd;
@ -84,67 +88,57 @@ public class CommandBuilder implements IBuildModelBuilder {
return new OutputStreamWrapper(out); 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 @Override
public int build(OutputStream out, OutputStream err, IProgressMonitor monitor){ public int build(OutputStream out, OutputStream err, IProgressMonitor monitor) {
//TODO: should we display the command line here? int status = STATUS_ERROR_LAUNCH;
monitor.beginTask("", getNumCommands()); //$NON-NLS-1$
monitor.subTask(""/*getCommandLine()*/); //$NON-NLS-1$
ICommandLauncher launcher = createLauncher();
int status = STATUS_OK;
launcher.showCommand(true);
try { try {
fProcess = launcher.execute(fCmd.getCommand(), fCmd.getArgs(), mapToStringArray(fCmd.getEnvironment()), fCmd.getCWD(), monitor); if (monitor == null) {
} catch (CoreException e1) { monitor = new NullProgressMonitor();
// TODO Auto-generated catch block }
if(DbgUtil.DEBUG) monitor.beginTask("", getNumCommands()); //$NON-NLS-1$
DbgUtil.trace("Error launching command: " + e1.getMessage()); //$NON-NLS-1$ monitor.subTask(ManagedMakeMessages.getResourceString("MakeBuilder.Invoking_Command") + getCommandLine()); //$NON-NLS-1$
monitor.done();
return STATUS_ERROR_LAUNCH; ICommandLauncher launcher = createLauncher();
} launcher.showCommand(true);
int st = ICommandLauncher.ILLEGAL_COMMAND; fProcess = launcher.execute(fCmd.getCommand(), fCmd.getArgs(), mapToStringArray(fCmd.getEnvironment()), fCmd.getCWD(), monitor);
if (fProcess != null) { if (fProcess != null) {
try { try {
// Close the input of the process since we will never write to it // Close the input of the process since we will never write to it
fProcess.getOutputStream().close(); fProcess.getOutputStream().close();
} catch (IOException e) { } 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(); fErrMsg = launcher.getErrorMessage();
if(DbgUtil.DEBUG) if (fErrMsg != null && !fErrMsg.isEmpty()) {
DbgUtil.trace("command cancelled: " + fErrMsg); //$NON-NLS-1$ printMessage(fErrMsg, err);
}
printMessage(fErrMsg, out); } catch (CoreException e) {
break; ManagedBuilderCorePlugin.log(new Status(IStatus.ERROR, ManagedBuilderCorePlugin.PLUGIN_ID,
case ICommandLauncher.ILLEGAL_COMMAND: "Error launching command [" + fCmd.getCommand() + "]", e)); //$NON-NLS-1$ //$NON-NLS-2$
default:
status = STATUS_ERROR_LAUNCH; status = STATUS_ERROR_LAUNCH;
fErrMsg = launcher.getErrorMessage(); } finally {
if(DbgUtil.DEBUG) monitor.done();
DbgUtil.trace("error launching the command: " + fErrMsg); //$NON-NLS-1$
printMessage(fErrMsg, out);
break;
} }
monitor.done();
return status; return status;
} }

View file

@ -15,6 +15,8 @@
package org.eclipse.cdt.managedbuilder.internal.core; package org.eclipse.cdt.managedbuilder.internal.core;
import java.io.IOException; import java.io.IOException;
import java.io.OutputStream;
import java.net.URI;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
@ -25,12 +27,15 @@ import java.util.Set;
import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.ConsoleOutputStream; 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.ProblemMarkerInfo;
import org.eclipse.cdt.core.model.CoreModel; import org.eclipse.cdt.core.model.CoreModel;
import org.eclipse.cdt.core.resources.ACBuilder; import org.eclipse.cdt.core.resources.ACBuilder;
import org.eclipse.cdt.core.resources.IConsole; import org.eclipse.cdt.core.resources.IConsole;
import org.eclipse.cdt.core.settings.model.ICProjectDescription; import org.eclipse.cdt.core.settings.model.ICProjectDescription;
import org.eclipse.cdt.core.settings.model.util.ListComparator; 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.BuildDescriptionManager;
import org.eclipse.cdt.managedbuilder.buildmodel.IBuildDescription; import org.eclipse.cdt.managedbuilder.buildmodel.IBuildDescription;
import org.eclipse.cdt.managedbuilder.buildmodel.IBuildStep; import org.eclipse.cdt.managedbuilder.buildmodel.IBuildStep;
@ -76,14 +81,11 @@ import org.eclipse.core.runtime.jobs.Job;
public class CommonBuilder extends ACBuilder { public class CommonBuilder extends ACBuilder {
public final static String BUILDER_ID = ManagedBuilderCorePlugin.getUniqueIdentifier() + ".genmakebuilder"; //$NON-NLS-1$ 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 ERROR_HEADER = "GeneratedmakefileBuilder error ["; //$NON-NLS-1$
private static final String NEWLINE = System.getProperty("line.separator"); //$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_FOOTER = "]: "; //$NON-NLS-1$
private static final String TRACE_HEADER = "GeneratedmakefileBuilder trace ["; //$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 int MONITOR_SCALE = 100;
private static final String TYPE_INC = "ManagedMakeBuider.type.incremental"; //$NON-NLS-1$
public static boolean VERBOSE = false; public static boolean VERBOSE = false;
private static CfgBuildSet fBuildSet = new CfgBuildSet(); private static CfgBuildSet fBuildSet = new CfgBuildSet();
@ -805,7 +807,7 @@ public class CommonBuilder extends ACBuilder {
String configName = bInfo.getConfiguration().getName(); String configName = bInfo.getConfiguration().getName();
String projName = bInfo.getProject().getName(); String projName = bInfo.getProject().getName();
if (buildType == FULL_BUILD || buildType == INCREMENTAL_BUILD) { if (buildType == FULL_BUILD || buildType == INCREMENTAL_BUILD) {
consoleHeader[0] = ManagedMakeMessages.getResourceString(TYPE_INC); consoleHeader[0] = ManagedMakeMessages.getResourceString("ManagedMakeBuider.type.incremental"); //$NON-NLS-1$
} else { } else {
consoleHeader[0] = new String(); consoleHeader[0] = new String();
outputError(projName, "The given build type is not supported in this context"); //$NON-NLS-1$ 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[1] = configName;
consoleHeader[2] = projName; consoleHeader[2] = projName;
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(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(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()); buf.append(status.getMessage());
@ -1166,73 +1168,82 @@ public class CommonBuilder extends ACBuilder {
protected void cleanWithInternalBuilder(CfgBuildInfo bInfo, IProgressMonitor monitor) throws CoreException { protected void cleanWithInternalBuilder(CfgBuildInfo bInfo, IProgressMonitor monitor) throws CoreException {
// referencedProjects = getProject().getReferencedProjects(); // referencedProjects = getProject().getReferencedProjects();
IProject curProject = bInfo.getProject(); IProject project = bInfo.getProject();
outputTrace(curProject.getName(), "Clean build with Internal Builder requested"); //$NON-NLS-1$ outputTrace(project.getName(), "Clean build with Internal Builder requested"); //$NON-NLS-1$
IConfiguration cfg = bInfo.getConfiguration(); IConfiguration configuration = bInfo.getConfiguration();
int flags = BuildDescriptionManager.DEPFILES; 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(); IBuildStep cleanStep = des.getCleanStep();
StepBuilder sBuilder = new StepBuilder(cleanStep, null, null); StepBuilder sBuilder = new StepBuilder(cleanStep, null, null);
BuildRunnerHelper buildRunnerHelper = new BuildRunnerHelper(project);
try { try {
// try the brute force approach first if (monitor == null) {
StringBuffer buf = new StringBuffer(); monitor = new NullProgressMonitor();
// 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);
} }
// Report a successful clean monitor.beginTask("", 2 * MONITOR_SCALE); //$NON-NLS-1$
String successMsg = ManagedMakeMessages.getFormattedString(BUILD_FINISHED, curProject.getName());
buf.append(successMsg); IConsole console = bInfo.getConsole();
buf.append(System.getProperty("line.separator", "\n")); //$NON-NLS-1$//$NON-NLS-2$
consoleOutStream.write(buf.toString().getBytes()); IBuilder builder = bInfo.getBuilder();
consoleOutStream.flush(); String[] errorParsers = builder.getErrorParsers();
consoleOutStream.close(); URI workingDirectoryURI = ManagedBuildManager.getBuildLocationURI(configuration, builder);
curProject.refreshLocal(IResource.DEPTH_INFINITE, null); ErrorParserManager epm = new ErrorParserManager(project, workingDirectoryURI, this, errorParsers);
} catch (IOException io) {} // Ignore console failures...
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 { protected void cleanProgrammatically(CfgBuildInfo bInfo, IProgressMonitor monitor) throws CoreException {
// referencedProjects = getProject().getReferencedProjects(); // referencedProjects = getProject().getReferencedProjects();
IProject curProject = bInfo.getProject(); IProject project = bInfo.getProject();
outputTrace(curProject.getName(), "Clean build requested"); //$NON-NLS-1$ outputTrace(project.getName(), "Clean build requested"); //$NON-NLS-1$
IBuilder builder = bInfo.getBuilder(); IBuilder builder = bInfo.getBuilder();
IConfiguration cfg = bInfo.getConfiguration(); IConfiguration configuration = bInfo.getConfiguration();
IPath buildPath = ManagedBuildManager.getBuildFullPath(cfg, builder); IPath buildPath = ManagedBuildManager.getBuildFullPath(configuration, builder);
if(buildPath == null){ if(buildPath == null){
throw new CoreException(new Status(IStatus.ERROR, throw new CoreException(new Status(IStatus.ERROR,
ManagedBuilderCorePlugin.getUniqueIdentifier(), ManagedBuilderCorePlugin.getUniqueIdentifier(),
ManagedMakeMessages.getResourceString("CommonBuilder.0"))); //$NON-NLS-1$ ManagedMakeMessages.getResourceString("CommonBuilder.0"))); //$NON-NLS-1$
} }
IPath projectFullPath = curProject.getFullPath(); IPath projectFullPath = project.getFullPath();
if(!projectFullPath.isPrefixOf(buildPath)){ if(!projectFullPath.isPrefixOf(buildPath)){
throw new CoreException(new Status(IStatus.ERROR, throw new CoreException(new Status(IStatus.ERROR,
ManagedBuilderCorePlugin.getUniqueIdentifier(), ManagedBuilderCorePlugin.getUniqueIdentifier(),
@ -1255,37 +1266,47 @@ public class CommonBuilder extends ACBuilder {
ManagedBuilderCorePlugin.getUniqueIdentifier(), ManagedBuilderCorePlugin.getUniqueIdentifier(),
ManagedMakeMessages.getResourceString("CommonBuilder.13"))); //$NON-NLS-1$ ManagedMakeMessages.getResourceString("CommonBuilder.13"))); //$NON-NLS-1$
} }
String status;
try { BuildRunnerHelper buildRunnerHelper = new BuildRunnerHelper(project);
// try the brute force approach first try {
status = ManagedMakeMessages.getFormattedString("ManagedMakeBuilder.message.clean.deleting.output", buildDir.getName()); //$NON-NLS-1$ if (monitor == null) {
monitor.subTask(status); monitor = new NullProgressMonitor();
workspace.delete(new IResource[]{buildDir}, true, monitor); }
StringBuffer buf = new StringBuffer(); monitor.beginTask("", 2 * MONITOR_SCALE); //$NON-NLS-1$
// write to the console
// // try the brute force approach first
// IConsole console = CCorePlugin.getDefault().getConsole(); String status = ManagedMakeMessages.getFormattedString("ManagedMakeBuilder.message.clean.deleting.output", buildDir.getName()); //$NON-NLS-1$
// console.start(getProject()); monitor.subTask(status);
IConsole console = bInfo.getConsole();
ConsoleOutputStream consoleOutStream = console.getOutputStream(); IConsole console = bInfo.getConsole();
String[] consoleHeader = new String[3];
consoleHeader[0] = ManagedMakeMessages.getResourceString(TYPE_CLEAN); String[] errorParsers = builder.getErrorParsers();
consoleHeader[1] = cfg.getName(); URI workingDirectoryURI = ManagedBuildManager.getBuildLocationURI(configuration, builder);
consoleHeader[2] = curProject.getName(); ErrorParserManager epm = new ErrorParserManager(project, workingDirectoryURI, this, errorParsers);
buf.append(System.getProperty("line.separator", "\n")); //$NON-NLS-1$ //$NON-NLS-2$
buf.append(ManagedMakeMessages.getFormattedString(CONSOLE_HEADER, consoleHeader)); buildRunnerHelper.prepareStreams(epm, null, console, new SubProgressMonitor(monitor, 1 * MONITOR_SCALE));
buf.append(System.getProperty("line.separator", "\n")); //$NON-NLS-1$ //$NON-NLS-2$
consoleOutStream.write(buf.toString().getBytes()); String cfgName = configuration.getName();
consoleOutStream.flush(); String toolchainName = configuration.getToolChain().getName();
buf = new StringBuffer(); boolean isConfigurationSupported = configuration.isSupported();
// Report a successful clean
String successMsg = ManagedMakeMessages.getFormattedString(BUILD_FINISHED, curProject.getName()); buildRunnerHelper.greeting(CLEAN_BUILD, cfgName, toolchainName, isConfigurationSupported);
buf.append(successMsg); workspace.delete(new IResource[]{buildDir}, true, new SubProgressMonitor(monitor, 1 * MONITOR_SCALE));
buf.append(System.getProperty("line.separator", "\n")); //$NON-NLS-1$//$NON-NLS-2$ buildRunnerHelper.close();
consoleOutStream.write(buf.toString().getBytes()); buildRunnerHelper.goodbye();
consoleOutStream.flush();
consoleOutStream.close(); } catch (Exception e) {
} catch (IOException io) {} // Ignore console failures... 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();
}
} }
} }

View file

@ -15,6 +15,7 @@ import java.io.OutputStream;
import java.net.URI; import java.net.URI;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; 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.ACBuilder;
import org.eclipse.cdt.core.resources.IConsole; import org.eclipse.cdt.core.resources.IConsole;
import org.eclipse.cdt.core.resources.RefreshScopeManager; 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.BuildDescriptionManager;
import org.eclipse.cdt.managedbuilder.buildmodel.IBuildDescription; import org.eclipse.cdt.managedbuilder.buildmodel.IBuildDescription;
import org.eclipse.cdt.managedbuilder.buildmodel.IBuildIOType; 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 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 TYPE_REBUILD = "ManagedMakeBuider.type.rebuild"; //$NON-NLS-1$
private static final String INTERNAL_BUILDER = "ManagedMakeBuilder.message.internal.builder"; //$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; public static boolean VERBOSE = false;
// Local variables // Local variables
@ -314,7 +317,6 @@ public class GeneratedMakefileBuilder extends ACBuilder {
protected IProject[] referencedProjects; protected IProject[] referencedProjects;
protected List<IResource> resourcesToBuild; protected List<IResource> resourcesToBuild;
private IConsole console; private IConsole console;
private ConsoleOutputStream consoleOutStream;
public static void outputTrace(String resourceName, String message) { public static void outputTrace(String resourceName, String message) {
if (VERBOSE) { if (VERBOSE) {
System.out.println(TRACE_HEADER + resourceName + TRACE_FOOTER + message + NEWLINE); 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) { 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 // Get the project and make sure there's a monitor to cancel the build
IProject currentProject = getProject(); IProject project = getProject();
if (monitor == null) { if (monitor == null) {
monitor = new NullProgressMonitor(); monitor = new NullProgressMonitor();
} }
@ -879,7 +881,7 @@ public class GeneratedMakefileBuilder extends ACBuilder {
IPath workingDirectory = new Path(pathFromURI); IPath workingDirectory = new Path(pathFromURI);
IWorkspace workspace = currentProject.getWorkspace(); IWorkspace workspace = project.getWorkspace();
if (workspace == null) { if (workspace == null) {
return; return;
} }
@ -910,13 +912,13 @@ public class GeneratedMakefileBuilder extends ACBuilder {
IPath makeCommand = new Path(makeCmd); IPath makeCommand = new Path(makeCmd);
String[] msgs = new String[2]; String[] msgs = new String[2];
msgs[0] = makeCommand.toString(); msgs[0] = makeCommand.toString();
msgs[1] = currentProject.getName(); msgs[1] = project.getName();
monitor.subTask(ManagedMakeMessages.getFormattedString(MAKE, msgs)); monitor.subTask(ManagedMakeMessages.getFormattedString(MAKE, msgs));
// Get a build console for the project // Get a build console for the project
StringBuffer buf = new StringBuffer(); StringBuffer buf = new StringBuffer();
IConsole console = CCorePlugin.getDefault().getConsole(); IConsole console = CCorePlugin.getDefault().getConsole();
console.start(currentProject); console.start(project);
ConsoleOutputStream consoleOutStream = console.getOutputStream(); ConsoleOutputStream consoleOutStream = console.getOutputStream();
String[] consoleHeader = new String[3]; String[] consoleHeader = new String[3];
switch (buildType) { switch (buildType) {
@ -930,7 +932,7 @@ public class GeneratedMakefileBuilder extends ACBuilder {
} }
consoleHeader[1] = info.getConfigurationName(); consoleHeader[1] = info.getConfigurationName();
consoleHeader[2] = currentProject.getName(); consoleHeader[2] = project.getName();
buf.append(NEWLINE); buf.append(NEWLINE);
buf.append(ManagedMakeMessages.getFormattedString(CONSOLE_HEADER, consoleHeader)).append(NEWLINE); buf.append(ManagedMakeMessages.getFormattedString(CONSOLE_HEADER, consoleHeader)).append(NEWLINE);
buf.append(NEWLINE); buf.append(NEWLINE);
@ -945,24 +947,24 @@ public class GeneratedMakefileBuilder extends ACBuilder {
consoleOutStream.flush(); consoleOutStream.flush();
// Remove all markers for this project // Remove all markers for this project
removeAllMarkers(currentProject); removeAllMarkers(project);
// Get a launcher for the make command // Get a launcher for the make command
String errMsg = null; String errMsg = null;
IBuilder builder = info.getDefaultConfiguration().getBuilder(); IBuilder builder = info.getDefaultConfiguration().getBuilder();
ICommandLauncher launcher = builder.getCommandLauncher(); ICommandLauncher launcher = builder.getCommandLauncher();
launcher.setProject(currentProject); launcher.setProject(project);
launcher.showCommand(true); launcher.showCommand(true);
// Set the environmennt // Set the environmennt
IBuildEnvironmentVariable variables[] = ManagedBuildManager.getEnvironmentVariableProvider().getVariables(cfg,true,true); IBuildEnvironmentVariable variables[] = ManagedBuildManager.getEnvironmentVariableProvider().getVariables(cfg,true,true);
String[] env = null; String[] envp = null;
ArrayList<String> envList = new ArrayList<String>(); ArrayList<String> envList = new ArrayList<String>();
if (variables != null) { if (variables != null) {
for(int i = 0; i < variables.length; i++){ for(int i = 0; i < variables.length; i++){
envList.add(variables[i].getName() + "=" + variables[i].getValue()); //$NON-NLS-1$ 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 // Hook up an error parser manager
@ -1014,7 +1016,7 @@ public class GeneratedMakefileBuilder extends ACBuilder {
premakeArgs.add("-q"); //$NON-NLS-1$ premakeArgs.add("-q"); //$NON-NLS-1$
premakeArgs.add("main-build"); //$NON-NLS-1$ premakeArgs.add("main-build"); //$NON-NLS-1$
premakeTargets = premakeArgs.toArray(new String[premakeArgs.size()]); 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) { if (proc != null) {
try { try {
// Close the input of the process since we will never write to it // 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 // If the status value returned from "make -q" is 0, then the build state is up-to-date
isuptodate = true; isuptodate = true;
// Report that the build was up to date, and thus nothing needs to be built // 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 = new StringBuffer();
buf.append(NEWLINE); buf.append(NEWLINE);
buf.append(uptodateMsg).append(NEWLINE); buf.append(uptodateMsg).append(NEWLINE);
@ -1080,7 +1082,7 @@ public class GeneratedMakefileBuilder extends ACBuilder {
// Launch make - main invocation // Launch make - main invocation
if (!isuptodate) { if (!isuptodate) {
proc = launcher.execute(makeCommand, makeTargets, env, workingDirectory, monitor); proc = launcher.execute(makeCommand, makeTargets, envp, workingDirectory, monitor);
if (proc != null) { if (proc != null) {
try { try {
// Close the input of the process since we will never write to it // 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 // use the refresh scope manager to refresh
RefreshScopeManager refreshManager = RefreshScopeManager.getInstance(); RefreshScopeManager refreshManager = RefreshScopeManager.getInstance();
IWorkspaceRunnable runnable = refreshManager.getRefreshRunnable(currentProject); IWorkspaceRunnable runnable = refreshManager.getRefreshRunnable(project);
ResourcesPlugin.getWorkspace().run(runnable, null, IWorkspace.AVOID_UPDATE, null); ResourcesPlugin.getWorkspace().run(runnable, null, IWorkspace.AVOID_UPDATE, null);
} catch (CoreException e) { } catch (CoreException e) {
monitor.subTask(ManagedMakeMessages monitor.subTask(ManagedMakeMessages
@ -1129,7 +1131,7 @@ public class GeneratedMakefileBuilder extends ACBuilder {
} else { } else {
// Report a successful build // Report a successful build
String successMsg = ManagedMakeMessages.getFormattedString(BUILD_FINISHED, String successMsg = ManagedMakeMessages.getFormattedString(BUILD_FINISHED,
currentProject.getName()); project.getName());
buf.append(successMsg).append(NEWLINE); buf.append(successMsg).append(NEWLINE);
} }
@ -1367,330 +1369,280 @@ public class GeneratedMakefileBuilder extends ACBuilder {
} }
} }
/** private Map<IProject, List<IFile>> arrangeFilesByProject(List<IFile> files) {
* Called to invoke the MBS Internal Builder for building the given resources in Map<IProject, List<IFile>> projectMap = new HashMap<IProject, List<IFile>>();
* the given configuration for (IFile file : files) {
* IProject project = file.getProject();
* This method is considered experimental. Clients implementing this API should expect List<IFile> filesInProject = projectMap.get(project);
* possible changes in the API. if (filesInProject == null) {
* filesInProject = new ArrayList<IFile>();
* @param resourcesToBuild resources to be built projectMap.put(project, filesInProject);
* @param cfg configuration to be built }
* @param buildIncrementaly if true, incremental build will be performed, filesInProject.add(file);
* only files that need rebuild will be built. }
* If false, full rebuild will be performed return projectMap;
* @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) {
OutputStream epmOutputStream = null; /**
// Get the project and make sure there's a monitor to cancel the build * Called to invoke the MBS Internal Builder for building the given resources
IProject currentProject = cfg.getOwner().getProject(); *
* @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<IFile> files, IProgressMonitor monitor) {
// Make sure there's a monitor to cancel the build
if (monitor == null) { if (monitor == null) {
monitor = new NullProgressMonitor(); monitor = new NullProgressMonitor();
} }
try { try {
int flags = 0; Map<IProject, List<IFile>> projectMap = arrangeFilesByProject(files);
IResourceDelta delta = null; monitor.beginTask("", projectMap.size() * MONITOR_SCALE); //$NON-NLS-1$
if(buildIncrementaly){ for (List<IFile> filesInProject : projectMap.values()) {
flags = BuildDescriptionManager.REBUILD | BuildDescriptionManager.REMOVED | BuildDescriptionManager.DEPS; IProject project = filesInProject.get(0).getProject();
delta = getDelta(currentProject); 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<IFile> files, IProgressMonitor monitor) {
IProject project = files.get(0).getProject();
BuildRunnerHelper buildRunnerHelper = new BuildRunnerHelper(project);
String[] msgs = new String[2]; try {
msgs[0] = ManagedMakeMessages.getResourceString(INTERNAL_BUILDER); monitor.beginTask(ManagedMakeMessages.getFormattedString("GeneratedMakefileBuilder.buildingProject", project.getName()) + ':', files.size() * MONITOR_SCALE); //$NON-NLS-1$
msgs[1] = currentProject.getName();
if(initNewConsole) // Get a build console for the project
initNewBuildConsole(currentProject); console = CCorePlugin.getDefault().getConsole();
console.start(project);
StringBuffer buf = new StringBuffer(); IManagedBuildInfo buildInfo = ManagedBuildManager.getBuildInfo(project);
IConfiguration configuration = buildInfo.getDefaultConfiguration();
if (initNewConsole) { String cfgName = configuration.getName();
String msg; String toolchainName = configuration.getToolChain().getName();
if (buildIncrementaly) { boolean isSupported = configuration.isSupported();
msg = ManagedMakeMessages.getResourceString("GeneratedMakefileBuilder.buildSelectedIncremental"); //$NON-NLS-1$
} else { IBuildDescription des = BuildDescriptionManager.createBuildDescription(configuration, null, 0);
msg = ManagedMakeMessages.getResourceString("GeneratedMakefileBuilder.buildSelectedRebuild"); //$NON-NLS-1$
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;
} }
String filePath = file.getProjectRelativePath().toString();
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<IBuildStep> dependentSteps = new HashSet<IBuildStep>();
// 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<IBuildStep> 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$
try { try {
consoleOutStream.write(buf.toString().getBytes()); IBuildResource buildResource = des.getBuildResource(file);
consoleOutStream.flush();
} catch (IOException e1) { Set<IBuildStep> dependentSteps = new HashSet<IBuildStep>();
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(); forgetLastBuiltState();
} finally { } finally {
if(epmOutputStream != null){
try {
epmOutputStream.close();
} catch (IOException e) {
}
}
if(consoleOutStream != null){
try {
consoleOutStream.close();
} catch (IOException e) {
}
}
getGenerationProblems().clear(); 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(); monitor.done();
} }
} }
private void removeAllMarkers(IFile file) { public IStatus cleanFiles(List<IFile> files, IProgressMonitor monitor) {
IMarker[] markers; // Make sure there's a monitor to cancel the build
if (monitor == null) {
monitor = new NullProgressMonitor();
}
try { try {
markers = file.findMarkers( Map<IProject, List<IFile>> projectMap = arrangeFilesByProject(files);
ICModelMarker.C_MODEL_PROBLEM_MARKER, true, monitor.beginTask("", projectMap.size() * MONITOR_SCALE); //$NON-NLS-1$
IResource.DEPTH_INFINITE);
} catch (CoreException e) { for (List<IFile> filesInProject : projectMap.values()) {
// Handled just about every case in the sanity check IProject project = filesInProject.get(0).getProject();
return; 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));
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;
} }
} finally {
if (monitor.isCanceled()) {
return Status.CANCEL_STATUS;
}
monitor.done();
} }
return Status.OK_STATUS;
} }
public void cleanFile(IFile file, IProgressMonitor monitor) { public void cleanFilesForOneProject(List<IFile> files, IProgressMonitor monitor) {
IProject project = files.get(0).getProject();
monitor.subTask(ManagedMakeMessages.getResourceString("GeneratedMakefileBuilder.0") //$NON-NLS-1$ BuildRunnerHelper buildRunnerHelper = new BuildRunnerHelper(project);
+ file.getProjectRelativePath()); int countDeleted = 0;
// 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);
try { try {
IBuildDescription des = BuildDescriptionManager monitor.beginTask(ManagedMakeMessages.getFormattedString("GeneratedMakefileBuilder.cleaningProject", project.getName()) + ':', files.size() * MONITOR_SCALE); //$NON-NLS-1$
.createBuildDescription(cfg, delta, flags);
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 int flags = BuildDescriptionManager.REBUILD | BuildDescriptionManager.REMOVED;
Set<IBuildStep> dependentSteps = new HashSet<IBuildStep>(); IResourceDelta delta = getDelta(project);
// get dependent IO types IBuildDescription des = BuildDescriptionManager.createBuildDescription(configuration, delta, flags);
IBuildIOType depTypes[] = buildResource.getDependentIOTypes();
// iterate through each type and add the step the type belongs String[] errorParsers = configuration.getErrorParserList();
// to to ErrorParserManager epm = new ErrorParserManager(project, des.getDefaultBuildDirLocationURI(), this, errorParsers);
// the collector buildRunnerHelper.prepareStreams(epm, null , console, new SubProgressMonitor(monitor, 1 * MONITOR_SCALE));
for (int j = 0; j < depTypes.length; j++) {
IBuildIOType type = depTypes[j]; buildRunnerHelper.greeting(ManagedMakeMessages.getResourceString("CleanFilesAction.cleanSelectedFiles"), cfgName, toolchainName, isSupported); //$NON-NLS-1$
if (type != null && type.getStep() != null) buildRunnerHelper.printLine(ManagedMakeMessages.getResourceString("ManagedMakeBuilder.message.internal.builder.header.note")); //$NON-NLS-1$
dependentSteps.add(type.getStep());
for (IFile file : files) {
if (monitor.isCanceled()) {
break;
} }
String filePath = file.getProjectRelativePath().toString();
// iterate through all build steps try {
Iterator<IBuildStep> stepIter = dependentSteps.iterator(); IBuildResource buildResource = des.getBuildResource(file);
if (buildResource != null) {
Set<IBuildStep> dependentSteps = new HashSet<IBuildStep>();
IBuildIOType depTypes[] = buildResource.getDependentIOTypes();
for (IBuildIOType btype : depTypes) {
if (btype != null && btype.getStep() != null)
dependentSteps.add(btype.getStep());
}
while (stepIter.hasNext()) { SubProgressMonitor monitor2 = new SubProgressMonitor(monitor, 1 * MONITOR_SCALE, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK);
IBuildStep step = stepIter.next(); try {
monitor2.beginTask("", (1 + dependentSteps.size()) * MONITOR_SCALE); //$NON-NLS-1$
// Delete the output resources // Remove problem markers for the file
IBuildIOType[] outputIOTypes = step.getOutputIOTypes(); 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++) { // iterate through all build steps
IBuildResource[] resources = outputIOTypes[j].getResources(); for (IBuildStep step : dependentSteps) {
if (monitor2.isCanceled()) {
break;
}
for (int i = 0; i < resources.length; i++) { monitor2.subTask(filePath);
IResource outputFile = currentProject.findMember(resources[i] // Delete the output resources
.getFullPath().removeFirstSegments(1)); // strip project name IBuildIOType[] outputIOTypes = step.getOutputIOTypes();
if (outputFile != null) for (IBuildIOType ioType : outputIOTypes) {
outputFile.delete(true, new SubProgressMonitor(monitor, 1)); 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) { } catch (Exception e) {
// TODO Auto-generated catch block ManagedBuilderCorePlugin.log(new CoreException(new Status(IStatus.ERROR, ManagedBuilderCorePlugin.PLUGIN_ID, "CDT Build Error", e))); //$NON-NLS-1$
e.printStackTrace(); } 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();
} }
} }

View file

@ -21,10 +21,11 @@ ManagedMakeBuilder.message.regen.deps = Regenerating dependency files for {0}
ManagedMakeBuilder.message.updating.deps = Updating dependency files for {0} ManagedMakeBuilder.message.updating.deps = Updating dependency files for {0}
ManagedMakeBuilder.message.creating.markers = Generating markers... ManagedMakeBuilder.message.creating.markers = Generating markers...
ManagedMakeBuilder.message.console.header = **** {0} of configuration {1} for project {2} **** 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.internal.builder.header.note = Info: Internal Builder is used for build
ManagedMakeBuilder.message.no.build = Nothing to build for {0} ManagedMakeBuilder.message.no.build = Info: Nothing to build for {0}
ManagedMakeBuilder.message.error = Build error ManagedMakeBuilder.message.error = Internal error during build, see eclipse error log.
ManagedMakeBuilder.message.error.refresh = Error refreshing project 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.finished = Build complete for project {0}
ManagedMakeBuilder.message.cancelled = Build cancelled ManagedMakeBuilder.message.cancelled = Build cancelled
ManagedMakeBuilder.message.finished.with.errs = Build completed with errors 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 BuildFilesAction.buildingSelectedFiles=Building Selected Files
BuildDescriptionGnuMakefileGenerator.0=IO exception occurred: BuildDescriptionGnuMakefileGenerator.0=IO exception occurred:
BuildDescriptionGnuMakefileGenerator.1=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.eachother=Macros {0} and {1} reference each other
BuildMacroStatus.status.reference.incorrect=Macro {0} reference is incorrect BuildMacroStatus.status.reference.incorrect=Macro {0} reference is incorrect
BuildMacroStatus.status.macro.not.string=Macro {0} is not of String type 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 ResourceChangeHandler.buildInfoSerializationJob=Build Info Serialization
#ManagedBuilderCorePlugin messages #ManagedBuilderCorePlugin messages
GeneratedMakefileBuilder.buildResourcesFinished=Build of selected resources is complete. GeneratedMakefileBuilder.buildingProject=Building project {0}
GeneratedMakefileBuilder.buildSelectedIncremental=Building selected file(s) incrementally GeneratedMakefileBuilder.cleaningProject=Cleaning project {0}
GeneratedMakefileBuilder.buildSelectedRebuild=Rebuilding selected file(s) GeneratedMakefileBuilder.removingResourceMarkers=Removing problem markers for {0}
GeneratedMakefileBuilder.buildingFile=Building file GeneratedMakefileBuilder.refreshingArtifacts=Refreshing build artefacts for {0}
GeneratedMakefileBuilder.fileDeleted={0} deleted.
GeneratedMakefileBuilder.nothingToClean=Nothing to clean.
GenerateMakefileWithBuildDescription.0=info is null GenerateMakefileWithBuildDescription.0=info is null
GenerateMakefileWithBuildDescription.1=cfg 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 ManagedBuilderCorePlugin.resourceChangeHandlingInitializationJob=Initializing Resource Change Handling
#Internal Builder messages #Internal Builder messages
@ -146,7 +145,7 @@ InternalBuilder.msg.header=Internal Builder: {0}
InternalBuilder.nothing.todo=Nothing to be done for project {0} InternalBuilder.nothing.todo=Nothing to be done for project {0}
CfgScannerConfigUtil_ErrorNotSupported=Only type {0} is supported in this method. CfgScannerConfigUtil_ErrorNotSupported=Only type {0} is supported in this method.
CleanFilesAction.cleanFiles=Clean File(s) CleanFilesAction.cleanFiles=Clean File(s)
CleanFilesAction.cleanSelectedFiles=Clean the selected file(s). CleanFilesAction.cleanSelectedFiles=Cleaning Selected Files
CleanFilesAction.cleaningFiles=Cleaning files CleanFilesAction.cleaningFiles=Cleaning files
BuilderFactory.1=can not find builder with the specified id BuilderFactory.1=can not find builder with the specified id
FolderInfo.4=converter invocation failed 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.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.2=request for building non active configuration for the builder that does not support this
CommonBuilder.6=Time consumed: {0} ms. 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.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.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 CommonBuilder.12=can not clean programmatically: build workspace path is not folder

View file

@ -10,97 +10,18 @@
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.newmake.internal.core; package org.eclipse.cdt.newmake.internal.core;
import java.io.IOException;
import java.io.OutputStream; import java.io.OutputStream;
import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IProgressMonitor;
public class StreamMonitor extends OutputStream { /**
*
IProgressMonitor monitor; * @deprecated as of CDT 8.1. Use org.eclipse.cdt.internal.core.StreamMonitor
OutputStream console; *
public final int fTotalWork; */
private int halfWay; @Deprecated
private int currentIncrement = 2; public class StreamMonitor extends org.eclipse.cdt.internal.core.StreamMonitor {
private int nextProgress = currentIncrement;
private int worked = 0;
public StreamMonitor(IProgressMonitor mon, OutputStream cos, int totalWork) { public StreamMonitor(IProgressMonitor mon, OutputStream cos, int totalWork) {
monitor = mon; super(mon, cos, totalWork);
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;
} }
} }

View file

@ -31,7 +31,6 @@ import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Preferences; import org.eclipse.core.runtime.Preferences;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job; import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.jface.action.IAction; import org.eclipse.jface.action.IAction;
import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.ISelection;
@ -192,10 +191,7 @@ public class BuildFilesAction extends ActionDelegate implements
private final List<IFile> files; private final List<IFile> files;
BuildFilesJob(List<IFile> filesToBuild) { BuildFilesJob(List<IFile> filesToBuild) {
super( super(ManagedMakeMessages.getResourceString("BuildFilesAction.buildingSelectedFiles")); //$NON-NLS-1$
ManagedMakeMessages
.getResourceString("BuildFilesAction.buildingSelectedFiles")); //$NON-NLS-1$
files = filesToBuild; files = filesToBuild;
} }
@ -204,43 +200,8 @@ public class BuildFilesAction extends ActionDelegate implements
*/ */
@Override @Override
protected IStatus run(IProgressMonitor monitor) { protected IStatus run(IProgressMonitor monitor) {
Iterator<IFile> iterator = files.iterator();
GeneratedMakefileBuilder builder = new GeneratedMakefileBuilder(); GeneratedMakefileBuilder builder = new GeneratedMakefileBuilder();
return builder.invokeInternalBuilder(files, monitor);
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;
} }
/* (non-Javadoc) /* (non-Javadoc)
@ -260,9 +221,7 @@ public class BuildFilesAction extends ActionDelegate implements
*/ */
@Override @Override
public void run(IAction action) { public void run(IAction action) {
List<IFile> selectedFiles = getSelectedBuildableFiles(); List<IFile> selectedFiles = getSelectedBuildableFiles();
Job buildFilesJob = new BuildFilesJob(selectedFiles); Job buildFilesJob = new BuildFilesJob(selectedFiles);
List<IProject> projects = getProjectsToBuild(selectedFiles); List<IProject> projects = getProjectsToBuild(selectedFiles);
@ -277,7 +236,7 @@ public class BuildFilesAction extends ActionDelegate implements
private boolean shouldBeEnabled() { 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 // if build automatically is turned on, then this menu should be turned off as
// it will trigger the auto build // it will trigger the auto build
Preferences preferences = ResourcesPlugin.getPlugin().getPluginPreferences(); Preferences preferences = ResourcesPlugin.getPlugin().getPluginPreferences();

View file

@ -13,7 +13,6 @@ package org.eclipse.cdt.managedbuilder.internal.ui.actions;
import java.util.Iterator; import java.util.Iterator;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Vector;
import org.eclipse.cdt.core.model.ITranslationUnit; import org.eclipse.cdt.core.model.ITranslationUnit;
import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo; 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.IAdaptable;
import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.core.runtime.Preferences; import org.eclipse.core.runtime.Preferences;
import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job; 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 static final class CleanFilesJob extends Job {
private final List<IFile> files; private final List<IFile> files;
protected Vector<?> generationProblems; private CleanFilesJob(List<IFile> filesToBuild) {
super(ManagedMakeMessages.getResourceString("CleanFilesAction.cleaningFiles")); //$NON-NLS-1$
private CleanFilesJob(String name, List<IFile> filesToBuild) {
super(name);
files = filesToBuild; 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<IFile> iterator = files.iterator(); GeneratedMakefileBuilder builder = new GeneratedMakefileBuilder();
return builder.cleanFiles(files, monitor);
// 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;
} }
@Override @Override
@ -258,13 +227,8 @@ public class CleanFilesAction extends ActionDelegate implements
*/ */
@Override @Override
public void run(IAction action) { public void run(IAction action) {
List<IFile> selectedFiles = getSelectedBuildableFiles(); List<IFile> selectedFiles = getSelectedBuildableFiles();
CleanFilesJob job = new CleanFilesJob(selectedFiles);
CleanFilesJob job = new CleanFilesJob(
ManagedMakeMessages
.getResourceString("CleanFilesAction.cleaningFiles"), selectedFiles); //$NON-NLS-1$
job.schedule(); job.schedule();
} }

View file

@ -1,6 +1,6 @@
Manifest-Version: 1.0 Manifest-Version: 1.0
Bundle-ManifestVersion: 2 Bundle-ManifestVersion: 2
Bundle-Name: Core Bundle-Name: %Bundle-Name.0
Bundle-SymbolicName: org.eclipse.linuxtools.cdt.autotools.core;singleton:=true Bundle-SymbolicName: org.eclipse.linuxtools.cdt.autotools.core;singleton:=true
Bundle-Version: 2.0.0.qualifier Bundle-Version: 2.0.0.qualifier
Bundle-Activator: org.eclipse.linuxtools.cdt.autotools.core.Activator Bundle-Activator: org.eclipse.linuxtools.cdt.autotools.core.Activator
@ -10,3 +10,4 @@ Require-Bundle: org.eclipse.core.runtime,
Bundle-Localization: plugin Bundle-Localization: plugin
Bundle-ActivationPolicy: lazy Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.6 Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-Vendor: %provider

View file

@ -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 Makefile.builder.name=Autotools Makefile Generator

View file

@ -345,8 +345,12 @@ public class ChangeGenerator extends ASTVisitor {
int offset = edit.getOffset(); int offset = edit.getOffset();
int end = offset + edit.getLength(); int end = offset + edit.getLength();
int newOffset = document.getLineInformationOfOffset(offset).getOffset(); int newOffset = document.getLineInformationOfOffset(offset).getOffset();
int newEnd = endOffset(document.getLineInformationOfOffset(end));
edit = originalEdits[i]; 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 offsetBefore = edit.getOffset();
int newOffsetBefore = newOffset + offsetBefore - offset; int newOffsetBefore = newOffset + offsetBefore - offset;
int newEndBefore = newEnd + offsetBefore + edit.getLength() - end; int newEndBefore = newEnd + offsetBefore + edit.getLength() - end;

View file

@ -956,7 +956,8 @@ public class PDOM extends PlatformObject implements IPDOM {
CCorePlugin.log(e); CCorePlugin.log(e);
} }
assert lockCount == -1; assert lockCount == -1;
lastWriteAccess= System.currentTimeMillis(); if (!fEvent.isTrivial())
lastWriteAccess= System.currentTimeMillis();
final ChangeEvent event= fEvent; final ChangeEvent event= fEvent;
fEvent= new ChangeEvent(); fEvent= new ChangeEvent();
synchronized (mutex) { synchronized (mutex) {

View file

@ -50,7 +50,7 @@ import org.osgi.service.prefs.BackingStoreException;
* *
* @noextend This class is not intended to be subclassed by clients. * @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 * The list of error parsers stored in .project for 3.X projects
* as key/value pair with key="org.eclipse.cdt.core.errorOutputParser" * 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(); String lineTrimmed = line.trim();
lineCounter++; lineCounter++;
@ -363,6 +365,8 @@ outer:
} }
} }
outputLine(line, marker); outputLine(line, marker);
return false;
} }
/** /**
@ -848,4 +852,11 @@ outer:
} }
return result; return result;
} }
/**
* @since 5.4
*/
@Override
public void shutdown() {
}
} }

View file

@ -485,12 +485,35 @@ public class RefreshScopeManager {
String configName = child.getAttribute(CONFIGURATION_ELEMENT_NAME); String configName = child.getAttribute(CONFIGURATION_ELEMENT_NAME);
loadResourceData(workspaceRoot, project, configName, child.getChildren()); 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<String,HashMap<IResource, List<RefreshExclusion>>> configMap = fProjToConfToResToExcluMap.get(project);
if (configMap == null) {
configMap = new HashMap<String,HashMap<IResource, List<RefreshExclusion>>>();
CProjectDescriptionManager descriptionManager = CProjectDescriptionManager.getInstance();
ICProjectDescription projectDescription = descriptionManager.getProjectDescription(project, false);
ICConfigurationDescription cfgDescs[] = projectDescription.getConfigurations();
for (ICConfigurationDescription cfgDesc : cfgDescs) {
String configName = cfgDesc.getName();
HashMap<IResource, List<RefreshExclusion>> resourceMap = new HashMap<IResource, List<RefreshExclusion>>();
resourceMap.put(project, new LinkedList<RefreshExclusion>());
configMap.put(configName, resourceMap);
}
fProjToConfToResToExcluMap.put(project,configMap);
}
}
/** /**
* @since 5.4 * @since 5.4
*/ */

View file

@ -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.
* <strong>API is unstable and subject to change.</strong>
*/
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<IConsoleParser> 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<IConsoleParser> parsers = new ArrayList<IConsoleParser>();
// 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)}.
*
* <br><strong>Important: {@link #close()} the streams BEFORE calling this method to properly flush all outputs</strong>
*/
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<String, String> envMap) {
// Convert into env strings
List<String> strings= new ArrayList<String>(envMap.size());
for (Entry<String, String> 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$
}
}
}

View file

@ -90,3 +90,16 @@ CConfigBasedDescriptorManager.3=Failed to create descriptor
CConfigBasedDescriptorManager.4=error: read-only configuration can not be used for CDescriptor CConfigBasedDescriptorManager.4=error: read-only configuration can not be used for CDescriptor
CConfigBasedDescriptorManager.5=the project does not contain valid configurations CConfigBasedDescriptorManager.5=the project does not contain valid configurations
CCorePlugin.startupJob=CDT Startup 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

View file

@ -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 * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * 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 * Intercepts an output to console and forwards it to console parsers for processing
*
* @author vhirsl
*/ */
public class ConsoleOutputSniffer { public class ConsoleOutputSniffer {
/* /**
* Private class to sniffer the output stream for this snifffer. * Private class to sniff the output stream for this sniffer.
*/ */
private class ConsoleOutputStream extends OutputStream { private class ConsoleOutputStream extends OutputStream {
// Stream's private buffer for the stream's read contents. // Stream's private buffer for the stream's read contents.
private StringBuffer currentLine = new StringBuffer(); private StringBuffer currentLine = new StringBuffer();
private OutputStream outputStream = null; private OutputStream outputStream = null;
public ConsoleOutputStream(OutputStream outputStream) { public ConsoleOutputStream(OutputStream outputStream) {
this.outputStream = outputStream; this.outputStream = outputStream;
} }
/* (non-Javadoc) @Override
* @see java.io.OutputStream#write(int)
*/
@Override
public void write(int b) throws IOException { public void write(int b) throws IOException {
currentLine.append((char) b); currentLine.append((char) b);
checkLine(false); checkLine(false);
// Continue writing the bytes to the console's output. // Continue writing the bytes to the console's output.
if (outputStream != null) { if (outputStream != null) {
outputStream.write(b); outputStream.write(b);
} }
} }
/* (non-Javadoc) @Override
* @see java.io.OutputStream#write(byte[], int, int)
*/
@Override
public void write(byte[] b, int off, int len) throws IOException { public void write(byte[] b, int off, int len) throws IOException {
if (b == null) { if (b == null) {
throw new NullPointerException(); throw new NullPointerException();
} else if (off != 0 || (len < 0) || (len > b.length)) { } else if (off != 0 || (len < 0) || (len > b.length)) {
throw new IndexOutOfBoundsException(); throw new IndexOutOfBoundsException();
} else if (len == 0) { } else if (len == 0) {
return; return;
} }
currentLine.append(new String(b, 0, len)); currentLine.append(new String(b, 0, len));
checkLine(false); checkLine(false);
// Continue writing the bytes to the console's output. // Continue writing the bytes to the console's output.
if (outputStream != null) if (outputStream != null)
outputStream.write(b, off, len); outputStream.write(b, off, len);
} }
/* (non-Javadoc) @Override
* @see java.io.OutputStream#close()
*/
@Override
public void close() throws IOException { public void close() throws IOException {
checkLine(true); checkLine(true);
closeConsoleOutputStream(); closeConsoleOutputStream();
} }
/* (non-Javadoc) @Override
* @see java.io.OutputStream#flush()
*/
@Override
public void flush() throws IOException { public void flush() throws IOException {
if (outputStream != null) { if (outputStream != null) {
outputStream.flush(); outputStream.flush();
} }
} }
/* /**
* Checks to see if the already read input constitutes * Checks to see if the already read input constitutes
* a complete line (e.g. does the sniffing). If so, then * a complete line (e.g. does the sniffing). If so, then
* send it to processLine. * send it to processLine.
* *
* @param flush * @param flush
*/ */
private void checkLine(boolean flush) { private void checkLine(boolean flush) {
String buffer = currentLine.toString(); if (currentLine.length() == 0) {
int i = 0; return;
while ((i = buffer.indexOf('\n')) != -1) { }
// get rid of any trailing whitespace but keep leading whitespaces (bug 199245)
int end= i; String buffer = currentLine.toString();
while(end > 0 && buffer.charAt(end-1) <= ' ') { // see String.trim() int i = 0;
end--; while ((i = buffer.indexOf('\n')) != -1) {
} int eol = i;
if (end > 0) { if (i > 0 && buffer.charAt(i-1) == '\r') {
String line = buffer.substring(0, end); // also get rid of trailing \r in case of Windows line delimiter "\r\n"
processLine(line); eol = i - 1;
} }
buffer = buffer.substring(i + 1); // skip the \n and advance String line = buffer.substring(0, eol);
} processLine(line);
currentLine.setLength(0);
if (flush) { buffer = buffer.substring(i + 1); // skip the \n and advance
if (buffer.length() > 0) { }
processLine(buffer); currentLine.setLength(0);
} if (flush) {
} else { if (buffer.length() > 0) {
currentLine.append(buffer); processLine(buffer);
} }
} } else {
currentLine.append(buffer);
}
}
} // end ConsoleOutputStream class
} // end ConsoleOutputStream class
private int nOpens = 0; private int nOpens = 0;
private OutputStream consoleOutputStream; private OutputStream consoleOutputStream;
private OutputStream consoleErrorStream; private OutputStream consoleErrorStream;
private IConsoleParser[] parsers; private IConsoleParser[] parsers;
public ConsoleOutputSniffer(IConsoleParser[] parsers) { public ConsoleOutputSniffer(IConsoleParser[] parsers) {
this.parsers = parsers; this.parsers = parsers;
} }
public ConsoleOutputSniffer(OutputStream outputStream, OutputStream errorStream, IConsoleParser[] parsers) { public ConsoleOutputSniffer(OutputStream outputStream, OutputStream errorStream, IConsoleParser[] parsers) {
this(parsers); this(parsers);
this.consoleOutputStream = outputStream; this.consoleOutputStream = outputStream;
this.consoleErrorStream = errorStream; this.consoleErrorStream = errorStream;
} }
/** /**
* Returns an output stream that will be sniffed. * Returns an output stream that will be sniffed.
* This stream should be hooked up so the command * This stream should be hooked up so the command
* output stream goes into here. * output stream goes into here.
*/ */
public OutputStream getOutputStream() { public OutputStream getOutputStream() {
incNOpens(); incNOpens();
return new ConsoleOutputStream(consoleOutputStream); return new ConsoleOutputStream(consoleOutputStream);
} }
/** /**
* Returns an error stream that will be sniffed. * Returns an error stream that will be sniffed.
* This stream should be hooked up so the command * This stream should be hooked up so the command
* error stream goes into here. * error stream goes into here.
*/ */
public OutputStream getErrorStream() { public OutputStream getErrorStream() {
incNOpens(); incNOpens();
return new ConsoleOutputStream(consoleErrorStream); return new ConsoleOutputStream(consoleErrorStream);
} }
private synchronized void incNOpens() { private synchronized void incNOpens() {
nOpens++; nOpens++;
} }
/* /*
*/ */
public synchronized void closeConsoleOutputStream() throws IOException { public synchronized void closeConsoleOutputStream() throws IOException {
@ -170,10 +159,10 @@ public class ConsoleOutputSniffer {
} }
} }
} }
/* /*
* Processes the line by passing the line to the parsers. * Processes the line by passing the line to the parsers.
* *
* @param line * @param line
*/ */
private synchronized void processLine(String line) { private synchronized void processLine(String line) {
@ -181,5 +170,5 @@ public class ConsoleOutputSniffer {
parsers[i].processLine(line); parsers[i].processLine(line);
} }
} }
} }

View file

@ -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;
}
}

View file

@ -101,9 +101,11 @@ public abstract class RefactoringTestBase extends BaseTestCase {
BufferedReader reader = new BufferedReader(new StringReader(contents.toString())); BufferedReader reader = new BufferedReader(new StringReader(contents.toString()));
String line; String line;
while ((line = reader.readLine()) != null) { while ((line = reader.readLine()) != null) {
String trimmedLine = line.trim();
if (testFile == null) { if (testFile == null) {
testFile = new TestSourceFile(line.trim()); assertTrue("Invalid file name \"" + trimmedLine + "\"", trimmedLine.matches("^(\\w+/)*\\w+\\.\\w+$"));
} else if (isResultDelimiter(line.trim())) { testFile = new TestSourceFile(trimmedLine);
} else if (isResultDelimiter(trimmedLine)) {
expectedResult = true; expectedResult = true;
} else if (expectedResult) { } else if (expectedResult) {
testFile.addLineToExpectedSource(line); testFile.addLineToExpectedSource(line);

View file

@ -274,6 +274,41 @@ public class ExtractFunctionRefactoringTest extends RefactoringTestBase {
assertRefactoringSuccess(); 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 //A.h
//#ifndef A_H_ //#ifndef A_H_
//#define A_H_ //#define A_H_

View file

@ -336,11 +336,6 @@ public class ElementSelectionDialog extends TypeSelectionDialog {
return types.toArray(new ITypeInfo[types.size()]); return types.toArray(new ITypeInfo[types.size()]);
} }
@Override
protected final void setListElements(Object[] elements) {
super.setListElements(elements);
}
/** /**
* @deprecated Unsupported * @deprecated Unsupported
*/ */
@ -350,6 +345,14 @@ public class ElementSelectionDialog extends TypeSelectionDialog {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
/* (non-Javadoc)
* @see org.eclipse.ui.dialogs.AbstractElementListSelectionDialog#handleElementsChanged()
*/
@Override
protected void handleElementsChanged() {
updateOkState();
}
@Override @Override
protected void handleEmptyList() { protected void handleEmptyList() {
updateOkState(); updateOkState();

View file

@ -911,8 +911,11 @@ abstract class FlowAnalyzer extends ASTGenericVisitor {
if (binding instanceof IVariable) { if (binding instanceof IVariable) {
IVariable variable= (IVariable) binding; IVariable variable= (IVariable) binding;
if (!(variable instanceof IField)) { if (!(variable instanceof IField)) {
int accessMode = CPPVariableReadWriteFlags.getReadWriteFlags(node); int index = fFlowContext.getIndexFromLocal(variable);
setFlowInfo(node, new LocalFlowInfo(variable, accessMode, fFlowContext)); if (index >= 0) {
int accessMode = CPPVariableReadWriteFlags.getReadWriteFlags(node);
setFlowInfo(node, new LocalFlowInfo(variable, index, accessMode, fFlowContext));
}
} }
} }
return PROCESS_SKIP; return PROCESS_SKIP;
@ -957,7 +960,7 @@ abstract class FlowAnalyzer extends ASTGenericVisitor {
return leave((ICASTDesignatedInitializer) node); return leave((ICASTDesignatedInitializer) node);
} else if (node instanceof IASTInitializerList) { } else if (node instanceof IASTInitializerList) {
return leave((ICPPASTConstructorChainInitializer) node); return leave((ICPPASTConstructorChainInitializer) node);
} else if (node instanceof IASTInitializerList) { } else if (node instanceof ICPPASTConstructorInitializer) {
return leave((ICPPASTConstructorInitializer) node); return leave((ICPPASTConstructorInitializer) node);
} }
return PROCESS_SKIP; return PROCESS_SKIP;

View file

@ -16,11 +16,11 @@ import org.eclipse.cdt.core.dom.ast.IVariable;
class LocalFlowInfo extends FlowInfo { class LocalFlowInfo extends FlowInfo {
private final int fVariableIndex; 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); super(NO_RETURN);
fVariableIndex= context.getIndexFromLocal(binding); if (variableIndex < 0)
if (fVariableIndex < 0) throw new IllegalArgumentException("Invalid index for local variable \"" + binding.getName()); //$NON-NLS-1$
throw new IllegalStateException("Invalid local variable \"" + binding.getName() + "\" for the context."); //$NON-NLS-1$ //$NON-NLS-2$ fVariableIndex= variableIndex;
if (context.considerAccessMode()) { if (context.considerAccessMode()) {
createAccessModeArray(context); createAccessModeArray(context);
context.manageLocal(binding); context.manageLocal(binding);

View file

@ -132,16 +132,16 @@ public abstract class CRefactoring extends Refactoring {
public RefactoringStatus checkInitialConditions(IProgressMonitor pm) public RefactoringStatus checkInitialConditions(IProgressMonitor pm)
throws CoreException, OperationCanceledException { throws CoreException, OperationCanceledException {
SubMonitor sm = SubMonitor.convert(pm, 10); SubMonitor sm = SubMonitor.convert(pm, 10);
sm.subTask(Messages.Refactoring_PM_LoadTU); if (isProgressMonitorCanceled(sm, initStatus)) {
if (isProgressMonitorCanceld(sm, initStatus)) {
return initStatus; return initStatus;
} }
sm.subTask(Messages.Refactoring_PM_LoadTU);
IASTTranslationUnit ast = getAST(tu, sm); IASTTranslationUnit ast = getAST(tu, sm);
if (ast == null) { if (ast == null) {
initStatus.addError(NLS.bind(Messages.Refactoring_ParsingError, tu.getPath())); initStatus.addError(NLS.bind(Messages.Refactoring_ParsingError, tu.getPath()));
return initStatus; return initStatus;
} }
if (isProgressMonitorCanceld(sm, initStatus)) { if (isProgressMonitorCanceled(sm, initStatus)) {
return initStatus; return initStatus;
} }
sm.subTask(Messages.Refactoring_PM_CheckTU); sm.subTask(Messages.Refactoring_PM_CheckTU);
@ -152,7 +152,7 @@ public abstract class CRefactoring extends Refactoring {
return initStatus; return initStatus;
} }
protected static boolean isProgressMonitorCanceld(IProgressMonitor sm, RefactoringStatus status) { protected static boolean isProgressMonitorCanceled(IProgressMonitor sm, RefactoringStatus status) {
if (sm.isCanceled()) { if (sm.isCanceled()) {
status.addFatalError(Messages.Refactoring_CanceledByUser); status.addFatalError(Messages.Refactoring_CanceledByUser);
return true; return true;

View file

@ -278,6 +278,7 @@ public class NameInformation {
if (!isWriteAccess) { if (!isWriteAccess) {
indirection = Indirection.REFERENCE; indirection = Indirection.REFERENCE;
} }
// TODO(sprigogin): Verify availability of the copy ctor before passing by value
} else { } else {
indirection = Indirection.POINTER; indirection = Indirection.POINTER;
} }

View file

@ -173,7 +173,7 @@ public class ExtractFunctionRefactoring extends CRefactoring {
nodeFactory = ast.getASTNodeFactory(); nodeFactory = ast.getASTNodeFactory();
container = findExtractableNodes(); container = findExtractableNodes();
if (isProgressMonitorCanceld(sm, initStatus)) if (isProgressMonitorCanceled(sm, initStatus))
return initStatus; return initStatus;
if (container.isEmpty()) { if (container.isEmpty()) {

View file

@ -114,7 +114,7 @@ public class ExtractLocalVariableRefactoring extends CRefactoring {
} }
sm.worked(1); sm.worked(1);
if (isProgressMonitorCanceld(sm, initStatus)) if (isProgressMonitorCanceled(sm, initStatus))
return initStatus; return initStatus;
boolean oneMarked = selectedRegion != null && isOneMarked(container.getNodesToWrite(), selectedRegion); boolean oneMarked = selectedRegion != null && isOneMarked(container.getNodesToWrite(), selectedRegion);
@ -125,7 +125,7 @@ public class ExtractLocalVariableRefactoring extends CRefactoring {
} }
sm.worked(1); sm.worked(1);
if (isProgressMonitorCanceld(sm, initStatus)) if (isProgressMonitorCanceled(sm, initStatus))
return initStatus; return initStatus;
sm.worked(1); sm.worked(1);

View file

@ -93,7 +93,7 @@ public class HideMethodRefactoring extends CRefactoring {
return initStatus; return initStatus;
} }
if (isProgressMonitorCanceld(sm, initStatus)) if (isProgressMonitorCanceled(sm, initStatus))
return initStatus; return initStatus;
List<IASTName> names = findAllMarkedNames(); List<IASTName> names = findAllMarkedNames();
@ -118,7 +118,7 @@ public class HideMethodRefactoring extends CRefactoring {
return initStatus; return initStatus;
} }
if (isProgressMonitorCanceld(sm, initStatus)) if (isProgressMonitorCanceled(sm, initStatus))
return initStatus; return initStatus;
if (methodDeclaration instanceof IASTFunctionDefinition) { if (methodDeclaration instanceof IASTFunctionDefinition) {
IASTDeclarator declarator = ((IASTFunctionDefinition) methodDeclaration).getDeclarator(); IASTDeclarator declarator = ((IASTFunctionDefinition) methodDeclaration).getDeclarator();

View file

@ -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);
}
}

View file

@ -37,9 +37,9 @@ public class CToggleMethodBreakpointActionDelegate extends CToggleBreakpointObje
{ {
if ((event.stateMask & SWT.MOD1) != 0 && if ((event.stateMask & SWT.MOD1) != 0 &&
target instanceof IToggleBreakpointsTargetCExtension && target instanceof IToggleBreakpointsTargetCExtension &&
((IToggleBreakpointsTargetCExtension)target).canCreateLineBreakpointsInteractive(part, selection)) ((IToggleBreakpointsTargetCExtension)target).canCreateFunctionBreakpointInteractive(part, selection))
{ {
((IToggleBreakpointsTargetCExtension)target).createLineBreakpointsInteractive(part, selection); ((IToggleBreakpointsTargetCExtension)target).createFunctionBreakpointInteractive(part, selection);
} }
else { else {
target.toggleMethodBreakpoints(part, selection); target.toggleMethodBreakpoints(part, selection);

View file

@ -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.DSFDebugModelListener;
import org.eclipse.cdt.dsf.gdb.multicorevisualizer.internal.utils.DSFSessionState; 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.multicorevisualizer.internal.utils.DebugViewUtils;
import org.eclipse.cdt.dsf.gdb.service.IGDBHardware.ICPUDMContext; import org.eclipse.cdt.dsf.gdb.service.IGDBHardwareAndOS.ICPUDMContext;
import org.eclipse.cdt.dsf.gdb.service.IGDBHardware.ICoreDMContext; import org.eclipse.cdt.dsf.gdb.service.IGDBHardwareAndOS.ICoreDMContext;
import org.eclipse.cdt.dsf.mi.service.IMIExecutionDMContext; import org.eclipse.cdt.dsf.mi.service.IMIExecutionDMContext;
import org.eclipse.cdt.dsf.mi.service.IMIProcessDMContext; import org.eclipse.cdt.dsf.mi.service.IMIProcessDMContext;
import org.eclipse.cdt.dsf.ui.viewmodel.datamodel.IDMVMContext; import org.eclipse.cdt.dsf.ui.viewmodel.datamodel.IDMVMContext;

View file

@ -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;
import org.eclipse.cdt.dsf.debug.service.command.ICommandControlService.ICommandControlDMContext; 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.multicorevisualizer.internal.ui.model.VisualizerExecutionState;
import org.eclipse.cdt.dsf.gdb.service.IGDBHardware; import org.eclipse.cdt.dsf.gdb.service.IGDBHardwareAndOS;
import org.eclipse.cdt.dsf.gdb.service.IGDBHardware.ICPUDMContext; import org.eclipse.cdt.dsf.gdb.service.IGDBHardwareAndOS.ICPUDMContext;
import org.eclipse.cdt.dsf.gdb.service.IGDBHardware.ICoreDMContext; import org.eclipse.cdt.dsf.gdb.service.IGDBHardwareAndOS.ICoreDMContext;
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.IGDBProcesses.IGdbThreadDMData; import org.eclipse.cdt.dsf.gdb.service.IGDBProcesses.IGdbThreadDMData;
import org.eclipse.cdt.dsf.mi.service.IMIExecutionDMContext; import org.eclipse.cdt.dsf.mi.service.IMIExecutionDMContext;
@ -61,7 +61,7 @@ public class DSFDebugModel {
final Object arg) final Object arg)
{ {
ICommandControlService controlService = sessionState.getService(ICommandControlService.class); ICommandControlService controlService = sessionState.getService(ICommandControlService.class);
IGDBHardware hwService = sessionState.getService(IGDBHardware.class); IGDBHardwareAndOS hwService = sessionState.getService(IGDBHardwareAndOS.class);
if (controlService == null || hwService == null) { if (controlService == null || hwService == null) {
listener.getCPUsDone(null, arg); listener.getCPUsDone(null, arg);
return; return;
@ -99,7 +99,7 @@ public class DSFDebugModel {
final DSFDebugModelListener listener, final DSFDebugModelListener listener,
final Object arg) final Object arg)
{ {
IGDBHardware hwService = sessionState.getService(IGDBHardware.class); IGDBHardwareAndOS hwService = sessionState.getService(IGDBHardwareAndOS.class);
if (hwService == null) { if (hwService == null) {
listener.getCoresDone(cpuContext, null, arg); listener.getCoresDone(cpuContext, null, arg);
return; return;

View file

@ -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.datamodel.IDMContext;
import org.eclipse.cdt.dsf.debug.service.IProcesses.IThreadDMData; 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.multicorevisualizer.internal.ui.model.VisualizerExecutionState;
import org.eclipse.cdt.dsf.gdb.service.IGDBHardware.ICPUDMContext; import org.eclipse.cdt.dsf.gdb.service.IGDBHardwareAndOS.ICPUDMContext;
import org.eclipse.cdt.dsf.gdb.service.IGDBHardware.ICoreDMContext; import org.eclipse.cdt.dsf.gdb.service.IGDBHardwareAndOS.ICoreDMContext;
import org.eclipse.cdt.dsf.mi.service.IMIExecutionDMContext; import org.eclipse.cdt.dsf.mi.service.IMIExecutionDMContext;
/** Interface for classes that interact with DSFDebugModel. /** Interface for classes that interact with DSFDebugModel.

View file

@ -97,6 +97,12 @@ public class ProcessPrompter implements IStatusHandler {
// we will get confused when using path.lastSegment(), so, // we will get confused when using path.lastSegment(), so,
// let's only keep the name to be sure // let's only keep the name to be sure
String name = info.getName(); 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$ name = name.split("\\s", 2)[0]; //$NON-NLS-1$
IPath path = new Path(name); IPath path = new Path(name);

View file

@ -51,40 +51,43 @@ public class CoreList {
Vector<ICoreInfo> coreInfo = new Vector<ICoreInfo>(); Vector<ICoreInfo> coreInfo = new Vector<ICoreInfo>();
BufferedReader reader = null; BufferedReader reader = null;
try { try {
String processorId = null;
String physicalId = null; String physicalId = null;
String coreId = null;
String cpuCores = null;
Reader r = new InputStreamReader(new FileInputStream(cpuInfo)); Reader r = new InputStreamReader(new FileInputStream(cpuInfo));
reader = new BufferedReader(r); reader = new BufferedReader(r);
String line; String line;
while ((line = reader.readLine()) != null) { while ((line = reader.readLine()) != null) {
line = line.trim(); 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 // Found the physical id of this core, so store it temporarily
assert physicalId == null;
physicalId = line.split(":")[1].trim(); //$NON-NLS-1$ 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 coreInfo.add(new CoreInfo(processorId, physicalId));
// 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));
// Get ready to look for the next core. // Get ready to look for the next core.
processorId = null;
physicalId = 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) { } catch (IOException e) {
} finally { } finally {
try { try {

View file

@ -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.ISourceLookup.ISourceLookupDMContext;
import org.eclipse.cdt.dsf.debug.service.IStack; import org.eclipse.cdt.dsf.debug.service.IStack;
import org.eclipse.cdt.dsf.debug.service.command.ICommandControlService; 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.gdb.service.IGDBTraceControl;
import org.eclipse.cdt.dsf.mi.service.CSourceLookup; import org.eclipse.cdt.dsf.mi.service.CSourceLookup;
import org.eclipse.cdt.dsf.mi.service.IMIBackend; import org.eclipse.cdt.dsf.mi.service.IMIBackend;
@ -62,7 +62,7 @@ public class ServicesLaunchSequence extends Sequence {
}, },
new Step() { @Override new Step() { @Override
public void execute(RequestMonitor requestMonitor) { 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); hwService.initialize(requestMonitor);
}}, }},
new Step() { @Override new Step() { @Override

View file

@ -60,13 +60,13 @@ import org.eclipse.core.runtime.Status;
import org.osgi.framework.BundleContext; 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. * to hardware information about the target.
* *
* @since 4.1 * @since 4.1
*/ */
@SuppressWarnings("restriction") @SuppressWarnings("restriction")
public class GDBHardware extends AbstractDsfService implements IGDBHardware, ICachingService { public class GDBHardwareAndOS extends AbstractDsfService implements IGDBHardwareAndOS, ICachingService {
@Immutable @Immutable
protected static class GDBCPUDMC extends AbstractDMContext protected static class GDBCPUDMC extends AbstractDMContext
@ -171,7 +171,7 @@ public class GDBHardware extends AbstractDsfService implements IGDBHardware, ICa
// Bug 374293 // Bug 374293
private boolean fSessionInitializationComplete; private boolean fSessionInitializationComplete;
public GDBHardware(DsfSession session) { public GDBHardwareAndOS(DsfSession session) {
super(session); super(session);
} }
@ -216,8 +216,8 @@ public class GDBHardware extends AbstractDsfService implements IGDBHardware, ICa
getSession().addServiceEventListener(this, null); getSession().addServiceEventListener(this, null);
// Register this service. // Register this service.
register(new String[] { IGDBHardware.class.getName(), register(new String[] { IGDBHardwareAndOS.class.getName(),
GDBHardware.class.getName() }, GDBHardwareAndOS.class.getName() },
new Hashtable<String, String>()); new Hashtable<String, String>());
requestMonitor.done(); requestMonitor.done();

View file

@ -96,10 +96,10 @@ public class GdbDebugServicesFactory extends AbstractDsfDebugServicesFactory {
return (V)createTraceControlService(session, (ILaunchConfiguration)arg); return (V)createTraceControlService(session, (ILaunchConfiguration)arg);
} }
} }
} else if (IGDBHardware.class.isAssignableFrom(clazz)) { } else if (IGDBHardwareAndOS.class.isAssignableFrom(clazz)) {
for (Object arg : optionalArguments) { for (Object arg : optionalArguments) {
if (arg instanceof ILaunchConfiguration) { 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 */ /** @since 4.1 */
protected IGDBHardware createHardwareService(DsfSession session, ILaunchConfiguration config) { protected IGDBHardwareAndOS createHardwareAndOSService(DsfSession session, ILaunchConfiguration config) {
return new GDBHardware(session); return new GDBHardwareAndOS(session);
} }
} }

View file

@ -25,7 +25,7 @@ import org.eclipse.cdt.dsf.service.IDsfService;
* *
* @since 4.1 * @since 4.1
*/ */
public interface IGDBHardware extends IDsfService { public interface IGDBHardwareAndOS extends IDsfService {
/** /**
* The physical target that has CPUs and Cores. * The physical target that has CPUs and Cores.

View file

@ -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.IModules.ISymbolDMContext;
import org.eclipse.cdt.dsf.debug.service.ISignals.ISignalsDMContext; import org.eclipse.cdt.dsf.debug.service.ISignals.ISignalsDMContext;
import org.eclipse.cdt.dsf.debug.service.ISourceLookup.ISourceLookupDMContext; 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.gdb.service.IGDBTraceControl.ITraceTargetDMContext;
import org.eclipse.cdt.dsf.mi.service.command.MIControlDMContext; import org.eclipse.cdt.dsf.mi.service.command.MIControlDMContext;

View file

@ -468,7 +468,7 @@
id="org.eclipse.cdt.dsf.debug.ui.disassemblyViewToggleBreakpointTester" id="org.eclipse.cdt.dsf.debug.ui.disassemblyViewToggleBreakpointTester"
namespace="org.eclipse.cdt.dsf.debug.ui" namespace="org.eclipse.cdt.dsf.debug.ui"
properties="isDisassemblyViewSupportsCBreakpoint" properties="isDisassemblyViewSupportsCBreakpoint"
type="org.eclipse.cdt.dsf.debug.internal.ui.disassembly.DisassemblyView"> type="org.eclipse.cdt.dsf.debug.internal.ui.disassembly.DisassemblyPart">
</propertyTester> </propertyTester>
</extension> </extension>
<extension <extension

View file

@ -42,8 +42,4 @@
id="org.eclipse.cdt.gnu.dsf" id="org.eclipse.cdt.gnu.dsf"
version="0.0.0"/> version="0.0.0"/>
<includes
id="org.eclipse.cdt.autotools"
version="0.0.0"/>
</feature> </feature>

View file

@ -56,4 +56,10 @@
<feature url="features/org.eclipse.cdt.gnu.multicorevisualizer_0.0.0.qualifier.jar" id="org.eclipse.cdt.gnu.multicorevisualizer" version="0.0.0"> <feature url="features/org.eclipse.cdt.gnu.multicorevisualizer_0.0.0.qualifier.jar" id="org.eclipse.cdt.gnu.multicorevisualizer" version="0.0.0">
<category name="extra"/> <category name="extra"/>
</feature> </feature>
<feature url="features/org.eclipse.cdt.autotools_0.0.0.qualifier.jar" id="org.eclipse.cdt.autotools" version="0.0.0">
<category name="extra"/>
</feature>
<feature url="features/org.eclipse.cdt.autotools.source_0.0.0.qualifier.jar" id="org.eclipse.cdt.autotools.source" version="0.0.0">
<category name="extra"/>
</feature>
</site> </site>

View file

@ -45,10 +45,6 @@
id="org.eclipse.cdt" id="org.eclipse.cdt"
version="0.0.0"/> version="0.0.0"/>
<includes
id="org.eclipse.cdt.autotools.source"
version="0.0.0"/>
<plugin <plugin
id="org.eclipse.cdt.sdk" id="org.eclipse.cdt.sdk"
download-size="0" download-size="0"