mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-05 15:25:49 +02:00
fix for 313531 (xlc scanner discovery per file build output parser doesn't recognize automake format)
This commit is contained in:
parent
ba8fbc6c87
commit
41cd409a38
2 changed files with 87 additions and 12 deletions
|
@ -1373,10 +1373,13 @@ public class PerFileXLCScannerInfoCollector implements IScannerInfoCollector3, I
|
||||||
List<String> projectSymbols = (List<String>) projectScannerInfo
|
List<String> projectSymbols = (List<String>) projectScannerInfo
|
||||||
.get(ScannerInfoTypes.SYMBOL_DEFINITIONS);
|
.get(ScannerInfoTypes.SYMBOL_DEFINITIONS);
|
||||||
|
|
||||||
|
if (projectSymbols != null) {
|
||||||
|
|
||||||
for (String symbol : projectSymbols) {
|
for (String symbol : projectSymbols) {
|
||||||
symbols.put(symbol, "1"); //$NON-NLS-1$
|
symbols.put(symbol, "1"); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Map<String, String> fileSymbols = getAllSymbols1();
|
Map<String, String> fileSymbols = getAllSymbols1();
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,7 @@ package org.eclipse.cdt.make.xlc.core.scannerconfig;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
@ -47,6 +48,24 @@ public class XLCPerFileBuildOutputParser extends AbstractXLCBuildOutputParser {
|
||||||
int extensionsIndex = -1;
|
int extensionsIndex = -1;
|
||||||
boolean found = false;
|
boolean found = false;
|
||||||
String filePath = null;
|
String filePath = null;
|
||||||
|
|
||||||
|
// check for automake format first
|
||||||
|
// e.g. line will start with
|
||||||
|
// source='/some/path/source.cpp'
|
||||||
|
int automakeSrcIndex = findAutoMakeSourceIndex(tokens);
|
||||||
|
if(automakeSrcIndex != -1) {
|
||||||
|
filePath = getAutoMakeSourcePath(tokens[automakeSrcIndex]);
|
||||||
|
int k = filePath.lastIndexOf('.');
|
||||||
|
if (k != -1 && (filePath.length() - k < 5)) {
|
||||||
|
String fileExtension = filePath.substring(k);
|
||||||
|
extensionsIndex = getFileExtensionsList().indexOf(fileExtension);
|
||||||
|
if (extensionsIndex != -1) {
|
||||||
|
found = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!found) {
|
||||||
for (int i = compilerInvocationIndex + 1; i < tokens.length; i++) {
|
for (int i = compilerInvocationIndex + 1; i < tokens.length; i++) {
|
||||||
String token = tokens[i];
|
String token = tokens[i];
|
||||||
int k = token.lastIndexOf('.');
|
int k = token.lastIndexOf('.');
|
||||||
|
@ -60,6 +79,8 @@ public class XLCPerFileBuildOutputParser extends AbstractXLCBuildOutputParser {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!found) {
|
if (!found) {
|
||||||
TraceUtil.outputTrace("Error identifying file name :1", tokens, TraceUtil.EOL); //$NON-NLS-1$
|
TraceUtil.outputTrace("Error identifying file name :1", tokens, TraceUtil.EOL); //$NON-NLS-1$
|
||||||
return false;
|
return false;
|
||||||
|
@ -105,7 +126,7 @@ public class XLCPerFileBuildOutputParser extends AbstractXLCBuildOutputParser {
|
||||||
} else {
|
} else {
|
||||||
file = getUtility().findFileInWorkspace(pFilePath);
|
file = getUtility().findFileInWorkspace(pFilePath);
|
||||||
}
|
}
|
||||||
if (file != null) {
|
if (true /*file != null*/) {
|
||||||
CCommandDSC cmd = getUtility().getNewCCommandDSC(tokens, compilerInvocationIndex, extensionsIndex > 0);
|
CCommandDSC cmd = getUtility().getNewCCommandDSC(tokens, compilerInvocationIndex, extensionsIndex > 0);
|
||||||
List<CCommandDSC> cmdList = new ArrayList<CCommandDSC>();
|
List<CCommandDSC> cmdList = new ArrayList<CCommandDSC>();
|
||||||
cmdList.add(cmd);
|
cmdList.add(cmd);
|
||||||
|
@ -121,8 +142,34 @@ public class XLCPerFileBuildOutputParser extends AbstractXLCBuildOutputParser {
|
||||||
Activator.log(e);
|
Activator.log(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else
|
} else {
|
||||||
TraceUtil.outputError("Build command for file outside project: " + pFilePath.toString(), tokens); //$NON-NLS-1$
|
/*
|
||||||
|
//TraceUtil.outputError("Build command for file outside project: " + pFilePath.toString(), tokens); //$NON-NLS-1$
|
||||||
|
// put the info on the project
|
||||||
|
//CCommandDSC cmd = getUtility().getNewCCommandDSC(tokens, compilerInvocationIndex, extensionsIndex > 0);
|
||||||
|
//List<CCommandDSC> cmdList = new ArrayList<CCommandDSC>();
|
||||||
|
// cmdList.add(cmd);
|
||||||
|
Map<ScannerInfoTypes, List<?>> sc = new HashMap<ScannerInfoTypes, List<?>>();
|
||||||
|
// sc.put(ScannerInfoTypes.COMPILER_COMMAND, cmdList);
|
||||||
|
|
||||||
|
|
||||||
|
// put in empty info for the other types
|
||||||
|
sc.put(ScannerInfoTypes.INCLUDE_PATHS, new LinkedList<String>());
|
||||||
|
sc.put(ScannerInfoTypes.SYMBOL_DEFINITIONS, new LinkedList<String>());
|
||||||
|
|
||||||
|
getCollector().contributeToScannerConfig(getProject(), sc);
|
||||||
|
if (fCollector != null && fCollector instanceof IScannerInfoCollector2) {
|
||||||
|
IScannerInfoCollector2 collector = (IScannerInfoCollector2) fCollector;
|
||||||
|
try {
|
||||||
|
collector.updateScannerConfiguration(null);
|
||||||
|
} catch (CoreException e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
Activator.log(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
*/
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
@ -133,4 +180,29 @@ public class XLCPerFileBuildOutputParser extends AbstractXLCBuildOutputParser {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String getAutoMakeSourcePath(String string) {
|
||||||
|
// path may be enclosed in single quotes
|
||||||
|
int firstQuoteIndex = string.indexOf('\'');
|
||||||
|
int lastQuoteIndex = string.lastIndexOf('\'');
|
||||||
|
if(firstQuoteIndex != -1 && lastQuoteIndex != -1)
|
||||||
|
return string.substring(firstQuoteIndex, lastQuoteIndex);
|
||||||
|
else {
|
||||||
|
// just take everything after the equals sign
|
||||||
|
int equalsIndex = string.indexOf('=');
|
||||||
|
if(equalsIndex != -1 && equalsIndex < string.length())
|
||||||
|
return string.substring(equalsIndex+1);
|
||||||
|
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private int findAutoMakeSourceIndex(String[] tokens) {
|
||||||
|
for (int i = 0; i < tokens.length; i++) {
|
||||||
|
final String token = tokens[i].toLowerCase();
|
||||||
|
if(token.indexOf("source=") != -1) //$NON-NLS-1$
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue