Skip to main content
summaryrefslogtreecommitdiffstats
path: root/build
diff options
context:
space:
mode:
authorDoug Schaefer2018-05-29 00:13:47 -0400
committerDoug Schaefer2018-05-29 00:13:47 -0400
commiteb197ea3c72fe47ed95cb3ba70e63c79dd2a0dd4 (patch)
treeab75b9a6660a049e020d6297d2e99c4714b106b1 /build
parent0f8f4a24cf66f42a4cf0c426c382edcebb8a314e (diff)
downloadorg.eclipse.cdt-eb197ea3c72fe47ed95cb3ba70e63c79dd2a0dd4.tar.gz
org.eclipse.cdt-eb197ea3c72fe47ed95cb3ba70e63c79dd2a0dd4.tar.xz
org.eclipse.cdt-eb197ea3c72fe47ed95cb3ba70e63c79dd2a0dd4.zip
Bug 535091 separate out the two streams for macros and defines.
The output of the call to gcc to pick out the defines and include paths produces them on different streams, defines on stdout and paths on stderr. Separate the scanning of the two into two threads. Change-Id: I3173d3619e53d13a51a6e283eb320a618daacf21
Diffstat (limited to 'build')
-rw-r--r--build/org.eclipse.cdt.build.gcc.core/src/org/eclipse/cdt/build/gcc/core/GCCToolChain.java59
1 files changed, 39 insertions, 20 deletions
diff --git a/build/org.eclipse.cdt.build.gcc.core/src/org/eclipse/cdt/build/gcc/core/GCCToolChain.java b/build/org.eclipse.cdt.build.gcc.core/src/org/eclipse/cdt/build/gcc/core/GCCToolChain.java
index a73912ca3f..2c3f56b0e2 100644
--- a/build/org.eclipse.cdt.build.gcc.core/src/org/eclipse/cdt/build/gcc/core/GCCToolChain.java
+++ b/build/org.eclipse.cdt.build.gcc.core/src/org/eclipse/cdt/build/gcc/core/GCCToolChain.java
@@ -449,8 +449,7 @@ public class GCCToolChain extends PlatformObject implements IToolChain {
Files.createDirectories(buildDirectory);
// Startup the command
- ProcessBuilder processBuilder = new ProcessBuilder(commandLine).directory(buildDirectory.toFile())
- .redirectErrorStream(true);
+ ProcessBuilder processBuilder = new ProcessBuilder(commandLine).directory(buildDirectory.toFile());
CCorePlugin.getDefault().getBuildEnvironmentManager().setEnvironment(processBuilder.environment(),
buildConfig, true);
Process process = processBuilder.start();
@@ -459,30 +458,50 @@ public class GCCToolChain extends PlatformObject implements IToolChain {
Map<String, String> symbols = new HashMap<>();
List<String> includePath = new ArrayList<>();
Pattern definePattern = Pattern.compile("#define ([^\\s]*)\\s(.*)"); //$NON-NLS-1$
- try (BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()))) {
- for (String line = reader.readLine(); line != null; line = reader.readLine()) {
- if (line.startsWith("#define ")) { //$NON-NLS-1$
- Matcher matcher = definePattern.matcher(line);
- if (matcher.matches()) {
- symbols.put(matcher.group(1), matcher.group(2));
+
+ // First the include path off the error stream
+ new Thread("Include Path Reader") {
+ @Override
+ public void run() {
+ try (BufferedReader reader = new BufferedReader(new InputStreamReader(process.getErrorStream()))) {
+ for (String line = reader.readLine(); line != null; line = reader.readLine()) {
+ String dir = line.trim();
+ if (dir.equals(".")) { //$NON-NLS-1$
+ includePath.add(buildDirectory.toString());
+ } else {
+ try {
+ Path dirPath = Paths.get(dir);
+ if (Files.isDirectory(dirPath)) {
+ includePath.add(dirPath.toString());
+ }
+ } catch (InvalidPathException e) {
+ // nothing
+ }
+ }
}
- } else {
- String dir = line.trim();
- if (dir.equals(".")) { //$NON-NLS-1$
- includePath.add(buildDirectory.toString());
- } else {
- try {
- Path dirPath = Paths.get(dir);
- if (Files.isDirectory(dirPath)) {
- includePath.add(dirPath.toString());
+ } catch (IOException e) {
+ CCorePlugin.log(e);
+ }
+ }
+ }.start();
+
+ new Thread("Macro reader") {
+ public void run() {
+ // Now the defines off the output stream
+ try (BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()))) {
+ for (String line = reader.readLine(); line != null; line = reader.readLine()) {
+ if (line.startsWith("#define ")) { //$NON-NLS-1$
+ Matcher matcher = definePattern.matcher(line);
+ if (matcher.matches()) {
+ symbols.put(matcher.group(1), matcher.group(2));
}
- } catch (InvalidPathException e) {
- // nothing
}
}
+ } catch (IOException e) {
+ CCorePlugin.log(e);
}
}
- }
+ }.start();
try {
process.waitFor();

Back to the top