mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-16 04:35:45 +02:00
Fix for 187910: Scanner discovery does not support compiler paths
Patch by Gerhard Schaber (Wind River)
This commit is contained in:
parent
ec8a6daaa4
commit
2d93c32a48
1 changed files with 30 additions and 10 deletions
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2004, 2006 IBM Corporation and others.
|
* Copyright (c) 2004, 2007 IBM Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -8,6 +8,7 @@
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM - Initial API and implementation
|
* IBM - Initial API and implementation
|
||||||
* Tianchao Li (tianchao.li@gmail.com) - arbitrary build directory (bug #136136)
|
* Tianchao Li (tianchao.li@gmail.com) - arbitrary build directory (bug #136136)
|
||||||
|
* Gerhard Schaber (Wind River Systems) - bug 187910
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.make.internal.core.scannerconfig.gnu;
|
package org.eclipse.cdt.make.internal.core.scannerconfig.gnu;
|
||||||
|
|
||||||
|
@ -83,13 +84,8 @@ public class GCCPerFileBOPConsoleParser extends AbstractGCCBOPConsoleParser {
|
||||||
for (compilerInvocationIndex=0; compilerInvocationIndex<split.size(); compilerInvocationIndex++) {
|
for (compilerInvocationIndex=0; compilerInvocationIndex<split.size(); compilerInvocationIndex++) {
|
||||||
String command = (String)split.get(compilerInvocationIndex);
|
String command = (String)split.get(compilerInvocationIndex);
|
||||||
// verify that it is compiler invocation
|
// verify that it is compiler invocation
|
||||||
int cii2 = -1;
|
int idx = lastIndexOfCompilerCommand(command);
|
||||||
for (int cii = 0; cii < compilerInvocation.length; ++cii) {
|
if (idx >= 0)
|
||||||
cii2 = command.indexOf(compilerInvocation[cii]);
|
|
||||||
if (cii2 >= 0)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (cii2 >= 0)
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (compilerInvocationIndex >= split.size()) {
|
if (compilerInvocationIndex >= split.size()) {
|
||||||
|
@ -180,6 +176,17 @@ public class GCCPerFileBOPConsoleParser extends AbstractGCCBOPConsoleParser {
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private int lastIndexOfCompilerCommand(String command) {
|
||||||
|
int cii2 = -1;
|
||||||
|
for (int cii = 0; cii < compilerInvocation.length; ++cii) {
|
||||||
|
cii2 = command.lastIndexOf(compilerInvocation[cii]);
|
||||||
|
if (cii2 >= 0) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return cii2;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Splits and unquotes all compiler command segments; supports build command such as
|
* Splits and unquotes all compiler command segments; supports build command such as
|
||||||
* sh -c 'gcc -g -O0 -I"includemath" -I "include abc" -Iincludeprint -c impl/testmath.c'
|
* sh -c 'gcc -g -O0 -I"includemath" -I "include abc" -Iincludeprint -c impl/testmath.c'
|
||||||
|
@ -297,8 +304,21 @@ public class GCCPerFileBOPConsoleParser extends AbstractGCCBOPConsoleParser {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (startPos >= 0 && endPos >= 0 && startPos >= compilerInvocationIndex) {
|
if (startPos >= 0 && endPos >= 0) {
|
||||||
split.add(line.substring(startPos, endPos));
|
String cmdFragment = line.substring(startPos, endPos);
|
||||||
|
if (startPos >= compilerInvocationIndex) { // the compiler name or one of its options
|
||||||
|
split.add(cmdFragment);
|
||||||
|
}
|
||||||
|
else if (endPos > compilerInvocationIndex) {
|
||||||
|
// compiler name is found within another command fragment--we have to check, whether this
|
||||||
|
// is a valid compiler invocation (e.g., C:/Programs/gcc/gcc.exe) or only a part
|
||||||
|
// of a command that contains by chance the compiler name (e.g., cat testgccsettings.txt)
|
||||||
|
int idx = lastIndexOfCompilerCommand(cmdFragment);
|
||||||
|
if (idx == 0 ||
|
||||||
|
(idx > 0 && (cmdFragment.charAt(idx-1) == '\\' || cmdFragment.charAt(idx-1) == '/'))) {
|
||||||
|
split.add(cmdFragment);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return split;
|
return split;
|
||||||
|
|
Loading…
Add table
Reference in a new issue