mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-21 07:55:24 +02:00
bug 71511: Some house-cleaning
This commit is contained in:
parent
5326d2930a
commit
faf497d361
11 changed files with 183 additions and 86 deletions
|
@ -58,7 +58,10 @@ import org.eclipse.core.runtime.jobs.Job;
|
||||||
*/
|
*/
|
||||||
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 static final int PROGRESS_MONITOR_SCALE = 100;
|
||||||
|
private static final int TICKS_STREAM_PROGRESS_MONITOR = 1 * PROGRESS_MONITOR_SCALE;
|
||||||
|
private static final int TICKS_DELETE_MARKERS = 1 * PROGRESS_MONITOR_SCALE;
|
||||||
|
private static final int TICKS_EXECUTE_COMMAND = 1 * PROGRESS_MONITOR_SCALE;
|
||||||
|
|
||||||
private BuildRunnerHelper buildRunnerHelper = null;
|
private BuildRunnerHelper buildRunnerHelper = null;
|
||||||
|
|
||||||
|
@ -158,7 +161,8 @@ public class MakeBuilder extends ACBuilder {
|
||||||
if (monitor == null) {
|
if (monitor == null) {
|
||||||
monitor = new NullProgressMonitor();
|
monitor = new NullProgressMonitor();
|
||||||
}
|
}
|
||||||
monitor.beginTask(MakeMessages.getString("MakeBuilder.Invoking_Make_Builder") + project.getName(), 3 * MONITOR_SCALE); //$NON-NLS-1$
|
monitor.beginTask(MakeMessages.getString("MakeBuilder.Invoking_Make_Builder") + project.getName(), //$NON-NLS-1$
|
||||||
|
TICKS_STREAM_PROGRESS_MONITOR + TICKS_DELETE_MARKERS + TICKS_EXECUTE_COMMAND);
|
||||||
|
|
||||||
IPath buildCommand = info.getBuildCommand();
|
IPath buildCommand = info.getBuildCommand();
|
||||||
if (buildCommand != null) {
|
if (buildCommand != null) {
|
||||||
|
@ -187,12 +191,12 @@ public class MakeBuilder extends ACBuilder {
|
||||||
parsers.add(parserSD);
|
parsers.add(parserSD);
|
||||||
|
|
||||||
buildRunnerHelper.setLaunchParameters(launcher, buildCommand, args, workingDirectoryURI, envp);
|
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.prepareStreams(epm, parsers, console, new SubProgressMonitor(monitor, TICKS_STREAM_PROGRESS_MONITOR, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK));
|
||||||
|
|
||||||
buildRunnerHelper.removeOldMarkers(project, new SubProgressMonitor(monitor, 1 * MONITOR_SCALE, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK));
|
buildRunnerHelper.removeOldMarkers(project, new SubProgressMonitor(monitor, TICKS_DELETE_MARKERS, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK));
|
||||||
|
|
||||||
buildRunnerHelper.greeting(kind);
|
buildRunnerHelper.greeting(kind);
|
||||||
int state = buildRunnerHelper.build(new SubProgressMonitor(monitor, 1 * MONITOR_SCALE, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK));
|
int state = buildRunnerHelper.build(new SubProgressMonitor(monitor, TICKS_EXECUTE_COMMAND, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK));
|
||||||
buildRunnerHelper.close();
|
buildRunnerHelper.close();
|
||||||
buildRunnerHelper.goodbye();
|
buildRunnerHelper.goodbye();
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@ import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public class StreamMonitor extends org.eclipse.cdt.internal.core.StreamMonitor {
|
public class StreamMonitor extends org.eclipse.cdt.internal.core.StreamProgressMonitor {
|
||||||
public StreamMonitor(IProgressMonitor mon, OutputStream cos, int totalWork) {
|
public StreamMonitor(IProgressMonitor mon, OutputStream cos, int totalWork) {
|
||||||
super(mon, cos, totalWork);
|
super(mon, cos, totalWork);
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,7 +56,10 @@ 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 int MONITOR_SCALE = 100;
|
|
||||||
|
private static final int PROGRESS_MONITOR_SCALE = 100;
|
||||||
|
private static final int TICKS_STREAM_PROGRESS_MONITOR = 1 * PROGRESS_MONITOR_SCALE;
|
||||||
|
private static final int TICKS_EXECUTE_PROGRAM = 1 * PROGRESS_MONITOR_SCALE;
|
||||||
|
|
||||||
protected IResource resource;
|
protected IResource resource;
|
||||||
protected String providerId;
|
protected String providerId;
|
||||||
|
@ -97,7 +100,8 @@ public class DefaultRunSIProvider implements IExternalScannerInfoProvider {
|
||||||
if (monitor == null) {
|
if (monitor == null) {
|
||||||
monitor = new NullProgressMonitor();
|
monitor = new NullProgressMonitor();
|
||||||
}
|
}
|
||||||
monitor.beginTask(MakeMessages.getString("ExternalScannerInfoProvider.Reading_Specs"), 2 * MONITOR_SCALE); //$NON-NLS-1$
|
monitor.beginTask(MakeMessages.getString("ExternalScannerInfoProvider.Reading_Specs"), //$NON-NLS-1$
|
||||||
|
TICKS_STREAM_PROGRESS_MONITOR + TICKS_EXECUTE_PROGRAM);
|
||||||
|
|
||||||
// call a subclass to initialize protected fields
|
// call a subclass to initialize protected fields
|
||||||
if (!initialize()) {
|
if (!initialize()) {
|
||||||
|
@ -133,10 +137,10 @@ public class DefaultRunSIProvider implements IExternalScannerInfoProvider {
|
||||||
}
|
}
|
||||||
|
|
||||||
buildRunnerHelper.setLaunchParameters(launcher, program, comandLineOptions, workingDirectoryURI, envp );
|
buildRunnerHelper.setLaunchParameters(launcher, program, comandLineOptions, workingDirectoryURI, envp );
|
||||||
buildRunnerHelper.prepareStreams(epm, parsers, console, new SubProgressMonitor(monitor, 1 * MONITOR_SCALE, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK));
|
buildRunnerHelper.prepareStreams(epm, parsers, console, new SubProgressMonitor(monitor, TICKS_STREAM_PROGRESS_MONITOR, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK));
|
||||||
|
|
||||||
buildRunnerHelper.greeting(MakeMessages.getFormattedString("ExternalScannerInfoProvider.Greeting", project.getName())); //$NON-NLS-1$
|
buildRunnerHelper.greeting(MakeMessages.getFormattedString("ExternalScannerInfoProvider.Greeting", project.getName())); //$NON-NLS-1$
|
||||||
buildRunnerHelper.build(new SubProgressMonitor(monitor, 1 * MONITOR_SCALE, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK));
|
buildRunnerHelper.build(new SubProgressMonitor(monitor, TICKS_EXECUTE_PROGRAM, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK));
|
||||||
buildRunnerHelper.close();
|
buildRunnerHelper.close();
|
||||||
buildRunnerHelper.goodbye();
|
buildRunnerHelper.goodbye();
|
||||||
|
|
||||||
|
|
|
@ -57,7 +57,11 @@ 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 int PROGRESS_MONITOR_SCALE = 100;
|
||||||
|
private static final int TICKS_STREAM_PROGRESS_MONITOR = 1 * PROGRESS_MONITOR_SCALE;
|
||||||
|
private static final int TICKS_DELETE_MARKERS = 1 * PROGRESS_MONITOR_SCALE;
|
||||||
|
private static final int TICKS_EXECUTE_COMMAND = 1 * PROGRESS_MONITOR_SCALE;
|
||||||
|
private static final int TICKS_REFRESH_PROJECT = 1 * PROGRESS_MONITOR_SCALE;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean invokeBuild(int kind, IProject project, IConfiguration configuration,
|
public boolean invokeBuild(int kind, IProject project, IConfiguration configuration,
|
||||||
|
@ -78,7 +82,8 @@ public class ExternalBuildRunner extends AbstractBuildRunner {
|
||||||
if (monitor == null) {
|
if (monitor == null) {
|
||||||
monitor = new NullProgressMonitor();
|
monitor = new NullProgressMonitor();
|
||||||
}
|
}
|
||||||
monitor.beginTask(ManagedMakeMessages.getResourceString("MakeBuilder.Invoking_Make_Builder") + project.getName(), 4 * MONITOR_SCALE); //$NON-NLS-1$
|
monitor.beginTask(ManagedMakeMessages.getResourceString("MakeBuilder.Invoking_Make_Builder") + project.getName(), //$NON-NLS-1$
|
||||||
|
TICKS_STREAM_PROGRESS_MONITOR + TICKS_DELETE_MARKERS + TICKS_EXECUTE_COMMAND + TICKS_REFRESH_PROJECT);
|
||||||
|
|
||||||
IPath buildCommand = builder.getBuildCommand();
|
IPath buildCommand = builder.getBuildCommand();
|
||||||
if (buildCommand != null) {
|
if (buildCommand != null) {
|
||||||
|
@ -106,17 +111,17 @@ public class ExternalBuildRunner extends AbstractBuildRunner {
|
||||||
collectScannerInfoConsoleParsers(project, configuration, workingDirectoryURI, markerGenerator, parsers);
|
collectScannerInfoConsoleParsers(project, configuration, workingDirectoryURI, markerGenerator, parsers);
|
||||||
|
|
||||||
buildRunnerHelper.setLaunchParameters(launcher, buildCommand, args, workingDirectoryURI, envp);
|
buildRunnerHelper.setLaunchParameters(launcher, buildCommand, args, workingDirectoryURI, envp);
|
||||||
buildRunnerHelper.prepareStreams(epm, parsers, console, new SubProgressMonitor(monitor, 1 * MONITOR_SCALE));
|
buildRunnerHelper.prepareStreams(epm, parsers, console, new SubProgressMonitor(monitor, TICKS_STREAM_PROGRESS_MONITOR));
|
||||||
|
|
||||||
buildRunnerHelper.removeOldMarkers(project, new SubProgressMonitor(monitor, 1 * MONITOR_SCALE, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK));
|
buildRunnerHelper.removeOldMarkers(project, new SubProgressMonitor(monitor, TICKS_DELETE_MARKERS, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK));
|
||||||
|
|
||||||
buildRunnerHelper.greeting(kind, cfgName, toolchainName, isSupported);
|
buildRunnerHelper.greeting(kind, cfgName, toolchainName, isSupported);
|
||||||
int state = buildRunnerHelper.build(new SubProgressMonitor(monitor, 1 * MONITOR_SCALE, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK));
|
int state = buildRunnerHelper.build(new SubProgressMonitor(monitor, TICKS_EXECUTE_COMMAND, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK));
|
||||||
buildRunnerHelper.close();
|
buildRunnerHelper.close();
|
||||||
buildRunnerHelper.goodbye();
|
buildRunnerHelper.goodbye();
|
||||||
|
|
||||||
if (state != ICommandLauncher.ILLEGAL_COMMAND) {
|
if (state != ICommandLauncher.ILLEGAL_COMMAND) {
|
||||||
buildRunnerHelper.refreshProject(new SubProgressMonitor(monitor, 1 * MONITOR_SCALE, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK));
|
buildRunnerHelper.refreshProject(new SubProgressMonitor(monitor, TICKS_REFRESH_PROJECT, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
String msg = ManagedMakeMessages.getFormattedString("ManagedMakeBuilder.message.undefined.build.command", builder.getId()); //$NON-NLS-1$
|
String msg = ManagedMakeMessages.getFormattedString("ManagedMakeBuilder.message.undefined.build.command", builder.getId()); //$NON-NLS-1$
|
||||||
|
|
|
@ -45,7 +45,11 @@ import org.eclipse.core.runtime.SubProgressMonitor;
|
||||||
* @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 int PROGRESS_MONITOR_SCALE = 100;
|
||||||
|
private static final int TICKS_STREAM_PROGRESS_MONITOR = 1 * PROGRESS_MONITOR_SCALE;
|
||||||
|
private static final int TICKS_DELETE_MARKERS = 1 * PROGRESS_MONITOR_SCALE;
|
||||||
|
private static final int TICKS_EXECUTE_COMMAND = 1 * PROGRESS_MONITOR_SCALE;
|
||||||
|
private static final int TICKS_REFRESH_PROJECT = 1 * PROGRESS_MONITOR_SCALE;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean invokeBuild(int kind, IProject project, IConfiguration configuration,
|
public boolean invokeBuild(int kind, IProject project, IConfiguration configuration,
|
||||||
|
@ -58,7 +62,7 @@ public class InternalBuildRunner extends AbstractBuildRunner {
|
||||||
if (monitor == null) {
|
if (monitor == null) {
|
||||||
monitor = new NullProgressMonitor();
|
monitor = new NullProgressMonitor();
|
||||||
}
|
}
|
||||||
monitor.beginTask("", 3 * MONITOR_SCALE); //$NON-NLS-1$
|
monitor.beginTask("", TICKS_STREAM_PROGRESS_MONITOR + TICKS_DELETE_MARKERS + TICKS_EXECUTE_COMMAND + TICKS_REFRESH_PROJECT); //$NON-NLS-1$
|
||||||
|
|
||||||
boolean isParallel = builder.getParallelizationNum() > 1;
|
boolean isParallel = builder.getParallelizationNum() > 1;
|
||||||
boolean resumeOnErr = !builder.isStopOnError();
|
boolean resumeOnErr = !builder.isStopOnError();
|
||||||
|
@ -86,7 +90,7 @@ public class InternalBuildRunner extends AbstractBuildRunner {
|
||||||
String[] errorParsers = builder.getErrorParsers();
|
String[] errorParsers = builder.getErrorParsers();
|
||||||
ErrorParserManager epm = new ErrorParserManager(project, workingDirectoryURI, markerGenerator, errorParsers);
|
ErrorParserManager epm = new ErrorParserManager(project, workingDirectoryURI, markerGenerator, errorParsers);
|
||||||
|
|
||||||
buildRunnerHelper.prepareStreams(epm, null, console, new SubProgressMonitor(monitor, 1 * MONITOR_SCALE));
|
buildRunnerHelper.prepareStreams(epm, null, console, new SubProgressMonitor(monitor, TICKS_STREAM_PROGRESS_MONITOR));
|
||||||
|
|
||||||
IBuildDescription des = BuildDescriptionManager.createBuildDescription(configuration, cBS, delta, flags);
|
IBuildDescription des = BuildDescriptionManager.createBuildDescription(configuration, cBS, delta, flags);
|
||||||
DescriptionBuilder dBuilder = null;
|
DescriptionBuilder dBuilder = null;
|
||||||
|
@ -98,7 +102,7 @@ public class InternalBuildRunner extends AbstractBuildRunner {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
buildRunnerHelper.removeOldMarkers(project, new SubProgressMonitor(monitor, 1 * MONITOR_SCALE, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK));
|
buildRunnerHelper.removeOldMarkers(project, new SubProgressMonitor(monitor, TICKS_DELETE_MARKERS, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK));
|
||||||
|
|
||||||
if (buildIncrementaly) {
|
if (buildIncrementaly) {
|
||||||
buildRunnerHelper.greeting(IncrementalProjectBuilder.INCREMENTAL_BUILD, cfgName, toolchainName, isConfigurationSupported);
|
buildRunnerHelper.greeting(IncrementalProjectBuilder.INCREMENTAL_BUILD, cfgName, toolchainName, isConfigurationSupported);
|
||||||
|
@ -112,9 +116,9 @@ public class InternalBuildRunner extends AbstractBuildRunner {
|
||||||
|
|
||||||
int status;
|
int status;
|
||||||
if (dBuilder != null) {
|
if (dBuilder != null) {
|
||||||
status = dBuilder.build(stdout, stderr, new SubProgressMonitor(monitor, 1 * MONITOR_SCALE, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK));
|
status = dBuilder.build(stdout, stderr, new SubProgressMonitor(monitor, TICKS_EXECUTE_COMMAND, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK));
|
||||||
} else {
|
} else {
|
||||||
status = ParallelBuilder.build(des, null, null, stdout, stderr, new SubProgressMonitor(monitor, 1 * MONITOR_SCALE, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK), resumeOnErr, buildIncrementaly);
|
status = ParallelBuilder.build(des, null, null, stdout, stderr, new SubProgressMonitor(monitor, TICKS_EXECUTE_COMMAND, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK), resumeOnErr, buildIncrementaly);
|
||||||
buildRunnerHelper.printLine(ManagedMakeMessages.getFormattedString("CommonBuilder.7", Integer.toString(ParallelBuilder.lastThreadsUsed))); //$NON-NLS-1$
|
buildRunnerHelper.printLine(ManagedMakeMessages.getFormattedString("CommonBuilder.7", Integer.toString(ParallelBuilder.lastThreadsUsed))); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -124,7 +128,7 @@ public class InternalBuildRunner extends AbstractBuildRunner {
|
||||||
buildRunnerHelper.goodbye();
|
buildRunnerHelper.goodbye();
|
||||||
|
|
||||||
if (status != ICommandLauncher.ILLEGAL_COMMAND) {
|
if (status != ICommandLauncher.ILLEGAL_COMMAND) {
|
||||||
buildRunnerHelper.refreshProject(monitor);
|
buildRunnerHelper.refreshProject(new SubProgressMonitor(monitor, TICKS_REFRESH_PROJECT, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK));
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
|
@ -85,9 +85,14 @@ public class CommonBuilder extends ACBuilder {
|
||||||
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 int MONITOR_SCALE = 100;
|
|
||||||
public static boolean VERBOSE = false;
|
public static boolean VERBOSE = false;
|
||||||
|
|
||||||
|
private static final int PROGRESS_MONITOR_SCALE = 100;
|
||||||
|
private static final int TICKS_STREAM_PROGRESS_MONITOR = 1 * PROGRESS_MONITOR_SCALE;
|
||||||
|
private static final int TICKS_EXECUTE_COMMAND = 1 * PROGRESS_MONITOR_SCALE;
|
||||||
|
private static final int TICKS_REFRESH_PROJECT = 1 * PROGRESS_MONITOR_SCALE;
|
||||||
|
private static final int TICKS_DELETE_OUTPUTS = 1 * PROGRESS_MONITOR_SCALE;
|
||||||
|
|
||||||
private static CfgBuildSet fBuildSet = new CfgBuildSet();
|
private static CfgBuildSet fBuildSet = new CfgBuildSet();
|
||||||
|
|
||||||
private boolean fBuildErrOccured;
|
private boolean fBuildErrOccured;
|
||||||
|
@ -1183,7 +1188,7 @@ public class CommonBuilder extends ACBuilder {
|
||||||
if (monitor == null) {
|
if (monitor == null) {
|
||||||
monitor = new NullProgressMonitor();
|
monitor = new NullProgressMonitor();
|
||||||
}
|
}
|
||||||
monitor.beginTask("", 2 * MONITOR_SCALE); //$NON-NLS-1$
|
monitor.beginTask("", TICKS_STREAM_PROGRESS_MONITOR + TICKS_EXECUTE_COMMAND + TICKS_REFRESH_PROJECT); //$NON-NLS-1$
|
||||||
|
|
||||||
IConsole console = bInfo.getConsole();
|
IConsole console = bInfo.getConsole();
|
||||||
|
|
||||||
|
@ -1192,7 +1197,7 @@ public class CommonBuilder extends ACBuilder {
|
||||||
URI workingDirectoryURI = ManagedBuildManager.getBuildLocationURI(configuration, builder);
|
URI workingDirectoryURI = ManagedBuildManager.getBuildLocationURI(configuration, builder);
|
||||||
ErrorParserManager epm = new ErrorParserManager(project, workingDirectoryURI, this, errorParsers);
|
ErrorParserManager epm = new ErrorParserManager(project, workingDirectoryURI, this, errorParsers);
|
||||||
|
|
||||||
buildRunnerHelper.prepareStreams(epm, null, console, new SubProgressMonitor(monitor, 1 * MONITOR_SCALE));
|
buildRunnerHelper.prepareStreams(epm, null, console, new SubProgressMonitor(monitor, TICKS_STREAM_PROGRESS_MONITOR));
|
||||||
OutputStream stdout = buildRunnerHelper.getOutputStream();
|
OutputStream stdout = buildRunnerHelper.getOutputStream();
|
||||||
OutputStream stderr = buildRunnerHelper.getErrorStream();
|
OutputStream stderr = buildRunnerHelper.getErrorStream();
|
||||||
|
|
||||||
|
@ -1201,12 +1206,12 @@ public class CommonBuilder extends ACBuilder {
|
||||||
boolean isConfigurationSupported = configuration.isSupported();
|
boolean isConfigurationSupported = configuration.isSupported();
|
||||||
|
|
||||||
buildRunnerHelper.greeting(CLEAN_BUILD, cfgName, toolchainName, isConfigurationSupported);
|
buildRunnerHelper.greeting(CLEAN_BUILD, cfgName, toolchainName, isConfigurationSupported);
|
||||||
int status = sBuilder.build(stdout, stderr, new SubProgressMonitor(monitor, 1 * MONITOR_SCALE));
|
int status = sBuilder.build(stdout, stderr, new SubProgressMonitor(monitor, TICKS_EXECUTE_COMMAND));
|
||||||
buildRunnerHelper.close();
|
buildRunnerHelper.close();
|
||||||
buildRunnerHelper.goodbye();
|
buildRunnerHelper.goodbye();
|
||||||
|
|
||||||
if (status != ICommandLauncher.ILLEGAL_COMMAND) {
|
if (status != ICommandLauncher.ILLEGAL_COMMAND) {
|
||||||
buildRunnerHelper.refreshProject(monitor);
|
buildRunnerHelper.refreshProject(new SubProgressMonitor(monitor, TICKS_REFRESH_PROJECT));
|
||||||
}
|
}
|
||||||
|
|
||||||
//Throw a core exception indicating that the clean command failed
|
//Throw a core exception indicating that the clean command failed
|
||||||
|
@ -1272,7 +1277,7 @@ public class CommonBuilder extends ACBuilder {
|
||||||
if (monitor == null) {
|
if (monitor == null) {
|
||||||
monitor = new NullProgressMonitor();
|
monitor = new NullProgressMonitor();
|
||||||
}
|
}
|
||||||
monitor.beginTask("", 2 * MONITOR_SCALE); //$NON-NLS-1$
|
monitor.beginTask("", TICKS_STREAM_PROGRESS_MONITOR + TICKS_DELETE_OUTPUTS); //$NON-NLS-1$
|
||||||
|
|
||||||
// try the brute force approach first
|
// try the brute force approach first
|
||||||
String status = ManagedMakeMessages.getFormattedString("ManagedMakeBuilder.message.clean.deleting.output", buildDir.getName()); //$NON-NLS-1$
|
String status = ManagedMakeMessages.getFormattedString("ManagedMakeBuilder.message.clean.deleting.output", buildDir.getName()); //$NON-NLS-1$
|
||||||
|
@ -1284,14 +1289,14 @@ public class CommonBuilder extends ACBuilder {
|
||||||
URI workingDirectoryURI = ManagedBuildManager.getBuildLocationURI(configuration, builder);
|
URI workingDirectoryURI = ManagedBuildManager.getBuildLocationURI(configuration, builder);
|
||||||
ErrorParserManager epm = new ErrorParserManager(project, workingDirectoryURI, this, errorParsers);
|
ErrorParserManager epm = new ErrorParserManager(project, workingDirectoryURI, this, errorParsers);
|
||||||
|
|
||||||
buildRunnerHelper.prepareStreams(epm, null, console, new SubProgressMonitor(monitor, 1 * MONITOR_SCALE));
|
buildRunnerHelper.prepareStreams(epm, null, console, new SubProgressMonitor(monitor, TICKS_STREAM_PROGRESS_MONITOR));
|
||||||
|
|
||||||
String cfgName = configuration.getName();
|
String cfgName = configuration.getName();
|
||||||
String toolchainName = configuration.getToolChain().getName();
|
String toolchainName = configuration.getToolChain().getName();
|
||||||
boolean isConfigurationSupported = configuration.isSupported();
|
boolean isConfigurationSupported = configuration.isSupported();
|
||||||
|
|
||||||
buildRunnerHelper.greeting(CLEAN_BUILD, cfgName, toolchainName, isConfigurationSupported);
|
buildRunnerHelper.greeting(CLEAN_BUILD, cfgName, toolchainName, isConfigurationSupported);
|
||||||
workspace.delete(new IResource[]{buildDir}, true, new SubProgressMonitor(monitor, 1 * MONITOR_SCALE));
|
workspace.delete(new IResource[]{buildDir}, true, new SubProgressMonitor(monitor, TICKS_DELETE_OUTPUTS));
|
||||||
buildRunnerHelper.close();
|
buildRunnerHelper.close();
|
||||||
buildRunnerHelper.goodbye();
|
buildRunnerHelper.goodbye();
|
||||||
|
|
||||||
|
|
|
@ -309,7 +309,11 @@ 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;
|
|
||||||
|
private static final int PROGRESS_MONITOR_SCALE = 100;
|
||||||
|
private static final int TICKS_STREAM_PROGRESS_MONITOR = 1 * PROGRESS_MONITOR_SCALE;
|
||||||
|
private static final int TICKS_DELETE_MARKERS = 1 * PROGRESS_MONITOR_SCALE;
|
||||||
|
|
||||||
public static boolean VERBOSE = false;
|
public static boolean VERBOSE = false;
|
||||||
|
|
||||||
// Local variables
|
// Local variables
|
||||||
|
@ -1399,12 +1403,12 @@ public class GeneratedMakefileBuilder extends ACBuilder {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Map<IProject, List<IFile>> projectMap = arrangeFilesByProject(files);
|
Map<IProject, List<IFile>> projectMap = arrangeFilesByProject(files);
|
||||||
monitor.beginTask("", projectMap.size() * MONITOR_SCALE); //$NON-NLS-1$
|
monitor.beginTask("", projectMap.size() * PROGRESS_MONITOR_SCALE); //$NON-NLS-1$
|
||||||
|
|
||||||
for (List<IFile> filesInProject : projectMap.values()) {
|
for (List<IFile> filesInProject : projectMap.values()) {
|
||||||
IProject project = filesInProject.get(0).getProject();
|
IProject project = filesInProject.get(0).getProject();
|
||||||
monitor.subTask(ManagedMakeMessages.getFormattedString("GeneratedMakefileBuilder.buildingProject", project.getName())); //$NON-NLS-1$
|
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));
|
invokeInternalBuilderForOneProject(filesInProject, new SubProgressMonitor(monitor, 1 * PROGRESS_MONITOR_SCALE, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK));
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
if (monitor.isCanceled()) {
|
if (monitor.isCanceled()) {
|
||||||
|
@ -1420,7 +1424,8 @@ public class GeneratedMakefileBuilder extends ACBuilder {
|
||||||
BuildRunnerHelper buildRunnerHelper = new BuildRunnerHelper(project);
|
BuildRunnerHelper buildRunnerHelper = new BuildRunnerHelper(project);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
monitor.beginTask(ManagedMakeMessages.getFormattedString("GeneratedMakefileBuilder.buildingProject", project.getName()) + ':', files.size() * MONITOR_SCALE); //$NON-NLS-1$
|
monitor.beginTask(ManagedMakeMessages.getFormattedString("GeneratedMakefileBuilder.buildingProject", project.getName()) + ':', //$NON-NLS-1$
|
||||||
|
TICKS_STREAM_PROGRESS_MONITOR + files.size() * PROGRESS_MONITOR_SCALE);
|
||||||
|
|
||||||
// Get a build console for the project
|
// Get a build console for the project
|
||||||
console = CCorePlugin.getDefault().getConsole();
|
console = CCorePlugin.getDefault().getConsole();
|
||||||
|
@ -1438,7 +1443,7 @@ public class GeneratedMakefileBuilder extends ACBuilder {
|
||||||
String[] errorParsers = configuration.getErrorParserList();
|
String[] errorParsers = configuration.getErrorParserList();
|
||||||
ErrorParserManager epm = new ErrorParserManager(project, des.getDefaultBuildDirLocationURI(), this, errorParsers);
|
ErrorParserManager epm = new ErrorParserManager(project, des.getDefaultBuildDirLocationURI(), this, errorParsers);
|
||||||
|
|
||||||
buildRunnerHelper.prepareStreams(epm, null, console, new SubProgressMonitor(monitor, 1 * MONITOR_SCALE));
|
buildRunnerHelper.prepareStreams(epm, null, console, new SubProgressMonitor(monitor, TICKS_STREAM_PROGRESS_MONITOR));
|
||||||
OutputStream stdout = buildRunnerHelper.getOutputStream();
|
OutputStream stdout = buildRunnerHelper.getOutputStream();
|
||||||
OutputStream stderr = buildRunnerHelper.getErrorStream();
|
OutputStream stderr = buildRunnerHelper.getErrorStream();
|
||||||
|
|
||||||
|
@ -1462,13 +1467,13 @@ public class GeneratedMakefileBuilder extends ACBuilder {
|
||||||
dependentSteps.add(btype.getStep());
|
dependentSteps.add(btype.getStep());
|
||||||
}
|
}
|
||||||
|
|
||||||
SubProgressMonitor monitor2 = new SubProgressMonitor(monitor, 1 * MONITOR_SCALE, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK);
|
SubProgressMonitor monitor2 = new SubProgressMonitor(monitor, 1 * PROGRESS_MONITOR_SCALE, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK);
|
||||||
try {
|
try {
|
||||||
monitor2.beginTask("", (1 + dependentSteps.size()) * MONITOR_SCALE); //$NON-NLS-1$
|
monitor2.beginTask("", TICKS_DELETE_MARKERS + dependentSteps.size()*PROGRESS_MONITOR_SCALE); //$NON-NLS-1$
|
||||||
|
|
||||||
// Remove problem markers for the file
|
// Remove problem markers for the file
|
||||||
monitor2.subTask(ManagedMakeMessages.getFormattedString("GeneratedMakefileBuilder.removingResourceMarkers", filePath)); //$NON-NLS-1$
|
monitor2.subTask(ManagedMakeMessages.getFormattedString("GeneratedMakefileBuilder.removingResourceMarkers", filePath)); //$NON-NLS-1$
|
||||||
buildRunnerHelper.removeOldMarkers(file, new SubProgressMonitor(monitor2, 1 * MONITOR_SCALE, SubProgressMonitor.SUPPRESS_SUBTASK_LABEL));
|
buildRunnerHelper.removeOldMarkers(file, new SubProgressMonitor(monitor2, TICKS_DELETE_MARKERS, SubProgressMonitor.SUPPRESS_SUBTASK_LABEL));
|
||||||
|
|
||||||
// Build dependent steps
|
// Build dependent steps
|
||||||
for (IBuildStep step : dependentSteps) {
|
for (IBuildStep step : dependentSteps) {
|
||||||
|
@ -1478,7 +1483,7 @@ public class GeneratedMakefileBuilder extends ACBuilder {
|
||||||
|
|
||||||
monitor2.subTask(filePath);
|
monitor2.subTask(filePath);
|
||||||
StepBuilder stepBuilder = new StepBuilder(step, null);
|
StepBuilder stepBuilder = new StepBuilder(step, null);
|
||||||
stepBuilder.build(stdout, stderr, new SubProgressMonitor(monitor2, 1 * MONITOR_SCALE, SubProgressMonitor.SUPPRESS_SUBTASK_LABEL));
|
stepBuilder.build(stdout, stderr, new SubProgressMonitor(monitor2, 1 * PROGRESS_MONITOR_SCALE, SubProgressMonitor.SUPPRESS_SUBTASK_LABEL));
|
||||||
|
|
||||||
monitor2.subTask(ManagedMakeMessages.getFormattedString("GeneratedMakefileBuilder.refreshingArtifacts", filePath)); //$NON-NLS-1$
|
monitor2.subTask(ManagedMakeMessages.getFormattedString("GeneratedMakefileBuilder.refreshingArtifacts", filePath)); //$NON-NLS-1$
|
||||||
IBuildIOType[] outputIOTypes = step.getOutputIOTypes();
|
IBuildIOType[] outputIOTypes = step.getOutputIOTypes();
|
||||||
|
@ -1524,12 +1529,12 @@ public class GeneratedMakefileBuilder extends ACBuilder {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Map<IProject, List<IFile>> projectMap = arrangeFilesByProject(files);
|
Map<IProject, List<IFile>> projectMap = arrangeFilesByProject(files);
|
||||||
monitor.beginTask("", projectMap.size() * MONITOR_SCALE); //$NON-NLS-1$
|
monitor.beginTask("", projectMap.size() * PROGRESS_MONITOR_SCALE); //$NON-NLS-1$
|
||||||
|
|
||||||
for (List<IFile> filesInProject : projectMap.values()) {
|
for (List<IFile> filesInProject : projectMap.values()) {
|
||||||
IProject project = filesInProject.get(0).getProject();
|
IProject project = filesInProject.get(0).getProject();
|
||||||
monitor.subTask(ManagedMakeMessages.getFormattedString("GeneratedMakefileBuilder.cleaningProject", project.getName())); //$NON-NLS-1$
|
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));
|
cleanFilesForOneProject(filesInProject, new SubProgressMonitor(monitor, 1 * PROGRESS_MONITOR_SCALE, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK));
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
if (monitor.isCanceled()) {
|
if (monitor.isCanceled()) {
|
||||||
|
@ -1546,7 +1551,8 @@ public class GeneratedMakefileBuilder extends ACBuilder {
|
||||||
int countDeleted = 0;
|
int countDeleted = 0;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
monitor.beginTask(ManagedMakeMessages.getFormattedString("GeneratedMakefileBuilder.cleaningProject", project.getName()) + ':', files.size() * MONITOR_SCALE); //$NON-NLS-1$
|
monitor.beginTask(ManagedMakeMessages.getFormattedString("GeneratedMakefileBuilder.cleaningProject", project.getName()) + ':', //$NON-NLS-1$
|
||||||
|
TICKS_STREAM_PROGRESS_MONITOR + files.size() * PROGRESS_MONITOR_SCALE);
|
||||||
|
|
||||||
// Get a build console for the project
|
// Get a build console for the project
|
||||||
console = CCorePlugin.getDefault().getConsole();
|
console = CCorePlugin.getDefault().getConsole();
|
||||||
|
@ -1566,7 +1572,7 @@ public class GeneratedMakefileBuilder extends ACBuilder {
|
||||||
|
|
||||||
String[] errorParsers = configuration.getErrorParserList();
|
String[] errorParsers = configuration.getErrorParserList();
|
||||||
ErrorParserManager epm = new ErrorParserManager(project, des.getDefaultBuildDirLocationURI(), this, errorParsers);
|
ErrorParserManager epm = new ErrorParserManager(project, des.getDefaultBuildDirLocationURI(), this, errorParsers);
|
||||||
buildRunnerHelper.prepareStreams(epm, null , console, new SubProgressMonitor(monitor, 1 * MONITOR_SCALE));
|
buildRunnerHelper.prepareStreams(epm, null , console, new SubProgressMonitor(monitor, TICKS_STREAM_PROGRESS_MONITOR));
|
||||||
|
|
||||||
buildRunnerHelper.greeting(ManagedMakeMessages.getResourceString("CleanFilesAction.cleanSelectedFiles"), cfgName, toolchainName, isSupported); //$NON-NLS-1$
|
buildRunnerHelper.greeting(ManagedMakeMessages.getResourceString("CleanFilesAction.cleanSelectedFiles"), cfgName, toolchainName, isSupported); //$NON-NLS-1$
|
||||||
buildRunnerHelper.printLine(ManagedMakeMessages.getResourceString("ManagedMakeBuilder.message.internal.builder.header.note")); //$NON-NLS-1$
|
buildRunnerHelper.printLine(ManagedMakeMessages.getResourceString("ManagedMakeBuilder.message.internal.builder.header.note")); //$NON-NLS-1$
|
||||||
|
@ -1587,13 +1593,13 @@ public class GeneratedMakefileBuilder extends ACBuilder {
|
||||||
dependentSteps.add(btype.getStep());
|
dependentSteps.add(btype.getStep());
|
||||||
}
|
}
|
||||||
|
|
||||||
SubProgressMonitor monitor2 = new SubProgressMonitor(monitor, 1 * MONITOR_SCALE, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK);
|
SubProgressMonitor monitor2 = new SubProgressMonitor(monitor, 1 * PROGRESS_MONITOR_SCALE, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK);
|
||||||
try {
|
try {
|
||||||
monitor2.beginTask("", (1 + dependentSteps.size()) * MONITOR_SCALE); //$NON-NLS-1$
|
monitor2.beginTask("", TICKS_DELETE_MARKERS + dependentSteps.size()*PROGRESS_MONITOR_SCALE); //$NON-NLS-1$
|
||||||
|
|
||||||
// Remove problem markers for the file
|
// Remove problem markers for the file
|
||||||
monitor2.subTask(ManagedMakeMessages.getFormattedString("GeneratedMakefileBuilder.removingResourceMarkers", filePath)); //$NON-NLS-1$
|
monitor2.subTask(ManagedMakeMessages.getFormattedString("GeneratedMakefileBuilder.removingResourceMarkers", filePath)); //$NON-NLS-1$
|
||||||
buildRunnerHelper.removeOldMarkers(file, new SubProgressMonitor(monitor2, 1 * MONITOR_SCALE, SubProgressMonitor.SUPPRESS_SUBTASK_LABEL));
|
buildRunnerHelper.removeOldMarkers(file, new SubProgressMonitor(monitor2, TICKS_DELETE_MARKERS, SubProgressMonitor.SUPPRESS_SUBTASK_LABEL));
|
||||||
|
|
||||||
// iterate through all build steps
|
// iterate through all build steps
|
||||||
for (IBuildStep step : dependentSteps) {
|
for (IBuildStep step : dependentSteps) {
|
||||||
|
@ -1617,7 +1623,7 @@ public class GeneratedMakefileBuilder extends ACBuilder {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
monitor2.worked(1 * MONITOR_SCALE);
|
monitor2.worked(1 * PROGRESS_MONITOR_SCALE);
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
monitor2.done();
|
monitor2.done();
|
||||||
|
|
|
@ -20,7 +20,7 @@ import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public class StreamMonitor extends org.eclipse.cdt.internal.core.StreamMonitor {
|
public class StreamMonitor extends org.eclipse.cdt.internal.core.StreamProgressMonitor {
|
||||||
public StreamMonitor(IProgressMonitor mon, OutputStream cos, int totalWork) {
|
public StreamMonitor(IProgressMonitor mon, OutputStream cos, int totalWork) {
|
||||||
super(mon, cos, totalWork);
|
super(mon, cos, totalWork);
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,9 +27,12 @@ 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.IConsoleParser;
|
||||||
|
import org.eclipse.cdt.core.envvar.IEnvironmentVariable;
|
||||||
|
import org.eclipse.cdt.core.envvar.IEnvironmentVariableManager;
|
||||||
import org.eclipse.cdt.core.model.ICModelMarker;
|
import org.eclipse.cdt.core.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.resources.RefreshScopeManager;
|
||||||
|
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
|
||||||
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;
|
||||||
|
@ -44,7 +47,6 @@ import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
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.QualifiedName;
|
||||||
import org.eclipse.core.runtime.SubProgressMonitor;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper class attempting to unify interactions with build console,
|
* Helper class attempting to unify interactions with build console,
|
||||||
|
@ -55,13 +57,16 @@ import org.eclipse.core.runtime.SubProgressMonitor;
|
||||||
*/
|
*/
|
||||||
public class BuildRunnerHelper implements Closeable {
|
public class BuildRunnerHelper implements Closeable {
|
||||||
private static final String PROGRESS_MONITOR_QUALIFIER = CCorePlugin.PLUGIN_ID + ".progressMonitor"; //$NON-NLS-1$
|
private static final String PROGRESS_MONITOR_QUALIFIER = CCorePlugin.PLUGIN_ID + ".progressMonitor"; //$NON-NLS-1$
|
||||||
private static final int MONITOR_SCALE = 100;
|
private static final int PROGRESS_MONITOR_SCALE = 100;
|
||||||
|
private static final int TICKS_STREAM_PROGRESS_MONITOR = 1 * PROGRESS_MONITOR_SCALE;
|
||||||
|
private static final int TICKS_EXECUTE_PROGRAM = 1 * PROGRESS_MONITOR_SCALE;
|
||||||
|
private static final int TICKS_PARSE_OUTPUT = 1 * PROGRESS_MONITOR_SCALE;
|
||||||
|
|
||||||
private IProject project;
|
private IProject project;
|
||||||
|
|
||||||
private IConsole console = null;
|
private IConsole console = null;
|
||||||
private ErrorParserManager errorParserManager = null;
|
private ErrorParserManager errorParserManager = null;
|
||||||
private StreamMonitor streamMon = null;
|
private StreamProgressMonitor streamProgressMonitor = null;
|
||||||
private OutputStream stdout = null;
|
private OutputStream stdout = null;
|
||||||
private OutputStream stderr = null;
|
private OutputStream stderr = null;
|
||||||
private OutputStream consoleOut = null;
|
private OutputStream consoleOut = null;
|
||||||
|
@ -145,16 +150,16 @@ public class BuildRunnerHelper implements Closeable {
|
||||||
}
|
}
|
||||||
|
|
||||||
Integer lastWork = null;
|
Integer lastWork = null;
|
||||||
if (buildCommand != null) {
|
if (buildCommand != null && project != null) {
|
||||||
progressPropertyName = getProgressPropertyName(buildCommand, args);
|
progressPropertyName = getProgressPropertyName(buildCommand, args);
|
||||||
lastWork = (Integer)project.getSessionProperty(progressPropertyName);
|
lastWork = (Integer)project.getSessionProperty(progressPropertyName);
|
||||||
}
|
}
|
||||||
if (lastWork == null) {
|
if (lastWork == null) {
|
||||||
lastWork = MONITOR_SCALE;
|
lastWork = TICKS_STREAM_PROGRESS_MONITOR;
|
||||||
}
|
}
|
||||||
|
|
||||||
streamMon = new StreamMonitor(monitor, null, lastWork.intValue());
|
streamProgressMonitor = new StreamProgressMonitor(monitor, null, lastWork.intValue());
|
||||||
ConsoleOutputSniffer sniffer = new ConsoleOutputSniffer(streamMon, streamMon, parsers.toArray(new IConsoleParser[parsers.size()]));
|
ConsoleOutputSniffer sniffer = new ConsoleOutputSniffer(streamProgressMonitor, streamProgressMonitor, parsers.toArray(new IConsoleParser[parsers.size()]));
|
||||||
stdout = sniffer.getOutputStream();
|
stdout = sniffer.getOutputStream();
|
||||||
stderr = sniffer.getErrorStream();
|
stderr = sniffer.getErrorStream();
|
||||||
}
|
}
|
||||||
|
@ -187,8 +192,10 @@ public class BuildRunnerHelper implements Closeable {
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
monitor.beginTask("", IProgressMonitor.UNKNOWN); //$NON-NLS-1$
|
monitor.beginTask("", IProgressMonitor.UNKNOWN); //$NON-NLS-1$
|
||||||
|
if (rc != null) {
|
||||||
monitor.subTask(CCorePlugin.getFormattedString("BuildRunnerHelper.removingMarkers", rc.getFullPath().toString())); //$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);
|
rc.deleteMarkers(ICModelMarker.C_MODEL_PROBLEM_MARKER, false, IResource.DEPTH_INFINITE);
|
||||||
|
}
|
||||||
} finally {
|
} finally {
|
||||||
monitor.done();
|
monitor.done();
|
||||||
}
|
}
|
||||||
|
@ -212,10 +219,13 @@ public class BuildRunnerHelper implements Closeable {
|
||||||
monitor = new NullProgressMonitor();
|
monitor = new NullProgressMonitor();
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
monitor.beginTask("", 2 * MONITOR_SCALE); //$NON-NLS-1$
|
monitor.beginTask("", TICKS_EXECUTE_PROGRAM + TICKS_PARSE_OUTPUT); //$NON-NLS-1$
|
||||||
|
|
||||||
isCancelled = false;
|
isCancelled = false;
|
||||||
String pathFromURI = EFSExtensionManager.getDefault().getPathFromURI(workingDirectoryURI);
|
String pathFromURI = null;
|
||||||
|
if (workingDirectoryURI != null) {
|
||||||
|
pathFromURI = EFSExtensionManager.getDefault().getPathFromURI(workingDirectoryURI);
|
||||||
|
}
|
||||||
if(pathFromURI == null) {
|
if(pathFromURI == null) {
|
||||||
// fallback to CWD
|
// fallback to CWD
|
||||||
pathFromURI = System.getProperty("user.dir"); //$NON-NLS-1$
|
pathFromURI = System.getProperty("user.dir"); //$NON-NLS-1$
|
||||||
|
@ -223,7 +233,9 @@ public class BuildRunnerHelper implements Closeable {
|
||||||
IPath workingDirectory = new Path(pathFromURI);
|
IPath workingDirectory = new Path(pathFromURI);
|
||||||
|
|
||||||
String errMsg = null;
|
String errMsg = null;
|
||||||
|
monitor.subTask(CCorePlugin.getFormattedString("BuildRunnerHelper.invokingCommand", launcher.getCommandLine())); //$NON-NLS-1$
|
||||||
Process p = launcher.execute(buildCommand, args, envp, workingDirectory, monitor);
|
Process p = launcher.execute(buildCommand, args, envp, workingDirectory, monitor);
|
||||||
|
monitor.worked(TICKS_EXECUTE_PROGRAM);
|
||||||
if (p != null) {
|
if (p != null) {
|
||||||
try {
|
try {
|
||||||
// Close the input of the Process explicitly.
|
// Close the input of the Process explicitly.
|
||||||
|
@ -231,10 +243,9 @@ public class BuildRunnerHelper implements Closeable {
|
||||||
p.getOutputStream().close();
|
p.getOutputStream().close();
|
||||||
} catch (IOException e) {
|
} 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));
|
status = launcher.waitAndRead(stdout, stderr, monitor);
|
||||||
|
monitor.worked(TICKS_PARSE_OUTPUT);
|
||||||
if (status != ICommandLauncher.OK) {
|
if (status != ICommandLauncher.OK) {
|
||||||
errMsg = launcher.getErrorMessage();
|
errMsg = launcher.getErrorMessage();
|
||||||
}
|
}
|
||||||
|
@ -247,8 +258,8 @@ public class BuildRunnerHelper implements Closeable {
|
||||||
}
|
}
|
||||||
|
|
||||||
isCancelled = monitor.isCanceled();
|
isCancelled = monitor.isCanceled();
|
||||||
if (!isCancelled) {
|
if (!isCancelled && project != null) {
|
||||||
project.setSessionProperty(progressPropertyName, new Integer(streamMon.getWorkDone()));
|
project.setSessionProperty(progressPropertyName, new Integer(streamProgressMonitor.getWorkDone()));
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
monitor.done();
|
monitor.done();
|
||||||
|
@ -270,23 +281,36 @@ public class BuildRunnerHelper implements Closeable {
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
CCorePlugin.log(e);
|
CCorePlugin.log(e);
|
||||||
} finally {
|
} finally {
|
||||||
|
stdout = null;
|
||||||
try {
|
try {
|
||||||
if (stderr != null)
|
if (stderr != null)
|
||||||
stderr.close();
|
stderr.close();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
CCorePlugin.log(e);
|
CCorePlugin.log(e);
|
||||||
} finally {
|
} finally {
|
||||||
|
stderr = null;
|
||||||
try {
|
try {
|
||||||
if (streamMon != null)
|
if (streamProgressMonitor != null)
|
||||||
streamMon.close();
|
streamProgressMonitor.close();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
CCorePlugin.log(e);
|
CCorePlugin.log(e);
|
||||||
} finally {
|
} finally {
|
||||||
|
streamProgressMonitor = null;
|
||||||
try {
|
try {
|
||||||
if (consoleOut != null)
|
if (consoleOut != null)
|
||||||
consoleOut.close();
|
consoleOut.close();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
CCorePlugin.log(e);
|
CCorePlugin.log(e);
|
||||||
|
} finally {
|
||||||
|
consoleOut = null;
|
||||||
|
try {
|
||||||
|
if (consoleInfo != null)
|
||||||
|
consoleInfo.close();
|
||||||
|
} catch (Exception e) {
|
||||||
|
CCorePlugin.log(e);
|
||||||
|
} finally {
|
||||||
|
consoleInfo = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -375,6 +399,13 @@ public class BuildRunnerHelper implements Closeable {
|
||||||
*/
|
*/
|
||||||
public void greeting(String msg) {
|
public void greeting(String msg) {
|
||||||
startTime = System.currentTimeMillis();
|
startTime = System.currentTimeMillis();
|
||||||
|
if (consoleInfo == null) {
|
||||||
|
try {
|
||||||
|
consoleInfo = console.getInfoStream();
|
||||||
|
} catch (CoreException e) {
|
||||||
|
CCorePlugin.log(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
toConsole(BuildRunnerHelper.timestamp(startTime) + "**** " + msg + " ****"); //$NON-NLS-1$ //$NON-NLS-2$
|
toConsole(BuildRunnerHelper.timestamp(startTime) + "**** " + msg + " ****"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -393,7 +424,20 @@ public class BuildRunnerHelper implements Closeable {
|
||||||
String msg = isCancelled ? CCorePlugin.getFormattedString("BuildRunnerHelper.buildCancelled", duration) //$NON-NLS-1$
|
String msg = isCancelled ? CCorePlugin.getFormattedString("BuildRunnerHelper.buildCancelled", duration) //$NON-NLS-1$
|
||||||
: CCorePlugin.getFormattedString("BuildRunnerHelper.buildFinished", duration); //$NON-NLS-1$
|
: CCorePlugin.getFormattedString("BuildRunnerHelper.buildFinished", duration); //$NON-NLS-1$
|
||||||
String goodbye = '\n' + timestamp(endTime) + msg + '\n';
|
String goodbye = '\n' + timestamp(endTime) + msg + '\n';
|
||||||
|
|
||||||
|
if (consoleInfo != null) {
|
||||||
toConsole(goodbye);
|
toConsole(goodbye);
|
||||||
|
} else {
|
||||||
|
// in current flow goodbye() can be called after close()
|
||||||
|
try {
|
||||||
|
consoleInfo = console.getInfoStream();
|
||||||
|
toConsole(goodbye);
|
||||||
|
consoleInfo.close();
|
||||||
|
consoleInfo = null;
|
||||||
|
} catch (Exception e) {
|
||||||
|
CCorePlugin.log(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -413,9 +457,6 @@ public class BuildRunnerHelper implements Closeable {
|
||||||
private void toConsole(String msg) {
|
private void toConsole(String msg) {
|
||||||
Assert.isNotNull(console, "Streams must be created and connected before calling this method"); //$NON-NLS-1$
|
Assert.isNotNull(console, "Streams must be created and connected before calling this method"); //$NON-NLS-1$
|
||||||
try {
|
try {
|
||||||
if (consoleInfo == null) {
|
|
||||||
consoleInfo = console.getInfoStream();
|
|
||||||
}
|
|
||||||
consoleInfo.write((msg+"\n").getBytes()); //$NON-NLS-1$
|
consoleInfo.write((msg+"\n").getBytes()); //$NON-NLS-1$
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
CCorePlugin.log(e);
|
CCorePlugin.log(e);
|
||||||
|
@ -426,7 +467,7 @@ public class BuildRunnerHelper implements Closeable {
|
||||||
* Qualified name to keep previous value of build duration in project session properties.
|
* Qualified name to keep previous value of build duration in project session properties.
|
||||||
*/
|
*/
|
||||||
private static QualifiedName getProgressPropertyName(IPath buildCommand, String[] args) {
|
private static QualifiedName getProgressPropertyName(IPath buildCommand, String[] args) {
|
||||||
String name = buildCommand.toString();
|
String name = "buildCommand." + buildCommand.toString(); //$NON-NLS-1$
|
||||||
if (args != null) {
|
if (args != null) {
|
||||||
for (String arg : args) {
|
for (String arg : args) {
|
||||||
name = name + ' ' + arg;
|
name = name + ' ' + arg;
|
||||||
|
@ -436,19 +477,36 @@ public class BuildRunnerHelper implements Closeable {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert map of environment variables to array of "var=value"
|
* Get environment variables from configuration as array of "var=value" suitable
|
||||||
|
* for using as "envp" with Runtime.exec(String[] cmdarray, String[] envp, File dir)
|
||||||
*
|
*
|
||||||
* @param envMap - map of environment variables
|
* @param envMap - map of environment variables
|
||||||
* @return String array of environment variables in format "var=value" suitable for using
|
* @return String array of environment variables in format "var=value"
|
||||||
* as "envp" with Runtime.exec(String[] cmdarray, String[] envp, File dir)
|
|
||||||
*/
|
*/
|
||||||
public static String[] envMapToEnvp(Map<String, String> envMap) {
|
public static String[] envMapToEnvp(Map<String, String> envMap) {
|
||||||
// Convert into env strings
|
// Convert into envp strings
|
||||||
List<String> strings= new ArrayList<String>(envMap.size());
|
List<String> strings = new ArrayList<String>(envMap.size());
|
||||||
for (Entry<String, String> entry : envMap.entrySet()) {
|
for (Entry<String, String> entry : envMap.entrySet()) {
|
||||||
StringBuffer buffer= new StringBuffer(entry.getKey());
|
strings.add(entry.getKey() + '=' + entry.getValue());
|
||||||
buffer.append('=').append(entry.getValue());
|
}
|
||||||
strings.add(buffer.toString());
|
|
||||||
|
return strings.toArray(new String[strings.size()]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get environment variables from configuration as array of "var=value" suitable
|
||||||
|
* for using as "envp" with Runtime.exec(String[] cmdarray, String[] envp, File dir)
|
||||||
|
*
|
||||||
|
* @param cfgDescription - configuration description
|
||||||
|
* @return String array of environment variables in format "var=value"
|
||||||
|
*/
|
||||||
|
public static String[] getEnvp(ICConfigurationDescription cfgDescription) {
|
||||||
|
IEnvironmentVariableManager mngr = CCorePlugin.getDefault().getBuildEnvironmentManager();
|
||||||
|
IEnvironmentVariable[] vars = mngr.getVariables(cfgDescription, true);
|
||||||
|
// Convert into envp strings
|
||||||
|
List<String> strings = new ArrayList<String>(vars.length);
|
||||||
|
for (IEnvironmentVariable var : vars) {
|
||||||
|
strings.add(var.getName() + '=' + var.getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
return strings.toArray(new String[strings.size()]);
|
return strings.toArray(new String[strings.size()]);
|
||||||
|
|
|
@ -13,6 +13,7 @@ package org.eclipse.cdt.internal.core;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
import org.eclipse.cdt.core.IConsoleParser;
|
import org.eclipse.cdt.core.IConsoleParser;
|
||||||
|
|
||||||
|
|
||||||
|
@ -155,7 +156,12 @@ public class ConsoleOutputSniffer {
|
||||||
public synchronized void closeConsoleOutputStream() throws IOException {
|
public synchronized void closeConsoleOutputStream() throws IOException {
|
||||||
if (nOpens > 0 && --nOpens == 0) {
|
if (nOpens > 0 && --nOpens == 0) {
|
||||||
for (int i = 0; i < parsers.length; ++i) {
|
for (int i = 0; i < parsers.length; ++i) {
|
||||||
|
try {
|
||||||
parsers[i].shutdown();
|
parsers[i].shutdown();
|
||||||
|
} catch (Throwable e) {
|
||||||
|
// Report exception if any but let all the parsers a chance to shutdown.
|
||||||
|
CCorePlugin.log(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -166,8 +172,13 @@ public class ConsoleOutputSniffer {
|
||||||
* @param line
|
* @param line
|
||||||
*/
|
*/
|
||||||
private synchronized void processLine(String line) {
|
private synchronized void processLine(String line) {
|
||||||
for (int i = 0; i < parsers.length; ++i) {
|
for (IConsoleParser parser : parsers) {
|
||||||
parsers[i].processLine(line);
|
try {
|
||||||
|
// Report exception if any but let all the parsers a chance to process the line.
|
||||||
|
parser.processLine(line);
|
||||||
|
} catch (Throwable e) {
|
||||||
|
CCorePlugin.log(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,7 @@ import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
/**
|
/**
|
||||||
* Helper class to report progress of the build via {@link IProgressMonitor}
|
* Helper class to report progress of the build via {@link IProgressMonitor}
|
||||||
*/
|
*/
|
||||||
public class StreamMonitor extends OutputStream {
|
public class StreamProgressMonitor extends OutputStream {
|
||||||
|
|
||||||
private IProgressMonitor monitor;
|
private IProgressMonitor monitor;
|
||||||
private OutputStream console;
|
private OutputStream console;
|
||||||
|
@ -28,7 +28,7 @@ public class StreamMonitor extends OutputStream {
|
||||||
private int nextProgress = currentIncrement;
|
private int nextProgress = currentIncrement;
|
||||||
private int worked = 0;
|
private int worked = 0;
|
||||||
|
|
||||||
public StreamMonitor(IProgressMonitor mon, OutputStream cos, int totalWork) {
|
public StreamProgressMonitor(IProgressMonitor mon, OutputStream cos, int totalWork) {
|
||||||
monitor = mon;
|
monitor = mon;
|
||||||
console = cos;
|
console = cos;
|
||||||
fTotalWork = totalWork;
|
fTotalWork = totalWork;
|
Loading…
Add table
Reference in a new issue