From a7ad0b285dfa703e4ab8f06ed83cfd062c2c5fb8 Mon Sep 17 00:00:00 2001 From: Sean Evoy Date: Fri, 7 May 2004 18:55:24 +0000 Subject: [PATCH] Adding the capability of dynamically discovering the built-in compiler paths and symbols and storing them in a PathContainer. The UI has been modified to allw users to turn off indexing for a managed project --- .../plugin.xml | 2 + .../core/tests/ManagedBuildCoreTests.java | 4 +- .../plugin.xml | 1 + .../schema/ManagedBuildTools.exsd | 10 + .../managedbuilder/core/IConfiguration.java | 25 +- .../core/ManagedBuildManager.java | 35 +- .../core/ManagedBuilderCorePlugin.java | 38 ++ .../internal/core/Configuration.java | 37 ++ .../internal/core/ManagedBuildInfo.java | 200 +++++----- .../DefaultCygwinScannerInfoCollector.java | 64 ++++ .../DefaultGCCScannerInfoCollector.java | 95 +++++ .../DefaultMinGWScannerInfoCollector.java | 70 ++++ .../ManagedBuildCPathEntryContainer.java | 242 ++++++++++++ .../IManagedScannerInfoCollector.java | 52 +++ .../ManagedBuildCPathEntryContainer.java | 78 ---- .../plugin.xml | 343 +++++++++--------- .../ui/properties/FileListControl.java | 7 +- .../wizards/NewManagedProjectOptionPage.java | 9 +- 18 files changed, 938 insertions(+), 374 deletions(-) create mode 100644 build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/scannerconfig/DefaultCygwinScannerInfoCollector.java create mode 100644 build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/scannerconfig/DefaultGCCScannerInfoCollector.java create mode 100644 build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/scannerconfig/DefaultMinGWScannerInfoCollector.java create mode 100644 build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/scannerconfig/ManagedBuildCPathEntryContainer.java create mode 100644 build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/scannerconfig/IManagedScannerInfoCollector.java delete mode 100644 build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/scannerconfig/ManagedBuildCPathEntryContainer.java diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/plugin.xml b/build/org.eclipse.cdt.managedbuilder.core.tests/plugin.xml index 485f300db43..a528162d19d 100644 --- a/build/org.eclipse.cdt.managedbuilder.core.tests/plugin.xml +++ b/build/org.eclipse.cdt.managedbuilder.core.tests/plugin.xml @@ -1,10 +1,12 @@ + + diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuild/core/tests/ManagedBuildCoreTests.java b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuild/core/tests/ManagedBuildCoreTests.java index 51ce76b1a56..39d4c757301 100644 --- a/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuild/core/tests/ManagedBuildCoreTests.java +++ b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuild/core/tests/ManagedBuildCoreTests.java @@ -239,8 +239,8 @@ public class ManagedBuildCoreTests extends TestCase { buildInfo.setDefaultConfiguration(newTarget.getConfiguration(configs[0].getId())); // Save the build info - ManagedBuildManager.saveBuildInfo(project, false); - + ManagedBuildManager.saveBuildInfo(project, false); + // Use the plugin mechanism to discover the supplier of the path information IExtensionPoint extensionPoint = CCorePlugin.getDefault().getDescriptor().getExtensionPoint("ScannerInfoProvider"); if (extensionPoint == null) { diff --git a/build/org.eclipse.cdt.managedbuilder.core/plugin.xml b/build/org.eclipse.cdt.managedbuilder.core/plugin.xml index 6bfcd2b842b..9b8054bc0af 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/plugin.xml +++ b/build/org.eclipse.cdt.managedbuilder.core/plugin.xml @@ -16,6 +16,7 @@ + diff --git a/build/org.eclipse.cdt.managedbuilder.core/schema/ManagedBuildTools.exsd b/build/org.eclipse.cdt.managedbuilder.core/schema/ManagedBuildTools.exsd index a08dd4b3ee9..b7612d3ceb0 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/schema/ManagedBuildTools.exsd +++ b/build/org.eclipse.cdt.managedbuilder.core/schema/ManagedBuildTools.exsd @@ -493,6 +493,16 @@ Additional special types exist to flag options of special relevance to the build + + + + + + + + + + diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IConfiguration.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IConfiguration.java index 417cf56eb85..1b38abfc526 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IConfiguration.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IConfiguration.java @@ -10,6 +10,7 @@ **********************************************************************/ package org.eclipse.cdt.managedbuilder.core; +import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; public interface IConfiguration extends IBuildObject { @@ -19,11 +20,15 @@ public interface IConfiguration extends IBuildObject { public static final String PARENT = "parent"; //$NON-NLS-1$ /** - * Returns the target for this configuration. + * Projects have C or CC natures. Tools can specify a filter so they are not + * misapplied to a project. This method allows the caller to retrieve a list + * of tools from a project that are correct for a project's nature. * - * @return + * @param project the project to filter for + * @return an array of ITools that have compatible filters + * for the specified project */ - public ITarget getTarget(); + ITool[] getFilteredTools(IProject project); /** * Returns the resource that owns the target that owns the configuration. @@ -38,6 +43,20 @@ public interface IConfiguration extends IBuildObject { */ public IConfiguration getParent(); + /** + * Returns the target for this configuration. + * + * @return + */ + public ITarget getTarget(); + + /** + * Answers the ITool in the receiver with the same + * id as the argument, or null. + * + * @param id unique identifier to search for + * @return + */ public ITool getToolById(String id); /** diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ManagedBuildManager.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ManagedBuildManager.java index 7baf68696a4..cea801d2756 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ManagedBuildManager.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ManagedBuildManager.java @@ -35,12 +35,6 @@ import javax.xml.transform.dom.DOMSource; import javax.xml.transform.stream.StreamResult; import org.eclipse.cdt.core.AbstractCExtension; -import org.eclipse.cdt.core.model.CModelException; -import org.eclipse.cdt.core.model.CoreModel; -import org.eclipse.cdt.core.model.ICProject; -import org.eclipse.cdt.core.model.IContainerEntry; -import org.eclipse.cdt.core.model.IPathEntry; -import org.eclipse.cdt.core.model.IPathEntryContainer; import org.eclipse.cdt.core.parser.IScannerInfo; import org.eclipse.cdt.core.parser.IScannerInfoChangeListener; import org.eclipse.cdt.core.parser.IScannerInfoProvider; @@ -49,7 +43,6 @@ import org.eclipse.cdt.managedbuilder.internal.core.DefaultManagedConfigElement; import org.eclipse.cdt.managedbuilder.internal.core.ManagedBuildInfo; import org.eclipse.cdt.managedbuilder.internal.core.Target; import org.eclipse.cdt.managedbuilder.internal.core.Tool; -import org.eclipse.cdt.managedbuilder.scannerconfig.ManagedBuildCPathEntryContainer; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; @@ -58,8 +51,6 @@ import org.eclipse.core.runtime.IConfigurationElement; import org.eclipse.core.runtime.IExtension; import org.eclipse.core.runtime.IExtensionPoint; import org.eclipse.core.runtime.IPluginDescriptor; -import org.eclipse.core.runtime.NullProgressMonitor; -import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.PluginVersionIdentifier; import org.eclipse.core.runtime.QualifiedName; import org.w3c.dom.Document; @@ -79,7 +70,7 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI public static final String SETTINGS_FILE_NAME = ".cdtbuild"; //$NON-NLS-1$ private static final ITarget[] emptyTargets = new ITarget[0]; public static final String INTERFACE_IDENTITY = ManagedBuilderCorePlugin.getUniqueIdentifier() + "." + "ManagedBuildManager"; //$NON-NLS-1$ //$NON-NLS-2$ - private static final String EXTENSION_POINT_ID = "ManagedBuildInfo"; //$NON-NLS-1$ + public static final String EXTENSION_POINT_ID = "ManagedBuildInfo"; //$NON-NLS-1$ private static final String REVISION_ELEMENT_NAME = "managedBuildRevision"; //$NON-NLS-1$ private static final String VERSION_ELEMENT_NAME = "fileVersion"; //$NON-NLS-1$ private static final String MANIFEST_VERSION_ERROR ="ManagedBuildManager.error.manifest.version.error"; //$NON-NLS-1$ @@ -93,6 +84,7 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI private static Map extensionToolMap; private static Map configElementMap; + // Listeners interested in build model changes private static Map buildModelListeners; @@ -714,7 +706,7 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI return false; } - private static ManagedBuildInfo findBuildInfo(IResource resource, boolean create) { + private static synchronized ManagedBuildInfo findBuildInfo(IResource resource, boolean create) { // Make sure the extension information is loaded first try { loadExtensions(); @@ -723,8 +715,6 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI return null; } - // Flag to deteremine if a PathEntryContainer is needed for project - boolean needsContainer = false; ManagedBuildInfo buildInfo = null; // Check if there is any build info associated with this project for this session @@ -741,36 +731,19 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI if (buildInfo == null && resource instanceof IProject) { // Nothing in session store, so see if we can load it from cdtbuild buildInfo = loadBuildInfo((IProject)resource); - needsContainer = (buildInfo != null); } if (buildInfo == null && create) { try { // Create a new build info object for the project - buildInfo = new ManagedBuildInfo(resource); + buildInfo = new ManagedBuildInfo(resource, true); // Associate the build info with the project for the duration of the session resource.setSessionProperty(buildInfoProperty, buildInfo); - needsContainer = true; } catch (CoreException e) { return null; } } - // Assocaite a container with the project - if (buildInfo != null && needsContainer) { - IPathEntryContainer container = new ManagedBuildCPathEntryContainer(buildInfo); - try { - ICProject project = CoreModel.getDefault().create((IProject)resource); - IContainerEntry containerEntry = CoreModel.newContainerEntry(new Path("org.eclipse.cdt.managedbuilder.MANAGED_CONTAINER")); //$NON-NLS-1$ - CoreModel.getDefault().setRawPathEntries(project, new IPathEntry[]{containerEntry}, new NullProgressMonitor()); - CoreModel.getDefault().setPathEntryContainer(new ICProject[]{project}, container, new NullProgressMonitor()); - } catch (CModelException e) { - e.printStackTrace(); - // The build info is valid even if there's no container - return buildInfo; - } - } - return buildInfo; } diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ManagedBuilderCorePlugin.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ManagedBuilderCorePlugin.java index 829f6e36ba7..5b2330314de 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ManagedBuilderCorePlugin.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ManagedBuilderCorePlugin.java @@ -15,6 +15,11 @@ import java.text.MessageFormat; import java.util.MissingResourceException; import java.util.ResourceBundle; +import org.eclipse.cdt.managedbuilder.scannerconfig.IManagedScannerInfoCollector; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IConfigurationElement; +import org.eclipse.core.runtime.IExtension; +import org.eclipse.core.runtime.IExtensionPoint; import org.eclipse.core.runtime.IPluginDescriptor; import org.eclipse.core.runtime.Plugin; @@ -77,4 +82,37 @@ public class ManagedBuilderCorePlugin extends Plugin { return getDefault().getDescriptor().getUniqueIdentifier(); } + /** + * Targets may have a scanner collector defined that knows how to discover + * built-in compiler defines and includes search paths. Find the scanner + * collector implentation for the target specified. + * + * @param string the unique id of the target to search for + * @return an implementation of IManagedScannerInfoCollector + */ + public IManagedScannerInfoCollector getScannerInfoCollector(String targetId) { + try { + IExtensionPoint extension = getDescriptor().getExtensionPoint(ManagedBuildManager.EXTENSION_POINT_ID); + if (extension != null) { + // There could be many of these + IExtension[] extensions = extension.getExtensions(); + for (int i = 0; i < extensions.length; i++) { + IConfigurationElement[] configElements = extensions[i].getConfigurationElements(); + for (int j = 0; j < configElements.length; j++) { + IConfigurationElement element = configElements[j]; + if (element.getName().equals("target")) { //$NON-NLS-1$ + if (element.getAttribute(ITarget.ID).equals(targetId)) { + return (IManagedScannerInfoCollector) element.createExecutableExtension("scannerInfoCollector"); //$NON-NLS-1$ + } + } + } + } + } + } + catch (CoreException e) { + // Probably not defined + } + return null; + } + } diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Configuration.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Configuration.java index a003c75180c..4cd8e42b5d9 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Configuration.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Configuration.java @@ -14,6 +14,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Iterator; import java.util.List; +import java.util.Vector; import org.eclipse.cdt.core.CCProjectNature; import org.eclipse.cdt.core.CProjectNature; @@ -245,6 +246,42 @@ public class Configuration extends BuildObject implements IConfiguration { } } + /* (non-Javadoc) + * @see org.eclipse.cdt.managedbuilder.core.IConfiguration#getFilteredTools(org.eclipse.core.resources.IProject) + */ + public ITool[] getFilteredTools(IProject project) { + ITool[] localTools = getTools(); + Vector tools = new Vector(localTools.length); + for (int i = 0; i < localTools.length; i++) { + ITool tool = localTools[i]; + try { + // Make sure the tool is right for the project + switch (tool.getNatureFilter()) { + case ITool.FILTER_C: + if (project.hasNature(CProjectNature.C_NATURE_ID) && !project.hasNature(CCProjectNature.CC_NATURE_ID)) { + tools.add(tool); + } + break; + case ITool.FILTER_CC: + if (project.hasNature(CCProjectNature.CC_NATURE_ID)) { + tools.add(tool); + } + break; + case ITool.FILTER_BOTH: + tools.add(tool); + break; + default: + break; + } + } catch (CoreException e) { + continue; + } + } + + // Answer the filtered tools as an array + return (ITool[])tools.toArray(new ITool[tools.size()]); + } + /* (non-javadoc) * A safety method to avoid NPEs. It answers the tool reference list in the * receiver. It does not look at the tool references defined in the parent. diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ManagedBuildInfo.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ManagedBuildInfo.java index 98a3a13000d..497f3189054 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ManagedBuildInfo.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ManagedBuildInfo.java @@ -23,8 +23,11 @@ import org.eclipse.cdt.core.CProjectNature; import org.eclipse.cdt.core.model.CModelException; import org.eclipse.cdt.core.model.CoreModel; import org.eclipse.cdt.core.model.ICProject; +import org.eclipse.cdt.core.model.IContainerEntry; import org.eclipse.cdt.core.model.IIncludeEntry; +import org.eclipse.cdt.core.model.IMacroEntry; import org.eclipse.cdt.core.model.IPathEntry; +import org.eclipse.cdt.core.model.IPathEntryContainer; import org.eclipse.cdt.core.parser.IScannerInfo; import org.eclipse.cdt.managedbuilder.core.BuildException; import org.eclipse.cdt.managedbuilder.core.IConfiguration; @@ -33,10 +36,12 @@ import org.eclipse.cdt.managedbuilder.core.IOption; import org.eclipse.cdt.managedbuilder.core.ITarget; import org.eclipse.cdt.managedbuilder.core.ITool; import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin; +import org.eclipse.cdt.managedbuilder.internal.scannerconfig.ManagedBuildCPathEntryContainer; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.QualifiedName; import org.w3c.dom.Document; @@ -50,6 +55,10 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo { public static final String MINOR_SEPERATOR = "::"; //$NON-NLS-1$ private static final QualifiedName defaultConfigProperty = new QualifiedName(ManagedBuilderCorePlugin.getUniqueIdentifier(), "defaultConfig"); //$NON-NLS-1$ private static final QualifiedName defaultTargetProperty = new QualifiedName(ManagedBuilderCorePlugin.getUniqueIdentifier(), "defaultTarget"); //$NON-NLS-1$ + // The path container used for all managed projects + private static final IContainerEntry containerEntry = CoreModel.newContainerEntry(new Path("org.eclipse.cdt.managedbuilder.MANAGED_CONTAINER")); //$NON-NLS-1$ + + private ICProject cModelElement; private String defaultConfigIds; private Map defaultConfigMap; private ITarget defaultTarget; @@ -61,13 +70,34 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo { private List targetList; private String version; + /** - * Create a new managed build information for the IResource specified in the argument + * For compatability. * * @param owner */ public ManagedBuildInfo(IResource owner) { + this(owner, true); + } + + /** + * Create a new managed build information for the IResource specified in the argument + * + * @param owner + * @param intializeEntries + * @since 2.0 + */ + public ManagedBuildInfo(IResource owner, boolean intializeEntries) { this.owner = owner; + cModelElement = CoreModel.getDefault().create(owner.getProject()); + + try { + CoreModel.getDefault().setRawPathEntries(cModelElement, new IPathEntry[]{containerEntry}, new NullProgressMonitor()); + } catch (CModelException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + isDirty = false; // The id of the default target from the project persistent settings store @@ -89,6 +119,9 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo { return; } + if(intializeEntries) { + initializePathEntries(); + } } /** @@ -99,13 +132,15 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo { * @param element */ public ManagedBuildInfo(IResource owner, Element element) { - this(owner); + this(owner, false); // Inflate the targets NodeList targetNodes = element.getElementsByTagName(ITarget.TARGET_ELEMENT_NAME); for (int targIndex = targetNodes.getLength() - 1; targIndex >= 0; --targIndex) { new Target(this, (Element)targetNodes.item(targIndex)); } + + initializePathEntries(); } /* (non-Javadoc) @@ -273,7 +308,10 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo { } // If that failed, look for anything if (defaultTarget == null) { - defaultTarget = (ITarget) getTargets().get(0); + // Are there any defined targets + if (getTargets().size() > 0) { + return (ITarget) getTargets().get(0); + } } } return defaultTarget; @@ -283,32 +321,12 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo { * @see org.eclipse.cdt.core.build.managed.IScannerInfo#getDefinedSymbols() */ public Map getDefinedSymbols() { - IProject project = (IProject)owner; // Return the defined symbols for the default configuration - HashMap symbols = new HashMap(); + HashMap symbols = getMacroPathEntries(); IConfiguration config = getDefaultConfiguration(getDefaultTarget()); - ITool[] tools = config.getTools(); + ITool[] tools = config.getFilteredTools(owner.getProject()); for (int i = 0; i < tools.length; i++) { ITool tool = tools[i]; - try { - // Make sure the tool is right for the project - switch (tool.getNatureFilter()) { - case ITool.FILTER_C: - if (!project.hasNature(CProjectNature.C_NATURE_ID) || project.hasNature(CCProjectNature.CC_NATURE_ID)) { - continue; - } - break; - case ITool.FILTER_CC: - if (!project.hasNature(CCProjectNature.CC_NATURE_ID)) { - continue; - } - break; - case ITool.FILTER_BOTH: - break; - } - } catch (CoreException e) { - continue; - } // Now extract the valid tool's options IOption[] opts = tool.getOptions(); for (int j = 0; j < opts.length; j++) { @@ -316,7 +334,6 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo { if (option.getValueType() == IOption.PREPROCESSOR_SYMBOLS) { try { ArrayList symbolList = new ArrayList(); - symbolList.addAll(Arrays.asList(option.getBuiltIns())); symbolList.addAll(Arrays.asList(option.getDefinedSymbols())); Iterator iter = symbolList.listIterator(); while (iter.hasNext()) { @@ -324,15 +341,9 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo { if (symbol.length() == 0){ continue; } - String key = new String(); - String value = new String(); - int index = symbol.indexOf("="); //$NON-NLS-1$ - if (index != -1) { - key = symbol.substring(0, index).trim(); - value = symbol.substring(index + 1).trim(); - } else { - key = symbol.trim(); - } + String[] tokens = symbol.split("="); //$NON-NLS-1$ + String key = tokens[0].trim(); + String value = (tokens.length > 1) ? tokens[1].trim() : new String(); symbols.put(key, value); } @@ -426,14 +437,37 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo { return null; } + private ArrayList getIncludePathEntries() { + // Extract the resolved paths from the project (if any) + ArrayList paths = new ArrayList(); + if (cModelElement != null) { + try { + IPathEntry[] entries = cModelElement.getResolvedPathEntries(); + for (int index = 0; index < entries.length; ++index) { + int kind = entries[index].getEntryKind(); + if (kind == IPathEntry.CDT_INCLUDE) { + IIncludeEntry include = (IIncludeEntry) entries[index]; + if (include.isSystemInclude()) { + IPath entryPath = include.getFullIncludePath(); + paths.add(entryPath.toString()); + } + } + } + } catch (CModelException e) { + // Just return an empty array + paths.clear(); + return paths; + } + } + return paths; + } + /* (non-Javadoc) * @see org.eclipse.cdt.core.build.managed.IScannerInfo#getIncludePaths() */ public String[] getIncludePaths() { - IProject project = (IProject)owner; - // Return the include paths for the default configuration - ArrayList paths = new ArrayList(); + ArrayList paths = getIncludePathEntries(); IConfiguration config = getDefaultConfiguration(getDefaultTarget()); IPath location = owner.getLocation(); // If the build info is out of date this might be null @@ -441,36 +475,15 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo { location = new Path("."); //$NON-NLS-1$ } IPath root = location.addTrailingSeparator().append(config.getName()); - ITool[] tools = config.getTools(); + ITool[] tools = config.getFilteredTools(owner.getProject()); for (int i = 0; i < tools.length; i++) { ITool tool = tools[i]; - try { - // Make sure the tool is right for the project - switch (tool.getNatureFilter()) { - case ITool.FILTER_C: - if (!project.hasNature(CProjectNature.C_NATURE_ID) || project.hasNature(CCProjectNature.CC_NATURE_ID)) { - continue; - } - break; - case ITool.FILTER_CC: - if (!project.hasNature(CCProjectNature.CC_NATURE_ID)) { - continue; - } - break; - case ITool.FILTER_BOTH: - break; - } - } catch (CoreException e) { - continue; - } // The tool checks out for this project, get its options IOption[] opts = tool.getOptions(); for (int j = 0; j < opts.length; j++) { IOption option = opts[j]; if (option.getValueType() == IOption.INCLUDE_PATH) { try { - // Get all the built-in paths from the option - paths.addAll(getCompilerPaths(option)); // Get all the user-defined paths from the option as absolute paths String[] userPaths = option.getIncludePaths(); for (int index = 0; index < userPaths.length; ++index) { @@ -489,41 +502,30 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo { } } } - paths.trimToSize(); + + // Answer the results as an array return (String[])paths.toArray(new String[paths.size()]); } - /** - * @param owner2 - * @return - */ - private List getCompilerPaths(IOption option) { - // Extract the resolved paths from the project (if any) - ArrayList paths = new ArrayList(); - ICProject project = CoreModel.getDefault().create(owner.getProject()); - if (project != null) { + private HashMap getMacroPathEntries() { + HashMap macros = new HashMap(); + if (cModelElement != null) { try { - IPathEntry[] entries = project.getResolvedPathEntries(); - for (int index = entries.length - 1; index >=0; --index) { - int kind = entries[index].getEntryKind(); - if (kind == IPathEntry.CDT_INCLUDE) { - IIncludeEntry include = (IIncludeEntry) entries[index]; - if (include.isSystemInclude()) { - IPath entryPath = include.getPath(); - paths.add(entryPath.toString()); - } + IPathEntry[] entries = cModelElement.getResolvedPathEntries(); + for (int index = 0; index < entries.length; ++index) { + if (entries[index].getEntryKind() == IPathEntry.CDT_MACRO) { + IMacroEntry macro = (IMacroEntry) entries[index]; + macros.put(macro.getMacroName(), macro.getMacroValue()); } } } catch (CModelException e) { - // See if there are any built-ins from the tool definition - return Arrays.asList(option.getBuiltIns()); + // return an empty map + macros.clear(); + return macros; } + } -// if (paths.size() == 0) { - return Arrays.asList(option.getBuiltIns()); -// } else { -// return paths; -// } + return macros; } /* (non-Javadoc) @@ -975,6 +977,19 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo { } } + /* (non-Javadoc) + * + */ + private void initializePathEntries() { + try { + IPathEntryContainer container = new ManagedBuildCPathEntryContainer(this); + CoreModel.getDefault().setPathEntryContainer(new ICProject[]{cModelElement}, container, new NullProgressMonitor()); + } catch (CModelException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + /* (non-Javadoc) * @see org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo#removeTarget(java.lang.String) */ @@ -1045,6 +1060,7 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo { defaultTarget = target; defaultTargetId = target.getId(); persistDefaultTarget(); + initializePathEntries(); } } @@ -1103,6 +1119,18 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo { ITarget target = (ITarget) iter.next(); target.updateOwner(resource); } + // And finally update the cModelElement + cModelElement = CoreModel.getDefault().create(owner.getProject()); + try { + CoreModel.getDefault().setRawPathEntries(cModelElement, new IPathEntry[]{containerEntry}, new NullProgressMonitor()); + } catch (CModelException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + initializePathEntries(); + + // Save everything + setDirty(true); } } } diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/scannerconfig/DefaultCygwinScannerInfoCollector.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/scannerconfig/DefaultCygwinScannerInfoCollector.java new file mode 100644 index 00000000000..c1b19bb62bd --- /dev/null +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/scannerconfig/DefaultCygwinScannerInfoCollector.java @@ -0,0 +1,64 @@ +/********************************************************************** + * 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.managedbuilder.internal.scannerconfig; + +import java.util.Iterator; +import java.util.List; + +import org.eclipse.cdt.make.internal.core.scannerconfig.util.CygpathTranslator; +import org.eclipse.core.resources.IResource; + +/** + * Implementation class for gathering the built-in compiler settings for + * Cygwin-based targets. + * + * @since 2.0 + */ +public class DefaultCygwinScannerInfoCollector extends DefaultGCCScannerInfoCollector { + + /* (non-Javadoc) + * @see org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector#contributeToScannerConfig(org.eclipse.core.resources.IResource, java.util.List, java.util.List, java.util.List) + */ + public void contributeToScannerConfig(IResource resource, List includes, + List symbols, List targetSpecificOptions) { + // This method will be called by the parser each time there is a new value + Iterator pathIter = includes.listIterator(); + while (pathIter.hasNext()) { + String path = (String) pathIter.next(); + String convertedPath = convertPath(path); + getIncludePaths().add(convertedPath); + } + + // Now add the macros + Iterator symbolIter = symbols.listIterator(); + while (symbolIter.hasNext()) { + // See if it has an equals + String[] macroTokens = ((String)symbolIter.next()).split(EQUALS); + String macro = macroTokens[0].trim(); + String value = (macroTokens.length > 1) ? macroTokens[1].trim() : new String(); + getDefinedSymbols().put(macro, value); + } + } + + /* (non-Javadoc) + * Converts the argument from a POSIX-style path to a valid Win32 path. + * If the string is already in the proper format it will not be changed. + * + * @param path String containing path to convert + * @return String containing the converted path + */ + private String convertPath(String includePath) { + // Convert a POSIX-style path to Win32 + String translatedPath = new CygpathTranslator(project, includePath).run(); + return translatedPath; + } + +} diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/scannerconfig/DefaultGCCScannerInfoCollector.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/scannerconfig/DefaultGCCScannerInfoCollector.java new file mode 100644 index 00000000000..00ce6433fff --- /dev/null +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/scannerconfig/DefaultGCCScannerInfoCollector.java @@ -0,0 +1,95 @@ +/********************************************************************** + * 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.managedbuilder.internal.scannerconfig; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +import org.eclipse.cdt.managedbuilder.scannerconfig.IManagedScannerInfoCollector; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResource; + +/** + * Implementation class for gathering the built-in compiler settings for + * GCC-based targets. The assumption is that the tools will answer path + * information in POSIX format and that the Scanner will be able to search for + * files using this format. + * + * @since 2.0 + */ +public class DefaultGCCScannerInfoCollector implements IManagedScannerInfoCollector { + protected Map definedSymbols; + protected static final String EQUALS = "="; //$NON-NLS-1$ + protected List includePaths; + protected IProject project; + + /** + * + */ + public DefaultGCCScannerInfoCollector() { + super(); + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector#contributeToScannerConfig(org.eclipse.core.resources.IResource, java.util.List, java.util.List, java.util.List) + */ + public void contributeToScannerConfig(IResource resource, List includes, + List symbols, List targetSpecificOptions) { + + // This method will be called by the parser each time there is a new value + Iterator pathIter = includes.listIterator(); + while (pathIter.hasNext()) { + String path = (String) pathIter.next(); + getIncludePaths().add(path); + } + + // Now add the macros + Iterator symbolIter = symbols.listIterator(); + while (symbolIter.hasNext()) { + // See if it has an equals + String[] macroTokens = ((String)symbolIter.next()).split(EQUALS); + String macro = macroTokens[0].trim(); + String value = (macroTokens.length > 1) ? macroTokens[1].trim() : new String(); + getDefinedSymbols().put(macro, value); + } + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.parser.IScannerInfo#getDefinedSymbols() + */ + public Map getDefinedSymbols() { + if (definedSymbols == null) { + definedSymbols = new HashMap(); + } + return definedSymbols; + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.managedbuilder.scannerconfig.IManagedScannerInfoCollector#getIncludePaths() + */ + public List getIncludePaths() { + if (includePaths == null) { + includePaths = new ArrayList(); + } + return includePaths; + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.managedbuilder.scannerconfig.IManagedScannerInfoCollector#setProject(org.eclipse.core.resources.IProject) + */ + public void setProject(IProject project) { + this.project = project; + + } +} diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/scannerconfig/DefaultMinGWScannerInfoCollector.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/scannerconfig/DefaultMinGWScannerInfoCollector.java new file mode 100644 index 00000000000..7cda6bcf1f0 --- /dev/null +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/scannerconfig/DefaultMinGWScannerInfoCollector.java @@ -0,0 +1,70 @@ +/********************************************************************** + * 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.managedbuilder.internal.scannerconfig; + +import java.util.Iterator; +import java.util.List; + +import org.eclipse.core.resources.IResource; + +/** + * Implementation class for gathering the built-in compiler settings for + * MinGw-based targets. The paths are collected only in Win32 format. + * + * @since 2.0 + */ +public class DefaultMinGWScannerInfoCollector extends DefaultGCCScannerInfoCollector { + /* (non-Javadoc) + * @see org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector#contributeToScannerConfig(org.eclipse.core.resources.IResource, java.util.List, java.util.List, java.util.List) + */ + public void contributeToScannerConfig(IResource resource, List includes, + List symbols, List targetSpecificOptions) { + // This method will be called by the parser each time there is a new value + Iterator pathIter = includes.listIterator(); + while (pathIter.hasNext()) { + String path = (String) pathIter.next(); + if (!filterPath(path)) { + getIncludePaths().add(path); + } + } + + // Now add the macros + Iterator symbolIter = symbols.listIterator(); + while (symbolIter.hasNext()) { + // See if it has an equals + String[] macroTokens = ((String)symbolIter.next()).split(EQUALS); + String macro = macroTokens[0].trim(); + String value = (macroTokens.length > 1) ? macroTokens[1].trim() : new String(); + getDefinedSymbols().put(macro, value); + } + } + + /* (non-Javadoc) + * + * @param path + * @return + */ + private boolean filterPath(String includePath) { + // MinGW's compiler will return paths in both POSIX and Win32 format + // We only want to store the Win32 variant like: + // : + // \\ + int firstColon = includePath.indexOf(':'); //$NON-NLS-1$ + if (firstColon == 1 && Character.isLetter(includePath.charAt(0))) { + // : is OK + return false; + } + + return true; + } + + +} diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/scannerconfig/ManagedBuildCPathEntryContainer.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/scannerconfig/ManagedBuildCPathEntryContainer.java new file mode 100644 index 00000000000..083f1dc9d86 --- /dev/null +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/scannerconfig/ManagedBuildCPathEntryContainer.java @@ -0,0 +1,242 @@ +/********************************************************************** + * Copyright (c) Apr 21, 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.managedbuilder.internal.scannerconfig; + +import java.util.Arrays; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.Vector; + +import org.eclipse.cdt.core.model.CoreModel; +import org.eclipse.cdt.core.model.IIncludeEntry; +import org.eclipse.cdt.core.model.IMacroEntry; +import org.eclipse.cdt.core.model.IPathEntry; +import org.eclipse.cdt.core.model.IPathEntryContainer; +import org.eclipse.cdt.make.core.MakeCorePlugin; +import org.eclipse.cdt.make.core.scannerconfig.IExternalScannerInfoProvider; +import org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo; +import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector; +import org.eclipse.cdt.managedbuilder.core.IConfiguration; +import org.eclipse.cdt.managedbuilder.core.IOption; +import org.eclipse.cdt.managedbuilder.core.ITarget; +import org.eclipse.cdt.managedbuilder.core.ITool; +import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin; +import org.eclipse.cdt.managedbuilder.internal.core.ManagedBuildInfo; +import org.eclipse.cdt.managedbuilder.scannerconfig.IManagedScannerInfoCollector; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.ISafeRunnable; +import org.eclipse.core.runtime.NullProgressMonitor; +import org.eclipse.core.runtime.OperationCanceledException; +import org.eclipse.core.runtime.Path; +import org.eclipse.core.runtime.Platform; + +/** + * Implements a specialized path container for managed build projects. It will + * either start the dynamic path collector specified for a target in the tool + * manifest, or it will attempt to discover the built-in values specified in + * the manifest. + * + * @since 2.0 + */ +public class ManagedBuildCPathEntryContainer implements IPathEntryContainer { + + private static final String BUILDER_ID = MakeCorePlugin.getUniqueIdentifier() + ".ScannerConfigBuilder"; //$NON-NLS-1$ + private ITarget defaultTarget; + private Vector entries; + private ManagedBuildInfo info; + + /** + * Creates a new path container for the managed buildd project. + * + * @param info the build information associated with the project + */ + public ManagedBuildCPathEntryContainer(ManagedBuildInfo info) { + super(); + this.info = info; + defaultTarget = info.getDefaultTarget(); + entries = new Vector(); + } + + protected void addDefinedSymbols(Map definedSymbols) { + // Add a new macro entry for each defined symbol + Set macros = definedSymbols.keySet(); + Iterator keyIter = macros.iterator(); + while (keyIter.hasNext()) { + boolean add = true; + String macro = (String) keyIter.next(); + String value = (String) definedSymbols.get(macro); + // Make sure the current entries do not contain a duplicate + Iterator entryIter = entries.listIterator(); + while (entryIter.hasNext()) { + IPathEntry entry = (IPathEntry) entryIter.next(); + if (entry.getEntryKind() == IPathEntry.CDT_MACRO) { + if (((IMacroEntry)entry).getMacroName().equals(macro) && + ((IMacroEntry)entry).getMacroValue().equals(value)) { + add = false; + break; + } + } + } + + if (add) { + entries.add(CoreModel.newMacroEntry(new Path(""), macro, value)); //$NON-NLS-1$ + } + } + + } + + protected void addIncludePaths(List paths) { + // A little checking is needed to avoid adding duplicates + Iterator pathIter = paths.listIterator(); + while (pathIter.hasNext()) { + boolean add = true; + String path = (String) pathIter.next(); + // Make sure there is no other path with the same value + Iterator entryIter = entries.listIterator(); + while (entryIter.hasNext()) { + IPathEntry entry = (IPathEntry) entryIter.next(); + if (entry.getEntryKind() == IPathEntry.CDT_INCLUDE) { + if (((IIncludeEntry)entry).getFullIncludePath().equals(path)) { + add = false; + break; + } + } + } + if (add) { + entries.add(CoreModel.newIncludeEntry(new Path(""), null, new Path(path), true)); //$NON-NLS-1$ + } + } + + } + + protected void calculateBuiltIns(ITarget defaultTarget, IConfiguration config) { + ITool[] tools = config.getFilteredTools(info.getOwner().getProject()); + + // Iterate over the list + for (int toolIndex = 0; toolIndex < tools.length; ++toolIndex) { + ITool tool = tools[toolIndex]; + // Check its options + IOption[] options = tool.getOptions(); + for (int optIndex = 0; optIndex < options.length; ++optIndex) { + IOption option = options[optIndex]; + if (option.getValueType() == IOption.PREPROCESSOR_SYMBOLS) { + String[] builtIns = option.getBuiltIns(); + Map macroMap = new HashMap(); + for (int biIndex = 0; biIndex < builtIns.length; ++biIndex) { + String symbol = builtIns[biIndex]; + String[] tokens = symbol.split("="); //$NON-NLS-1$ + String macro = tokens[0].trim(); + String value = (tokens.length > 1) ? tokens[1] : new String(); + macroMap.put(macro, value); + } + addDefinedSymbols(macroMap); + } else if (option.getValueType() == IOption.INCLUDE_PATH) { + // Make sure it is a built-in, not a user-defined path + String[] values = option.getBuiltIns(); + if (values.length > 0) { + addIncludePaths(Arrays.asList(values)); + } + } + } + } + + } + + protected void calculateEntriesDynamically(final IProject project, final IScannerInfoCollector collector) { + final IScannerConfigBuilderInfo buildInfo; + buildInfo = MakeCorePlugin.createScannerConfigBuildInfo( + MakeCorePlugin.getDefault().getPluginPreferences(), + BUILDER_ID, + false); + + // TODO Get the provider from the toolchain specification + final IExternalScannerInfoProvider esiProvider; + esiProvider = MakeCorePlugin.getDefault().getExternalScannerInfoProvider(MakeCorePlugin.DEFAULT_EXTERNAL_SI_PROVIDER_ID); + + // Set the arguments for the provider + Vector compilerArgs = new Vector(); + String args = buildInfo.getESIProviderArguments(); + IPath command = buildInfo.getESIProviderCommand(); + final Vector buildArgs = compilerArgs; + + ISafeRunnable runnable = new ISafeRunnable() { + public void run() { + IProgressMonitor monitor = new NullProgressMonitor(); + esiProvider.invokeProvider(monitor, project, buildInfo, buildArgs, collector); + } + + public void handleException(Throwable exception) { + if (exception instanceof OperationCanceledException) { + throw (OperationCanceledException) exception; + } + } + }; + Platform.run(runnable); + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.model.IPathEntryContainer#getPathEntries() + */ + public synchronized IPathEntry[] getPathEntries() { + // TODO figure out when I can skip this step + if (entries.isEmpty()) { + // Load the toolchain-spec'd collector + defaultTarget = info.getDefaultTarget(); + if (defaultTarget == null) { + // The build information has not been loaded yet + return (IPathEntry[])entries.toArray(new IPathEntry[entries.size()]); + } + ITarget parent = defaultTarget.getParent(); + if (parent == null) { + // The build information has not been loaded yet + return (IPathEntry[])entries.toArray(new IPathEntry[entries.size()]); + } + // See if we can load a dynamic resolver + String baseTargetId = parent.getId(); + IManagedScannerInfoCollector collector = ManagedBuilderCorePlugin.getDefault().getScannerInfoCollector(baseTargetId); + if (collector != null) { + collector.setProject(info.getOwner().getProject()); + calculateEntriesDynamically((IProject)info.getOwner(), collector); + addIncludePaths(collector.getIncludePaths()); + addDefinedSymbols(collector.getDefinedSymbols()); + } else { + // If none supplied, use the built-ins + IConfiguration config = info.getDefaultConfiguration(defaultTarget); + if (config != null) { + calculateBuiltIns(defaultTarget, config); + } else { + return (IPathEntry[])entries.toArray(new IPathEntry[entries.size()]); + } + } + } + return (IPathEntry[])entries.toArray(new IPathEntry[entries.size()]); + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.model.IPathEntryContainer#getDescription() + */ + public String getDescription() { + return "CDT Managed Build Project"; //$NON-NLS-1$ + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.model.IPathEntryContainer#getPath() + */ + public IPath getPath() { + return new Path("org.eclipse.cdt.managedbuilder.MANAGED_CONTAINER"); //$NON-NLS-1$ + } +} diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/scannerconfig/IManagedScannerInfoCollector.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/scannerconfig/IManagedScannerInfoCollector.java new file mode 100644 index 00000000000..47c1eb7176e --- /dev/null +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/scannerconfig/IManagedScannerInfoCollector.java @@ -0,0 +1,52 @@ +/********************************************************************** + * 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.managedbuilder.scannerconfig; + +import java.util.List; +import java.util.Map; + +import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector; +import org.eclipse.core.resources.IProject; + +/** + * Interface that a colelctor of compiler information must implement. + * @since 2.0 + */ +public interface IManagedScannerInfoCollector extends IScannerInfoCollector { + /** + * Answers a map of collected defines that the the compiler uses by default. + * The symbols are defined in the map as a (macro, value) pair as follows + *

-DFOO will be stored as ("FOO","") + *

-DFOO=BAR will be stored as ("FOO","BAR") + *

Duplicates will not be stored in the map and any whitespaces in + * the macro or value will be trimmed out. + * + * @return a Map of defined symbols and values + */ + public Map getDefinedSymbols(); + + + /** + * Answers a List of unique built-in includes paths that have been + * collected for the receiver. The paths are stored as String in the proper + * format for the host tools. + * + * @return a List of built-in compiler include search paths. + */ + public List getIncludePaths(); + + /** + * Sets the IProject for the receiver. + * + * @param project + */ + public void setProject(IProject project); +} diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/scannerconfig/ManagedBuildCPathEntryContainer.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/scannerconfig/ManagedBuildCPathEntryContainer.java deleted file mode 100644 index 4eb68453b39..00000000000 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/scannerconfig/ManagedBuildCPathEntryContainer.java +++ /dev/null @@ -1,78 +0,0 @@ -/********************************************************************** - * Copyright (c) Apr 21, 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.managedbuilder.scannerconfig; - -import java.util.ArrayList; - -import org.eclipse.cdt.core.model.CoreModel; -import org.eclipse.cdt.core.model.IPathEntry; -import org.eclipse.cdt.core.model.IPathEntryContainer; -import org.eclipse.cdt.managedbuilder.internal.core.ManagedBuildInfo; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.Path; - -/** - * - * - */ -public class ManagedBuildCPathEntryContainer implements IPathEntryContainer { - - private ManagedBuildInfo info; - - /** - * - */ - public ManagedBuildCPathEntryContainer(ManagedBuildInfo info) { - super(); - this.info = info; - } - - /* (non-Javadoc) - * @see org.eclipse.cdt.core.model.IPathEntryContainer#getPathEntries() - */ - public IPathEntry[] getPathEntries() { - // Resolve the symbols and paths for the project - IPath resourcePath = info.getOwner().getProjectRelativePath(); - - ArrayList entries = new ArrayList(); - entries.add(CoreModel.newIncludeEntry(resourcePath, null, new Path("/usr/include/c++"), true)); - entries.add(CoreModel.newIncludeEntry(resourcePath, null, new Path("/usr/include/c++/i686-pc-cygwin"), true)); - entries.add(CoreModel.newIncludeEntry(resourcePath, null, new Path("/usr/include/c++/backward"), true)); - entries.add(CoreModel.newIncludeEntry(resourcePath, null, new Path("/usr/lib/gcc-lib/i686-pc-cygwin/3.3.1/include"), true)); - entries.add(CoreModel.newIncludeEntry(resourcePath, null, new Path("/usr/include"), true)); - entries.add(CoreModel.newIncludeEntry(resourcePath, null, new Path("/usr/include/api"), true)); - - entries.add(CoreModel.newMacroEntry(resourcePath, "__GNUC__", "3")); - entries.add(CoreModel.newMacroEntry(resourcePath, "__GNUC_MINOR__", "3")); - entries.add(CoreModel.newMacroEntry(resourcePath, "__GNUC_PATCHLEVEL__", "1")); - entries.add(CoreModel.newMacroEntry(resourcePath, "__CYGWIN32__", "")); - entries.add(CoreModel.newMacroEntry(resourcePath, "__CYGWIN__", "")); - entries.add(CoreModel.newMacroEntry(resourcePath, "unix", "")); - entries.add(CoreModel.newMacroEntry(resourcePath, "__unix__", "")); - entries.add(CoreModel.newMacroEntry(resourcePath, "unix__", "")); - return (IPathEntry[])entries.toArray(new IPathEntry[entries.size()]); - } - - /* (non-Javadoc) - * @see org.eclipse.cdt.core.model.IPathEntryContainer#getDescription() - */ - public String getDescription() { - return "CDT Managed Build Project"; //$NON-NLS-1$ - } - - /* (non-Javadoc) - * @see org.eclipse.cdt.core.model.IPathEntryContainer#getPath() - */ - public IPath getPath() { - return new Path("org.eclipse.cdt.managedbuilder.MANAGED_CONTAINER"); //$NON-NLS-1$ - } -} diff --git a/build/org.eclipse.cdt.managedbuilder.ui/plugin.xml b/build/org.eclipse.cdt.managedbuilder.ui/plugin.xml index e10bfaeeb5e..51b6c6d8749 100644 --- a/build/org.eclipse.cdt.managedbuilder.ui/plugin.xml +++ b/build/org.eclipse.cdt.managedbuilder.ui/plugin.xml @@ -31,8 +31,8 @@ icon="icons/full/wizban/newmngcc_app.gif" category="org.eclipse.cdt.ui.newCCWizards" class="org.eclipse.cdt.managedbuilder.ui.wizards.NewManagedCCProjectWizard" - project="true" finalPerspective="org.eclipse.cdt.ui.CPerspective" + project="true" id="org.eclipse.cdt.managedbuilder.ui.wizards.StdCCWizard"> %MngCCWizard.description @@ -43,8 +43,8 @@ icon="icons/full/wizban/newmngc_app.gif" category="org.eclipse.cdt.ui.newCWizards" class="org.eclipse.cdt.managedbuilder.ui.wizards.NewManagedCProjectWizard" - project="true" finalPerspective="org.eclipse.cdt.ui.CPerspective" + project="true" id="org.eclipse.cdt.managedbuilder.ui.wizards.StdCWizard"> %MngCWizard.description @@ -54,8 +54,8 @@ @@ -68,8 +68,8 @@ @@ -95,8 +95,8 @@ @@ -110,40 +110,40 @@ name="%Option.Posix.Linker.NoStartFiles" category="gnu.c.link.category.general" command="-nostartfiles" - id="gnu.c.link.option.nostart" - valueType="boolean"> + valueType="boolean" + id="gnu.c.link.option.nostart"> + id="gnu.c.link.option.libs"> + id="gnu.c.link.option.ldflags" + valueType="string"> + valueType="boolean" + id="gnu.c.link.option.shared"> @@ -243,32 +243,32 @@ name="%Option.Posix.Linker.NoStartFiles" category="gnu.cpp.link.category.options" command="-nostartfiles" - id="gnu.cpp.link.option.nostart" - valueType="boolean"> + valueType="boolean" + id="gnu.cpp.link.option.nostart"> + id="gnu.cpp.link.option.libs"> + id="gnu.cpp.link.option.flags" + valueType="string"> + id="gnu.cpp.link.option.shared" + valueType="boolean"> + id="gnu.both.lib.option.flags" + valueType="string"> + valueType="boolean" + id="gnu.c.compiler.option.preprocessor.nostdinc"> + valueType="definedSymbols" + id="gnu.c.compiler.option.preprocessor.def.symbols"> + id="gnu.c.compiler.option.include.paths"> + valueType="enumerated" + id="gnu.c.compiler.option.optimization.level"> + valueType="string" + id="gnu.c.compiler.option.optimization.flags"> + valueType="enumerated" + id="gnu.c.compiler.option.debugging.level"> + valueType="string" + id="gnu.c.compiler.option.debugging.other"> + valueType="boolean" + id="gnu.c.compiler.option.warnings.syntax"> + valueType="string" + id="gnu.c.compiler.option.misc.other"> + valueType="boolean" + id="gnu.cpp.compiler.option.preprocessor.nostdinc"> + id="gnu.cpp.compiler.option.include.paths"> + valueType="enumerated" + id="gnu.cpp.compiler.option.optimization.level"> + valueType="string" + id="gnu.cpp.compiler.option.optimization.flags"> + valueType="enumerated" + id="gnu.cpp.compiler.option.debugging.level"> + valueType="string" + id="gnu.cpp.compiler.option.debugging.other"> + valueType="boolean" + id="gnu.cpp.compiler.option.warnings.syntax"> + valueType="string" + id="gnu.cpp.compiler.option.other.other"> @@ -849,6 +849,7 @@ isTest="false" osList="solaris,linux,hpux,aix,macosx,qnx" name="%TargetName.gnu.exe" + scannerInfoCollector="org.eclipse.cdt.managedbuilder.internal.scannerconfig.DefaultGCCScannerInfoCollector" parent="cdt.managedbuild.target.gnu" isAbstract="false" id="cdt.managedbuild.target.gnu.exe"> @@ -915,6 +916,7 @@ isTest="false" osList="solaris,linux,hpux,aix,macosx,qnx" name="%TargetName.gnu.so" + scannerInfoCollector="org.eclipse.cdt.managedbuilder.internal.scannerconfig.DefaultGCCScannerInfoCollector" parent="cdt.managedbuild.target.gnu" defaultExtension="so" isAbstract="false" @@ -972,13 +974,13 @@ @@ -986,6 +988,7 @@ isTest="false" osList="solaris,linux,hpux,aix,macosx,qnx" name="%TargetName.gnu.lib" + scannerInfoCollector="org.eclipse.cdt.managedbuilder.internal.scannerconfig.DefaultGCCScannerInfoCollector" parent="cdt.managedbuild.target.gnu" defaultExtension="a" isAbstract="false" @@ -1043,20 +1046,21 @@ + binaryParser="org.eclipse.cdt.core.PE" + parent="cdt.managedbuild.target.gnu" + osList="win32"> @@ -1119,14 +1123,15 @@ + osList="win32"> @@ -1189,14 +1194,15 @@ + binaryParser="org.eclipse.cdt.core.PE" + parent="cdt.managedbuild.target.gnu" + osList="win32"> @@ -1250,8 +1256,8 @@ @@ -1260,6 +1266,7 @@ id="cdt.managedbuild.target.gnu.mingw.exe" isTest="false" defaultExtension="exe" + scannerInfoCollector="org.eclipse.cdt.managedbuilder.internal.scannerconfig.DefaultMinGWScannerInfoCollector" isAbstract="false" makeCommand="mingw32-make" binaryParser="org.eclipse.cdt.core.PE" @@ -1331,6 +1338,7 @@ id="cdt.managedbuild.target.gnu.mingw.so" isTest="false" defaultExtension="dll" + scannerInfoCollector="org.eclipse.cdt.managedbuilder.internal.scannerconfig.DefaultMinGWScannerInfoCollector" isAbstract="false" makeCommand="mingw32-make" binaryParser="org.eclipse.cdt.core.PE" @@ -1402,6 +1410,7 @@ id="cdt.managedbuild.target.gnu.mingw.lib" isTest="false" defaultExtension="lib" + scannerInfoCollector="org.eclipse.cdt.managedbuilder.internal.scannerconfig.DefaultMinGWScannerInfoCollector" isAbstract="false" makeCommand="mingw32-make" binaryParser="org.eclipse.cdt.core.PE" @@ -1460,8 +1469,8 @@ diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/FileListControl.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/FileListControl.java index 47d4857d6ef..cbd48733cb9 100644 --- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/FileListControl.java +++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/FileListControl.java @@ -74,8 +74,7 @@ public class FileListControl { protected void createButtonsForButtonBar(Composite parent) { super.createButtonsForButtonBar(parent); if (type != IOption.BROWSE_NONE) { - final Button browse = createButton(parent, 3, ManagedBuilderUIPlugin.getResourceString(BROWSE), true); - getOkButton().setFocus(); + final Button browse = createButton(parent, 3, ManagedBuilderUIPlugin.getResourceString(BROWSE), false); browse.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent ev) { String currentName; @@ -90,8 +89,6 @@ public class FileListControl { result = dialog.open(); if(result != null) { getText().setText(result); - // Give the OK button focus - getOkButton().setFocus(); } break; case IOption.BROWSE_FILE: @@ -103,8 +100,6 @@ public class FileListControl { result = browseDialog.open(); if (result != null) { getText().setText(result); - // Give the OK button focus - getOkButton().setFocus(); } break; } diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/NewManagedProjectOptionPage.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/NewManagedProjectOptionPage.java index f89b3d85be2..33fad728288 100644 --- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/NewManagedProjectOptionPage.java +++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/NewManagedProjectOptionPage.java @@ -11,9 +11,10 @@ package org.eclipse.cdt.managedbuilder.ui.wizards; * IBM Rational Software - Initial API and implementation * **********************************************************************/ +import org.eclipse.cdt.managedbuilder.internal.ui.ErrorParserBlock; import org.eclipse.cdt.managedbuilder.internal.ui.ManagedBuilderUIPlugin; import org.eclipse.cdt.managedbuilder.internal.ui.ManagedProjectOptionBlock; -import org.eclipse.cdt.managedbuilder.internal.ui.ErrorParserBlock; +import org.eclipse.cdt.ui.dialogs.IndexerBlock; import org.eclipse.cdt.ui.dialogs.ReferenceBlock; import org.eclipse.cdt.ui.dialogs.TabFolderOptionBlock; import org.eclipse.cdt.ui.wizards.NewCProjectWizard; @@ -22,11 +23,14 @@ import org.eclipse.core.resources.IProject; import org.eclipse.core.runtime.Preferences; public class NewManagedProjectOptionPage extends NewCProjectWizardOptionPage { + public class ManagedWizardOptionBlock extends ManagedProjectOptionBlock { NewManagedProjectOptionPage parent; ErrorParserBlock errorParsers; + IndexerBlock indexBlock; + public ManagedWizardOptionBlock(NewManagedProjectOptionPage parentPage) { super(parentPage); @@ -47,6 +51,7 @@ public class NewManagedProjectOptionPage extends NewCProjectWizardOptionPage { addTab(new ReferenceBlock()); errorParsers = new ErrorParserBlock(); addTab(errorParsers); + addTab(indexBlock = new IndexerBlock()); } } @@ -87,4 +92,6 @@ public class NewManagedProjectOptionPage extends NewCProjectWizardOptionPage { // Update the error parser list optionBlock.updateTargetProperties(); } + + }