diff options
author | Andrew Gvozdev | 2012-03-22 03:59:54 +0000 |
---|---|---|
committer | Andrew Gvozdev | 2012-03-22 04:03:36 +0000 |
commit | f9f991fa3fa8bd4b50b626c571820d166614833e (patch) | |
tree | 00c9b43c612c0715de3993f70f0f92b08d5d20b6 /build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal | |
parent | 2789b67a23b425dec4fe00fc90058ac5be727cce (diff) | |
download | org.eclipse.cdt-f9f991fa3fa8bd4b50b626c571820d166614833e.tar.gz org.eclipse.cdt-f9f991fa3fa8bd4b50b626c571820d166614833e.tar.xz org.eclipse.cdt-f9f991fa3fa8bd4b50b626c571820d166614833e.zip |
bug 71511: [Error Parser] Interleaved stdout and stderr output causes
spurious error task markers
Diffstat (limited to 'build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal')
5 files changed, 152 insertions, 237 deletions
diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/MakeMessages.properties b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/MakeMessages.properties index 7509f90aa47..5673ce0ea8e 100644 --- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/MakeMessages.properties +++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/MakeMessages.properties @@ -14,10 +14,8 @@ AbstractGCCBOPConsoleParser_EnteringDirectory=Entering directory AbstractGCCBOPConsoleParser_LeavingDirectory=Leaving directory MakeBuilder.Invoking_Make_Builder=Invoking Make Builder... -MakeBuilder.Invoking_Command=Invoking Command: -MakeBuilder.Updating_project=Updating project... -MakeBuilder.Creating_Markers=Generating markers... -MakeBuilder.ErrorWorkingDirectory=Error determining working directory. +MakeBuilder.message.error.build = Internal error building project {0} +MakeBuilder.message.undefined.build.command = Build command is null for project {0} BuildInfoFactory.Missing_Builder=Missing Builder: @@ -37,12 +35,7 @@ ScannerConfigInfoFactory.Missing_Builder=Missing Builder: ExternalScannerInfoProvider.Console_Name=CDT Built-in Specs Console, {0} ExternalScannerInfoProvider.Reading_Specs=Reading specs ... -ExternalScannerInfoProvider.Invoking_Command=Invoking Command: -ExternalScannerInfoProvider.Parsing_Output=Parsing output ... -ExternalScannerInfoProvider.Creating_Markers=Generating markers ... -ExternalScannerInfoProvider.Provider_Error=Warning: Error launching external scanner info generator ({0}) -ExternalScannerInfoProvider.Working_Directory=Working directory: {0} -ExternalScannerInfoProvider.Program_Not_In_Path=Program ''{0}'' is not found in $PATH +ExternalScannerInfoProvider.Greeting=Scanner Discovery of compiler built-in settings for project {0} ScannerInfoCollector.Processing=Processing discovered scanner configuration ... ScannerInfoCollector.Updating=Updating Scanner Configuration for project diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/StreamMonitor.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/StreamMonitor.java index ef7363695bb..dde487ec6b9 100644 --- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/StreamMonitor.java +++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/StreamMonitor.java @@ -10,97 +10,18 @@ *******************************************************************************/ package org.eclipse.cdt.make.internal.core; -import java.io.IOException; import java.io.OutputStream; import org.eclipse.core.runtime.IProgressMonitor; -public class StreamMonitor extends OutputStream { - - IProgressMonitor monitor; - OutputStream console; - public final int fTotalWork; - private int halfWay; - private int currentIncrement = 2; - private int nextProgress = currentIncrement; - private int worked = 0; - +/** + * + * @deprecated as of CDT 8.1. Use org.eclipse.cdt.internal.core.StreamMonitor + * + */ +@Deprecated +public class StreamMonitor extends org.eclipse.cdt.internal.core.StreamMonitor { public StreamMonitor(IProgressMonitor mon, OutputStream cos, int totalWork) { - monitor = mon; - console = cos; - fTotalWork = totalWork; - halfWay = fTotalWork / 2; - monitor.beginTask("", fTotalWork); //$NON-NLS-1$ - } - - private void progressUpdate() { - if (--nextProgress <= 0) { - //we have exhausted the current increment, so report progress - if (fTotalWork > worked) { - monitor.worked(1); - } - worked++; - if (worked >= halfWay) { - //we have passed the current halfway point, so double the - //increment and reset the halfway point. - currentIncrement *= 2; - halfWay += (fTotalWork - halfWay) / 2; - } - //reset the progress counter to another full increment - nextProgress = currentIncrement; - } - } - /** - * @see java.io.OutputStream#close() - */ - @Override - public void close() throws IOException { - if (console != null) { - console.close(); - } - monitor.done(); - } - - /** - * @see java.io.OutputStream#flush() - */ - @Override - public void flush() throws IOException { - if (console != null) { - console.flush(); - } - } - - /** - * @see java.io.OutputStream#write(int) - */ - @Override - public synchronized void write(int b) throws IOException { - if (console != null) { - console.write(b); - } - progressUpdate(); - } - - /** - * @see java.io.OutputStream#write(byte[], int, int) - */ - @Override - public synchronized void write(byte[] b, int off, int len) throws IOException { - if (b == null) { - throw new NullPointerException(); - } else if (off != 0 || (len < 0) || (len > b.length)) { - throw new IndexOutOfBoundsException(); - } else if (len == 0) { - return; - } - if (console != null) { - console.write(b, off, len); - } - progressUpdate(); - } - - public int getWorkDone() { - return worked; + super(mon, cos, totalWork); } } diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/ScannerInfoConsoleParserFactory.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/ScannerInfoConsoleParserFactory.java index 0bd3ebaf6b6..f1f2b9ddd4e 100644 --- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/ScannerInfoConsoleParserFactory.java +++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/ScannerInfoConsoleParserFactory.java @@ -4,7 +4,7 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html - * + * * Contributors: * IBM - Initial API and implementation * Tianchao Li (tianchao.li@gmail.com) - arbitrary build directory (bug #136136) @@ -12,6 +12,7 @@ package org.eclipse.cdt.make.internal.core.scannerconfig; import java.io.OutputStream; +import java.net.URI; import org.eclipse.cdt.core.IMarkerGenerator; import org.eclipse.cdt.internal.core.ConsoleOutputSniffer; @@ -23,15 +24,18 @@ import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector; import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoConsoleParser; import org.eclipse.cdt.make.core.scannerconfig.InfoContext; import org.eclipse.cdt.make.internal.core.scannerconfig2.SCProfileInstance; +import org.eclipse.cdt.make.internal.core.scannerconfig2.ScannerConfigProfile; import org.eclipse.cdt.make.internal.core.scannerconfig2.ScannerConfigProfileManager; +import org.eclipse.cdt.utils.EFSExtensionManager; import org.eclipse.core.resources.IProject; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.Path; /** * A factory that creates a ConsoleOutputStreamSniffer, * ScannerInfoConsoleParser and optionally a ScannerInfoConsoleParserUtility. - * + * * @author vhirsl */ public class ScannerInfoConsoleParserFactory { @@ -64,14 +68,14 @@ public class ScannerInfoConsoleParserFactory { IScannerInfoCollector collector, IMarkerGenerator markerGenerator) { if (scBuildInfo.isProviderOutputParserEnabled(providerId)) { - // get the ESIProvider console parser + // get the ESIProvider console parser SCProfileInstance profileInstance = ScannerConfigProfileManager.getInstance(). getSCProfileInstance(currentProject, context, scBuildInfo.getSelectedProfileId()); IScannerInfoConsoleParser clParser = profileInstance.createExternalScannerInfoParser(providerId); IPath buildDirectory = MakeBuilderUtil.getBuildDirectory(currentProject, MakeBuilder.BUILDER_ID); clParser.startup(currentProject, buildDirectory, collector, markerGenerator); // create an output stream sniffer - return new ConsoleOutputSniffer(outputStream, errorStream, new + return new ConsoleOutputSniffer(outputStream, errorStream, new IScannerInfoConsoleParser[] {clParser}); } return null; @@ -86,9 +90,9 @@ public class ScannerInfoConsoleParserFactory { OutputStream errorStream, IProject currentProject, IPath workingDirectory, - IScannerConfigBuilderInfo2 scBuildInfo, + IScannerConfigBuilderInfo2 scBuildInfo, IMarkerGenerator markerGenerator, - IScannerInfoCollector collector) { + IScannerInfoCollector collector) { return getMakeBuilderOutputSniffer(outputStream, errorStream, currentProject, new InfoContext(currentProject), workingDirectory, scBuildInfo, markerGenerator, collector); } @@ -99,48 +103,90 @@ public class ScannerInfoConsoleParserFactory { public static ConsoleOutputSniffer getMakeBuilderOutputSniffer( OutputStream outputStream, OutputStream errorStream, - IProject currentProject, - InfoContext context, + IProject project, + InfoContext infoContext, IPath workingDirectory, - IScannerConfigBuilderInfo2 scBuildInfo, + IScannerConfigBuilderInfo2 info2, IMarkerGenerator markerGenerator, - IScannerInfoCollector collector) { + IScannerInfoCollector collector) { + + IScannerInfoConsoleParser parser = getScannerInfoConsoleParserInternal(project, infoContext, workingDirectory, info2, markerGenerator, collector); + if (parser != null) { + // create an output stream sniffer + return new ConsoleOutputSniffer(outputStream, errorStream, new IScannerInfoConsoleParser[] {parser}); + + } + return null; + } + + private static IScannerInfoConsoleParser getScannerInfoConsoleParserInternal(IProject project, InfoContext infoContext, IPath workingDirectory, + IScannerConfigBuilderInfo2 info2, IMarkerGenerator markerGenerator, IScannerInfoCollector collector) { + + IScannerInfoConsoleParser parser = null; // try { // get the SC builder settings /*if (currentProject.hasNature(ScannerConfigNature.NATURE_ID))*/ { - if (scBuildInfo == null) { - try { - IScannerConfigBuilderInfo2Set container = ScannerConfigProfileManager. - createScannerConfigBuildInfo2Set(currentProject); - scBuildInfo = container.getInfo(context); - } - catch (CoreException e) { - // builder not installed or disabled - } - } - if (scBuildInfo != null && - scBuildInfo.isAutoDiscoveryEnabled() && - scBuildInfo.isBuildOutputParserEnabled()) { - // get the make builder console parser - SCProfileInstance profileInstance = ScannerConfigProfileManager.getInstance(). - getSCProfileInstance(currentProject, context, scBuildInfo.getSelectedProfileId()); - IScannerInfoConsoleParser clParser = profileInstance.createBuildOutputParser(); - if (collector == null) { - collector = profileInstance.getScannerInfoCollector(); - } - if(clParser != null){ - clParser.startup(currentProject, workingDirectory, collector, - scBuildInfo.isProblemReportingEnabled() ? markerGenerator : null); - // create an output stream sniffer - return new ConsoleOutputSniffer(outputStream, errorStream, new - IScannerInfoConsoleParser[] {clParser}); - } + if (info2 == null) { + try { + IScannerConfigBuilderInfo2Set container = ScannerConfigProfileManager.createScannerConfigBuildInfo2Set(project); + info2 = container.getInfo(infoContext); + } catch (CoreException e) { + // builder not installed or disabled + } + } + if (info2 != null && info2.isAutoDiscoveryEnabled() && info2.isBuildOutputParserEnabled()) { + String id = info2.getSelectedProfileId(); + + // get the make builder console parser + SCProfileInstance profileInstance = ScannerConfigProfileManager.getInstance().getSCProfileInstance(project, infoContext, id); + parser = profileInstance.createBuildOutputParser(); + if (parser != null){ + if (collector == null) { + collector = profileInstance.getScannerInfoCollector(); + } + parser.startup(project, workingDirectory, collector, info2.isProblemReportingEnabled() ? markerGenerator : null); + } } } -// } +// } // catch (CoreException e) { // MakeCorePlugin.log(e.getStatus()); // } - return null; + + return parser; + } + + public static IScannerInfoConsoleParser getScannerInfoConsoleParser(IProject project, URI workingDirectoryURI, IMarkerGenerator markerGenerator) { + String pathFromURI = EFSExtensionManager.getDefault().getPathFromURI(workingDirectoryURI); + if(pathFromURI == null) { + // fallback to CWD + pathFromURI = System.getProperty("user.dir"); //$NON-NLS-1$ + } + return getScannerInfoConsoleParserInternal(project, new InfoContext(project), new Path(pathFromURI), null, markerGenerator, null); + } + + // TODO - perhaps this be unified with the other one? + public static IScannerInfoConsoleParser getScannerInfoConsoleParser(IProject project, InfoContext infoContext, IPath workingDirectory, + IScannerConfigBuilderInfo2 info2, IMarkerGenerator markerGenerator, IScannerInfoCollector collector) { + + IScannerInfoConsoleParser parser = null; + if (info2 != null && info2.isAutoDiscoveryEnabled() && info2.isBuildOutputParserEnabled()) { + String id = info2.getSelectedProfileId(); + ScannerConfigProfile profile = ScannerConfigProfileManager.getInstance().getSCProfileConfiguration(id); + if(profile.getBuildOutputProviderElement() != null){ + // get the make builder console parser + SCProfileInstance profileInstance = ScannerConfigProfileManager.getInstance().getSCProfileInstance(project, infoContext, id); + parser = profileInstance.createBuildOutputParser(); + if(parser != null){ + if (collector == null) { + collector = profileInstance.getScannerInfoCollector(); + } + parser.startup(project, workingDirectory, collector, info2.isProblemReportingEnabled() ? markerGenerator : null); + } + + } + } + + return parser; } } diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/gnu/GCCSpecsConsoleParser.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/gnu/GCCSpecsConsoleParser.java index bd42c16fd97..30ea92422bf 100644 --- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/gnu/GCCSpecsConsoleParser.java +++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/gnu/GCCSpecsConsoleParser.java @@ -44,10 +44,7 @@ public class GCCSpecsConsoleParser implements IScannerInfoConsoleParser { protected List<String> symbols = new ArrayList<String>(); protected List<String> includes = new ArrayList<String>(); - /* (non-Javadoc) - * @see org.eclipse.cdt.make.core.scannerconfig.IScannerInfoConsoleParser#startup(org.eclipse.core.resources.IProject, org.eclipse.core.runtime.IPath, org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector, org.eclipse.cdt.core.IMarkerGenerator) - */ - @Override + @Override public void startup(IProject project, IPath workingDirectory, IScannerInfoCollector collector, IMarkerGenerator markerGenerator) { this.fProject = project; this.fCollector = collector; @@ -58,21 +55,24 @@ public class GCCSpecsConsoleParser implements IScannerInfoConsoleParser { */ @Override public boolean processLine(String line) { - boolean rc = false; - line= line.trim(); TraceUtil.outputTrace("GCCSpecsConsoleParser parsing line: [", line, "]"); //$NON-NLS-1$ //$NON-NLS-2$ + line= line.trim(); + if (line.length() == 0) { + return false; + } + // contribution of -dD option if (line.startsWith(DEFINE)) { String[] defineParts = line.split("\\s+", 3); //$NON-NLS-1$ if (defineParts[0].equals(DEFINE)) { - if (defineParts[1].indexOf('(') >= 0) { - // #define __X__(P1, P2) __Y__(P1, P2) - // Enclose matching parentheses pairs - // in the macro name if they are present - int i = line.indexOf(')'); // macro definition itself can have only one pair of brackets + if (defineParts[1].indexOf('(') >= 0) { + // #define __X__(P1, P2) __Y__(P1, P2) + // Enclose matching parentheses pairs + // in the macro name if they are present + int i = line.indexOf(')'); // macro definition itself can have only one pair of brackets - // i now marks the space between the name and definition + // i now marks the space between the name and definition if (i > 0) { int start = line.indexOf(defineParts[1]); // start of definition defineParts[1] = line.substring(start, i + 1); @@ -82,18 +82,18 @@ public class GCCSpecsConsoleParser implements IScannerInfoConsoleParser { } else { MakeCorePlugin.log(new Exception("GCCSpecsConsoleParser ERROR: Unmatched brackets: ["+ line+ "]")); //$NON-NLS-1$ //$NON-NLS-2$ } - } + } - // Now defineParts[1] is the symbol name, and [2] is the definition - String symbol = null; - if (defineParts.length > 1) { - symbol = defineParts[1] + "="; //$NON-NLS-1$ - if (defineParts.length > 2) { - symbol += defineParts[2]; - } - if (!symbols.contains(symbol)) { - symbols.add(symbol); - } + // Now defineParts[1] is the symbol name, and [2] is the definition + String symbol = null; + if (defineParts.length > 1) { + symbol = defineParts[1] + "="; //$NON-NLS-1$ + if (defineParts.length > 2) { + symbol += defineParts[2]; + } + if (!symbols.contains(symbol)) { + symbols.add(symbol); + } } } } @@ -109,7 +109,7 @@ public class GCCSpecsConsoleParser implements IScannerInfoConsoleParser { includes.add(line); } - return rc; + return false; } /* (non-Javadoc) diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/DefaultRunSIProvider.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/DefaultRunSIProvider.java index 19123121aa0..a88e64bb236 100644 --- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/DefaultRunSIProvider.java +++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/DefaultRunSIProvider.java @@ -12,7 +12,6 @@ package org.eclipse.cdt.make.internal.core.scannerconfig2; import java.io.IOException; -import java.io.OutputStream; import java.net.URI; import java.util.ArrayList; import java.util.Enumeration; @@ -24,7 +23,7 @@ import org.eclipse.cdt.core.ErrorParserManager; import org.eclipse.cdt.core.ICommandLauncher; import org.eclipse.cdt.core.model.ILanguage; import org.eclipse.cdt.core.resources.IConsole; -import org.eclipse.cdt.internal.core.ConsoleOutputSniffer; +import org.eclipse.cdt.internal.core.BuildRunnerHelper; import org.eclipse.cdt.make.core.MakeBuilder; import org.eclipse.cdt.make.core.MakeBuilderUtil; import org.eclipse.cdt.make.core.MakeCorePlugin; @@ -33,9 +32,7 @@ import org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo2; import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector; import org.eclipse.cdt.make.core.scannerconfig.InfoContext; import org.eclipse.cdt.make.internal.core.MakeMessages; -import org.eclipse.cdt.make.internal.core.StreamMonitor; import org.eclipse.cdt.make.internal.core.scannerconfig.ScannerConfigUtil; -import org.eclipse.cdt.make.internal.core.scannerconfig.ScannerInfoConsoleParserFactory; import org.eclipse.cdt.utils.EFSExtensionManager; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; @@ -56,7 +53,7 @@ import org.osgi.service.prefs.BackingStoreException; public class DefaultRunSIProvider implements IExternalScannerInfoProvider { private static final String GMAKE_ERROR_PARSER_ID = "org.eclipse.cdt.core.GmakeErrorParser"; //$NON-NLS-1$ private static final String PREF_CONSOLE_ENABLED = "org.eclipse.cdt.make.core.scanner.discovery.console.enabled"; //$NON-NLS-1$ - private static final String NEWLINE = System.getProperty("line.separator", "\n"); //$NON-NLS-1$ //$NON-NLS-2$ + private static final int MONITOR_SCALE = 100; protected IResource resource; protected String providerId; @@ -90,17 +87,20 @@ public class DefaultRunSIProvider implements IExternalScannerInfoProvider { this.buildInfo = buildInfo; this.collector = collector; - IProject currentProject = resource.getProject(); - // call a subclass to initialize protected fields - if (!initialize()) { - return false; - } - if (monitor == null) { - monitor = new NullProgressMonitor(); - } - monitor.beginTask(MakeMessages.getString("ExternalScannerInfoProvider.Reading_Specs"), 100); //$NON-NLS-1$ + IProject project = resource.getProject(); + BuildRunnerHelper buildRunnerHelper = new BuildRunnerHelper(project); try { + if (monitor == null) { + monitor = new NullProgressMonitor(); + } + monitor.beginTask(MakeMessages.getString("ExternalScannerInfoProvider.Reading_Specs"), 2 * MONITOR_SCALE); //$NON-NLS-1$ + + // call a subclass to initialize protected fields + if (!initialize()) { + return false; + } + ILanguage language = context.getLanguage(); IConsole console; if (language!=null && isConsoleEnabled()) { @@ -111,64 +111,34 @@ public class DefaultRunSIProvider implements IExternalScannerInfoProvider { // that looks in extension points registry and won't find the id console = CCorePlugin.getDefault().getConsole(MakeCorePlugin.PLUGIN_ID + ".console.hidden"); //$NON-NLS-1$ } - console.start(currentProject); - OutputStream cos = console.getOutputStream(); - - // Before launching give visual cues via the monitor - monitor.subTask(MakeMessages.getString("ExternalScannerInfoProvider.Reading_Specs")); //$NON-NLS-1$ + console.start(project); - String errMsg = null; ICommandLauncher launcher = new CommandLauncher(); - launcher.setProject(currentProject); - // Print the command for visual interaction. - launcher.showCommand(true); + launcher.setProject(project); String[] comandLineOptions = getCommandLineOptions(); IPath program = getCommandToLaunch(); - String params = coligate(comandLineOptions); + URI workingDirectoryURI = MakeBuilderUtil.getBuildDirectoryURI(project, MakeBuilder.BUILDER_ID); + String[] envp = setEnvironment(launcher, env); - monitor.subTask(MakeMessages.getString("ExternalScannerInfoProvider.Invoking_Command") //$NON-NLS-1$ - + program + params); + ErrorParserManager epm = new ErrorParserManager(project, markerGenerator, new String[] {GMAKE_ERROR_PARSER_ID}); - ErrorParserManager epm = new ErrorParserManager(currentProject, markerGenerator, new String[] {GMAKE_ERROR_PARSER_ID}); - epm.setOutputStream(cos); - StreamMonitor streamMon = new StreamMonitor(new SubProgressMonitor(monitor, 70), epm, 100); - OutputStream stdout = streamMon; - OutputStream stderr = streamMon; + buildRunnerHelper.setLaunchParameters(launcher, program, comandLineOptions, workingDirectoryURI, envp ); + buildRunnerHelper.prepareStreams(epm, null, console, new SubProgressMonitor(monitor, 1 * MONITOR_SCALE, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK)); - ConsoleOutputSniffer sniffer = ScannerInfoConsoleParserFactory.getESIProviderOutputSniffer( - stdout, stderr, currentProject, context, providerId, buildInfo, collector, markerGenerator); - OutputStream consoleOut = (sniffer == null ? cos : sniffer.getOutputStream()); - OutputStream consoleErr = (sniffer == null ? cos : sniffer.getErrorStream()); - Process p = launcher.execute(program, comandLineOptions, setEnvironment(launcher, env), fWorkingDirectory, monitor); - if (p != null) { - try { - // Close the input of the Process explicitly. - // We will never write to it. - p.getOutputStream().close(); - } catch (IOException e) { - } - if (launcher.waitAndRead(consoleOut, consoleErr, new SubProgressMonitor(monitor, 0)) != ICommandLauncher.OK) { - errMsg = launcher.getErrorMessage(); - } - monitor.subTask(MakeMessages.getString("ExternalScannerInfoProvider.Parsing_Output")); //$NON-NLS-1$ - } else { - errMsg = launcher.getErrorMessage(); - } + buildRunnerHelper.greeting(MakeMessages.getFormattedString("ExternalScannerInfoProvider.Greeting", project.getName())); //$NON-NLS-1$ + buildRunnerHelper.build(new SubProgressMonitor(monitor, 1 * MONITOR_SCALE, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK)); + buildRunnerHelper.close(); + buildRunnerHelper.goodbye(); - if (errMsg != null) { - printLine(consoleErr, errMsg); - printLine(consoleErr, MakeMessages.getFormattedString("ExternalScannerInfoProvider.Provider_Error", program + params) + NEWLINE); //$NON-NLS-1$ - } - - consoleOut.close(); - consoleErr.close(); - cos.close(); - } - catch (Exception e) { + } catch (Exception e) { MakeCorePlugin.log(e); - } - finally { + } finally { + try { + buildRunnerHelper.close(); + } catch (IOException e) { + MakeCorePlugin.log(e); + } monitor.done(); } return true; @@ -185,11 +155,6 @@ public class DefaultRunSIProvider implements IExternalScannerInfoProvider { buildInfo.isUseDefaultProviderCommand(providerId)); } - private void printLine(OutputStream stream, String msg) throws IOException { - stream.write((msg + NEWLINE).getBytes()); - stream.flush(); - } - /** * Initialization of protected fields. * Subclasses are most likely to override default implementation. @@ -223,16 +188,6 @@ public class DefaultRunSIProvider implements IExternalScannerInfoProvider { return fCompileArguments; } - private String coligate(String[] array) { - StringBuffer sb = new StringBuffer(128); - for (int i = 0; i < array.length; ++i) { - sb.append(' '); - sb.append(array[i]); - } - String ca = sb.toString(); - return ca; - } - private Properties getEnvMap(ICommandLauncher launcher, Properties initialEnv) { // Set the environmennt, some scripts may need the CWD var to be set. Properties props = initialEnv != null ? initialEnv : launcher.getEnvironment(); |