mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-22 06:02:11 +02:00
patch from vlad
This commit is contained in:
parent
7d7a436378
commit
69bab80e56
10 changed files with 299 additions and 34 deletions
4
build/org.eclipse.cdt.make.core/.options
Normal file
4
build/org.eclipse.cdt.make.core/.options
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
org.eclipse.cdt.make.core/debug=true
|
||||||
|
|
||||||
|
# Reports scanner config discovery activity
|
||||||
|
org.eclipse.cdt.make.core/debug/scdiscovery=false
|
|
@ -29,6 +29,7 @@ import org.eclipse.cdt.make.internal.core.BuildInfoFactory;
|
||||||
import org.eclipse.cdt.make.internal.core.MakeTargetManager;
|
import org.eclipse.cdt.make.internal.core.MakeTargetManager;
|
||||||
import org.eclipse.cdt.make.internal.core.makefile.gnu.GNUMakefile;
|
import org.eclipse.cdt.make.internal.core.makefile.gnu.GNUMakefile;
|
||||||
import org.eclipse.cdt.make.internal.core.scannerconfig.ScannerConfigInfoFactory;
|
import org.eclipse.cdt.make.internal.core.scannerconfig.ScannerConfigInfoFactory;
|
||||||
|
import org.eclipse.cdt.make.internal.core.scannerconfig.util.TraceUtil;
|
||||||
import org.eclipse.core.resources.IFile;
|
import org.eclipse.core.resources.IFile;
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
import org.eclipse.core.resources.ResourcesPlugin;
|
import org.eclipse.core.resources.ResourcesPlugin;
|
||||||
|
@ -40,6 +41,7 @@ import org.eclipse.core.runtime.IPath;
|
||||||
import org.eclipse.core.runtime.IPluginDescriptor;
|
import org.eclipse.core.runtime.IPluginDescriptor;
|
||||||
import org.eclipse.core.runtime.IStatus;
|
import org.eclipse.core.runtime.IStatus;
|
||||||
import org.eclipse.core.runtime.Path;
|
import org.eclipse.core.runtime.Path;
|
||||||
|
import org.eclipse.core.runtime.Platform;
|
||||||
import org.eclipse.core.runtime.Plugin;
|
import org.eclipse.core.runtime.Plugin;
|
||||||
import org.eclipse.core.runtime.Preferences;
|
import org.eclipse.core.runtime.Preferences;
|
||||||
import org.eclipse.core.runtime.Status;
|
import org.eclipse.core.runtime.Status;
|
||||||
|
@ -318,4 +320,27 @@ public class MakeCorePlugin extends Plugin {
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.core.runtime.Plugin#startup()
|
||||||
|
*/
|
||||||
|
public void startup() throws CoreException {
|
||||||
|
super.startup();
|
||||||
|
|
||||||
|
//Set debug tracing options
|
||||||
|
configurePluginDebugOptions();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static final String SCANNER_CONFIG = MakeCorePlugin.getUniqueIdentifier() + "/debug/scdiscovery"; //$NON-NLS-1$
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private void configurePluginDebugOptions() {
|
||||||
|
if (isDebugging()) {
|
||||||
|
String option = Platform.getDebugOption(SCANNER_CONFIG);
|
||||||
|
if (option != null) {
|
||||||
|
TraceUtil.SCANNER_CONFIG = option.equalsIgnoreCase("true") ; //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,10 +10,27 @@
|
||||||
**********************************************************************/
|
**********************************************************************/
|
||||||
package org.eclipse.cdt.make.core.scannerconfig;
|
package org.eclipse.cdt.make.core.scannerconfig;
|
||||||
|
|
||||||
|
import java.io.ByteArrayOutputStream;
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
import java.io.FileOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import javax.xml.parsers.DocumentBuilder;
|
||||||
|
import javax.xml.parsers.DocumentBuilderFactory;
|
||||||
|
import javax.xml.parsers.FactoryConfigurationError;
|
||||||
|
import javax.xml.parsers.ParserConfigurationException;
|
||||||
|
import javax.xml.transform.OutputKeys;
|
||||||
|
import javax.xml.transform.Transformer;
|
||||||
|
import javax.xml.transform.TransformerConfigurationException;
|
||||||
|
import javax.xml.transform.TransformerException;
|
||||||
|
import javax.xml.transform.TransformerFactory;
|
||||||
|
import javax.xml.transform.TransformerFactoryConfigurationError;
|
||||||
|
import javax.xml.transform.dom.DOMSource;
|
||||||
|
import javax.xml.transform.stream.StreamResult;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.AbstractCExtension;
|
import org.eclipse.cdt.core.AbstractCExtension;
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
import org.eclipse.cdt.core.ICDescriptor;
|
import org.eclipse.cdt.core.ICDescriptor;
|
||||||
|
@ -28,10 +45,14 @@ import org.eclipse.cdt.make.internal.core.scannerconfig.util.SymbolEntry;
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
import org.eclipse.core.resources.IResource;
|
import org.eclipse.core.resources.IResource;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
import org.eclipse.core.runtime.IPath;
|
||||||
|
import org.eclipse.core.runtime.IStatus;
|
||||||
import org.eclipse.core.runtime.QualifiedName;
|
import org.eclipse.core.runtime.QualifiedName;
|
||||||
|
import org.eclipse.core.runtime.Status;
|
||||||
import org.w3c.dom.Document;
|
import org.w3c.dom.Document;
|
||||||
import org.w3c.dom.Element;
|
import org.w3c.dom.Element;
|
||||||
import org.w3c.dom.Node;
|
import org.w3c.dom.Node;
|
||||||
|
import org.xml.sax.SAXException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provider of both user specified and discovered scanner info
|
* Provider of both user specified and discovered scanner info
|
||||||
|
@ -124,7 +145,8 @@ public class DiscoveredScannerInfoProvider extends AbstractCExtension implements
|
||||||
private DiscoveredScannerInfo loadScannerInfo(IProject project) throws CoreException {
|
private DiscoveredScannerInfo loadScannerInfo(IProject project) throws CoreException {
|
||||||
LinkedHashMap includes = new LinkedHashMap();
|
LinkedHashMap includes = new LinkedHashMap();
|
||||||
LinkedHashMap symbols = new LinkedHashMap();
|
LinkedHashMap symbols = new LinkedHashMap();
|
||||||
loadDiscoveredScannerInfoFromCDescriptor(project, includes, symbols);
|
// loadDiscoveredScannerInfoFromCDescriptor(project, includes, symbols);
|
||||||
|
loadDiscoveredScannerInfoFromState(project, includes, symbols);
|
||||||
MakeScannerInfo userInfo = MakeScannerProvider.getDefault().loadScannerInfo(project);
|
MakeScannerInfo userInfo = MakeScannerProvider.getDefault().loadScannerInfo(project);
|
||||||
DiscoveredScannerInfo info = new DiscoveredScannerInfo(project);
|
DiscoveredScannerInfo info = new DiscoveredScannerInfo(project);
|
||||||
info.setUserScannerInfo(userInfo);
|
info.setUserScannerInfo(userInfo);
|
||||||
|
@ -143,6 +165,15 @@ public class DiscoveredScannerInfoProvider extends AbstractCExtension implements
|
||||||
private void loadDiscoveredScannerInfoFromCDescriptor(IProject project, LinkedHashMap includes, LinkedHashMap symbols) throws CoreException {
|
private void loadDiscoveredScannerInfoFromCDescriptor(IProject project, LinkedHashMap includes, LinkedHashMap symbols) throws CoreException {
|
||||||
ICDescriptor descriptor = CCorePlugin.getDefault().getCProjectDescription(project);
|
ICDescriptor descriptor = CCorePlugin.getDefault().getCProjectDescription(project);
|
||||||
Node child = descriptor.getProjectData(CDESCRIPTOR_ID).getFirstChild();
|
Node child = descriptor.getProjectData(CDESCRIPTOR_ID).getFirstChild();
|
||||||
|
loadDiscoveredScannerInfo(includes, symbols, child);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param includes
|
||||||
|
* @param symbols
|
||||||
|
* @param child
|
||||||
|
*/
|
||||||
|
private void loadDiscoveredScannerInfo(LinkedHashMap includes, LinkedHashMap symbols, Node child) {
|
||||||
while (child != null) {
|
while (child != null) {
|
||||||
if (child.getNodeName().equals(INCLUDE_PATH)) {
|
if (child.getNodeName().equals(INCLUDE_PATH)) {
|
||||||
// Add the path to the property list
|
// Add the path to the property list
|
||||||
|
@ -152,7 +183,7 @@ public class DiscoveredScannerInfoProvider extends AbstractCExtension implements
|
||||||
// Add the symbol to the symbol list
|
// Add the symbol to the symbol list
|
||||||
String symbol = ((Element)child).getAttribute(SYMBOL);
|
String symbol = ((Element)child).getAttribute(SYMBOL);
|
||||||
String removed = ((Element)child).getAttribute(REMOVED);
|
String removed = ((Element)child).getAttribute(REMOVED);
|
||||||
boolean bRemoved = (removed != null && removed == "true"); //$NON-NLS-1$
|
boolean bRemoved = (removed != null && removed.equals("true")); // $NON-NLS-1$
|
||||||
ScannerConfigUtil.scAddSymbolString2SymbolEntryMap(symbols, symbol, !bRemoved);
|
ScannerConfigUtil.scAddSymbolString2SymbolEntryMap(symbols, symbol, !bRemoved);
|
||||||
}
|
}
|
||||||
child = child.getNextSibling();
|
child = child.getNextSibling();
|
||||||
|
@ -193,7 +224,8 @@ public class DiscoveredScannerInfoProvider extends AbstractCExtension implements
|
||||||
project.setSessionProperty(scannerInfoProperty, scannerInfo);
|
project.setSessionProperty(scannerInfoProperty, scannerInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
saveDiscoveredScannerInfoToCDescriptor(scannerInfo, project);
|
// saveDiscoveredScannerInfoToCDescriptor(scannerInfo, project);
|
||||||
|
saveDiscoveredScannerInfoToState(scannerInfo, project);
|
||||||
|
|
||||||
MakeScannerProvider.updateScannerInfo(scannerInfo.getUserScannerInfo());
|
MakeScannerProvider.updateScannerInfo(scannerInfo.getUserScannerInfo());
|
||||||
// listeners are notified by MakeScannerProvider.updateScannerInfo
|
// listeners are notified by MakeScannerProvider.updateScannerInfo
|
||||||
|
@ -218,11 +250,20 @@ public class DiscoveredScannerInfoProvider extends AbstractCExtension implements
|
||||||
rootElement.removeChild(child);
|
rootElement.removeChild(child);
|
||||||
child = rootElement.getFirstChild();
|
child = rootElement.getFirstChild();
|
||||||
}
|
}
|
||||||
|
Document doc = rootElement.getOwnerDocument();
|
||||||
|
|
||||||
|
saveDiscoveredScannerInfo(scannerInfo, rootElement, doc);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param scannerInfo
|
||||||
|
* @param rootElement
|
||||||
|
* @param doc
|
||||||
|
*/
|
||||||
|
private static void saveDiscoveredScannerInfo(DiscoveredScannerInfo scannerInfo, Element rootElement, Document doc) {
|
||||||
// Save the build info
|
// Save the build info
|
||||||
if (scannerInfo != null) {
|
if (scannerInfo != null) {
|
||||||
// Serialize the include paths
|
// Serialize the include paths
|
||||||
Document doc = rootElement.getOwnerDocument();
|
|
||||||
Map discoveredIncludes = scannerInfo.getDiscoveredIncludePaths();
|
Map discoveredIncludes = scannerInfo.getDiscoveredIncludePaths();
|
||||||
Iterator iter = discoveredIncludes.keySet().iterator();
|
Iterator iter = discoveredIncludes.keySet().iterator();
|
||||||
while (iter.hasNext()) {
|
while (iter.hasNext()) {
|
||||||
|
@ -259,4 +300,87 @@ public class DiscoveredScannerInfoProvider extends AbstractCExtension implements
|
||||||
// descriptor.saveProjectData();
|
// descriptor.saveProjectData();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void loadDiscoveredScannerInfoFromState(IProject project, LinkedHashMap includes, LinkedHashMap symbols) throws CoreException {
|
||||||
|
// Save the document
|
||||||
|
IPath path = MakeCorePlugin.getWorkingDirectory();
|
||||||
|
path = path.append(project.getName() + ".sc");
|
||||||
|
if (path.toFile().exists()) {
|
||||||
|
try {
|
||||||
|
FileInputStream file = new FileInputStream(path.toFile());
|
||||||
|
DocumentBuilder parser = DocumentBuilderFactory.newInstance().newDocumentBuilder();
|
||||||
|
Document document = parser.parse(file);
|
||||||
|
Node rootElement = document.getFirstChild();
|
||||||
|
if (rootElement.getNodeName().equals("scannerInfo")) {
|
||||||
|
Node child = rootElement.getFirstChild();
|
||||||
|
loadDiscoveredScannerInfo(includes, symbols, child);
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new CoreException(new Status(IStatus.ERROR,
|
||||||
|
MakeCorePlugin.getUniqueIdentifier(), -1,
|
||||||
|
MakeCorePlugin.getResourceString("GCCScannerConfigUtil.Error_Message"), e)); //$NON-NLS-1$
|
||||||
|
} catch (ParserConfigurationException e) {
|
||||||
|
MakeCorePlugin.log(e);
|
||||||
|
} catch (FactoryConfigurationError e) {
|
||||||
|
MakeCorePlugin.log(e);
|
||||||
|
} catch (SAXException e) {
|
||||||
|
MakeCorePlugin.log(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void saveDiscoveredScannerInfoToState(DiscoveredScannerInfo scannerInfo, IProject project) throws CoreException {
|
||||||
|
// Create document
|
||||||
|
try {
|
||||||
|
DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
|
||||||
|
Document doc = builder.newDocument();
|
||||||
|
Element rootElement = doc.createElement("scannerInfo");
|
||||||
|
rootElement.setAttribute("id", CDESCRIPTOR_ID);
|
||||||
|
doc.appendChild(rootElement);
|
||||||
|
|
||||||
|
saveDiscoveredScannerInfo(scannerInfo, rootElement, doc);
|
||||||
|
|
||||||
|
// Transform the document to something we can save in a file
|
||||||
|
ByteArrayOutputStream stream = new ByteArrayOutputStream();
|
||||||
|
Transformer transformer = TransformerFactory.newInstance().newTransformer();
|
||||||
|
transformer.setOutputProperty(OutputKeys.METHOD, "xml"); //$NON-NLS-1$
|
||||||
|
transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8"); //$NON-NLS-1$
|
||||||
|
transformer.setOutputProperty(OutputKeys.INDENT, "yes"); //$NON-NLS-1$
|
||||||
|
DOMSource source = new DOMSource(doc);
|
||||||
|
StreamResult result = new StreamResult(stream);
|
||||||
|
transformer.transform(source, result);
|
||||||
|
|
||||||
|
// Save the document
|
||||||
|
IPath path = MakeCorePlugin.getWorkingDirectory();
|
||||||
|
path = path.append(project.getName() + ".sc");
|
||||||
|
try {
|
||||||
|
FileOutputStream file = new FileOutputStream(path.toFile());
|
||||||
|
file.write(stream.toByteArray());
|
||||||
|
file.close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new CoreException(new Status(IStatus.ERROR,
|
||||||
|
MakeCorePlugin.getUniqueIdentifier(), -1,
|
||||||
|
MakeCorePlugin.getResourceString("GCCScannerConfigUtil.Error_Message"), e)); //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
|
||||||
|
// Close the streams
|
||||||
|
stream.close();
|
||||||
|
} catch (ParserConfigurationException e) {
|
||||||
|
MakeCorePlugin.log(e);
|
||||||
|
} catch (FactoryConfigurationError e) {
|
||||||
|
MakeCorePlugin.log(e);
|
||||||
|
} catch (TransformerConfigurationException e) {
|
||||||
|
MakeCorePlugin.log(e);
|
||||||
|
} catch (TransformerFactoryConfigurationError e) {
|
||||||
|
MakeCorePlugin.log(e);
|
||||||
|
} catch (TransformerException e) {
|
||||||
|
MakeCorePlugin.log(e);
|
||||||
|
} catch (IOException e) {
|
||||||
|
MakeCorePlugin.log(e);
|
||||||
|
} catch (CoreException e) {
|
||||||
|
// Save to IFile failed
|
||||||
|
MakeCorePlugin.log(e.getStatus());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -36,10 +36,23 @@ public class ScannerConfigBuilder extends ACBuilder {
|
||||||
* @see IncrementalProjectBuilder#build
|
* @see IncrementalProjectBuilder#build
|
||||||
*/
|
*/
|
||||||
protected IProject [] build(int kind, Map args, IProgressMonitor monitor) throws CoreException {
|
protected IProject [] build(int kind, Map args, IProgressMonitor monitor) throws CoreException {
|
||||||
monitor.beginTask("", 100); //$NON-NLS-1$
|
// If auto discovery is disabled, do nothing
|
||||||
monitor.subTask(MakeCorePlugin.getResourceString("ScannerConfigBuilder.Invoking_Builder") + //$NON-NLS-1$
|
boolean autodiscoveryEnabled;
|
||||||
getProject().getName());
|
try {
|
||||||
ScannerInfoCollector.getInstance().updateScannerConfiguration(getProject(), new SubProgressMonitor(monitor, 100));
|
IScannerConfigBuilderInfo buildInfo = MakeCorePlugin.createScannerConfigBuildInfo(getProject(), BUILDER_ID);
|
||||||
|
autodiscoveryEnabled = buildInfo.isAutoDiscoveryEnabled();
|
||||||
|
}
|
||||||
|
catch (CoreException e) {
|
||||||
|
// builder not installed or disabled
|
||||||
|
autodiscoveryEnabled = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (autodiscoveryEnabled) {
|
||||||
|
monitor.beginTask("ScannerConfigBuilder.Invoking_Builder", 100); //$NON-NLS-1$
|
||||||
|
monitor.subTask(MakeCorePlugin.getResourceString("ScannerConfigBuilder.Invoking_Builder") + //$NON-NLS-1$
|
||||||
|
getProject().getName());
|
||||||
|
ScannerInfoCollector.getInstance().updateScannerConfiguration(getProject(), new SubProgressMonitor(monitor, 100));
|
||||||
|
}
|
||||||
return getProject().getReferencedProjects();
|
return getProject().getReferencedProjects();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,8 +75,15 @@ public class ScannerInfoConsoleParserFactory {
|
||||||
try {
|
try {
|
||||||
// get the SC builder settings
|
// get the SC builder settings
|
||||||
if (currentProject.hasNature(ScannerConfigNature.NATURE_ID)) {
|
if (currentProject.hasNature(ScannerConfigNature.NATURE_ID)) {
|
||||||
IScannerConfigBuilderInfo scBuildInfo = MakeCorePlugin.
|
IScannerConfigBuilderInfo scBuildInfo;
|
||||||
createScannerConfigBuildInfo(currentProject, ScannerConfigBuilder.BUILDER_ID);
|
try {
|
||||||
|
scBuildInfo = MakeCorePlugin.
|
||||||
|
createScannerConfigBuildInfo(currentProject, ScannerConfigBuilder.BUILDER_ID);
|
||||||
|
}
|
||||||
|
catch (CoreException e) {
|
||||||
|
// builder not installed or disabled
|
||||||
|
scBuildInfo = null;
|
||||||
|
}
|
||||||
if (scBuildInfo != null && scBuildInfo.isMakeBuilderConsoleParserEnabled()) {
|
if (scBuildInfo != null && scBuildInfo.isMakeBuilderConsoleParserEnabled()) {
|
||||||
// get the make builder console parser
|
// get the make builder console parser
|
||||||
IScannerInfoConsoleParser clParser = MakeCorePlugin.getDefault().
|
IScannerInfoConsoleParser clParser = MakeCorePlugin.getDefault().
|
||||||
|
|
|
@ -14,7 +14,6 @@ import java.util.StringTokenizer;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.CCProjectNature;
|
import org.eclipse.cdt.core.CCProjectNature;
|
||||||
import org.eclipse.cdt.core.CProjectNature;
|
import org.eclipse.cdt.core.CProjectNature;
|
||||||
import org.eclipse.cdt.core.IMarkerGenerator;
|
|
||||||
import org.eclipse.core.resources.IFile;
|
import org.eclipse.core.resources.IFile;
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
@ -23,9 +22,9 @@ import org.eclipse.cdt.make.core.MakeCorePlugin;
|
||||||
import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoConsoleParser;
|
import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoConsoleParser;
|
||||||
import org.eclipse.cdt.make.internal.core.scannerconfig.IScannerInfoConsoleParserUtility;
|
import org.eclipse.cdt.make.internal.core.scannerconfig.IScannerInfoConsoleParserUtility;
|
||||||
import org.eclipse.cdt.make.internal.core.scannerconfig.ScannerInfoCollector;
|
import org.eclipse.cdt.make.internal.core.scannerconfig.ScannerInfoCollector;
|
||||||
|
import org.eclipse.cdt.make.internal.core.scannerconfig.util.TraceUtil;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -105,16 +104,31 @@ public class GCCScannerInfoConsoleParser implements IScannerInfoConsoleParser {
|
||||||
|
|
||||||
rc = true;
|
rc = true;
|
||||||
String fileName = null;
|
String fileName = null;
|
||||||
String desc = "Found";
|
|
||||||
while (scanner.hasMoreTokens()) {
|
while (scanner.hasMoreTokens()) {
|
||||||
token = scanner.nextToken();
|
token = scanner.nextToken();
|
||||||
if (token.startsWith("-D")) {//$NON-NLS-1$
|
if (token.startsWith("-D")) {//$NON-NLS-1$
|
||||||
String symbol = token.substring(2);
|
String symbol = token.substring(2);
|
||||||
|
if (symbol.length() == 0) {
|
||||||
|
if (scanner.hasMoreTokens()) {
|
||||||
|
symbol = scanner.nextToken();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
if (!symbols.contains(symbol))
|
if (!symbols.contains(symbol))
|
||||||
symbols.add(symbol);
|
symbols.add(symbol);
|
||||||
}
|
}
|
||||||
else if (token.startsWith("-I")) {//$NON-NLS-1$
|
else if (token.startsWith("-I")) {//$NON-NLS-1$
|
||||||
String iPath = token.substring(2);
|
String iPath = token.substring(2);
|
||||||
|
if (iPath.length() == 0) {
|
||||||
|
if (scanner.hasMoreTokens()) {
|
||||||
|
iPath = scanner.nextToken();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
String nPath = fUtil.normalizePath(iPath);
|
String nPath = fUtil.normalizePath(iPath);
|
||||||
if (!includes.contains(nPath))
|
if (!includes.contains(nPath))
|
||||||
includes.add(nPath);
|
includes.add(nPath);
|
||||||
|
@ -146,35 +160,29 @@ public class GCCScannerInfoConsoleParser implements IScannerInfoConsoleParser {
|
||||||
|
|
||||||
IProject project = fProject;
|
IProject project = fProject;
|
||||||
IFile file = null;
|
IFile file = null;
|
||||||
|
List translatedIncludes = includes;
|
||||||
if (includes.size() > 0) {
|
if (includes.size() > 0) {
|
||||||
if (fileName != null) {
|
if (fileName != null) {
|
||||||
file = fUtil.findFile(fileName);
|
file = fUtil.findFile(fileName);
|
||||||
if (file != null) {
|
if (file != null) {
|
||||||
project = file.getProject();
|
project = file.getProject();
|
||||||
includes = fUtil.translateRelativePaths(file, fileName, includes);
|
translatedIncludes = fUtil.translateRelativePaths(file, fileName, includes);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
fUtil.generateMarker(fProject, -1, "Unable to find file name: " + line,
|
TraceUtil.outputError("Unable to find file name: ", line); //$NON-NLS-1$
|
||||||
IMarkerGenerator.SEVERITY_ERROR_RESOURCE, null);
|
// fUtil.generateMarker(fProject, -1, "Unable to find file name: " + line, //$NON-NLS-1$
|
||||||
|
// IMarkerGenerator.SEVERITY_ERROR_RESOURCE, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Contribute discovered includes and symbols to the ScannerInfoCollector
|
// Contribute discovered includes and symbols to the ScannerInfoCollector
|
||||||
ScannerInfoCollector.getInstance().
|
if (translatedIncludes.size() > 0 || symbols.size() > 0) {
|
||||||
contributeToScannerConfig(project, includes, symbols, targetSpecificOptions);
|
ScannerInfoCollector.getInstance().
|
||||||
|
contributeToScannerConfig(project, translatedIncludes, symbols, targetSpecificOptions);
|
||||||
|
|
||||||
// TODO : VMIR remove when debugging is done
|
TraceUtil.outputTrace("Discovered scanner info for file \'" + fileName + '\'', //$NON-NLS-1$
|
||||||
int severity = IMarkerGenerator.SEVERITY_INFO;
|
"Include paths", includes, translatedIncludes, "Defined symbols", symbols); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
|
|
||||||
for (Iterator i = includes.iterator(); i.hasNext(); ) {
|
|
||||||
String iPath = (String)i.next();
|
|
||||||
fUtil.generateMarker(file, -1, "Found an include path: "+iPath, severity, iPath);
|
|
||||||
}
|
}
|
||||||
for (Iterator i = symbols.iterator(); i.hasNext(); ) {
|
|
||||||
String symbol = (String)i.next();
|
|
||||||
fUtil.generateMarker(file, -1, "Found a symbol definition: "+symbol, severity, symbol);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,6 +17,7 @@ import java.util.StringTokenizer;
|
||||||
import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoConsoleParser;
|
import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoConsoleParser;
|
||||||
import org.eclipse.cdt.make.internal.core.scannerconfig.IScannerInfoConsoleParserUtility;
|
import org.eclipse.cdt.make.internal.core.scannerconfig.IScannerInfoConsoleParserUtility;
|
||||||
import org.eclipse.cdt.make.internal.core.scannerconfig.ScannerInfoCollector;
|
import org.eclipse.cdt.make.internal.core.scannerconfig.ScannerInfoCollector;
|
||||||
|
import org.eclipse.cdt.make.internal.core.scannerconfig.util.TraceUtil;
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -94,6 +95,8 @@ public class GCCSpecsConsoleParser implements IScannerInfoConsoleParser {
|
||||||
}
|
}
|
||||||
|
|
||||||
ScannerInfoCollector.getInstance().contributeToScannerConfig(project, includes, symbols, null);
|
ScannerInfoCollector.getInstance().contributeToScannerConfig(project, includes, symbols, null);
|
||||||
|
TraceUtil.outputTrace("Scanner info from \'specs\' file", //$NON-NLS-1$
|
||||||
|
"Include paths", includes, new ArrayList(), "Defined symbols", symbols); //$NON-NLS-1$ //$NON-NLS-2$);
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,76 @@
|
||||||
|
/**********************************************************************
|
||||||
|
* Copyright (c) 2004 IBM Corporation and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Common Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/cpl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* IBM - Initial API and implementation
|
||||||
|
**********************************************************************/
|
||||||
|
package org.eclipse.cdt.make.internal.core.scannerconfig.util;
|
||||||
|
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tracebility related utility functions
|
||||||
|
*
|
||||||
|
* @author vhirsl
|
||||||
|
*/
|
||||||
|
public class TraceUtil {
|
||||||
|
public static boolean SCANNER_CONFIG = false;
|
||||||
|
|
||||||
|
public static boolean isTracing() {
|
||||||
|
return SCANNER_CONFIG;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void outputTrace(String prefix, String msg, String postfix) {
|
||||||
|
System.out.println(prefix + ' ' + msg + ' ' + postfix);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* For traces of type:
|
||||||
|
* Title:
|
||||||
|
* Subtitle1:
|
||||||
|
* item1[0]
|
||||||
|
* item1[1]
|
||||||
|
* ...
|
||||||
|
* Subtitle2:
|
||||||
|
* item2[0]
|
||||||
|
* item2[1]
|
||||||
|
* ...
|
||||||
|
* @param title
|
||||||
|
* @param col1
|
||||||
|
* @param col2
|
||||||
|
*/
|
||||||
|
public static void outputTrace(String title, String subtitle1, List item1, List item1new, String subtitle2, List item2) {
|
||||||
|
if (isTracing()) {
|
||||||
|
System.out.println();
|
||||||
|
System.out.println(title);
|
||||||
|
final String prefix = " "; //$NON-NLS-1$
|
||||||
|
final String doublePrefix = " "; //$NON-NLS-1$
|
||||||
|
System.out.println(prefix + subtitle1 + " (" + item1.size() + "):"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
|
int count = 0;
|
||||||
|
for (Iterator i = item1.iterator(), j = item1new.iterator(); i.hasNext(); ) {
|
||||||
|
System.out.println(doublePrefix + String.valueOf(++count) + "\t\'" +(String)i.next() + (j.hasNext()?"\' -> \'" + (String)j.next():"") + '\''); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
|
}
|
||||||
|
System.out.println(prefix + subtitle2 + " (" + item2.size() + "):"); //$NON-NLS-1$
|
||||||
|
count = 0;
|
||||||
|
for (Iterator i = item2.iterator(); i.hasNext(); ) {
|
||||||
|
System.out.println(doublePrefix + String.valueOf(++count) + "\t\'" + (String)i.next() + '\''); //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string
|
||||||
|
* @param line
|
||||||
|
*/
|
||||||
|
public static void outputError(String string, String line) {
|
||||||
|
if (isTracing()) {
|
||||||
|
System.out.println();
|
||||||
|
System.out.println("Error: " + string + line); //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -228,7 +228,12 @@ public class BuildPathInfoBlock extends AbstractCOptionPage {
|
||||||
}
|
}
|
||||||
// First store scanner config options
|
// First store scanner config options
|
||||||
if (scOptionsDialog.isInitialized()) {
|
if (scOptionsDialog.isInitialized()) {
|
||||||
scOptionsDialog.performApply(monitor);
|
try {
|
||||||
|
scOptionsDialog.performApply(monitor);
|
||||||
|
}
|
||||||
|
catch (CoreException e) {
|
||||||
|
// builder was disabled while scOptionsDialog was initialized
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
IProject project = getContainer().getProject();
|
IProject project = getContainer().getProject();
|
||||||
|
|
|
@ -202,7 +202,7 @@ public class ScannerConfigOptionsDialog extends Dialog {
|
||||||
fInfo = MakeCorePlugin.createScannerConfigBuildInfo(project, ScannerConfigBuilder.BUILDER_ID);
|
fInfo = MakeCorePlugin.createScannerConfigBuildInfo(project, ScannerConfigBuilder.BUILDER_ID);
|
||||||
}
|
}
|
||||||
catch (CoreException e) {
|
catch (CoreException e) {
|
||||||
// fInitialized = false;
|
fInitialized = false;
|
||||||
fInfo = MakeCorePlugin.createScannerConfigBuildInfo(fPrefs, ScannerConfigBuilder.BUILDER_ID, true);
|
fInfo = MakeCorePlugin.createScannerConfigBuildInfo(fPrefs, ScannerConfigBuilder.BUILDER_ID, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue