mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
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
This commit is contained in:
parent
ceeac1865a
commit
87cd8401f4
6 changed files with 66 additions and 24 deletions
|
@ -94,6 +94,7 @@ public class CMakeBuildConfiguration extends CBuildConfiguration {
|
||||||
public IProject[] build(int kind, Map<String, String> args, IConsole console, IProgressMonitor monitor)
|
public IProject[] build(int kind, Map<String, String> args, IConsole console, IProgressMonitor monitor)
|
||||||
throws CoreException {
|
throws CoreException {
|
||||||
IProject project = getProject();
|
IProject project = getProject();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
String generator = getProperty(CMAKE_GENERATOR);
|
String generator = getProperty(CMAKE_GENERATOR);
|
||||||
if (generator == null) {
|
if (generator == null) {
|
||||||
|
@ -146,11 +147,13 @@ public class CMakeBuildConfiguration extends CBuildConfiguration {
|
||||||
setBuildEnvironment(processBuilder.environment());
|
setBuildEnvironment(processBuilder.environment());
|
||||||
Process process = processBuilder.start();
|
Process process = processBuilder.start();
|
||||||
outStream.write(String.join(" ", command) + '\n'); //$NON-NLS-1$
|
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,
|
try (ErrorParserManager epm = new ErrorParserManager(project, getBuildDirectoryURI(), this,
|
||||||
getToolChain().getErrorParserIds())) {
|
getToolChain().getErrorParserIds())) {
|
||||||
|
epm.setOutputStream(console.getOutputStream());
|
||||||
|
|
||||||
String buildCommand = getProperty(BUILD_COMMAND);
|
String buildCommand = getProperty(BUILD_COMMAND);
|
||||||
if (buildCommand == null) {
|
if (buildCommand == null) {
|
||||||
if (generator.equals("Ninja")) { //$NON-NLS-1$
|
if (generator.equals("Ninja")) { //$NON-NLS-1$
|
||||||
|
@ -170,7 +173,7 @@ public class CMakeBuildConfiguration extends CBuildConfiguration {
|
||||||
setBuildEnvironment(processBuilder.environment());
|
setBuildEnvironment(processBuilder.environment());
|
||||||
Process process = processBuilder.start();
|
Process process = processBuilder.start();
|
||||||
outStream.write(String.join(" ", command) + '\n'); //$NON-NLS-1$
|
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);
|
project.refreshLocal(IResource.DEPTH_INFINITE, monitor);
|
||||||
|
@ -219,7 +222,7 @@ public class CMakeBuildConfiguration extends CBuildConfiguration {
|
||||||
ProcessBuilder processBuilder = new ProcessBuilder(command).directory(buildDir.toFile());
|
ProcessBuilder processBuilder = new ProcessBuilder(command).directory(buildDir.toFile());
|
||||||
Process process = processBuilder.start();
|
Process process = processBuilder.start();
|
||||||
outStream.write(String.join(" ", command) + '\n'); //$NON-NLS-1$
|
outStream.write(String.join(" ", command) + '\n'); //$NON-NLS-1$
|
||||||
watchProcess(process, new IConsoleParser[0], console);
|
watchProcess(process, console);
|
||||||
|
|
||||||
project.refreshLocal(IResource.DEPTH_INFINITE, monitor);
|
project.refreshLocal(IResource.DEPTH_INFINITE, monitor);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
|
|
@ -18,7 +18,6 @@ import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.IConsoleParser;
|
|
||||||
import org.eclipse.cdt.core.autotools.core.internal.Activator;
|
import org.eclipse.cdt.core.autotools.core.internal.Activator;
|
||||||
import org.eclipse.cdt.core.build.CBuildConfiguration;
|
import org.eclipse.cdt.core.build.CBuildConfiguration;
|
||||||
import org.eclipse.cdt.core.build.IToolChain;
|
import org.eclipse.cdt.core.build.IToolChain;
|
||||||
|
@ -90,8 +89,9 @@ public class AutotoolsBuildConfiguration extends CBuildConfiguration {
|
||||||
setBuildEnvironment(builder.environment());
|
setBuildEnvironment(builder.environment());
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
// TODO Error parsers
|
||||||
Process process = builder.start();
|
Process process = builder.start();
|
||||||
watchProcess(process, new IConsoleParser[0], console);
|
watchProcess(process, console);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new CoreException(Activator.errorStatus("Error executing: " + String.join(" ", command), e)); //$NON-NLS-2$
|
throw new CoreException(Activator.errorStatus("Error executing: " + String.join(" ", command), e)); //$NON-NLS-2$
|
||||||
}
|
}
|
||||||
|
|
|
@ -450,10 +450,37 @@ public abstract class CBuildConfiguration extends PlatformObject
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
protected int watchProcess(Process process, IConsoleParser[] consoleParsers, IConsole console)
|
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 {
|
throws CoreException {
|
||||||
new ReaderThread(process.getInputStream(), consoleParsers, console.getOutputStream()).start();
|
new ReaderThread(process.getInputStream(), consoleParsers).start();
|
||||||
new ReaderThread(process.getErrorStream(), consoleParsers, console.getErrorStream()).start();
|
new ReaderThread(process.getErrorStream(), consoleParsers).start();
|
||||||
try {
|
try {
|
||||||
return process.waitFor();
|
return process.waitFor();
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
|
@ -463,34 +490,42 @@ public abstract class CBuildConfiguration extends PlatformObject
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class ReaderThread extends Thread {
|
private static class ReaderThread extends Thread {
|
||||||
|
|
||||||
private final BufferedReader in;
|
private final BufferedReader in;
|
||||||
private final PrintStream out;
|
|
||||||
private final IConsoleParser[] consoleParsers;
|
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.in = new BufferedReader(new InputStreamReader(in));
|
||||||
|
this.out = null;
|
||||||
this.consoleParsers = consoleParsers;
|
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
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
for (String line = in.readLine(); line != null; line = in.readLine()) {
|
for (String line = in.readLine(); line != null; line = in.readLine()) {
|
||||||
for (IConsoleParser consoleParser : consoleParsers) {
|
if (consoleParsers != null) {
|
||||||
// Synchronize to avoid interleaving of lines
|
for (IConsoleParser consoleParser : consoleParsers) {
|
||||||
synchronized (consoleParser) {
|
// Synchronize to avoid interleaving of lines
|
||||||
consoleParser.processLine(line);
|
synchronized (consoleParser) {
|
||||||
|
consoleParser.processLine(line);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
out.println(line);
|
if (out != null) {
|
||||||
|
out.println(line);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
CCorePlugin.log(e);
|
CCorePlugin.log(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private File getScannerInfoCacheFile() {
|
private File getScannerInfoCacheFile() {
|
||||||
|
|
|
@ -87,6 +87,7 @@ public class StandardBuildConfiguration extends CBuildConfiguration {
|
||||||
|
|
||||||
try (ErrorParserManager epm = new ErrorParserManager(project, getBuildDirectoryURI(), this,
|
try (ErrorParserManager epm = new ErrorParserManager(project, getBuildDirectoryURI(), this,
|
||||||
getToolChain().getErrorParserIds())) {
|
getToolChain().getErrorParserIds())) {
|
||||||
|
epm.setOutputStream(console.getOutputStream());
|
||||||
// run make
|
// run make
|
||||||
console.getOutputStream().write(String.format("%s\n", String.join(" ", command))); //$NON-NLS-1$ //$NON-NLS-2$
|
console.getOutputStream().write(String.format("%s\n", String.join(" ", command))); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
ProcessBuilder processBuilder = new ProcessBuilder(command)
|
ProcessBuilder processBuilder = new ProcessBuilder(command)
|
||||||
|
@ -94,7 +95,7 @@ public class StandardBuildConfiguration extends CBuildConfiguration {
|
||||||
setBuildEnvironment(processBuilder.environment());
|
setBuildEnvironment(processBuilder.environment());
|
||||||
Process process = processBuilder.start();
|
Process process = processBuilder.start();
|
||||||
IConsoleParser[] consoleParsers = new IConsoleParser[] { epm, this };
|
IConsoleParser[] consoleParsers = new IConsoleParser[] { epm, this };
|
||||||
watchProcess(process, consoleParsers, console);
|
watchProcess(process, consoleParsers);
|
||||||
}
|
}
|
||||||
|
|
||||||
project.refreshLocal(IResource.DEPTH_INFINITE, monitor);
|
project.refreshLocal(IResource.DEPTH_INFINITE, monitor);
|
||||||
|
@ -125,7 +126,7 @@ public class StandardBuildConfiguration extends CBuildConfiguration {
|
||||||
.directory(getBuildDirectory().toFile());
|
.directory(getBuildDirectory().toFile());
|
||||||
setBuildEnvironment(processBuilder.environment());
|
setBuildEnvironment(processBuilder.environment());
|
||||||
Process process = processBuilder.start();
|
Process process = processBuilder.start();
|
||||||
watchProcess(process, new IConsoleParser[0], console);
|
watchProcess(process, console);
|
||||||
|
|
||||||
project.refreshLocal(IResource.DEPTH_INFINITE, monitor);
|
project.refreshLocal(IResource.DEPTH_INFINITE, monitor);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
|
|
@ -391,12 +391,13 @@ public class QtBuildConfiguration extends CBuildConfiguration
|
||||||
outStream.write(msg.toString());
|
outStream.write(msg.toString());
|
||||||
|
|
||||||
// TODO qmake error parser
|
// TODO qmake error parser
|
||||||
watchProcess(process, new IConsoleParser[0], console);
|
watchProcess(process, console);
|
||||||
doFullBuild = false;
|
doFullBuild = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
try (ErrorParserManager epm = new ErrorParserManager(project, getBuildDirectoryURI(), this,
|
try (ErrorParserManager epm = new ErrorParserManager(project, getBuildDirectoryURI(), this,
|
||||||
getToolChain().getErrorParserIds())) {
|
getToolChain().getErrorParserIds())) {
|
||||||
|
epm.setOutputStream(console.getOutputStream());
|
||||||
// run make
|
// run make
|
||||||
List<String> command = new ArrayList<>(Arrays.asList(makeCommand));
|
List<String> command = new ArrayList<>(Arrays.asList(makeCommand));
|
||||||
command.add("all"); //$NON-NLS-1$
|
command.add("all"); //$NON-NLS-1$
|
||||||
|
@ -404,7 +405,7 @@ public class QtBuildConfiguration extends CBuildConfiguration
|
||||||
setBuildEnvironment(processBuilder.environment());
|
setBuildEnvironment(processBuilder.environment());
|
||||||
Process process = processBuilder.start();
|
Process process = processBuilder.start();
|
||||||
outStream.write(String.join(" ", command) + '\n'); //$NON-NLS-1$
|
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);
|
getProject().refreshLocal(IResource.DEPTH_INFINITE, monitor);
|
||||||
|
@ -433,6 +434,7 @@ public class QtBuildConfiguration extends CBuildConfiguration
|
||||||
|
|
||||||
try (ErrorParserManager epm = new ErrorParserManager(project, getBuildDirectoryURI(), this,
|
try (ErrorParserManager epm = new ErrorParserManager(project, getBuildDirectoryURI(), this,
|
||||||
getToolChain().getErrorParserIds())) {
|
getToolChain().getErrorParserIds())) {
|
||||||
|
epm.setOutputStream(console.getOutputStream());
|
||||||
// run make
|
// run make
|
||||||
List<String> command = new ArrayList<>(Arrays.asList(makeCommand));
|
List<String> command = new ArrayList<>(Arrays.asList(makeCommand));
|
||||||
command.add("clean"); //$NON-NLS-1$
|
command.add("clean"); //$NON-NLS-1$
|
||||||
|
@ -440,7 +442,7 @@ public class QtBuildConfiguration extends CBuildConfiguration
|
||||||
setBuildEnvironment(processBuilder.environment());
|
setBuildEnvironment(processBuilder.environment());
|
||||||
Process process = processBuilder.start();
|
Process process = processBuilder.start();
|
||||||
outStream.write(String.join(" ", command) + '\n'); //$NON-NLS-1$
|
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);
|
project.refreshLocal(IResource.DEPTH_INFINITE, monitor);
|
||||||
|
|
|
@ -741,11 +741,12 @@ public class ArduinoBuildConfiguration extends CBuildConfiguration
|
||||||
|
|
||||||
try (ErrorParserManager epm = new ErrorParserManager(project, getBuildDirectoryURI(), this,
|
try (ErrorParserManager epm = new ErrorParserManager(project, getBuildDirectoryURI(), this,
|
||||||
getToolChain().getErrorParserIds())) {
|
getToolChain().getErrorParserIds())) {
|
||||||
|
epm.setOutputStream(console.getOutputStream());
|
||||||
ProcessBuilder processBuilder = new ProcessBuilder().command(getBuildCommand())
|
ProcessBuilder processBuilder = new ProcessBuilder().command(getBuildCommand())
|
||||||
.directory(getBuildDirectory().toFile());
|
.directory(getBuildDirectory().toFile());
|
||||||
setBuildEnvironment(processBuilder.environment());
|
setBuildEnvironment(processBuilder.environment());
|
||||||
Process process = processBuilder.start();
|
Process process = processBuilder.start();
|
||||||
if (watchProcess(process, new IConsoleParser[] { epm }, console) == 0) {
|
if (watchProcess(process, new IConsoleParser[] { epm }) == 0) {
|
||||||
showSizes(console);
|
showSizes(console);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -773,7 +774,7 @@ public class ArduinoBuildConfiguration extends CBuildConfiguration
|
||||||
setBuildEnvironment(processBuilder.environment());
|
setBuildEnvironment(processBuilder.environment());
|
||||||
Process process = processBuilder.start();
|
Process process = processBuilder.start();
|
||||||
|
|
||||||
watchProcess(process, new IConsoleParser[0], console);
|
watchProcess(process, console);
|
||||||
|
|
||||||
getBuildContainer().refreshLocal(IResource.DEPTH_INFINITE, monitor);
|
getBuildContainer().refreshLocal(IResource.DEPTH_INFINITE, monitor);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue