Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDoug Schaefer2017-11-03 16:48:20 -0400
committerDoug Schaefer2017-11-03 16:48:20 -0400
commit87cd8401f4e36dfc25912e6c768dde2ae9caed4a (patch)
tree6aa870bd1899bc7e3bc6279c958389dc938f09af
parentceeac1865a9b25e7bb97142abb3ac2d4b8213dc5 (diff)
downloadorg.eclipse.cdt-87cd8401f4e36dfc25912e6c768dde2ae9caed4a.tar.gz
org.eclipse.cdt-87cd8401f4e36dfc25912e6c768dde2ae9caed4a.tar.xz
org.eclipse.cdt-87cd8401f4e36dfc25912e6c768dde2ae9caed4a.zip
Hook up the error parser properly in the build configuration.
So we can have the error partitions that work with double clicking in the build console. Change-Id: I357f4efb8fd16232b78b18958c9863071feeebcc
-rw-r--r--build/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/internal/CMakeBuildConfiguration.java9
-rw-r--r--build/org.eclipse.cdt.core.autotools.core/src/org/eclipse/cdt/core/autotools/core/AutotoolsBuildConfiguration.java4
-rw-r--r--core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/CBuildConfiguration.java59
-rw-r--r--core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/StandardBuildConfiguration.java5
-rw-r--r--qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/build/QtBuildConfiguration.java8
-rw-r--r--toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/build/ArduinoBuildConfiguration.java5
6 files changed, 66 insertions, 24 deletions
diff --git a/build/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/internal/CMakeBuildConfiguration.java b/build/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/internal/CMakeBuildConfiguration.java
index 14d9fae4f0..31be86178b 100644
--- a/build/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/internal/CMakeBuildConfiguration.java
+++ b/build/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/internal/CMakeBuildConfiguration.java
@@ -94,6 +94,7 @@ public class CMakeBuildConfiguration extends CBuildConfiguration {
public IProject[] build(int kind, Map<String, String> args, IConsole console, IProgressMonitor monitor)
throws CoreException {
IProject project = getProject();
+
try {
String generator = getProperty(CMAKE_GENERATOR);
if (generator == null) {
@@ -146,11 +147,13 @@ public class CMakeBuildConfiguration extends CBuildConfiguration {
setBuildEnvironment(processBuilder.environment());
Process process = processBuilder.start();
outStream.write(String.join(" ", command) + '\n'); //$NON-NLS-1$
- watchProcess(process, new IConsoleParser[0], console);
+ watchProcess(process, console);
}
try (ErrorParserManager epm = new ErrorParserManager(project, getBuildDirectoryURI(), this,
getToolChain().getErrorParserIds())) {
+ epm.setOutputStream(console.getOutputStream());
+
String buildCommand = getProperty(BUILD_COMMAND);
if (buildCommand == null) {
if (generator.equals("Ninja")) { //$NON-NLS-1$
@@ -170,7 +173,7 @@ public class CMakeBuildConfiguration extends CBuildConfiguration {
setBuildEnvironment(processBuilder.environment());
Process process = processBuilder.start();
outStream.write(String.join(" ", command) + '\n'); //$NON-NLS-1$
- watchProcess(process, new IConsoleParser[] { epm }, console);
+ watchProcess(process, new IConsoleParser[] { epm });
}
project.refreshLocal(IResource.DEPTH_INFINITE, monitor);
@@ -219,7 +222,7 @@ public class CMakeBuildConfiguration extends CBuildConfiguration {
ProcessBuilder processBuilder = new ProcessBuilder(command).directory(buildDir.toFile());
Process process = processBuilder.start();
outStream.write(String.join(" ", command) + '\n'); //$NON-NLS-1$
- watchProcess(process, new IConsoleParser[0], console);
+ watchProcess(process, console);
project.refreshLocal(IResource.DEPTH_INFINITE, monitor);
} catch (IOException e) {
diff --git a/build/org.eclipse.cdt.core.autotools.core/src/org/eclipse/cdt/core/autotools/core/AutotoolsBuildConfiguration.java b/build/org.eclipse.cdt.core.autotools.core/src/org/eclipse/cdt/core/autotools/core/AutotoolsBuildConfiguration.java
index 3a69a28d7d..929a4b3ae9 100644
--- a/build/org.eclipse.cdt.core.autotools.core/src/org/eclipse/cdt/core/autotools/core/AutotoolsBuildConfiguration.java
+++ b/build/org.eclipse.cdt.core.autotools.core/src/org/eclipse/cdt/core/autotools/core/AutotoolsBuildConfiguration.java
@@ -18,7 +18,6 @@ import java.util.Arrays;
import java.util.List;
import java.util.Map;
-import org.eclipse.cdt.core.IConsoleParser;
import org.eclipse.cdt.core.autotools.core.internal.Activator;
import org.eclipse.cdt.core.build.CBuildConfiguration;
import org.eclipse.cdt.core.build.IToolChain;
@@ -90,8 +89,9 @@ public class AutotoolsBuildConfiguration extends CBuildConfiguration {
setBuildEnvironment(builder.environment());
try {
+ // TODO Error parsers
Process process = builder.start();
- watchProcess(process, new IConsoleParser[0], console);
+ watchProcess(process, console);
} catch (IOException e) {
throw new CoreException(Activator.errorStatus("Error executing: " + String.join(" ", command), e)); //$NON-NLS-2$
}
diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/CBuildConfiguration.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/CBuildConfiguration.java
index fe55abecc9..edd0c89dd8 100644
--- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/CBuildConfiguration.java
+++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/CBuildConfiguration.java
@@ -450,10 +450,37 @@ public abstract class CBuildConfiguration extends PlatformObject
return null;
}
+ @Deprecated
protected int watchProcess(Process process, IConsoleParser[] consoleParsers, IConsole console)
+ throws CoreException {
+ if (consoleParsers == null || consoleParsers.length == 0) {
+ return watchProcess(process, console);
+ } else {
+ return watchProcess(process, consoleParsers);
+ }
+ }
+
+ /**
+ * @since 6.4
+ */
+ protected int watchProcess(Process process, IConsole console) throws CoreException {
+ new ReaderThread(process.getInputStream(), console.getOutputStream()).start();
+ new ReaderThread(process.getErrorStream(), console.getErrorStream()).start();
+ try {
+ return process.waitFor();
+ } catch (InterruptedException e) {
+ CCorePlugin.log(e);
+ return -1;
+ }
+ }
+
+ /**
+ * @since 6.4
+ */
+ protected int watchProcess(Process process, IConsoleParser[] consoleParsers)
throws CoreException {
- new ReaderThread(process.getInputStream(), consoleParsers, console.getOutputStream()).start();
- new ReaderThread(process.getErrorStream(), consoleParsers, console.getErrorStream()).start();
+ new ReaderThread(process.getInputStream(), consoleParsers).start();
+ new ReaderThread(process.getErrorStream(), consoleParsers).start();
try {
return process.waitFor();
} catch (InterruptedException e) {
@@ -463,34 +490,42 @@ public abstract class CBuildConfiguration extends PlatformObject
}
private static class ReaderThread extends Thread {
-
private final BufferedReader in;
- private final PrintStream out;
private final IConsoleParser[] consoleParsers;
+ private final PrintStream out;
- public ReaderThread(InputStream in, IConsoleParser[] consoleParsers, OutputStream out) {
+ public ReaderThread(InputStream in, IConsoleParser[] consoleParsers) {
this.in = new BufferedReader(new InputStreamReader(in));
+ this.out = null;
this.consoleParsers = consoleParsers;
- this.out = new PrintStream(out);
}
+ public ReaderThread(InputStream in, OutputStream out) {
+ this.in = new BufferedReader(new InputStreamReader(in));
+ this.out = new PrintStream(out);
+ this.consoleParsers = null;
+ }
+
@Override
public void run() {
try {
for (String line = in.readLine(); line != null; line = in.readLine()) {
- for (IConsoleParser consoleParser : consoleParsers) {
- // Synchronize to avoid interleaving of lines
- synchronized (consoleParser) {
- consoleParser.processLine(line);
+ if (consoleParsers != null) {
+ for (IConsoleParser consoleParser : consoleParsers) {
+ // Synchronize to avoid interleaving of lines
+ synchronized (consoleParser) {
+ consoleParser.processLine(line);
+ }
}
}
- out.println(line);
+ if (out != null) {
+ out.println(line);
+ }
}
} catch (IOException e) {
CCorePlugin.log(e);
}
}
-
}
private File getScannerInfoCacheFile() {
diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/StandardBuildConfiguration.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/StandardBuildConfiguration.java
index 50f28769f2..fbd3aeeddf 100644
--- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/StandardBuildConfiguration.java
+++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/StandardBuildConfiguration.java
@@ -87,6 +87,7 @@ public class StandardBuildConfiguration extends CBuildConfiguration {
try (ErrorParserManager epm = new ErrorParserManager(project, getBuildDirectoryURI(), this,
getToolChain().getErrorParserIds())) {
+ epm.setOutputStream(console.getOutputStream());
// run make
console.getOutputStream().write(String.format("%s\n", String.join(" ", command))); //$NON-NLS-1$ //$NON-NLS-2$
ProcessBuilder processBuilder = new ProcessBuilder(command)
@@ -94,7 +95,7 @@ public class StandardBuildConfiguration extends CBuildConfiguration {
setBuildEnvironment(processBuilder.environment());
Process process = processBuilder.start();
IConsoleParser[] consoleParsers = new IConsoleParser[] { epm, this };
- watchProcess(process, consoleParsers, console);
+ watchProcess(process, consoleParsers);
}
project.refreshLocal(IResource.DEPTH_INFINITE, monitor);
@@ -125,7 +126,7 @@ public class StandardBuildConfiguration extends CBuildConfiguration {
.directory(getBuildDirectory().toFile());
setBuildEnvironment(processBuilder.environment());
Process process = processBuilder.start();
- watchProcess(process, new IConsoleParser[0], console);
+ watchProcess(process, console);
project.refreshLocal(IResource.DEPTH_INFINITE, monitor);
} catch (IOException e) {
diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/build/QtBuildConfiguration.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/build/QtBuildConfiguration.java
index 545ce7f0b0..5fc73297b4 100644
--- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/build/QtBuildConfiguration.java
+++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/build/QtBuildConfiguration.java
@@ -391,12 +391,13 @@ public class QtBuildConfiguration extends CBuildConfiguration
outStream.write(msg.toString());
// TODO qmake error parser
- watchProcess(process, new IConsoleParser[0], console);
+ watchProcess(process, console);
doFullBuild = false;
}
try (ErrorParserManager epm = new ErrorParserManager(project, getBuildDirectoryURI(), this,
getToolChain().getErrorParserIds())) {
+ epm.setOutputStream(console.getOutputStream());
// run make
List<String> command = new ArrayList<>(Arrays.asList(makeCommand));
command.add("all"); //$NON-NLS-1$
@@ -404,7 +405,7 @@ public class QtBuildConfiguration extends CBuildConfiguration
setBuildEnvironment(processBuilder.environment());
Process process = processBuilder.start();
outStream.write(String.join(" ", command) + '\n'); //$NON-NLS-1$
- watchProcess(process, new IConsoleParser[] { epm }, console);
+ watchProcess(process, new IConsoleParser[] { epm });
}
getProject().refreshLocal(IResource.DEPTH_INFINITE, monitor);
@@ -433,6 +434,7 @@ public class QtBuildConfiguration extends CBuildConfiguration
try (ErrorParserManager epm = new ErrorParserManager(project, getBuildDirectoryURI(), this,
getToolChain().getErrorParserIds())) {
+ epm.setOutputStream(console.getOutputStream());
// run make
List<String> command = new ArrayList<>(Arrays.asList(makeCommand));
command.add("clean"); //$NON-NLS-1$
@@ -440,7 +442,7 @@ public class QtBuildConfiguration extends CBuildConfiguration
setBuildEnvironment(processBuilder.environment());
Process process = processBuilder.start();
outStream.write(String.join(" ", command) + '\n'); //$NON-NLS-1$
- watchProcess(process, new IConsoleParser[] { epm }, console);
+ watchProcess(process, new IConsoleParser[] { epm });
}
project.refreshLocal(IResource.DEPTH_INFINITE, monitor);
diff --git a/toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/build/ArduinoBuildConfiguration.java b/toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/build/ArduinoBuildConfiguration.java
index 01ba5a08f1..5005862906 100644
--- a/toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/build/ArduinoBuildConfiguration.java
+++ b/toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/build/ArduinoBuildConfiguration.java
@@ -741,11 +741,12 @@ public class ArduinoBuildConfiguration extends CBuildConfiguration
try (ErrorParserManager epm = new ErrorParserManager(project, getBuildDirectoryURI(), this,
getToolChain().getErrorParserIds())) {
+ epm.setOutputStream(console.getOutputStream());
ProcessBuilder processBuilder = new ProcessBuilder().command(getBuildCommand())
.directory(getBuildDirectory().toFile());
setBuildEnvironment(processBuilder.environment());
Process process = processBuilder.start();
- if (watchProcess(process, new IConsoleParser[] { epm }, console) == 0) {
+ if (watchProcess(process, new IConsoleParser[] { epm }) == 0) {
showSizes(console);
}
}
@@ -773,7 +774,7 @@ public class ArduinoBuildConfiguration extends CBuildConfiguration
setBuildEnvironment(processBuilder.environment());
Process process = processBuilder.start();
- watchProcess(process, new IConsoleParser[0], console);
+ watchProcess(process, console);
getBuildContainer().refreshLocal(IResource.DEPTH_INFINITE, monitor);
} catch (IOException e) {

Back to the top