1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Fix for 101156: Scanner Info Discovery support needs to allow specification of compiler command.

New attribute is added to scannerInfoConsoleParser element in ScannerConfigurationDiscoveryProfile extension point schema. No public API has been changed.
This commit is contained in:
Vladimir Hirsl 2005-06-24 19:37:26 +00:00
parent 14c4a4fb50
commit e5baf66734
7 changed files with 67 additions and 13 deletions

View file

@ -100,6 +100,15 @@
</appInfo> </appInfo>
</annotation> </annotation>
</attribute> </attribute>
<attribute name="compilerCommands" type="string">
<annotation>
<documentation>
Comma separated list of compiler commands to use for detecting lines with preprocessor options.
Example: &quot;gcc, g++, cc, c++&quot;
</documentation>
</annotation>
</attribute>
</complexType> </complexType>
</element> </element>

View file

@ -13,6 +13,9 @@ package org.eclipse.cdt.make.internal.core.scannerconfig.gnu;
import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector; import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector;
import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoConsoleParser; import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoConsoleParser;
import org.eclipse.cdt.make.internal.core.scannerconfig.util.TraceUtil; import org.eclipse.cdt.make.internal.core.scannerconfig.util.TraceUtil;
import org.eclipse.cdt.make.internal.core.scannerconfig2.SCProfileInstance;
import org.eclipse.cdt.make.internal.core.scannerconfig2.ScannerConfigProfileManager;
import org.eclipse.cdt.make.internal.core.scannerconfig2.ScannerConfigProfile.BuildOutputProvider;
import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProject;
/** /**
@ -21,6 +24,10 @@ import org.eclipse.core.resources.IProject;
* @author vhirsl * @author vhirsl
*/ */
public abstract class AbstractGCCBOPConsoleParser implements IScannerInfoConsoleParser { public abstract class AbstractGCCBOPConsoleParser implements IScannerInfoConsoleParser {
private static final String[] COMPILER_INVOCATION = {
"gcc", "g++", "cc", "c++" //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
};
private IProject project; private IProject project;
private IScannerInfoCollector collector; private IScannerInfoCollector collector;
@ -45,6 +52,30 @@ public abstract class AbstractGCCBOPConsoleParser implements IScannerInfoConsole
this.collector = collector; this.collector = collector;
} }
/**
* Returns array of additional compiler commands to look for
*
* @return String[]
*/
public String[] getCompilerCommands() {
SCProfileInstance profileInstance = ScannerConfigProfileManager.getInstance().
getSCProfileInstance(project, ScannerConfigProfileManager.NULL_PROFILE_ID);
BuildOutputProvider boProvider = profileInstance.getProfile().getBuildOutputProviderElement();
if (boProvider != null) {
String compilerCommandsString = boProvider.getScannerInfoConsoleParser().getCompilerCommands();
if (compilerCommandsString != null && compilerCommandsString.length() > 0) {
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);
System.arraycopy(compilerCommands, 0, compilerInvocation, COMPILER_INVOCATION.length, compilerCommands.length);
return compilerInvocation;
}
}
}
return COMPILER_INVOCATION;
}
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.make.core.scannerconfig.IScannerInfoConsoleParser#processLine(java.lang.String) * @see org.eclipse.cdt.make.core.scannerconfig.IScannerInfoConsoleParser#processLine(java.lang.String)
*/ */

View file

@ -35,11 +35,9 @@ public class GCCPerFileBOPConsoleParser extends AbstractGCCBOPConsoleParser {
private final static String[] FILE_EXTENSIONS = { private final static String[] FILE_EXTENSIONS = {
".c", ".cc", ".cpp", ".cxx", ".C", ".CC", ".CPP", ".CXX" //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ ".c", ".cc", ".cpp", ".cxx", ".C", ".CC", ".CPP", ".CXX" //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$
}; };
private final static String[] COMPILER_INVOCATION = {
"gcc", "g++", "cc", "c++" //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
};
private final static List FILE_EXTENSIONS_LIST = Arrays.asList(FILE_EXTENSIONS); private final static List FILE_EXTENSIONS_LIST = Arrays.asList(FILE_EXTENSIONS);
private String[] compilerInvocation;
private GCCPerFileBOPConsoleParserUtility fUtil; private GCCPerFileBOPConsoleParserUtility fUtil;
/* (non-Javadoc) /* (non-Javadoc)
@ -49,6 +47,9 @@ public class GCCPerFileBOPConsoleParser extends AbstractGCCBOPConsoleParser {
fUtil = (project != null && workingDirectory != null && markerGenerator != null) ? fUtil = (project != null && workingDirectory != null && markerGenerator != null) ?
new GCCPerFileBOPConsoleParserUtility(project, workingDirectory, markerGenerator) : null; new GCCPerFileBOPConsoleParserUtility(project, workingDirectory, markerGenerator) : null;
super.startup(project, collector); super.startup(project, collector);
// check additional compiler commands from extension point manifest
compilerInvocation = getCompilerCommands();
} }
/* (non-Javadoc) /* (non-Javadoc)
@ -65,8 +66,8 @@ public class GCCPerFileBOPConsoleParser extends AbstractGCCBOPConsoleParser {
boolean rc = false; boolean rc = false;
// GCC C/C++ compiler invocation // GCC C/C++ compiler invocation
int compilerInvocationIndex = -1; int compilerInvocationIndex = -1;
for (int cii = 0; cii < COMPILER_INVOCATION.length; ++cii) { for (int cii = 0; cii < compilerInvocation.length; ++cii) {
compilerInvocationIndex = line.indexOf(COMPILER_INVOCATION[cii]); compilerInvocationIndex = line.indexOf(compilerInvocation[cii]);
if (compilerInvocationIndex != -1) if (compilerInvocationIndex != -1)
break; break;
} }
@ -78,8 +79,8 @@ public class GCCPerFileBOPConsoleParser extends AbstractGCCBOPConsoleParser {
String command = split[0]; String command = split[0];
// verify that it is compiler invocation // verify that it is compiler invocation
int cii2 = -1; int cii2 = -1;
for (int cii = 0; cii < COMPILER_INVOCATION.length; ++cii) { for (int cii = 0; cii < compilerInvocation.length; ++cii) {
cii2 = command.indexOf(COMPILER_INVOCATION[cii]); cii2 = command.indexOf(compilerInvocation[cii]);
if (cii2 != -1) if (cii2 != -1)
break; break;
} }

View file

@ -36,7 +36,9 @@ public class GCCScannerInfoConsoleParser extends AbstractGCCBOPConsoleParser {
private final static String DOUBLE_QUOTE_STRING = "\""; //$NON-NLS-1$ private final static String DOUBLE_QUOTE_STRING = "\""; //$NON-NLS-1$
private final static char[] matchingChars = {'`', '\'', '\"'}; private final static char[] matchingChars = {'`', '\'', '\"'};
private ScannerInfoConsoleParserUtility fUtil = null; private String[] compilerInvocation;
private ScannerInfoConsoleParserUtility fUtil = null;
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.make.core.scannerconfig.IScannerInfoConsoleParser#startup(org.eclipse.core.resources.IProject, org.eclipse.core.runtime.IPath, org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector, org.eclipse.cdt.core.IMarkerGenerator) * @see org.eclipse.cdt.make.core.scannerconfig.IScannerInfoConsoleParser#startup(org.eclipse.core.resources.IProject, org.eclipse.core.runtime.IPath, org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector, org.eclipse.cdt.core.IMarkerGenerator)
@ -45,6 +47,9 @@ public class GCCScannerInfoConsoleParser extends AbstractGCCBOPConsoleParser {
fUtil = (project != null && workingDirectory != null && markerGenerator != null) ? fUtil = (project != null && workingDirectory != null && markerGenerator != null) ?
new ScannerInfoConsoleParserUtility(project, workingDirectory, markerGenerator) : null; new ScannerInfoConsoleParserUtility(project, workingDirectory, markerGenerator) : null;
super.startup(project, collector); super.startup(project, collector);
// check additional compiler commands from extension point manifest
compilerInvocation = getCompilerCommands();
} }
/* (non-Javadoc) /* (non-Javadoc)
@ -67,7 +72,15 @@ public class GCCScannerInfoConsoleParser extends AbstractGCCBOPConsoleParser {
return false; return false;
Iterator I = allTokens.iterator(); Iterator I = allTokens.iterator();
String token = ((String) I.next()).toLowerCase(); String token = ((String) I.next()).toLowerCase();
if (token.indexOf("gcc") != -1 || token.indexOf("g++") != -1) {//$NON-NLS-1$ //$NON-NLS-2$
boolean found = false;
for (int i = 0; i < compilerInvocation.length; i++) {
if (token.indexOf(compilerInvocation[i]) != -1) {
found = true;
break;
}
}
if (found) {
// Recognized gcc or g++ compiler invocation // Recognized gcc or g++ compiler invocation
List includes = new ArrayList(); List includes = new ArrayList();
List symbols = new ArrayList(); List symbols = new ArrayList();

View file

@ -48,7 +48,7 @@ public class SCProfileInstance {
collector = createScannerInfoCollector(); collector = createScannerInfoCollector();
if (collector != null) { if (collector != null) {
// call collector.setProject(project) if class supports it // call collector.setProject(project) if class supports it
Class clazz = (Class) collector.getClass(); Class clazz = collector.getClass();
try { try {
Method setProjectMethod = clazz.getMethod("setProject", new Class[] {IProject.class});//$NON-NLS-1$ Method setProjectMethod = clazz.getMethod("setProject", new Class[] {IProject.class});//$NON-NLS-1$
setProjectMethod.invoke(collector, new Object[] {project}); setProjectMethod.invoke(collector, new Object[] {project});

View file

@ -75,6 +75,9 @@ public class ScannerConfigProfile {
return null; return null;
} }
} }
public String getCompilerCommands() {
return configElem.getAttribute("compilerCommands"); //$NON-NLS-1$
}
} }
/** /**
* tag interface, a placeholder for either run or open element * tag interface, a placeholder for either run or open element
@ -242,12 +245,10 @@ public class ScannerConfigProfile {
* loads the profile from the manifest file. * loads the profile from the manifest file.
*/ */
private void load() { private void load() {
String[] empty = new String[0];
IExtensionPoint extension = Platform.getExtensionRegistry(). IExtensionPoint extension = Platform.getExtensionRegistry().
getExtensionPoint(MakeCorePlugin.PLUGIN_ID, ScannerConfigProfileManager.SI_PROFILE_SIMPLE_ID); getExtensionPoint(MakeCorePlugin.PLUGIN_ID, ScannerConfigProfileManager.SI_PROFILE_SIMPLE_ID);
if (extension != null) { if (extension != null) {
IExtension[] extensions = extension.getExtensions(); IExtension[] extensions = extension.getExtensions();
List rProfileIds = new ArrayList(extensions.length);
for (int i = 0; i < extensions.length; ++i) { for (int i = 0; i < extensions.length; ++i) {
String rProfileId = extensions[i].getUniqueIdentifier(); String rProfileId = extensions[i].getUniqueIdentifier();
if (rProfileId != null && rProfileId.equals(getId())) { if (rProfileId != null && rProfileId.equals(getId())) {

View file

@ -126,7 +126,6 @@ public class ScannerConfigProfileManager {
getExtensionPoint(MakeCorePlugin.PLUGIN_ID, ScannerConfigProfileManager.SI_PROFILE_SIMPLE_ID); getExtensionPoint(MakeCorePlugin.PLUGIN_ID, ScannerConfigProfileManager.SI_PROFILE_SIMPLE_ID);
if (extension != null) { if (extension != null) {
IExtension[] extensions = extension.getExtensions(); IExtension[] extensions = extension.getExtensions();
List rProfileIds = new ArrayList(extensions.length);
for (int i = 0; i < extensions.length; ++i) { for (int i = 0; i < extensions.length; ++i) {
String rProfileId = extensions[i].getUniqueIdentifier(); String rProfileId = extensions[i].getUniqueIdentifier();
profileIds.add(rProfileId); profileIds.add(rProfileId);