diff --git a/build/org.eclipse.cdt.managedbuilder.core/schema/ManagedBuildTools.exsd b/build/org.eclipse.cdt.managedbuilder.core/schema/ManagedBuildTools.exsd
index 03fc3ca5540..9c5e7a1dcd4 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/schema/ManagedBuildTools.exsd
+++ b/build/org.eclipse.cdt.managedbuilder.core/schema/ManagedBuildTools.exsd
@@ -1,623 +1,623 @@
-
-
-null
.
- *
- * @param resourceName
+ * @param sourceExtension
* @return
*/
- public String getOutputExtension(String resourceExtension);
-
- /**
- * Answers the flag to be passed to the build tool to produce a specific output
- * or an empty String
if there is no special flag. For example, the
- * GCC tools use the '-o' flag to produce a named output, for example
- * gcc -c foo.c -o foo.o
- *
- * @param outputExt
- * @return
- */
- public String getOutputFlag(String outputExt);
-
- /**
- * Get the target specified in the argument.
- *
- * @param id
- * @return
- */
- public ITarget getTarget(String id);
-
- /**
- * Answers the prefix that should be prepended to the name of the build
- * artifact. For example, a library foo, should have the prefix 'lib' and
- * the extension '.a', so the final goal would be 'libfoo.a'
- *
- * @param extension
- * @return
- */
- public String getOutputPrefix(String outputExtension);
-
- /**
- * Get all of the targets associated with the receiver.
- *
- * @return
- */
- public List getTargets();
+ public IManagedDependencyGenerator getDependencyGenerator(String sourceExtension);
/**
* Returns a String
containing the flags, including
@@ -173,22 +136,75 @@ public interface IManagedBuildInfo {
* for the default target/configuration.
*/
public String getMakeCommand();
+
+ /**
+ * Answers the extension that will be built by the current configuration
+ * for the extension passed in the argument or null
.
+ *
+ * @param resourceName
+ * @return
+ */
+ public String getOutputExtension(String resourceExtension);
+
+ /**
+ * Answers the flag to be passed to the build tool to produce a specific output
+ * or an empty String
if there is no special flag. For example, the
+ * GCC tools use the '-o' flag to produce a named output, for example
+ * gcc -c foo.c -o foo.o
+ *
+ * @param outputExt
+ * @return
+ */
+ public String getOutputFlag(String outputExt);
+
+ /**
+ * Answers the prefix that should be prepended to the name of the build
+ * artifact. For example, a library foo, should have the prefix 'lib' and
+ * the extension '.a', so the final goal would be 'libfoo.a'
+ *
+ * @param extension
+ * @return
+ */
+ public String getOutputPrefix(String outputExtension);
+
+ /**
+ * Get the currently selected target. This is used while the project
+ * property pages are displayed
+ *
+ * @return target
+ */
+ public ITarget getSelectedTarget();
+
+ /**
+ * Get the target specified in the argument.
+ *
+ * @param id
+ * @return
+ */
+ public ITarget getTarget(String id);
+
+ /**
+ * Get all of the targets associated with the receiver.
+ *
+ * @return
+ */
+ public List getTargets();
/**
* Returns a String
containing the command-line invocation
* for the tool associated with the source extension.
*
- * @param extension the file extension of the file to be built
- * @return String
+ * @param sourceExtension the file extension of the file to be built
+ * @return a String containing the command line invocation for the tool
*/
- public String getToolForSource(String extension);
+ public String getToolForSource(String sourceExtension);
/**
* Returns a String
containing the command-line invocation
* for the tool associated with the target extension.
*
- * @param extension
- * @return
+ * @param extension the file extension of the build goal
+ * @return a String containing the command line invocation for the tool
*/
public String getToolForTarget(String extension);
@@ -204,26 +220,10 @@ public interface IManagedBuildInfo {
/**
* Answers the version of the build information in the format
- * @return
+ * @return a String
containing the build information
+ * version
*/
public String getVersion();
-
-
- /**
- * Answers whether the receiver has been changed and requires the
- * project to be rebuilt. When a project is first created, it is
- * assumed that the user will need it to be fully rebuilt. However
- * only option and tool command changes will trigger the build
- * information for an existing project to require a rebuild.
- *
- * Clients can reset the state to force or clear the rebuild status
- * using setRebuildState()
- * @see ManagedBuildInfo#setRebuildState(boolean)
- *
- * @return true
if the resource managed by the
- * receiver needs to be rebuilt
- */
- public boolean needsRebuild();
/**
* Answers true if the build model has been changed by the user.
@@ -241,14 +241,24 @@ public interface IManagedBuildInfo {
*/
public boolean isHeaderFile(String ext);
- public void removeTarget(String id);
/**
- * Set the dirty flag for the build model to the value of the argument.
+ * Answers whether the receiver has been changed and requires the
+ * project to be rebuilt. When a project is first created, it is
+ * assumed that the user will need it to be fully rebuilt. However
+ * only option and tool command changes will trigger the build
+ * information for an existing project to require a rebuild.
+ *
+ * Clients can reset the state to force or clear the rebuild status
+ * using setRebuildState()
+ * @see ManagedBuildInfo#setRebuildState(boolean)
*
- * @param isDirty
+ * @return true
if the resource managed by the
+ * receiver needs to be rebuilt
*/
- public void setDirty(boolean isDirty);
+ public boolean needsRebuild();
+
+ public void removeTarget(String id);
/**
* Set the primary configuration for the receiver.
@@ -259,6 +269,7 @@ public interface IManagedBuildInfo {
public void setDefaultConfiguration(IConfiguration configuration);
/**
+ *
* @param configuration
* @return
*/
@@ -271,6 +282,13 @@ public interface IManagedBuildInfo {
*/
public void setDefaultTarget(ITarget target);
+ /**
+ * Set the dirty flag for the build model to the value of the argument.
+ *
+ * @param isDirty
+ */
+ public void setDirty(boolean isDirty);
+
/**
* Sets the rebuild state in the receiver to the value of the argument.
* This is a potentially expensive option, so setting it to true should
@@ -282,18 +300,10 @@ public interface IManagedBuildInfo {
public void setRebuildState(boolean rebuild);
/**
- * Set the currently selected target. This is used while the project
+ * Set the currently selected target. This is used while the project
* property pages are displayed
*
- * @param target
+ * @param target the user selection
*/
public void setSelectedTarget(ITarget target);
-
- /**
- * Get the currently selected target. This is used while the project
- * property pages are displayed
- *
- * @return target
- */
- public ITarget getSelectedTarget();
}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ITarget.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ITarget.java
index 0462f35c9cb..e1fad3621c8 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ITarget.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ITarget.java
@@ -10,6 +10,7 @@
**********************************************************************/
package org.eclipse.cdt.managedbuilder.core;
+import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyGenerator;
import org.eclipse.core.resources.IResource;
/**
@@ -117,6 +118,17 @@ public interface ITarget extends IBuildObject {
*/
public String getDefaultExtension();
+ /**
+ * Answers a class instance that implements an interface to generate
+ * source-level dependencies for the tool specified in the argument.
+ * This method may return null
in which case, the receiver
+ * should assume that the tool does not require dependency information
+ * when the project is built.
+ *
+ * @param toolId
+ * @return
+ */
+ public IManagedDependencyGenerator getDependencyGenerator(String toolId);
/**
* Answers the command line arguments to pass to the make utility used
@@ -162,12 +174,12 @@ public interface ITarget extends IBuildObject {
*/
public String[] getTargetOSList();
- /**
- * Answers an array of architectures the target can be created on.
- *
- * @return String[]
- */
- public String[] getTargetArchList();
+ /**
+ * Answers an array of architectures the target can be created on.
+ *
+ * @return String[]
+ */
+ public String[] getTargetArchList();
/**
* Returns the list of platform specific tools associated with this
@@ -229,7 +241,7 @@ public interface ITarget extends IBuildObject {
/**
* Removes the configuration with the ID specified in the argument.
*
- * @param id
+ * @param id
*/
public void removeConfiguration(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 59644eb61c9..65701fe3f5f 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
@@ -47,6 +47,7 @@ import org.eclipse.cdt.managedbuilder.internal.core.ManagedBuildInfo;
import org.eclipse.cdt.managedbuilder.internal.core.ManagedMakeMessages;
import org.eclipse.cdt.managedbuilder.internal.core.Target;
import org.eclipse.cdt.managedbuilder.internal.core.Tool;
+import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyGenerator;
import org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderMakefileGenerator;
import org.eclipse.cdt.managedbuilder.scannerconfig.IManagedScannerInfoCollector;
import org.eclipse.core.resources.IFile;
@@ -88,6 +89,7 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
// This is the version of the manifest and project files that
private static final PluginVersionIdentifier buildInfoVersion = new PluginVersionIdentifier(2, 0, 0);
+ private static Map depCalculatorsMap;
private static boolean extensionTargetsLoaded = false;
private static Map extensionTargetMap;
private static List extensionTargets;
@@ -136,6 +138,69 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
return targets;
}
+ /**
+ * Answers an instance of a class that implements the
+ * IManagedDependencyGenerator
interface to generate
+ * the source-level dependencies that make utilities rely on to
+ * properly rebuild projects
+ *
+ * @param toolId the unique ID
of the tool to look for
+ * @return the dependency generator for the tool specified in the argument or null
+ */
+ public static IManagedDependencyGenerator getDependencyGenerator(String toolId) {
+ return (IManagedDependencyGenerator) getExtensionDepCalcMap().get(toolId);
+ }
+
+ /**
+ * @param toolId
+ * @return
+ */
+ public static IManagedDependencyGenerator createDependencyGenerator(String toolId) {
+ try {
+ IExtensionRegistry registry = Platform.getExtensionRegistry();
+ IExtensionPoint extension = registry.getExtensionPoint(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(ITool.TOOL_ELEMENT_NAME)) {
+ if (element.getAttribute(ITool.ID).equals(toolId)) {
+ if (element.getAttribute(ManagedBuilderCorePlugin.DEP_CALC_ID) != null) {
+ return (IManagedDependencyGenerator) element.createExecutableExtension(ManagedBuilderCorePlugin.DEP_CALC_ID);
+ }
+ }
+ } else if (element.getName().equals(ITarget.TARGET_ELEMENT_NAME)) {
+ IConfigurationElement[] children = element.getChildren(ITool.TOOL_ELEMENT_NAME);
+ for (int k = 0; k < children.length; ++k) {
+ IConfigurationElement child = children[k];
+ if (child.getAttribute(ITool.ID).equals(toolId)) {
+ if (child.getAttribute(ManagedBuilderCorePlugin.DEP_CALC_ID) != null) {
+ return (IManagedDependencyGenerator) child.createExecutableExtension(ManagedBuilderCorePlugin.DEP_CALC_ID);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ catch (CoreException e) {
+ // Probably not defined
+ ManagedBuilderCorePlugin.log(e);
+ }
+ return null;
+ }
+
+ protected static Map getExtensionDepCalcMap() {
+ if (depCalculatorsMap == null) {
+ depCalculatorsMap = new HashMap();
+ }
+ return depCalculatorsMap;
+ }
+
/* (non-Javadoc)
* Safe accessor for the map of IDs to Targets
*
@@ -247,6 +312,10 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
}
}
+ /**
+ * @param targetId
+ * @return
+ */
public static IManagedBuilderMakefileGenerator getMakefileGenerator(String targetId) {
try {
IExtensionRegistry registry = Platform.getExtensionRegistry();
@@ -555,10 +624,17 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
}
/**
+ * Adds a tool that is is specified in the manifest to the
+ * build system. This tool is available to any target that
+ * has a reference to it as part of its description. This
+ * permits a tool that is common to many targets to be defined
+ * only once.
+ *
* @param tool
*/
public static void addExtensionTool(Tool tool) {
getExtensionToolMap().put(tool.getId(), tool);
+ getExtensionDepCalcMap().put(tool.getId(), createDependencyGenerator(tool.getId()));
}
/**
@@ -609,7 +685,7 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
ManagedBuilderCorePlugin.log(e);
return new Status(IStatus.ERROR,
ManagedBuilderCorePlugin.getUniqueIdentifier(),
- -1,
+ IStatus.ERROR,
e.getLocalizedMessage(),
e);
}
@@ -628,6 +704,13 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
* @throws CoreException
*/
private static void initBuildInfoContainer(ManagedBuildInfo info) throws CoreException {
+ if (info == null) {
+ throw new CoreException(new Status(IStatus.ERROR,
+ ManagedBuilderCorePlugin.getUniqueIdentifier(),
+ IStatus.ERROR,
+ new String(),
+ null));
+ }
// Now associate the path entry container with the project
ICProject cProject = info.getCProject();
// This does not block the workspace or trigger delta events
@@ -901,6 +984,8 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
// Nothing in session store, so see if we can load it from cdtbuild
if (buildInfo == null && resource instanceof IProject) {
buildInfo = loadBuildInfo((IProject)resource);
+ // Make sure there was no error
+
try {
// Check if the project needs its container initialized
initBuildInfoContainer(buildInfo);
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/GeneratedMakefileBuilder.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/GeneratedMakefileBuilder.java
index c47244271f9..ed4d58c1897 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/GeneratedMakefileBuilder.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/GeneratedMakefileBuilder.java
@@ -31,7 +31,7 @@ import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
import org.eclipse.cdt.managedbuilder.core.ITool;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
-import org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderDependencyCalculator;
+import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyGenerator;
import org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderMakefileGenerator;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IMarker;
@@ -326,7 +326,7 @@ public class GeneratedMakefileBuilder extends ACBuilder {
* @param toolId
* @return
*/
- public IManagedBuilderDependencyCalculator getDependencyCalculator(String toolId) {
+ public IManagedDependencyGenerator getDependencyCalculator(String toolId) {
try {
IExtensionPoint extension = Platform.getExtensionRegistry().getExtensionPoint(ManagedBuilderCorePlugin.getUniqueIdentifier(), ManagedBuilderCorePlugin.DEP_CALC_ID);
if (extension != null) {
@@ -339,7 +339,7 @@ public class GeneratedMakefileBuilder extends ACBuilder {
if (element.getName().equals(ITool.TOOL_ELEMENT_NAME)) {
if (element.getAttribute(ITool.ID).equals(toolId)) {
if (element.getAttribute(ManagedBuilderCorePlugin.DEP_CALC_ID) != null) {
- return (IManagedBuilderDependencyCalculator) element.createExecutableExtension(ManagedBuilderCorePlugin.DEP_CALC_ID);
+ return (IManagedDependencyGenerator) element.createExecutableExtension(ManagedBuilderCorePlugin.DEP_CALC_ID);
}
}
}
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 0dfce1aeb84..8789dc7a188 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
@@ -1,7 +1,5 @@
-package org.eclipse.cdt.managedbuilder.internal.core;
-
/**********************************************************************
- * Copyright (c) 2002,2004 Rational Software Corporation and others.
+ * Copyright (c) 2002,2004 IBM Software Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v0.5
* which accompanies this distribution, and is available at
@@ -10,6 +8,7 @@ package org.eclipse.cdt.managedbuilder.internal.core;
* Contributors:
* IBM Rational Software - Initial API and implementation
* **********************************************************************/
+package org.eclipse.cdt.managedbuilder.internal.core;
import java.util.ArrayList;
import java.util.Arrays;
@@ -38,6 +37,7 @@ 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.cdt.managedbuilder.makegen.IManagedDependencyGenerator;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
@@ -49,15 +49,17 @@ import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
+/**
+ *
+ * @since 1.2
+ */
public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
-
- // Local variables
- public static final String MAJOR_SEPERATOR = ";"; //$NON-NLS-1$
- 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
public static final IContainerEntry containerEntry = CoreModel.newContainerEntry(new Path("org.eclipse.cdt.managedbuilder.MANAGED_CONTAINER")); //$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$
+ public static final String MAJOR_SEPERATOR = ";"; //$NON-NLS-1$
+ public static final String MINOR_SEPERATOR = "::"; //$NON-NLS-1$
private boolean containerCreated;
private ICProject cProject;
@@ -69,8 +71,8 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
private IResource owner;
private boolean rebuildNeeded;
private ITarget selectedTarget;
- private Map targetMap;
private List targetList;
+ private Map targetMap;
private String version;
@@ -91,7 +93,7 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
rebuildNeeded = true;
// The id of the default target from the project persistent settings store
- IProject project = (IProject)owner;
+ IProject project = owner.getProject();
defaultTargetId = null;
try {
defaultTargetId = project.getPersistentProperty(defaultTargetProperty);
@@ -119,6 +121,7 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
*/
public ManagedBuildInfo(IResource owner, Element element) {
this(owner);
+
// Container has already been created for this project
containerCreated = true;
@@ -159,17 +162,6 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
}
return false;
}
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo#setRebuildState(boolean)
- */
- public void setRebuildState(boolean rebuild) {
- Iterator iter = getTargets().listIterator();
- while (iter.hasNext()) {
- ((ITarget)iter.next()).setRebuildState(rebuild);
- }
- rebuildNeeded = rebuild;
- }
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo#getBuildArtifactExtension()
@@ -196,10 +188,6 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
return name;
}
- public ICProject getCProject() {
- return cProject;
- }
-
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#getCleanCommand()
*/
@@ -236,6 +224,10 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
return (String[])configNames.toArray(new String[configNames.size()]);
}
+ public ICProject getCProject() {
+ return cProject;
+ }
+
/* (non-Javadoc)
*
* @return Returns the map of ITarget ids to IConfigurations.
@@ -343,15 +335,46 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
return symbols;
}
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo#getDependencyGenerator(java.lang.String)
+ */
+ public IManagedDependencyGenerator getDependencyGenerator(String sourceExtension) {
+ // Find the tool and ask the target for its dep generator
+ try {
+ ITarget target = getDefaultTarget();
+ ITool[] tools = getFilteredTools();
+ for (int index = 0; index < tools.length; ++index) {
+ if(tools[index].buildsFileType(sourceExtension)) {
+ return target.getDependencyGenerator(tools[index].getId());
+ }
+ }
+ } catch (NullPointerException e) {
+ ManagedBuilderCorePlugin.log(e);
+ return null;
+ }
+
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * Helper method to extract a list of valid tools that are filtered by the
+ * project nature.
+ *
+ * @return
+ */
+ private ITool[] getFilteredTools() {
+ // Get all the tools for the current config filtered by the project nature
+ IProject project = owner.getProject();
+ IConfiguration config = getDefaultConfiguration(getDefaultTarget());
+ return config.getFilteredTools(project);
+ }
+
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#getFlagsForSource(java.lang.String)
*/
public String getFlagsForSource(String extension) {
- IProject project = (IProject)owner;
-
// Get all the tools for the current config
- IConfiguration config = getDefaultConfiguration(getDefaultTarget());
- ITool[] tools = config.getFilteredTools(project);
+ ITool[] tools = getFilteredTools();
for (int index = 0; index < tools.length; index++) {
ITool tool = tools[index];
if (tool != null && tool.buildsFileType(extension)) {
@@ -369,13 +392,11 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
* @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#getToolFlags(java.lang.String)
*/
public String getFlagsForTarget(String extension) {
- IProject project = (IProject)owner;
// Treat null extensions as an empty string
String ext = extension == null ? new String() : extension;
// Get all the tools for the current config
- IConfiguration config = getDefaultConfiguration(getDefaultTarget());
- ITool[] tools = config.getFilteredTools(project);
+ ITool[] tools = getFilteredTools();
for (int index = 0; index < tools.length; index++) {
ITool tool = tools[index];
if (tool.producesFileType(ext)) {
@@ -459,37 +480,12 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
return (String[])paths.toArray(new String[paths.size()]);
}
- private HashMap getMacroPathEntries() {
- HashMap macros = new HashMap();
- if (cProject != null) {
- try {
- IPathEntry[] entries = cProject.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) {
- // return an empty map
- macros.clear();
- return macros;
- }
-
- }
- return macros;
- }
-
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#getLibsForTarget(java.lang.String)
*/
public String[] getLibsForTarget(String extension) {
- IProject project = (IProject)owner;
-
Vector libs = new Vector();
- // Get all the tools for the current config
- IConfiguration config = getDefaultConfiguration(getDefaultTarget());
- ITool[] tools = config.getFilteredTools(project);
+ ITool[] tools = getFilteredTools();
for (int index = 0; index < tools.length; index++) {
ITool tool = tools[index];
if (tool.producesFileType(extension)) {
@@ -515,6 +511,27 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
return (String[])libs.toArray(new String[libs.size()]);
}
+ private HashMap getMacroPathEntries() {
+ HashMap macros = new HashMap();
+ if (cProject != null) {
+ try {
+ IPathEntry[] entries = cProject.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) {
+ // return an empty map
+ macros.clear();
+ return macros;
+ }
+
+ }
+ return macros;
+ }
+
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#getMakeArguments()
*/
@@ -533,12 +550,8 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
* @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#getOutputExtension(java.lang.String)
*/
public String getOutputExtension(String resourceExtension) {
- IProject project = (IProject)owner;
String outputExtension = null;
-
- // Get all the tools for the current config
- IConfiguration config = getDefaultConfiguration(getDefaultTarget());
- ITool[] tools = config.getFilteredTools(project);
+ ITool[] tools = getFilteredTools();
for (int index = 0; index < tools.length; index++) {
ITool tool = tools[index];
outputExtension = tool.getOutputExtension(resourceExtension);
@@ -553,14 +566,12 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
* @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#getOutputFlag()
*/
public String getOutputFlag(String outputExt) {
- IProject project = (IProject)owner;
// Treat null extension as an empty string
String ext = outputExt == null ? new String() : outputExt;
// Get all the tools for the current config
String flags = new String();
- IConfiguration config = getDefaultConfiguration(getDefaultTarget());
- ITool[] tools = config.getFilteredTools(project);
+ ITool[] tools = getFilteredTools();
for (int index = 0; index < tools.length; index++) {
ITool tool = tools[index];
// It's OK
@@ -575,14 +586,12 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
* @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#getOutputPrefix(java.lang.String)
*/
public String getOutputPrefix(String outputExtension) {
- IProject project = (IProject)owner;
// Treat null extensions as empty string
String ext = outputExtension == null ? new String() : outputExtension;
// Get all the tools for the current config
String flags = new String();
- IConfiguration config = getDefaultConfiguration(getDefaultTarget());
- ITool[] tools = config.getFilteredTools(project);
+ ITool[] tools = getFilteredTools();
for (int index = 0; index < tools.length; index++) {
ITool tool = tools[index];
if (tool.producesFileType(ext)) {
@@ -599,6 +608,13 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
return owner;
}
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#getSelectedTarget()
+ */
+ public ITarget getSelectedTarget() {
+ return selectedTarget;
+ }
+
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#getTarget(org.eclipse.cdt.core.build.managed.IConfiguration)
*/
@@ -631,15 +647,12 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#getToolForSource(java.lang.String)
*/
- public String getToolForSource(String extension) {
- IProject project = (IProject)owner;
-
+ public String getToolForSource(String sourceExtension) {
// Get all the tools for the current config
- IConfiguration config = getDefaultConfiguration(getDefaultTarget());
- ITool[] tools = config.getFilteredTools(project);
+ ITool[] tools = getFilteredTools();
for (int index = 0; index < tools.length; index++) {
ITool tool = tools[index];
- if (tool.buildsFileType(extension)) {
+ if (tool.buildsFileType(sourceExtension)) {
return tool.getToolCommand();
}
}
@@ -650,13 +663,10 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
* @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#getToolInvocation(java.lang.String)
*/
public String getToolForTarget(String extension) {
- IProject project = (IProject)owner;
-
// Treat a null argument as an empty string
String ext = extension == null ? new String() : extension;
// Get all the tools for the current config
- IConfiguration config = getDefaultConfiguration(getDefaultTarget());
- ITool[] tools = config.getFilteredTools(project);
+ ITool[] tools = getFilteredTools();
for (int index = 0; index < tools.length; index++) {
ITool tool = tools[index];
if (tool.producesFileType(ext)) {
@@ -670,11 +680,9 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
* @see org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo#getUserObjectsForTarget(java.lang.String)
*/
public String[] getUserObjectsForTarget(String extension) {
- IProject project = (IProject)owner;
Vector objs = new Vector();
// Get all the tools for the current config
- IConfiguration config = getDefaultConfiguration(getDefaultTarget());
- ITool[] tools = config.getFilteredTools(project);
+ ITool[] tools = getFilteredTools();
for (int index = 0; index < tools.length; index++) {
ITool tool = tools[index];
// The tool is OK for this project nature
@@ -702,6 +710,18 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
public String getVersion() {
return version;
}
+
+ /* (non-Javadoc)
+ *
+ */
+ private void initializePathEntries() {
+ try {
+ IPathEntryContainer container = new ManagedBuildCPathEntryContainer(getOwner().getProject());
+ CoreModel.getDefault().setPathEntryContainer(new ICProject[]{cProject}, container, new NullProgressMonitor());
+ } catch (CModelException e) {
+ ManagedBuilderCorePlugin.log(e);
+ }
+ }
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo#isDirty()
@@ -792,7 +812,7 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
}
}
// Persist the default configurations
- IProject project = (IProject) getOwner();
+ IProject project = owner.getProject();
try {
project.setPersistentProperty(defaultConfigProperty, defaultConfigs.toString().trim());
} catch (CoreException e) {
@@ -805,7 +825,7 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
*/
private void persistDefaultTarget() {
// Persist the default target as a project setting
- IProject project = (IProject) getOwner();
+ IProject project = owner.getProject();
ITarget defTarget = getDefaultTarget();
if (defTarget != null){
try {
@@ -815,18 +835,6 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
}
}
}
-
- /* (non-Javadoc)
- *
- */
- private void initializePathEntries() {
- try {
- IPathEntryContainer container = new ManagedBuildCPathEntryContainer(getOwner().getProject());
- CoreModel.getDefault().setPathEntryContainer(new ICProject[]{cProject}, container, new NullProgressMonitor());
- } catch (CModelException e) {
- ManagedBuilderCorePlugin.log(e);
- }
- }
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo#removeTarget(java.lang.String)
@@ -925,20 +933,6 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
}
}
}
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#setSelectedTarget(org.eclipse.cdt.core.build.managed.ITarget)
- */
- public void setSelectedTarget(ITarget target) {
- selectedTarget = target;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#getSelectedTarget()
- */
- public ITarget getSelectedTarget() {
- return selectedTarget;
- }
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo#setDirty(boolean)
@@ -954,6 +948,24 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
}
}
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo#setRebuildState(boolean)
+ */
+ public void setRebuildState(boolean rebuild) {
+ Iterator iter = getTargets().listIterator();
+ while (iter.hasNext()) {
+ ((ITarget)iter.next()).setRebuildState(rebuild);
+ }
+ rebuildNeeded = rebuild;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#setSelectedTarget(org.eclipse.cdt.core.build.managed.ITarget)
+ */
+ public void setSelectedTarget(ITarget target) {
+ selectedTarget = target;
+ }
+
/**
* @param version
*/
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Target.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Target.java
index 60c0dba655e..cfadb475490 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Target.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Target.java
@@ -18,6 +18,7 @@ import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.StringTokenizer;
+import java.util.Vector;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
@@ -26,6 +27,7 @@ import org.eclipse.cdt.managedbuilder.core.IManagedConfigElement;
import org.eclipse.cdt.managedbuilder.core.ITarget;
import org.eclipse.cdt.managedbuilder.core.ITool;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
+import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyGenerator;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.Platform;
import org.w3c.dom.Document;
@@ -33,15 +35,16 @@ import org.w3c.dom.Element;
import org.w3c.dom.Node;
public class Target extends BuildObject implements ITarget {
-
- // Build model elements that come from the plugin or project files
+ private static final String EMPTY_STRING = new String();
+ private static final IConfiguration[] emptyConfigs = new IConfiguration[0];
private String artifactName;
private String binaryParserId;
- private String errorParserIds;
private String cleanCommand;
private List configList;
private Map configMap;
private String defaultExtension;
+ private Map depCalculatorsMap;
+ private String errorParserIds;
private String extension;
private boolean isAbstract = false;
private boolean isDirty = false;
@@ -50,57 +53,12 @@ public class Target extends BuildObject implements ITarget {
private String makeCommand;
private IResource owner;
private ITarget parent;
- private List targetOSList;
- private List targetArchList;
- private Map toolMap;
- private List toolList;
- private List toolReferences;
private boolean resolved = true;
-
- private static final IConfiguration[] emptyConfigs = new IConfiguration[0];
- private static final String EMPTY_STRING = new String();
-
- /* (non-Javadoc)
- * Set the resource that owns the target.
- *
- * @param owner
- */
- protected Target(IResource owner) {
- this.owner = owner;
- }
-
- /**
- * Create a copy of the target specified in the argument,
- * that is owned by the owned by the specified resource.
- *
- * @param owner
- * @param parent
- */
- public Target(IResource owner, ITarget parent) {
- // Make the owner of the target the project resource
- this(owner);
-
- // Copy the parent's identity
- this.parent = parent;
- Random r = new Random();
- r.setSeed(System.currentTimeMillis());
- int id = r.nextInt();
- if (id < 0) {
- id *= -1;
- }
- setId(owner.getName() + "." + parent.getId() + "." + id); //$NON-NLS-1$ //$NON-NLS-2$
- setName(parent.getName());
- setArtifactName(parent.getArtifactName());
- this.binaryParserId = parent.getBinaryParserId();
- this.errorParserIds = parent.getErrorParserIds();
- this.defaultExtension = parent.getArtifactExtension();
- this.isTest = parent.isTestTarget();
- this.cleanCommand = parent.getCleanCommand();
-
- // Hook me up
- IManagedBuildInfo buildInfo = ManagedBuildManager.getBuildInfo(owner);
- buildInfo.addTarget(this);
- }
+ private List targetArchList;
+ private List targetOSList;
+ private List toolList;
+ private Map toolMap;
+ private List toolReferences;
/**
* This constructor is called to create a target defined by an extension point in
@@ -176,6 +134,48 @@ public class Target extends BuildObject implements ITarget {
new Configuration(this, configs[k]);
}
}
+
+ /* (non-Javadoc)
+ * Set the resource that owns the target.
+ *
+ * @param owner
+ */
+ protected Target(IResource owner) {
+ this.owner = owner;
+ }
+
+ /**
+ * Create a copy of the target specified in the argument,
+ * that is owned by the owned by the specified resource.
+ *
+ * @param owner
+ * @param parent
+ */
+ public Target(IResource owner, ITarget parent) {
+ // Make the owner of the target the project resource
+ this(owner);
+
+ // Copy the parent's identity
+ this.parent = parent;
+ Random r = new Random();
+ r.setSeed(System.currentTimeMillis());
+ int id = r.nextInt();
+ if (id < 0) {
+ id *= -1;
+ }
+ setId(owner.getName() + "." + parent.getId() + "." + id); //$NON-NLS-1$ //$NON-NLS-2$
+ setName(parent.getName());
+ setArtifactName(parent.getArtifactName());
+ this.binaryParserId = parent.getBinaryParserId();
+ this.errorParserIds = parent.getErrorParserIds();
+ this.defaultExtension = parent.getArtifactExtension();
+ this.isTest = parent.isTestTarget();
+ this.cleanCommand = parent.getCleanCommand();
+
+ // Hook me up
+ IManagedBuildInfo buildInfo = ManagedBuildManager.getBuildInfo(owner);
+ buildInfo.addTarget(this);
+ }
/**
* Create target from project file.
@@ -242,116 +242,258 @@ public class Target extends BuildObject implements ITarget {
child = child.getNextSibling();
}
}
-
- /**
- *
- */
- public void resolveReferences() {
- if (!resolved) {
- resolved = true;
- IManagedConfigElement element = ManagedBuildManager.getConfigElement(this);
- // parent
- String parentId = element.getAttribute(PARENT);
- if (parentId != null) {
- parent = ManagedBuildManager.getTarget(null, parentId);
- // should resolve before calling methods on it
- ((Target)parent).resolveReferences();
- // copy over the parents configs
- IConfiguration[] parentConfigs = parent.getConfigurations();
- for (int i = 0; i < parentConfigs.length; ++i)
- addConfiguration(parentConfigs[i]);
- }
- // call resolve references on any children
- Iterator toolIter = getToolList().iterator();
- while (toolIter.hasNext()) {
- Tool current = (Tool)toolIter.next();
- current.resolveReferences();
- }
- Iterator refIter = getLocalToolReferences().iterator();
- while (refIter.hasNext()) {
- ToolReference current = (ToolReference)refIter.next();
- current.resolveReferences();
- }
- Iterator configIter = getConfigurationList().iterator();
- while (configIter.hasNext()) {
- Configuration current = (Configuration)configIter.next();
- current.resolveReferences();
- }
- }
+ /**
+ * @param configuration
+ */
+ public void addConfiguration(IConfiguration configuration) {
+ getConfigurationList().add(configuration);
+ getConfigurationMap().put(configuration.getId(), configuration);
+ }
+
+ /**
+ * Adds a tool specification to the receiver. This tool is defined
+ * only for the receiver, and cannot be shared by other targets.
+ *
+ * @param tool
+ */
+ public void addTool(ITool tool) {
+ getToolList().add(tool);
+ getToolMap().put(tool.getId(), tool);
+ getDepCalcMap().put(tool.getId(), ManagedBuildManager.createDependencyGenerator(tool.getId()));
+ }
+
+ /**
+ * Adds a tool reference to the receiver.
+ *
+ * @param toolRef
+ */
+ public void addToolReference(ToolReference toolRef) {
+ getLocalToolReferences().add(toolRef);
}
+
/* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.ITarget#removeConfiguration(java.lang.String)
+ * Tail-recursion method that creates a lits of tools and tool reference
+ * walking the receiver's parent hierarchy.
+ *
+ * @param toolArray
*/
- public void removeConfiguration(String id) {
- // Remove the specified configuration from the list and map
- Iterator iter = getConfigurationList().listIterator();
- while (iter.hasNext()) {
- IConfiguration config = (IConfiguration)iter.next();
- if (config.getId().equals(id)) {
- getConfigurationList().remove(config);
- getConfigurationMap().remove(id);
- isDirty = true;
- break;
- }
+ private void addToolsToArray(Vector toolArray) {
+ if (parent != null) {
+ ((Target)parent).addToolsToArray(toolArray);
}
+
+ // Add the tools from out own list
+ toolArray.addAll(getToolList());
+
+ // Add local tool references
+ toolArray.addAll(getLocalToolReferences());
}
/* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.ITarget#resetMakeCommand()
+ * @see org.eclipse.cdt.core.build.managed.ITarget#createConfiguration(org.eclipse.cdt.core.build.managed.IConfiguration)
*/
- public void resetMakeCommand() {
- // Flag target as dirty if the reset actually changes something
- if (makeCommand != null) {
- setDirty(true);
- }
- makeCommand = null;
- makeArguments = null;
+ public IConfiguration createConfiguration(IConfiguration parent, String id) {
+ isDirty = true;
+ return new Configuration(this, parent, id);
}
-
- /**
- * Persist receiver to project file.
- *
- * @param doc
- * @param element
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.ITarget#createConfiguration()
*/
- public void serialize(Document doc, Element element) {
- element.setAttribute(ID, getId());
- element.setAttribute(NAME, getName());
- if (parent != null)
- element.setAttribute(PARENT, parent.getId());
- element.setAttribute(IS_ABSTRACT, isAbstract ? "true" : "false"); //$NON-NLS-1$ //$NON-NLS-2$
- element.setAttribute(ARTIFACT_NAME, getArtifactName());
+ public IConfiguration createConfiguration(String id) {
+ return new Configuration(this, id);
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.ITarget#getArtifactExtension()
+ */
+ public String getArtifactExtension() {
+ // Has the user changed the extension for this target
if (extension != null) {
- element.setAttribute(EXTENSION, extension);
+ return extension;
}
- element.setAttribute(IS_TEST, isTest ? "true" : "false"); //$NON-NLS-1$ //$NON-NLS-2$
-
- if (makeCommand != null) {
- element.setAttribute(MAKE_COMMAND, makeCommand);
+ // If not, then go through the default extension lookup
+ if (defaultExtension == null) {
+ // Ask my parent first
+ if (parent != null) {
+ return parent.getArtifactExtension();
+ } else {
+ return EMPTY_STRING;
+ }
} else {
- // Make sure we use the default
- }
-
- if (makeArguments != null) {
- element.setAttribute(MAKE_ARGS, makeArguments);
- }
- if (errorParserIds != null) {
- element.setAttribute(ERROR_PARSERS, errorParserIds);
+ return defaultExtension;
}
+ }
- // Serialize the configuration settings
- Iterator iter = getConfigurationList().listIterator();
- while (iter.hasNext()) {
- Configuration config = (Configuration) iter.next();
- Element configElement = doc.createElement(IConfiguration.CONFIGURATION_ELEMENT_NAME);
- element.appendChild(configElement);
- config.serialize(doc, configElement);
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.ITarget#getArtifactName()
+ */
+ public String getArtifactName() {
+ if (artifactName == null) {
+ // If I have a parent, ask it
+ if (parent != null) {
+ return parent.getArtifactName();
+ } else {
+ // I'm it and this is not good!
+ return EMPTY_STRING;
+ }
+ } else {
+ return artifactName;
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.ITarget#getBinaryParserId()
+ */
+ public String getBinaryParserId() {
+ if (binaryParserId == null) {
+ // If I have a parent, ask it
+ if (parent != null) {
+ return parent.getBinaryParserId();
+ } else {
+ // I'm it and this is not good!
+ return EMPTY_STRING;
+ }
+ }
+ return binaryParserId;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.ITarget#getCleanCommand()
+ */
+ public String getCleanCommand() {
+ // Return the command used to remove files
+ if (cleanCommand == null) {
+ if (parent != null) {
+ return parent.getCleanCommand();
+ } else {
+ // User forgot to specify it. Guess based on OS.
+ if (Platform.getOS().equals("OS_WIN32")) { //$NON-NLS-1$
+ return new String("del"); //$NON-NLS-1$
+ } else {
+ return new String("rm"); //$NON-NLS-1$
+ }
+ }
+ } else {
+ // This was spec'd in the manifest
+ return cleanCommand;
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.ITarget#getConfiguration()
+ */
+ public IConfiguration getConfiguration(String id) {
+ return (IConfiguration)getConfigurationMap().get(id);
+ }
+
+ /* (non-Javadoc)
+ * Safe accessor for the list of configurations.
+ *
+ * @return List containing the configurations
+ */
+ private List getConfigurationList() {
+ if (configList == null) {
+ configList = new ArrayList();
+ }
+ return configList;
+ }
+
+ /* (non-Javadoc)
+ * Safe accessor for the map of configuration ids to configurations
+ *
+ * @return
+ */
+ private Map getConfigurationMap() {
+ if (configMap == null) {
+ configMap = new HashMap();
+ }
+ return configMap;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.ITarget#getConfigurations()
+ */
+ public IConfiguration[] getConfigurations() {
+ return (IConfiguration[])getConfigurationList().toArray(new IConfiguration[getConfigurationList().size()]);
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.ITarget#getDefaultExtension()
+ */
+ public String getDefaultExtension() {
+ return defaultExtension == null ? EMPTY_STRING : defaultExtension;
+ }
+
+ private Map getDepCalcMap() {
+ if (depCalculatorsMap == null) {
+ depCalculatorsMap = new HashMap();
+ }
+ return depCalculatorsMap;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.ITarget#getDependencyCalculator(java.lang.String)
+ */
+ public IManagedDependencyGenerator getDependencyGenerator(String toolId) {
+ // If I have this tool defined locally, answer its dependency calculator
+ IManagedDependencyGenerator answer = (IManagedDependencyGenerator) getDepCalcMap().get(toolId);
+
+ // I do not have a local tool definition
+ if (answer == null && parent != null) {
+ answer = parent.getDependencyGenerator(toolId);
}
- // I am clean now
- isDirty = false;
+ // Perhaps this is a reference, in which case the build manager is cacheing its generator
+ if (answer == null && parent == null) {
+ answer = ManagedBuildManager.getDependencyGenerator(toolId);
+ }
+
+ return answer;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.ITarget#getErrorParserIds()
+ */
+ public String getErrorParserIds() {
+ if (errorParserIds == null) {
+ // If I have a parent, ask it
+ if (parent != null) {
+ return parent.getErrorParserIds();
+ }
+ }
+ return errorParserIds;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.ITarget#getErrorParserList()
+ */
+ public String[] getErrorParserList() {
+ String parserIDs = getErrorParserIds();
+ String[] errorParsers = null;
+ if (parserIDs != null) {
+ // Check for an empty string
+ if (parserIDs.length() == 0) {
+ errorParsers = new String[0];
+ } else {
+ StringTokenizer tok = new StringTokenizer(parserIDs, ";"); //$NON-NLS-1$
+ List list = new ArrayList(tok.countTokens());
+ while (tok.hasMoreElements()) {
+ list.add(tok.nextToken());
+ }
+ String[] strArr = {""}; //$NON-NLS-1$
+ errorParsers = (String[]) list.toArray(strArr);
+ }
+ } else {
+ // If no error parsers are specified by the target, the default is
+ // all error parsers
+ errorParsers = CCorePlugin.getDefault().getAllErrorParsersIDs();
+ }
+ return errorParsers;
}
/* (non-javadoc)
@@ -360,42 +502,12 @@ public class Target extends BuildObject implements ITarget {
*
* @return List
*/
- protected List getLocalToolReferences() {
+ private List getLocalToolReferences() {
if (toolReferences == null) {
toolReferences = new ArrayList();
- toolReferences.clear();
}
return toolReferences;
}
-
- /* (non-javadoc)
- *
- * @param tool
- * @return List
- */
- protected List getOptionReferences(ITool tool) {
- List references = new ArrayList();
-
- // Get all the option references I add for this tool
- ToolReference toolRef = getToolReference(tool);
- if (toolRef != null) {
- references.addAll(toolRef.getOptionReferenceList());
- }
-
- // See if there is anything that my parents add that I don't
- if (parent != null) {
- List temp = ((Target)parent).getOptionReferences(tool);
- Iterator iter = temp.listIterator();
- while (iter.hasNext()) {
- OptionReference ref = (OptionReference) iter.next();
- if (!references.contains(ref)) {
- references.add(ref);
- }
- }
- }
-
- return references;
- }
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.ITarget#getMakeArguments()
@@ -447,12 +559,64 @@ public class Target extends BuildObject implements ITarget {
}
}
+ /* (non-javadoc)
+ *
+ * @param tool
+ * @return List
+ */
+ protected List getOptionReferences(ITool tool) {
+ List references = new ArrayList();
+
+ // Get all the option references I add for this tool
+ ToolReference toolRef = getToolReference(tool);
+ if (toolRef != null) {
+ references.addAll(toolRef.getOptionReferenceList());
+ }
+
+ // See if there is anything that my parents add that I don't
+ if (parent != null) {
+ List temp = ((Target)parent).getOptionReferences(tool);
+ Iterator iter = temp.listIterator();
+ while (iter.hasNext()) {
+ OptionReference ref = (OptionReference) iter.next();
+ if (!references.contains(ref)) {
+ references.add(ref);
+ }
+ }
+ }
+
+ return references;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.ITarget#getOwner()
+ */
+ public IResource getOwner() {
+ return owner;
+ }
+
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.ITarget#getParent()
*/
public ITarget getParent() {
return parent;
}
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.ITarget#getTargetArchList()
+ */
+ public String[] getTargetArchList() {
+ if (targetArchList == null) {
+ // Ask parent for its list
+ if (parent != null) {
+ return parent.getTargetArchList();
+ } else {
+ // I have no parent and no defined list
+ return new String[] {"all"}; //$NON-NLS-1$
+ }
+ }
+ return (String[]) targetArchList.toArray(new String[targetArchList.size()]);
+ }
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.ITarget#getTargetOSList()
@@ -471,65 +635,27 @@ public class Target extends BuildObject implements ITarget {
}
/* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.ITarget#getTargetArchList()
+ * @see org.eclipse.cdt.managedbuilder.core.ITarget#getTool(java.lang.String)
*/
- public String[] getTargetArchList() {
- if (targetArchList == null) {
- // Ask parent for its list
- if (parent != null) {
- return parent.getTargetArchList();
- } else {
- // I have no parent and no defined list
- return new String[] {"all"}; //$NON-NLS-1$
- }
- }
- return (String[]) targetArchList.toArray(new String[targetArchList.size()]);
- }
+ public ITool getTool(String id) {
+ ITool result = null;
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.ITarget#getOwner()
- */
- public IResource getOwner() {
- return owner;
- }
+ // See if receiver has it in list
+ result = (ITool) getToolMap().get(id);
- private int getToolCount() {
- // Count the tools that belong to the target
- int n = getToolList().size();
- // Count the references the target has
- n += getLocalToolReferences().size();
- // Count the tools in the parent
- if (parent != null)
- n += ((Target)parent).getToolCount();
- return n;
- }
-
-
- /* (non-Javadoc)
- * Tail-recursion method that creates a lits of tools and tool reference
- * walking the receiver's parent hierarchy.
- *
- * @param toolArray
- * @param start
- * @return
- */
- private int addToolsToArray(ITool[] toolArray, int start) {
- int n = start;
- if (parent != null)
- n = ((Target)parent).addToolsToArray(toolArray, start);
-
- for (int i = 0; i < getToolList().size(); ++i) {
- toolArray[n++] = (ITool)getToolList().get(i);
- }
-
- // Add local tool references
- for (int j = 0; j < getLocalToolReferences().size(); ++j) {
- toolArray[n++] = (ITool)getLocalToolReferences().get(j);
+ // If not, check if parent has it
+ if (result == null && parent != null) {
+ result = ((Target)parent).getTool(id);
}
- return n;
+ // If not defined in parents, check if defined at all
+ if (result == null) {
+ result = ManagedBuildManager.getTool(id);
+ }
+
+ return result;
}
-
+
/* (non-Javadoc)
* A safe accessor method for the list of tools maintained by the
* target
@@ -538,7 +664,6 @@ public class Target extends BuildObject implements ITarget {
private List getToolList() {
if (toolList == null) {
toolList = new ArrayList();
- toolList.clear();
}
return toolList;
}
@@ -550,7 +675,6 @@ public class Target extends BuildObject implements ITarget {
private Map getToolMap() {
if (toolMap == null) {
toolMap = new HashMap();
- toolMap.clear();
}
return toolMap;
}
@@ -581,9 +705,9 @@ public class Target extends BuildObject implements ITarget {
* @see org.eclipse.cdt.managedbuilder.core.ITarget#getTools()
*/
public ITool[] getTools() {
- ITool[] toolArray = new ITool[getToolCount()];
- addToolsToArray(toolArray, 0);
- return toolArray;
+ Vector toolArray = new Vector();
+ addToolsToArray(toolArray);
+ return (ITool[]) toolArray.toArray(new ITool[toolArray.size()]);
}
/* (non-Javadoc)
@@ -595,207 +719,6 @@ public class Target extends BuildObject implements ITarget {
|| (makeArguments != null && !makeArguments.equals(parent.getMakeArguments())));
}
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.ITarget#getTool(java.lang.String)
- */
- public ITool getTool(String id) {
- ITool result = null;
-
- // See if receiver has it in list
- result = (ITool) getToolMap().get(id);
-
- // If not, check if parent has it
- if (result == null && parent != null) {
- result = ((Target)parent).getTool(id);
- }
-
- // If not defined in parents, check if defined at all
- if (result == null) {
- result = ManagedBuildManager.getTool(id);
- }
-
- return result;
- }
-
- /**
- * @param tool
- */
- public void addTool(ITool tool) {
- getToolList().add(tool);
- getToolMap().put(tool.getId(), tool);
- }
-
- /* (non-Javadoc)
- * Safe accessor for the list of configurations.
- *
- * @return List containing the configurations
- */
- private List getConfigurationList() {
- if (configList == null) {
- configList = new ArrayList();
- }
- return configList;
- }
-
- /* (non-Javadoc)
- * Safe accessor for the map of configuration ids to configurations
- *
- * @return
- */
- private Map getConfigurationMap() {
- if (configMap == null) {
- configMap = new HashMap();
- }
- return configMap;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.ITarget#getConfigurations()
- */
- public IConfiguration[] getConfigurations() {
- return (IConfiguration[])getConfigurationList().toArray(new IConfiguration[getConfigurationList().size()]);
- }
-
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.ITarget#getDefaultExtension()
- */
- public String getDefaultExtension() {
- return defaultExtension == null ? EMPTY_STRING : defaultExtension;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.ITarget#getCleanCommand()
- */
- public String getCleanCommand() {
- // Return the command used to remove files
- if (cleanCommand == null) {
- if (parent != null) {
- return parent.getCleanCommand();
- } else {
- // User forgot to specify it. Guess based on OS.
- if (Platform.getOS().equals("OS_WIN32")) { //$NON-NLS-1$
- return new String("del"); //$NON-NLS-1$
- } else {
- return new String("rm"); //$NON-NLS-1$
- }
- }
- } else {
- // This was spec'd in the manifest
- return cleanCommand;
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.ITarget#getArtifactName()
- */
- public String getArtifactName() {
- if (artifactName == null) {
- // If I have a parent, ask it
- if (parent != null) {
- return parent.getArtifactName();
- } else {
- // I'm it and this is not good!
- return EMPTY_STRING;
- }
- } else {
- return artifactName;
- }
- }
-
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.ITarget#getArtifactExtension()
- */
- public String getArtifactExtension() {
- // Has the user changed the extension for this target
- if (extension != null) {
- return extension;
- }
- // If not, then go through the default extension lookup
- if (defaultExtension == null) {
- // Ask my parent first
- if (parent != null) {
- return parent.getArtifactExtension();
- } else {
- return EMPTY_STRING;
- }
- } else {
- return defaultExtension;
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.ITarget#getBinaryParserId()
- */
- public String getBinaryParserId() {
- if (binaryParserId == null) {
- // If I have a parent, ask it
- if (parent != null) {
- return parent.getBinaryParserId();
- } else {
- // I'm it and this is not good!
- return EMPTY_STRING;
- }
- }
- return binaryParserId;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.ITarget#getErrorParserIds()
- */
- public String getErrorParserIds() {
- if (errorParserIds == null) {
- // If I have a parent, ask it
- if (parent != null) {
- return parent.getErrorParserIds();
- }
- }
- return errorParserIds;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.ITarget#getErrorParserList()
- */
- public String[] getErrorParserList() {
- String parserIDs = getErrorParserIds();
- String[] errorParsers = null;
- if (parserIDs != null) {
- // Check for an empty string
- if (parserIDs.length() == 0) {
- errorParsers = new String[0];
- } else {
- StringTokenizer tok = new StringTokenizer(parserIDs, ";"); //$NON-NLS-1$
- List list = new ArrayList(tok.countTokens());
- while (tok.hasMoreElements()) {
- list.add(tok.nextToken());
- }
- String[] strArr = {""}; //$NON-NLS-1$
- errorParsers = (String[]) list.toArray(strArr);
- }
- } else {
- // If no error parsers are specified by the target, the default is
- // all error parsers
- errorParsers = CCorePlugin.getDefault().getAllErrorParsersIDs();
- }
- return errorParsers;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.ITarget#getConfiguration()
- */
- public IConfiguration getConfiguration(String id) {
- return (IConfiguration)getConfigurationMap().get(id);
- }
-
- /**
- * @param configuration
- */
- public void addConfiguration(IConfiguration configuration) {
- getConfigurationList().add(configuration);
- getConfigurationMap().put(configuration.getId(), configuration);
- }
-
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.ITarget#isAbstract()
*/
@@ -822,37 +745,17 @@ public class Target extends BuildObject implements ITarget {
return false;
}
+
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.ITarget#isTestTarget()
*/
public boolean isTestTarget() {
return isTest;
}
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.ITarget#createConfiguration()
- */
- public IConfiguration createConfiguration(String id) {
- return new Configuration(this, id);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.ITarget#createConfiguration(org.eclipse.cdt.core.build.managed.IConfiguration)
- */
- public IConfiguration createConfiguration(IConfiguration parent, String id) {
- isDirty = true;
- return new Configuration(this, parent, id);
- }
-
- /**
- * Adds a tool reference to the receiver.
- *
- * @param toolRef
- */
- public void addToolReference(ToolReference toolRef) {
- getLocalToolReferences().add(toolRef);
- }
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.ITarget#needsRebuild()
+ */
public boolean needsRebuild(){
// Iterate over the configurations and ask them if they need saving
Iterator iter = getConfigurationList().listIterator();
@@ -864,6 +767,117 @@ public class Target extends BuildObject implements ITarget {
return false;
}
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.ITarget#removeConfiguration(java.lang.String)
+ */
+ public void removeConfiguration(String id) {
+ // Remove the specified configuration from the list and map
+ Iterator iter = getConfigurationList().listIterator();
+ while (iter.hasNext()) {
+ IConfiguration config = (IConfiguration)iter.next();
+ if (config.getId().equals(id)) {
+ getConfigurationList().remove(config);
+ getConfigurationMap().remove(id);
+ isDirty = true;
+ break;
+ }
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.ITarget#resetMakeCommand()
+ */
+ public void resetMakeCommand() {
+ // Flag target as dirty if the reset actually changes something
+ if (makeCommand != null) {
+ setDirty(true);
+ }
+ makeCommand = null;
+ makeArguments = null;
+ }
+
+ /**
+ *
+ */
+ public void resolveReferences() {
+ if (!resolved) {
+ resolved = true;
+ IManagedConfigElement element = ManagedBuildManager.getConfigElement(this);
+ // parent
+ String parentId = element.getAttribute(PARENT);
+ if (parentId != null) {
+ parent = ManagedBuildManager.getTarget(null, parentId);
+ // should resolve before calling methods on it
+ ((Target)parent).resolveReferences();
+ // copy over the parents configs
+ IConfiguration[] parentConfigs = parent.getConfigurations();
+ for (int i = 0; i < parentConfigs.length; ++i)
+ addConfiguration(parentConfigs[i]);
+ }
+
+ // call resolve references on any children
+ Iterator toolIter = getToolList().iterator();
+ while (toolIter.hasNext()) {
+ Tool current = (Tool)toolIter.next();
+ current.resolveReferences();
+ }
+ Iterator refIter = getLocalToolReferences().iterator();
+ while (refIter.hasNext()) {
+ ToolReference current = (ToolReference)refIter.next();
+ current.resolveReferences();
+ }
+ Iterator configIter = getConfigurationList().iterator();
+ while (configIter.hasNext()) {
+ Configuration current = (Configuration)configIter.next();
+ current.resolveReferences();
+ }
+ }
+ }
+
+ /**
+ * Persist receiver to project file.
+ *
+ * @param doc
+ * @param element
+ */
+ public void serialize(Document doc, Element element) {
+ element.setAttribute(ID, getId());
+ element.setAttribute(NAME, getName());
+ if (parent != null)
+ element.setAttribute(PARENT, parent.getId());
+ element.setAttribute(IS_ABSTRACT, isAbstract ? "true" : "false"); //$NON-NLS-1$ //$NON-NLS-2$
+ element.setAttribute(ARTIFACT_NAME, getArtifactName());
+ if (extension != null) {
+ element.setAttribute(EXTENSION, extension);
+ }
+ element.setAttribute(IS_TEST, isTest ? "true" : "false"); //$NON-NLS-1$ //$NON-NLS-2$
+
+ if (makeCommand != null) {
+ element.setAttribute(MAKE_COMMAND, makeCommand);
+ } else {
+ // Make sure we use the default
+ }
+
+ if (makeArguments != null) {
+ element.setAttribute(MAKE_ARGS, makeArguments);
+ }
+ if (errorParserIds != null) {
+ element.setAttribute(ERROR_PARSERS, errorParserIds);
+ }
+
+ // Serialize the configuration settings
+ Iterator iter = getConfigurationList().listIterator();
+ while (iter.hasNext()) {
+ Configuration config = (Configuration) iter.next();
+ Element configElement = doc.createElement(IConfiguration.CONFIGURATION_ELEMENT_NAME);
+ element.appendChild(configElement);
+ config.serialize(doc, configElement);
+ }
+
+ // I am clean now
+ isDirty = false;
+ }
+
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.ITarget#setArtifactExtension(java.lang.String)
*/
@@ -898,6 +912,18 @@ public class Target extends BuildObject implements ITarget {
config.setDirty(isDirty);
}
}
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.ITarget#setErrorParserIds()
+ */
+ public void setErrorParserIds(String ids) {
+ if (ids == null) return;
+ String currentIds = getErrorParserIds();
+ if (currentIds == null || !(currentIds.equals(ids))) {
+ errorParserIds = ids;
+ isDirty = true;
+ }
+ }
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.ITarget#setMakeArguments(java.lang.String)
@@ -920,18 +946,6 @@ public class Target extends BuildObject implements ITarget {
isDirty = true;
}
}
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.ITarget#setErrorParserIds()
- */
- public void setErrorParserIds(String ids) {
- if (ids == null) return;
- String currentIds = getErrorParserIds();
- if (currentIds == null || !(currentIds.equals(ids))) {
- errorParserIds = ids;
- isDirty = true;
- }
- }
/* (non-Javadoc)
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/IManagedBuilderDependencyCalculator.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/IManagedDependencyGenerator.java
similarity index 82%
rename from build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/IManagedBuilderDependencyCalculator.java
rename to build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/IManagedDependencyGenerator.java
index b0e6e1026f0..4d32df0c6f2 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/IManagedBuilderDependencyCalculator.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/IManagedDependencyGenerator.java
@@ -10,13 +10,14 @@
**********************************************************************/
package org.eclipse.cdt.managedbuilder.makegen;
+import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
/**
* @since 2.0
*/
-public interface IManagedBuilderDependencyCalculator {
+public interface IManagedDependencyGenerator {
public int TYPE_NODEPS = 0;
public int TYPE_COMMAND = 1;
public int TYPE_INDEXER = 2;
@@ -24,5 +25,5 @@ public interface IManagedBuilderDependencyCalculator {
public IResource[] findDependencies(IResource resource, IProject project);
public int getCalculatorType();
- public String getDependencyCommand();
+ public String getDependencyCommand(IResource resource, IManagedBuildInfo info);
}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/gnu/DefaultGCCDependencyCalculator.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/gnu/DefaultGCCDependencyCalculator.java
index e049897b334..eb67e9e27c8 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/gnu/DefaultGCCDependencyCalculator.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/gnu/DefaultGCCDependencyCalculator.java
@@ -10,14 +10,18 @@
**********************************************************************/
package org.eclipse.cdt.managedbuilder.makegen.gnu;
-import org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderDependencyCalculator;
+import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
+import org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderMakefileGenerator;
+import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyGenerator;
+import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
/**
* @since 2.0
*/
-public class DefaultGCCDependencyCalculator implements IManagedBuilderDependencyCalculator {
+public class DefaultGCCDependencyCalculator implements IManagedDependencyGenerator {
+
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderDependencyCalculator#findDependencies(org.eclipse.core.resources.IResource)
*/
@@ -35,9 +39,75 @@ public class DefaultGCCDependencyCalculator implements IManagedBuilderDependency
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderDependencyCalculator#getDependencyCommand()
*/
- public String getDependencyCommand() {
- // TODO Auto-generated method stub
- return "$(CC) -M $(CC_FLAGS) $< > makefile.dep"; //$NON-NLS-1$
+ public String getDependencyCommand(IResource resource, IManagedBuildInfo info) {
+ /*
+ * For a given input, String
*
@@ -1017,9 +1015,6 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
*/
protected Set getOutputExtentions() {
if (outputExtensionsSet == null) {
- // Get the list of tools associated with our target
- ITool toolArray[] = defaultTarget.getTools();
-
// The set of output extensions which will be produced by this tool.
// It is presumed that this set is not very large (likely < 10) so
// a HashSet should provide good performance.
@@ -1027,8 +1022,9 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
// For each tool for the target, lookup the kinds of sources it outputs
// and add that to our list of output extensions.
- for(int k = 0; k < toolArray.length; k++) {
- String[] outputs = toolArray[k].getOutputExtensions();
+ Iterator iter = buildTools.iterator();
+ while(iter.hasNext()) {
+ String[] outputs = ((ITool)iter.next()) .getOutputExtensions();
outputExtensionsSet.addAll(Arrays.asList(outputs));
}
}
@@ -1079,10 +1075,11 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
if (extension == null) {
extension = new String();
}
- defaultTarget = info.getDefaultTarget();
+ // Cache the build tools
+ buildTools = new Vector(Arrays.asList(info.getDefaultTarget().getTools()));
}
- /**
+ /* (non-Javadoc)
* Answers true
if the argument is found in a generated container
* @param resource
* @return boolean
@@ -1274,7 +1271,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
Util.save(makeBuf, modMakefile);
}
- /**
+ /* (non-Javadoc)
* The makefile generator "knows" about source files participating in the
* the build. It does not keep track of the targets that the build produces.
* Instead, it keeps a set of transformation macros that it supplies to the
@@ -1316,17 +1313,16 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
// which says that B depends on A.
// TODO Handle dependencies for complex chains of the form A->B->C
- // get the list of tools associated with our target
- ITool toolArray[] = defaultTarget.getTools();
-
// set of input extensions for which rules have been created so far
HashSet handledInputExtensions = new HashSet();
// Look at each input extension and generate an appropriate macro for that extension
// based on whether the file is generated or not. We do not want to create rules for
// generated files due to the current way the makefile is structured.
- for(int k = 0; k < toolArray.length; k++) {
- List extensionsList = toolArray[k].getInputExtensions();
+ Iterator iter = buildTools.iterator();
+ while(iter.hasNext()) {
+ ITool tool = (ITool)iter.next();
+ List extensionsList = tool.getInputExtensions();
// iterate over all extensions that the tool knows how to handle
Iterator exListIterator = extensionsList.iterator();
@@ -1348,7 +1344,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
// OBJS = $(macroName1: $(ROOT)/%.input1=%.output1) ... $(macroNameN: $(ROOT)/%.inputN=%.outputN)
objectsBuffer.append(WHITESPACE + "$(" + macroName + COLON + "$(ROOT)" + SEPARATOR + WILDCARD //$NON-NLS-1$ //$NON-NLS-2$
+ DOT + extensionName + "=" + WILDCARD + DOT + //$NON-NLS-1$
- toolArray[k].getOutputExtension(extensionName) + ")" ); //$NON-NLS-1$
+ tool.getOutputExtension(extensionName) + ")" ); //$NON-NLS-1$
// And another for the deps makefiles
// DEPS = $(macroName1: $(ROOT)/%.input1=%.DEP_EXT) ... $(macroNameN: $(ROOT)/%.inputN=%.DEP_EXT)
@@ -1367,7 +1363,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
Util.save(macroBuffer, fileHandle);
}
- /**
+ /* (non-Javadoc)
* @param fileHandle
* @throws CoreException
*/
@@ -1376,10 +1372,10 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
StringBuffer buffer = addDefaultHeader();
// Add the known macros
- ITool toolArray[] = defaultTarget.getTools();
HashSet handledInputExtensions = new HashSet();
- for(int k = 0; k < toolArray.length; k++) {
- List extensionsList = toolArray[k].getInputExtensions();
+ Iterator iter = buildTools.iterator();
+ while(iter.hasNext()) {
+ List extensionsList = ((ITool)iter.next()).getInputExtensions();
Iterator exListIterator = extensionsList.iterator();
while(exListIterator.hasNext()) {
// create a macro of the form "EXTENSION_SRCS :="
@@ -1399,7 +1395,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
Util.save(buffer, fileHandle);
}
- /* (non-javadoc)
+ /* (non-Javadoc)
* Create the entire contents of the makefile.
*
* @param fileHandle The file to place the contents in.
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/gnu/DefaultIndexerDependencyCalculator.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/internal/DefaultIndexerDependencyCalculator.java
similarity index 90%
rename from build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/gnu/DefaultIndexerDependencyCalculator.java
rename to build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/internal/DefaultIndexerDependencyCalculator.java
index 811b4dfe96c..e966f109eea 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/gnu/DefaultIndexerDependencyCalculator.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/internal/DefaultIndexerDependencyCalculator.java
@@ -8,7 +8,7 @@
* Contributors:
* IBM - Initial API and implementation
**********************************************************************/
-package org.eclipse.cdt.managedbuilder.makegen.gnu;
+package org.eclipse.cdt.managedbuilder.makegen.internal;
import java.util.ArrayList;
import java.util.List;
@@ -21,7 +21,8 @@ import org.eclipse.cdt.internal.core.search.PathCollector;
import org.eclipse.cdt.internal.core.search.PatternSearchJob;
import org.eclipse.cdt.internal.core.search.indexing.IndexManager;
import org.eclipse.cdt.internal.core.search.matching.CSearchPattern;
-import org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderDependencyCalculator;
+import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
+import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyGenerator;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IWorkspaceRoot;
@@ -29,7 +30,7 @@ import org.eclipse.core.resources.IWorkspaceRoot;
/**
* @since 2.0
*/
-public class DefaultIndexerDependencyCalculator implements IManagedBuilderDependencyCalculator {
+public class DefaultIndexerDependencyCalculator implements IManagedDependencyGenerator {
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderDependencyCalculator#findDependencies(org.eclipse.core.resources.IResource)
@@ -79,7 +80,7 @@ public class DefaultIndexerDependencyCalculator implements IManagedBuilderDepend
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderDependencyCalculator#getDependencyCommand()
*/
- public String getDependencyCommand() {
+ public String getDependencyCommand(IResource resource, IManagedBuildInfo info) {
// There is no command
return null;
}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/internal/DefaultNoDependencyCalculator.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/internal/DefaultNoDependencyCalculator.java
new file mode 100644
index 00000000000..6f2f582f8a5
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/internal/DefaultNoDependencyCalculator.java
@@ -0,0 +1,50 @@
+/**********************************************************************
+ * 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.makegen.internal;
+
+import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
+import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyGenerator;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+
+/**
+ * This is the dependency calculator used by the makefile generation system when
+ * nothing is defined for a tool.
+ *
+ * @since 2.0
+ */
+public class DefaultNoDependencyCalculator implements IManagedDependencyGenerator {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderDependencyCalculator#findDependencies(org.eclipse.core.resources.IResource, org.eclipse.core.resources.IProject)
+ */
+ public IResource[] findDependencies(IResource resource, IProject project) {
+ // Never answers any dependencies
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderDependencyCalculator#getCalculatorType()
+ */
+ public int getCalculatorType() {
+ return TYPE_NODEPS;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderDependencyCalculator#getDependencyCommand(org.eclipse.core.resources.IResource)
+ */
+ public String getDependencyCommand(IResource resource, IManagedBuildInfo info) {
+ // Never answers this call with an actual value
+ return null;
+ }
+
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/plugin.xml b/build/org.eclipse.cdt.managedbuilder.ui/plugin.xml
index ed37509ae28..da913f7ee19 100644
--- a/build/org.eclipse.cdt.managedbuilder.ui/plugin.xml
+++ b/build/org.eclipse.cdt.managedbuilder.ui/plugin.xml
@@ -99,6 +99,7 @@
name="%ToolName.linker.gnu.c"
outputFlag="-o"
command="gcc"
+ dependencyCalculator="org.eclipse.cdt.managedbuilder.makegen.internal.DefaultNoDependencyCalculator"
id="cdt.managedbuild.tool.gnu.c.linker">