mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 22:52:11 +02:00
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
This commit is contained in:
parent
0f8f4a24cf
commit
eb197ea3c7
1 changed files with 40 additions and 21 deletions
|
@ -449,8 +449,7 @@ public class GCCToolChain extends PlatformObject implements IToolChain {
|
||||||
Files.createDirectories(buildDirectory);
|
Files.createDirectories(buildDirectory);
|
||||||
|
|
||||||
// Startup the command
|
// Startup the command
|
||||||
ProcessBuilder processBuilder = new ProcessBuilder(commandLine).directory(buildDirectory.toFile())
|
ProcessBuilder processBuilder = new ProcessBuilder(commandLine).directory(buildDirectory.toFile());
|
||||||
.redirectErrorStream(true);
|
|
||||||
CCorePlugin.getDefault().getBuildEnvironmentManager().setEnvironment(processBuilder.environment(),
|
CCorePlugin.getDefault().getBuildEnvironmentManager().setEnvironment(processBuilder.environment(),
|
||||||
buildConfig, true);
|
buildConfig, true);
|
||||||
Process process = processBuilder.start();
|
Process process = processBuilder.start();
|
||||||
|
@ -459,30 +458,50 @@ public class GCCToolChain extends PlatformObject implements IToolChain {
|
||||||
Map<String, String> symbols = new HashMap<>();
|
Map<String, String> symbols = new HashMap<>();
|
||||||
List<String> includePath = new ArrayList<>();
|
List<String> includePath = new ArrayList<>();
|
||||||
Pattern definePattern = Pattern.compile("#define ([^\\s]*)\\s(.*)"); //$NON-NLS-1$
|
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()) {
|
// First the include path off the error stream
|
||||||
if (line.startsWith("#define ")) { //$NON-NLS-1$
|
new Thread("Include Path Reader") {
|
||||||
Matcher matcher = definePattern.matcher(line);
|
@Override
|
||||||
if (matcher.matches()) {
|
public void run() {
|
||||||
symbols.put(matcher.group(1), matcher.group(2));
|
try (BufferedReader reader = new BufferedReader(new InputStreamReader(process.getErrorStream()))) {
|
||||||
}
|
for (String line = reader.readLine(); line != null; line = reader.readLine()) {
|
||||||
} else {
|
String dir = line.trim();
|
||||||
String dir = line.trim();
|
if (dir.equals(".")) { //$NON-NLS-1$
|
||||||
if (dir.equals(".")) { //$NON-NLS-1$
|
includePath.add(buildDirectory.toString());
|
||||||
includePath.add(buildDirectory.toString());
|
} else {
|
||||||
} else {
|
try {
|
||||||
try {
|
Path dirPath = Paths.get(dir);
|
||||||
Path dirPath = Paths.get(dir);
|
if (Files.isDirectory(dirPath)) {
|
||||||
if (Files.isDirectory(dirPath)) {
|
includePath.add(dirPath.toString());
|
||||||
includePath.add(dirPath.toString());
|
}
|
||||||
|
} catch (InvalidPathException e) {
|
||||||
|
// nothing
|
||||||
}
|
}
|
||||||
} catch (InvalidPathException e) {
|
|
||||||
// nothing
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} 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 (IOException e) {
|
||||||
|
CCorePlugin.log(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}.start();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
process.waitFor();
|
process.waitFor();
|
||||||
|
|
Loading…
Add table
Reference in a new issue