mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Fix for 203059: [Scanner Discovery] Compiler commands within sh -c '...' are ignored (Patch by Gerhard Schaber)
Fix for 203104: GCCScannerInfoConsoleParser too strict when reading compilerCommands
This commit is contained in:
parent
378af88ee3
commit
85f7e83870
5 changed files with 31 additions and 5 deletions
|
@ -128,7 +128,7 @@ public abstract class BaseBOPConsoleParserTests extends BaseTestCase {
|
|||
}
|
||||
|
||||
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=203059
|
||||
public void _testCompilerCommandInsideShellInvocation_bug203059() throws Exception {
|
||||
public void testCompilerCommandInsideShellInvocation_bug203059() throws Exception {
|
||||
fOutputParser.processLine("sh -c '/usr/bin/gcc -DA test1.c'"); //$NON-NLS-1$
|
||||
fOutputParser.processLine("sh -c '/usr/gcc-installs/gcc -DB test2.c;"); //$NON-NLS-1$
|
||||
fOutputParser.processLine("sh -c '/usr/gcc/gcc -DC test3.c'"); //$NON-NLS-1$
|
||||
|
|
|
@ -63,6 +63,9 @@ public class GCCScannerInfoConsoleParserTests extends BaseBOPConsoleParserTests
|
|||
fOutputParser.processLine("gcc -I \\"); //$NON-NLS-1$
|
||||
fOutputParser.processLine("/multiline\\"); //$NON-NLS-1$
|
||||
fOutputParser.processLine("/dir -c test.c"); // multiline //$NON-NLS-1$
|
||||
fOutputParser.processLine("gcc -Imultiline2 \\"); //$NON-NLS-1$
|
||||
fOutputParser.processLine("-Imultiline3\\"); //$NON-NLS-1$
|
||||
fOutputParser.processLine(" -DAA=\"BB\" test.c"); //$NON-NLS-1$
|
||||
|
||||
List sumIncludes = fCollector.getCollectedScannerInfo(null, ScannerInfoTypes.INCLUDE_PATHS);
|
||||
assertTrue(sumIncludes.contains("/dir/include")); //$NON-NLS-1$
|
||||
|
@ -89,6 +92,8 @@ public class GCCScannerInfoConsoleParserTests extends BaseBOPConsoleParserTests
|
|||
assertTrue(sumIncludes.contains("//server5/include")); //$NON-NLS-1$
|
||||
assertTrue(sumIncludes.contains("//server6/include")); //$NON-NLS-1$
|
||||
assertTrue(sumIncludes.contains("/multiline/dir")); //$NON-NLS-1$
|
||||
assertTrue(sumIncludes.size() == 24);
|
||||
assertTrue(sumIncludes.contains("multiline2")); //$NON-NLS-1$
|
||||
assertTrue(sumIncludes.contains("multiline3")); //$NON-NLS-1$
|
||||
assertTrue(sumIncludes.size() == 26);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
* Contributors:
|
||||
* IBM - Initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* Gerhard Schaber (Wind River Systems) - bug 203059
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.make.internal.core.scannerconfig.gnu;
|
||||
|
||||
|
@ -74,7 +75,7 @@ public abstract class AbstractGCCBOPConsoleParser implements IScannerInfoConsole
|
|||
if (boProvider != null) {
|
||||
String compilerCommandsString = boProvider.getScannerInfoConsoleParser().getCompilerCommands();
|
||||
if (compilerCommandsString != null && compilerCommandsString.length() > 0) {
|
||||
String[] compilerCommands = compilerCommandsString.split(",\\s+"); //$NON-NLS-1$
|
||||
String[] compilerCommands = compilerCommandsString.split(",\\s*"); //$NON-NLS-1$
|
||||
if (compilerCommands.length > 0) {
|
||||
String[] compilerInvocation = new String[COMPILER_INVOCATION.length + compilerCommands.length];
|
||||
System.arraycopy(COMPILER_INVOCATION, 0, compilerInvocation, 0, COMPILER_INVOCATION.length);
|
||||
|
@ -298,6 +299,19 @@ public abstract class AbstractGCCBOPConsoleParser implements IScannerInfoConsole
|
|||
if (processCommand(command)) {
|
||||
rc= true;
|
||||
}
|
||||
else { // go inside quotes, if the compiler is called per wrapper or shell script
|
||||
for (int j = 0; j < command.length; j++) {
|
||||
String[][] subtokens= tokenize(command[j], true);
|
||||
for (int k = 0; k < subtokens.length; k++) {
|
||||
String[] subcommand = subtokens[k];
|
||||
if (subcommand.length > 1) { // only proceed if there is any additional info
|
||||
if (processCommand(subcommand)) {
|
||||
rc= true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
|
|
@ -88,12 +88,12 @@ public class GCCPerFileBOPConsoleParser extends AbstractGCCBOPConsoleParser {
|
|||
}
|
||||
if (!found) {
|
||||
TraceUtil.outputTrace("Error identifying file name :1", tokens, TraceUtil.EOL); //$NON-NLS-1$
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
// sanity check
|
||||
if (filePath.indexOf(FILE_EXTENSIONS[extensionsIndex]) == -1) {
|
||||
TraceUtil.outputTrace("Error identifying file name :2", tokens, TraceUtil.EOL); //$NON-NLS-1$
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
if (fUtil != null) {
|
||||
IPath pFilePath = fUtil.getAbsolutePath(filePath);
|
||||
|
|
|
@ -59,6 +59,10 @@ public class GCCScannerInfoConsoleParser extends AbstractGCCBOPConsoleParser {
|
|||
return false;
|
||||
}
|
||||
|
||||
if (compilerInvocationIdx+1 >= tokens.length) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Recognized gcc or g++ compiler invocation
|
||||
List includes = new ArrayList();
|
||||
List symbols = new ArrayList();
|
||||
|
@ -149,6 +153,9 @@ public class GCCScannerInfoConsoleParser extends AbstractGCCBOPConsoleParser {
|
|||
if (fileName != null && fileName.startsWith("/cygdrive/")) { //$NON-NLS-1$
|
||||
fileName= AbstractGCCBOPConsoleParserUtility.convertCygpath(new Path(fileName)).toOSString();
|
||||
}
|
||||
if (fileName == null) {
|
||||
return false; // return when no file was given (analogous to GCCPerFileBOPConsoleParser)
|
||||
}
|
||||
|
||||
IProject project = getProject();
|
||||
IFile file = null;
|
||||
|
|
Loading…
Add table
Reference in a new issue