mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-08 02:06:01 +02:00
Fix for 102709: Conversion to LONG_NAME/SHORT_NAME in GCCPerFileBOPConsoleParser causes problems.
Conversion to a generic command line now excludes -include and -imacros options.
This commit is contained in:
parent
6c71187540
commit
6833f73fa5
2 changed files with 37 additions and 18 deletions
|
@ -58,21 +58,23 @@ public abstract class AbstractGCCBOPConsoleParser implements IScannerInfoConsole
|
||||||
* @return String[]
|
* @return String[]
|
||||||
*/
|
*/
|
||||||
public String[] getCompilerCommands() {
|
public String[] getCompilerCommands() {
|
||||||
SCProfileInstance profileInstance = ScannerConfigProfileManager.getInstance().
|
if (project != null) {
|
||||||
getSCProfileInstance(project, ScannerConfigProfileManager.NULL_PROFILE_ID);
|
SCProfileInstance profileInstance = ScannerConfigProfileManager.getInstance().
|
||||||
BuildOutputProvider boProvider = profileInstance.getProfile().getBuildOutputProviderElement();
|
getSCProfileInstance(project, ScannerConfigProfileManager.NULL_PROFILE_ID);
|
||||||
if (boProvider != null) {
|
BuildOutputProvider boProvider = profileInstance.getProfile().getBuildOutputProviderElement();
|
||||||
String compilerCommandsString = boProvider.getScannerInfoConsoleParser().getCompilerCommands();
|
if (boProvider != null) {
|
||||||
if (compilerCommandsString != null && compilerCommandsString.length() > 0) {
|
String compilerCommandsString = boProvider.getScannerInfoConsoleParser().getCompilerCommands();
|
||||||
String[] compilerCommands = compilerCommandsString.split(",\\s+"); //$NON-NLS-1$
|
if (compilerCommandsString != null && compilerCommandsString.length() > 0) {
|
||||||
if (compilerCommands.length > 0) {
|
String[] compilerCommands = compilerCommandsString.split(",\\s+"); //$NON-NLS-1$
|
||||||
String[] compilerInvocation = new String[COMPILER_INVOCATION.length + compilerCommands.length];
|
if (compilerCommands.length > 0) {
|
||||||
System.arraycopy(COMPILER_INVOCATION, 0, compilerInvocation, 0, COMPILER_INVOCATION.length);
|
String[] compilerInvocation = new String[COMPILER_INVOCATION.length + compilerCommands.length];
|
||||||
System.arraycopy(compilerCommands, 0, compilerInvocation, COMPILER_INVOCATION.length, compilerCommands.length);
|
System.arraycopy(COMPILER_INVOCATION, 0, compilerInvocation, 0, COMPILER_INVOCATION.length);
|
||||||
return compilerInvocation;
|
System.arraycopy(compilerCommands, 0, compilerInvocation, COMPILER_INVOCATION.length, compilerCommands.length);
|
||||||
}
|
return compilerInvocation;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
return COMPILER_INVOCATION;
|
return COMPILER_INVOCATION;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -125,10 +125,27 @@ public class GCCPerFileBOPConsoleParser extends AbstractGCCBOPConsoleParser {
|
||||||
if (fUtil != null) {
|
if (fUtil != null) {
|
||||||
IPath pFilePath = fUtil.getAbsolutePath(filePath);
|
IPath pFilePath = fUtil.getAbsolutePath(filePath);
|
||||||
String shortFileName = pFilePath.removeFileExtension().lastSegment();
|
String shortFileName = pFilePath.removeFileExtension().lastSegment();
|
||||||
String genericLine = line.replaceAll(filePath, "LONG_NAME"); //$NON-NLS-1$
|
|
||||||
genericLine = genericLine.replaceAll(shortFileName+"\\.", "SHORT_NAME\\."); //$NON-NLS-1$ //$NON-NLS-2$
|
|
||||||
|
|
||||||
CCommandDSC cmd = fUtil.getNewCCommandDSC(genericLine, extensionsIndex > 0);
|
// generalize occurances of the file name
|
||||||
|
StringBuffer genericLine = new StringBuffer();
|
||||||
|
for (int i = 0; i < split.length; i++) {
|
||||||
|
String token = split[i];
|
||||||
|
if (token.equals("-include") || token.equals("-imacros")) { //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
|
++i;
|
||||||
|
genericLine.append(token);
|
||||||
|
genericLine.append(' ');
|
||||||
|
}
|
||||||
|
else if (token.equals(filePath)) {
|
||||||
|
split[i] = "LONG_NAME"; //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
else if (token.startsWith(shortFileName)) {
|
||||||
|
split[i] = token.replaceFirst(shortFileName, "SHORT_NAME"); //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
genericLine.append(split[i]);
|
||||||
|
genericLine.append(' ');
|
||||||
|
}
|
||||||
|
|
||||||
|
CCommandDSC cmd = fUtil.getNewCCommandDSC(genericLine.toString(), extensionsIndex > 0);
|
||||||
if (getProject().getLocation().isPrefixOf(pFilePath)) {
|
if (getProject().getLocation().isPrefixOf(pFilePath)) {
|
||||||
List cmdList = new ArrayList();
|
List cmdList = new ArrayList();
|
||||||
cmdList.add(cmd);
|
cmdList.add(cmd);
|
||||||
|
|
Loading…
Add table
Reference in a new issue