mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Fix for PR 77940: Missing built-ins for mingw
Addendum: Symbol definitions as a result of -dD option are written to the standard error stream since gcc version 3.4.x. This is now proprly handled.
This commit is contained in:
parent
8fc3226f2d
commit
2f8b9abb4b
1 changed files with 29 additions and 61 deletions
|
@ -31,16 +31,11 @@ public class GCCSpecsConsoleParser implements IScannerInfoConsoleParser {
|
||||||
private final String INCLUDE = "#include"; //$NON-NLS-1$
|
private final String INCLUDE = "#include"; //$NON-NLS-1$
|
||||||
private final String DEFINE = "#define"; //$NON-NLS-1$
|
private final String DEFINE = "#define"; //$NON-NLS-1$
|
||||||
|
|
||||||
private final int STATE_BEGIN = 0;
|
|
||||||
private final int STATE_SPECS_STARTED = 1;
|
|
||||||
private final int STATE_INCLUDES_STARTED = 2;
|
|
||||||
private final int STATE_ADDITIONAL_DEFINES_STARTED = 3;
|
|
||||||
|
|
||||||
private IProject fProject = null;
|
private IProject fProject = null;
|
||||||
private IScannerInfoConsoleParserUtility fUtil = null;
|
private IScannerInfoConsoleParserUtility fUtil = null;
|
||||||
private IScannerInfoCollector fCollector = null;
|
private IScannerInfoCollector fCollector = null;
|
||||||
|
|
||||||
private int state = STATE_BEGIN;
|
private boolean expectingIncludes = false;
|
||||||
private List symbols = new ArrayList();
|
private List symbols = new ArrayList();
|
||||||
private List includes = new ArrayList();
|
private List includes = new ArrayList();
|
||||||
|
|
||||||
|
@ -59,65 +54,38 @@ public class GCCSpecsConsoleParser implements IScannerInfoConsoleParser {
|
||||||
public boolean processLine(String line) {
|
public boolean processLine(String line) {
|
||||||
boolean rc = false;
|
boolean rc = false;
|
||||||
TraceUtil.outputTrace("GCCSpecsConsoleParser parsing line:", TraceUtil.EOL, line); //$NON-NLS-1$ //$NON-NLS-2$
|
TraceUtil.outputTrace("GCCSpecsConsoleParser parsing line:", TraceUtil.EOL, line); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
// Known patterns:
|
|
||||||
// (a) gcc|g++ ... -Dxxx -Iyyy ...
|
// contribution of -dD option
|
||||||
switch (state) {
|
if (line.startsWith(DEFINE)) {
|
||||||
case STATE_BEGIN:
|
String[] defineParts = line.split("\\s+", 3); //$NON-NLS-1$
|
||||||
if (line.startsWith("Reading specs from")) { //$NON-NLS-1$
|
if (defineParts[0].equals(DEFINE)) {
|
||||||
state = STATE_SPECS_STARTED;
|
String symbol = null;
|
||||||
|
switch (defineParts.length) {
|
||||||
|
case 2:
|
||||||
|
symbol = defineParts[1];
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
symbol = defineParts[1] + "=" + defineParts[2];
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
break;
|
if (symbol != null && !symbols.contains(symbol)) { //$NON-NLS-1$
|
||||||
case STATE_SPECS_STARTED:
|
symbols.add(symbol);
|
||||||
if (line.indexOf("-D") != -1) { //$NON-NLS-1$
|
|
||||||
// line contains -Ds, extract them
|
|
||||||
String[] tokens = line.split("\\s+");//$NON-NLS-1$
|
|
||||||
for (int i = 0; i < tokens.length; ++i) {
|
|
||||||
if (tokens[i].startsWith("-D")) { //$NON-NLS-1$
|
|
||||||
String symbol = tokens[i].substring(2);
|
|
||||||
if (!symbols.contains(symbol))
|
|
||||||
symbols.add(symbol);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// now get all the includes
|
}
|
||||||
if (line.startsWith(INCLUDE) && line.endsWith("search starts here:")) { //$NON-NLS-1$
|
}
|
||||||
state = STATE_INCLUDES_STARTED;
|
// now get all the includes
|
||||||
}
|
else if (line.startsWith(INCLUDE) && line.endsWith("search starts here:")) { //$NON-NLS-1$
|
||||||
break;
|
expectingIncludes = true;
|
||||||
case STATE_INCLUDES_STARTED:
|
}
|
||||||
if (line.startsWith(INCLUDE) && line.endsWith("search starts here:")) { //$NON-NLS-1$
|
else if (line.startsWith("End of search list.")) { //$NON-NLS-1$
|
||||||
state = STATE_INCLUDES_STARTED;
|
expectingIncludes = false;
|
||||||
}
|
}
|
||||||
else if (line.startsWith("End of search list.")) { //$NON-NLS-1$
|
else if (expectingIncludes) {
|
||||||
state = STATE_ADDITIONAL_DEFINES_STARTED;
|
if (!includes.contains(line))
|
||||||
}
|
includes.add(line);
|
||||||
else {
|
|
||||||
if (!includes.contains(line))
|
|
||||||
includes.add(line);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case STATE_ADDITIONAL_DEFINES_STARTED:
|
|
||||||
if (line.startsWith(DEFINE)) {
|
|
||||||
String[] defineParts = line.split("\\s+", 3); //$NON-NLS-1$
|
|
||||||
if (defineParts[0].equals(DEFINE)) {
|
|
||||||
String symbol = null;
|
|
||||||
switch (defineParts.length) {
|
|
||||||
case 2:
|
|
||||||
symbol = defineParts[1];
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
symbol = defineParts[1] + "=" + defineParts[2];
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (symbol != null && !symbols.contains(symbol)) { //$NON-NLS-1$
|
|
||||||
symbols.add(symbol);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
|
Loading…
Add table
Reference in a new issue