[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[cdt-patch] Applied: New Build Model enhancements
|
Work on the Build Model.
- Model is maturing
- Loading/saving moved into the objects
themselves
- Project build info saved to/loaded
from a file
Doug Schaefer
Rational Software - IBM Software Group
Ottawa, Ontario, Canada
Index: build/org/eclipse/cdt/core/build/managed/IOption.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/build/org/eclipse/cdt/core/build/managed/IOption.java,v
retrieving revision 1.3
diff -u -r1.3 IOption.java
--- build/org/eclipse/cdt/core/build/managed/IOption.java 9 Apr 2003 20:56:20 -0000 1.3
+++ build/org/eclipse/cdt/core/build/managed/IOption.java 14 Apr 2003 19:59:52 -0000
@@ -85,7 +85,8 @@
* @param config
* @param value
*/
- public IOption setStringValue(IConfiguration config, String value);
+ public IOption setValue(IConfiguration config, String value)
+ throws BuildException;
/**
* Sets the value for this option in a given configuration.
@@ -95,6 +96,7 @@
* @param config
* @param value
*/
- public IOption setStringValue(IConfiguration config, String[] value);
+ public IOption setValue(IConfiguration config, String[] value)
+ throws BuildException;
}
Index: build/org/eclipse/cdt/core/build/managed/IOptionCategory.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/build/org/eclipse/cdt/core/build/managed/IOptionCategory.java,v
retrieving revision 1.3
diff -u -r1.3 IOptionCategory.java
--- build/org/eclipse/cdt/core/build/managed/IOptionCategory.java 9 Apr 2003 20:56:20 -0000 1.3
+++ build/org/eclipse/cdt/core/build/managed/IOptionCategory.java 14 Apr 2003 19:59:52 -0000
@@ -23,20 +23,13 @@
public IOptionCategory[] getChildCategories();
/**
- * Returns a new child category for this category.
- *
- * @return
- */
- public IOptionCategory createChildCategory();
-
- /**
- * Returns the options in this category for a given tool.
+ * Returns the options in this category for a given configuration.
*
* @param tool
* @return
*/
- public IOption[] getOptions(ITool tool);
-
+ public IOption[] getOptions(IConfiguration configuration);
+
/**
* Returns the category that owns this category, or null if this is the
* top category for a tool.
Index: build/org/eclipse/cdt/core/build/managed/ITarget.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/build/org/eclipse/cdt/core/build/managed/ITarget.java,v
retrieving revision 1.4
diff -u -r1.4 ITarget.java
--- build/org/eclipse/cdt/core/build/managed/ITarget.java 9 Apr 2003 20:56:20 -0000 1.4
+++ build/org/eclipse/cdt/core/build/managed/ITarget.java 14 Apr 2003 19:59:52 -0000
@@ -19,6 +19,12 @@
public interface ITarget extends IBuildObject {
/**
+ * Returns whether this target is abstract
+ * @return
+ */
+ public boolean isAbstract();
+
+ /**
* Gets the resource that this target is applied to.
*
* @return
@@ -34,33 +40,9 @@
public ITool[] getTools();
/**
- * Creates a new tool.
- *
- * @return
- */
- public ITool createTool();
-
- /**
* Returns all of the configurations defined by this target.
* @return
*/
public IConfiguration[] getConfigurations();
-
- /**
- * Creates a new configuration for this target.
- *
- * @return
- */
- public IConfiguration createConfiguration()
- throws BuildException;
-
- /**
- * Creates a new configuration based on the parent config for this target.
- *
- * @param parentConfig
- * @return
- */
- public IConfiguration createConfiguration(IConfiguration parentConfig)
- throws BuildException;
}
Index: build/org/eclipse/cdt/core/build/managed/ITool.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/build/org/eclipse/cdt/core/build/managed/ITool.java,v
retrieving revision 1.2
diff -u -r1.2 ITool.java
--- build/org/eclipse/cdt/core/build/managed/ITool.java 9 Apr 2003 20:56:20 -0000 1.2
+++ build/org/eclipse/cdt/core/build/managed/ITool.java 14 Apr 2003 19:59:52 -0000
@@ -27,12 +27,12 @@
public IOption[] getOptions();
/**
- * Creates a new option for this tool. Generally, this should only be
- * done by the extension and project data loaders.
+ * Get a particular option.
*
+ * @param id
* @return
*/
- public IOption createOption();
+ public IOption getOption(String id);
/**
* Options are organized into categories for UI purposes.
Index: build/org/eclipse/cdt/core/build/managed/ManagedBuildManager.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/build/org/eclipse/cdt/core/build/managed/ManagedBuildManager.java,v
retrieving revision 1.4
diff -u -r1.4 ManagedBuildManager.java
--- build/org/eclipse/cdt/core/build/managed/ManagedBuildManager.java 9 Apr 2003 20:56:20 -0000 1.4
+++ build/org/eclipse/cdt/core/build/managed/ManagedBuildManager.java 14 Apr 2003 19:59:52 -0000
@@ -10,15 +10,27 @@
**********************************************************************/
package org.eclipse.cdt.core.build.managed;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.InputStream;
+import java.io.OutputStreamWriter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import org.apache.xerces.dom.DocumentImpl;
+import org.apache.xml.serialize.Method;
+import org.apache.xml.serialize.OutputFormat;
+import org.apache.xml.serialize.Serializer;
+import org.apache.xml.serialize.SerializerFactory;
import org.eclipse.cdt.core.CCorePlugin;
-import org.eclipse.cdt.internal.core.build.managed.Configuration;
+import org.eclipse.cdt.internal.core.build.managed.ResourceBuildInfo;
import org.eclipse.cdt.internal.core.build.managed.Target;
-import org.eclipse.cdt.internal.core.build.managed.Tool;
+import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
@@ -26,6 +38,9 @@
import org.eclipse.core.runtime.IExtension;
import org.eclipse.core.runtime.IExtensionPoint;
import org.eclipse.core.runtime.QualifiedName;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
/**
* This is the main entry point for getting at the build information
@@ -33,13 +48,16 @@
*/
public class ManagedBuildManager {
- private static final QualifiedName ownedTargetsProperty
- = new QualifiedName(CCorePlugin.PLUGIN_ID, "ownedTargets");
- private static final QualifiedName definedTargetsProperty
- = new QualifiedName(CCorePlugin.PLUGIN_ID, "definedTargets");
+ private static final QualifiedName buildInfoProperty
+ = new QualifiedName(CCorePlugin.PLUGIN_ID, "buildInfo");
private static final ITarget[] emptyTargets = new ITarget[0];
-
+
+ // Targets defined by extensions (i.e., not associated with a resource)
+ private static boolean extensionTargetsLoaded = false;
+ private static List extensionTargets;
+ private static Map extensionTargetMap;
+
/**
* Returns the list of targets that are defined by this project,
* projects referenced by this project, and by the extensions.
@@ -53,13 +71,7 @@
// Get the targets for this project and all referenced projects
List definedTargets = null;
-
- if (project != null) {
- try {
- definedTargets = (List)project.getSessionProperty(definedTargetsProperty);
- } catch (CoreException e) {
- }
- }
+ // To Do
// Create the array and copy the elements over
int size = extensionTargets.size()
@@ -86,15 +98,30 @@
* @return
*/
public static ITarget[] getTargets(IResource resource) {
- List targets = getOwnedTargetsProperty(resource);
+ ResourceBuildInfo buildInfo = getBuildInfo(resource);
- if (targets != null) {
+ if (buildInfo != null) {
+ List targets = buildInfo.getTargets();
return (ITarget[])targets.toArray(new ITarget[targets.size()]);
} else {
return emptyTargets;
}
}
+ public static ITarget getTarget(IResource resource, String id) {
+ if (resource != null) {
+ ResourceBuildInfo buildInfo = getBuildInfo(resource);
+ if (buildInfo != null)
+ return buildInfo.getTarget(id);
+ }
+
+ ITarget target = (ITarget)extensionTargetMap.get(id);
+ if (target != null)
+ return target;
+
+ return null;
+ }
+
/**
* Adds a new target to the resource based on the parentTarget.
*
@@ -103,7 +130,7 @@
* @return
* @throws BuildException
*/
- public static ITarget addTarget(IResource resource, ITarget parentTarget)
+ public static ITarget createTarget(IResource resource, ITarget parentTarget)
throws BuildException
{
IResource owner = parentTarget.getOwner();
@@ -113,7 +140,7 @@
return parentTarget;
if (resource instanceof IProject) {
- // Owner must be null
+ // Must be an extension target (why?)
if (owner != null)
throw new BuildException("addTarget: owner not null");
} else {
@@ -125,19 +152,7 @@
}
// Passed validation
- List targets = getOwnedTargetsProperty(resource);
- if (targets == null) {
- targets = new ArrayList();
- try {
- resource.setSessionProperty(ownedTargetsProperty, targets);
- } catch (CoreException e) {
- throw new BuildException("addTarget: could not add property");
- }
- }
-
- Target newTarget = new Target(resource, parentTarget);
- targets.add(newTarget);
- return newTarget;
+ return new Target(resource, parentTarget);
}
/**
@@ -147,19 +162,65 @@
* @param project
*/
public static void saveBuildInfo(IProject project) {
+ // Create document
+ Document doc = new DocumentImpl();
+ Element rootElement = doc.createElement("buildInfo");
+ doc.appendChild(rootElement);
+
+ // Populate from buildInfo
+ // To do - find other resources also
+ ResourceBuildInfo buildInfo = getBuildInfo(project);
+ if (buildInfo != null)
+ buildInfo.serialize(doc, rootElement);
+
+ // Save the document
+ ByteArrayOutputStream s = new ByteArrayOutputStream();
+ OutputFormat format = new OutputFormat();
+ format.setIndenting(true);
+ format.setLineSeparator(System.getProperty("line.separator")); //$NON-NLS-1$
+ String xml = null;
+ try {
+ Serializer serializer
+ = SerializerFactory.getSerializerFactory(Method.XML).makeSerializer(new OutputStreamWriter(s, "UTF8"), format);
+ serializer.asDOMSerializer().serialize(doc);
+ xml = s.toString("UTF8"); //$NON-NLS-1$
+ IFile rscFile = project.getFile(".cdtbuild");
+ InputStream inputStream = new ByteArrayInputStream(xml.getBytes());
+ // update the resource content
+ if (rscFile.exists()) {
+ rscFile.setContents(inputStream, IResource.FORCE, null);
+ } else {
+ rscFile.create(inputStream, IResource.FORCE, null);
+ }
+ } catch (Exception e) {
+ return;
+ }
+ }
+
+ public static void removeBuildInfo(IResource resource) {
+ try {
+ resource.setSessionProperty(buildInfoProperty, null);
+ } catch (CoreException e) {
+ }
}
// Private stuff
-
- private static List extensionTargets;
-
+
+ public static void addExtensionTarget(Target target) {
+ if (extensionTargets == null) {
+ extensionTargets = new ArrayList();
+ extensionTargetMap = new HashMap();
+ }
+
+ extensionTargets.add(target);
+ extensionTargetMap.put(target.getId(), target);
+ }
+
private static void loadExtensions() {
- if (extensionTargets != null)
+ if (extensionTargetsLoaded)
return;
-
- extensionTargets = new ArrayList();
- Map targetMap = new HashMap();
-
+ extensionTargetsLoaded = true;
+
IExtensionPoint extensionPoint
= CCorePlugin.getDefault().getDescriptor().getExtensionPoint("ManagedBuildInfo");
IExtension[] extensions = extensionPoint.getExtensions();
@@ -169,61 +230,58 @@
for (int j = 0; j < elements.length; ++j) {
IConfigurationElement element = elements[j];
if (element.getName().equals("target")) {
- String parentId = element.getAttribute("parent");
- Target target = null;
- if (parentId != null)
- target = new Target(null, (Target)targetMap.get(parentId));
- else
- target = new Target(null);
- target.setName(element.getAttribute("name"));
- extensionTargets.add(target);
- targetMap.put(element.getAttribute("id"), target);
-
- IConfigurationElement[] targetElements = element.getChildren();
- for (int k = 0; k < targetElements.length; ++k) {
- IConfigurationElement targetElement = targetElements[k];
- if (targetElement.getName().equals("tool")) {
- ITool tool = target.createTool();
- tool.setName(targetElement.getAttribute("name"));
-
- Map categoryMap = new HashMap();
- categoryMap.put(targetElement.getAttribute("id"), tool.getTopOptionCategory());
- IConfigurationElement[] toolElements = targetElement.getChildren();
- for (int l = 0; l < toolElements.length; ++l) {
- IConfigurationElement toolElement = toolElements[l];
- if (toolElement.getName().equals("option")) {
- IOption option = tool.createOption();
- option.setName(toolElement.getAttribute("name"));
-
- String categoryId = toolElement.getAttribute("category");
- if (categoryId != null)
- option.setCategory((IOptionCategory)categoryMap.get(categoryId));
- } else if (toolElement.getName().equals("optionCategory")) {
- IOptionCategory owner = (IOptionCategory)categoryMap.get(toolElement.getAttribute("owner"));
- IOptionCategory category = owner.createChildCategory();
- category.setName(toolElement.getAttribute("name"));
- categoryMap.put(toolElement.getAttribute("id"), category);
- }
- }
- } else if (targetElement.getName().equals("configuration")) {
- try {
- IConfiguration config = target.createConfiguration();
- config.setName(targetElement.getAttribute("name"));
- } catch (BuildException e) {
- // Not sure what to do here.
- }
- }
- }
+ new Target(element);
}
}
}
}
+
+ private static ResourceBuildInfo loadBuildInfo(IProject project) {
+ ResourceBuildInfo buildInfo = null;
+ IFile file = project.getFile(".cdtbuild");
+ if (!file.exists())
+ return null;
- private static List getOwnedTargetsProperty(IResource resource) {
try {
- return (List)resource.getSessionProperty(ownedTargetsProperty);
+ InputStream stream = file.getContents();
+ DocumentBuilder parser = DocumentBuilderFactory.newInstance().newDocumentBuilder();
+ Document document = parser.parse(stream);
+ Node rootElement = document.getFirstChild();
+ if (rootElement.getNodeName().equals("buildInfo")) {
+ buildInfo = new ResourceBuildInfo(project, (Element)rootElement);
+ project.setSessionProperty(buildInfoProperty, buildInfo);
+ }
+ } catch (Exception e) {
+ buildInfo = null;
+ }
+
+ return buildInfo;
+ }
+
+ public static ResourceBuildInfo getBuildInfo(IResource resource, boolean create) {
+ ResourceBuildInfo buildInfo = null;
+ try {
+ buildInfo = (ResourceBuildInfo)resource.getSessionProperty(buildInfoProperty);
} catch (CoreException e) {
- return null;
}
+
+ if (buildInfo == null && resource instanceof IProject) {
+ buildInfo = loadBuildInfo((IProject)resource);
+ }
+
+ if (buildInfo == null && create) {
+ try {
+ buildInfo = new ResourceBuildInfo();
+ resource.setSessionProperty(buildInfoProperty, buildInfo);
+ } catch (CoreException e) {
+ buildInfo = null;
+ }
+ }
+
+ return buildInfo;
+ }
+
+ public static ResourceBuildInfo getBuildInfo(IResource resource) {
+ return getBuildInfo(resource, false);
}
}
Index: build/org/eclipse/cdt/internal/core/build/managed/Configuration.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/build/org/eclipse/cdt/internal/core/build/managed/Configuration.java,v
retrieving revision 1.4
diff -u -r1.4 Configuration.java
--- build/org/eclipse/cdt/internal/core/build/managed/Configuration.java 9 Apr 2003 20:56:20 -0000 1.4
+++ build/org/eclipse/cdt/internal/core/build/managed/Configuration.java 14 Apr 2003 19:59:52 -0000
@@ -10,12 +10,14 @@
**********************************************************************/
package org.eclipse.cdt.internal.core.build.managed;
+import java.util.ArrayList;
import java.util.List;
import org.eclipse.cdt.core.build.managed.IConfiguration;
import org.eclipse.cdt.core.build.managed.ITarget;
import org.eclipse.cdt.core.build.managed.ITool;
import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.IConfigurationElement;
/**
*
@@ -24,7 +26,7 @@
private ITarget target;
private IConfiguration parent;
- private List toolReference;
+ private List toolReferences;
public Configuration(Target target) {
this.target = target;
@@ -34,6 +36,27 @@
this.parent = parent;
}
+ public Configuration(Target target, IConfigurationElement element) {
+ this(target);
+
+ // id
+ setId(element.getAttribute("id"));
+
+ // hook me up
+ target.addConfiguration(this);
+
+ // name
+ setName(element.getAttribute("name"));
+
+ IConfigurationElement[] configElements = element.getChildren();
+ for (int l = 0; l < configElements.length; ++l) {
+ IConfigurationElement configElement = configElements[l];
+ if (configElement.getName().equals("toolRef")) {
+ new ToolReference(this, configElement);
+ }
+ }
+ }
+
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IConfiguration#getName()
*/
@@ -45,8 +68,18 @@
* @see org.eclipse.cdt.core.build.managed.IConfiguration#getTools()
*/
public ITool[] getTools() {
- // TODO Auto-generated method stub
- return null;
+ ITool[] tools = parent != null
+ ? parent.getTools()
+ : target.getTools();
+
+ // Replace tools with overrides
+ for (int i = 0; i < tools.length; ++i) {
+ ToolReference ref = getToolReference(tools[i]);
+ if (ref != null)
+ tools[i] = ref;
+ }
+
+ return tools;
}
/* (non-Javadoc)
@@ -70,4 +103,25 @@
return getTarget().getOwner();
}
+ /**
+ * Returns the reference for a given tool.
+ *
+ * @param tool
+ * @return
+ */
+ private ToolReference getToolReference(ITool tool) {
+ if (toolReferences != null)
+ for (int i = 0; i < toolReferences.size(); ++i) {
+ ToolReference toolRef = (ToolReference)toolReferences.get(i);
+ if (toolRef.references(tool))
+ return toolRef;
+ }
+ return null;
+ }
+
+ public void addToolReference(ToolReference toolRef) {
+ if (toolReferences == null)
+ toolReferences = new ArrayList();
+ toolReferences.add(toolRef);
+ }
}
Index: build/org/eclipse/cdt/internal/core/build/managed/Option.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/build/org/eclipse/cdt/internal/core/build/managed/Option.java,v
retrieving revision 1.2
diff -u -r1.2 Option.java
--- build/org/eclipse/cdt/internal/core/build/managed/Option.java 9 Apr 2003 20:56:20 -0000 1.2
+++ build/org/eclipse/cdt/internal/core/build/managed/Option.java 14 Apr 2003 19:59:52 -0000
@@ -10,10 +10,14 @@
**********************************************************************/
package org.eclipse.cdt.internal.core.build.managed;
+import java.util.List;
+
+import org.eclipse.cdt.core.build.managed.BuildException;
import org.eclipse.cdt.core.build.managed.IConfiguration;
import org.eclipse.cdt.core.build.managed.IOption;
import org.eclipse.cdt.core.build.managed.IOptionCategory;
import org.eclipse.cdt.core.build.managed.ITool;
+import org.eclipse.core.runtime.IConfigurationElement;
/**
*
@@ -22,40 +26,66 @@
private ITool tool;
private IOptionCategory category;
+ private List enumValues;
+
+ private int valueType;
+ private Object value;
+ private static final String[] emptyStrings = new String[0];
+
public Option(ITool tool) {
this.tool = tool;
}
+ public Option(Tool tool, IConfigurationElement element) {
+ this(tool);
+
+ // id
+ setId(element.getAttribute("id"));
+
+ // hook me up
+ tool.addOption(this);
+
+ // name
+ setName(element.getAttribute("name"));
+
+ // category
+ String categoryId = element.getAttribute("category");
+ if (categoryId != null)
+ setCategory(tool.getOptionCategory(categoryId));
+ }
+
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IOption#getApplicableValues()
*/
public String[] getApplicableValues() {
- // TODO Auto-generated method stub
- return null;
+ return enumValues != null
+ ? (String[])enumValues.toArray(new String[enumValues.size()])
+ : emptyStrings;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IOption#getCategory()
*/
public IOptionCategory getCategory() {
- return (category != null) ? category : getTool().getTopOptionCategory();
+ return category != null ? category : getTool().getTopOptionCategory();
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IOption#getStringListValue()
*/
public String[] getStringListValue() {
- // TODO Auto-generated method stub
- return null;
+ List v = (List)value;
+ return v != null
+ ? (String[])v.toArray(new String[v.size()])
+ : emptyStrings;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IOption#getStringValue()
*/
public String getStringValue() {
- // TODO Auto-generated method stub
- return null;
+ return (String)value;
}
/* (non-Javadoc)
@@ -69,24 +99,45 @@
* @see org.eclipse.cdt.core.build.managed.IOption#getValueType()
*/
public int getValueType() {
- // TODO Auto-generated method stub
- return 0;
+ return valueType;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IOption#setStringValue(org.eclipse.cdt.core.build.managed.IConfiguration, java.lang.String)
*/
- public IOption setStringValue(IConfiguration config, String value) {
- // TODO Auto-generated method stub
- return null;
+ public IOption setValue(IConfiguration config, String value)
+ throws BuildException
+ {
+ if (valueType != IOption.STRING)
+ throw new BuildException("Bad value for type");
+
+ if (config == null) {
+ this.value = value;
+ return this;
+ } else {
+
+ // Magic time
+
+ return null;
+ }
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IOption#setStringValue(org.eclipse.cdt.core.build.managed.IConfiguration, java.lang.String[])
*/
- public IOption setStringValue(IConfiguration config, String[] value) {
- // TODO Auto-generated method stub
- return null;
+ public IOption setValue(IConfiguration config, String[] value)
+ throws BuildException
+ {
+ if (valueType != IOption.STRING_LIST)
+ throw new BuildException("Bad value for type");
+
+ if (config == null) {
+ this.value = value;
+ return this;
+ } else {
+ // More magic
+ return null;
+ }
}
/* (non-Javadoc)
Index: build/org/eclipse/cdt/internal/core/build/managed/OptionCategory.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/build/org/eclipse/cdt/internal/core/build/managed/OptionCategory.java,v
retrieving revision 1.2
diff -u -r1.2 OptionCategory.java
--- build/org/eclipse/cdt/internal/core/build/managed/OptionCategory.java 9 Apr 2003 20:56:20 -0000 1.2
+++ build/org/eclipse/cdt/internal/core/build/managed/OptionCategory.java 14 Apr 2003 19:59:52 -0000
@@ -13,9 +13,11 @@
import java.util.ArrayList;
import java.util.List;
+import org.eclipse.cdt.core.build.managed.IConfiguration;
import org.eclipse.cdt.core.build.managed.IOption;
import org.eclipse.cdt.core.build.managed.IOptionCategory;
import org.eclipse.cdt.core.build.managed.ITool;
+import org.eclipse.core.runtime.IConfigurationElement;
/**
*
@@ -31,6 +33,28 @@
this.owner = owner;
}
+ public OptionCategory(Tool tool, IConfigurationElement element) {
+ String parentId = element.getAttribute("parent");
+ if (parentId != null)
+ owner = tool.getOptionCategory(element.getAttribute("parent"));
+ else
+ owner = tool;
+
+ // id
+ setId(element.getAttribute("id"));
+
+ // Name
+ setName(element.getAttribute("name"));
+
+ // Hook me in
+ if (owner instanceof Tool)
+ ((Tool)owner).addChildCategory(this);
+ else
+ ((OptionCategory)owner).addChildCategory(this);
+
+ tool.addOptionCategory(this);
+ }
+
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IOptionCategory#getChildCategories()
*/
@@ -41,17 +65,10 @@
return emtpyCategories;
}
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IOptionCategory#createChildCategory()
- */
- public IOptionCategory createChildCategory() {
- IOptionCategory category = new OptionCategory(this);
-
+ public void addChildCategory(OptionCategory category) {
if (children == null)
children = new ArrayList();
children.add(category);
-
- return category;
}
/* (non-Javadoc)
@@ -72,16 +89,31 @@
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IOptionCategory#getOptions(org.eclipse.cdt.core.build.managed.ITool)
*/
- public IOption[] getOptions(ITool tool) {
- List myOptions = new ArrayList();
+ public IOption[] getOptions(IConfiguration configuration) {
+ ITool tool = getTool();
+ if (configuration != null) {
+ // TODO don't like this much
+ ITool[] tools = configuration.getTools();
+ for (int i = 0; i < tools.length; ++i) {
+ if (tools[i] instanceof ToolReference) {
+ if (((ToolReference)tools[i]).references(tool)) {
+ tool = tools[i];
+ break;
+ }
+ } else if (tools[i].equals(tool))
+ break;
+ }
+ }
+
IOption[] allOptions = tool.getOptions();
-
+ List myOptions = new ArrayList();
+
for (int i = 0; i < allOptions.length; ++i) {
IOption option = allOptions[i];
if (option.getCategory().equals(this))
myOptions.add(option);
}
-
+
return (IOption[])myOptions.toArray(new IOption[myOptions.size()]);
}
Index: build/org/eclipse/cdt/internal/core/build/managed/OptionReference.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/build/org/eclipse/cdt/internal/core/build/managed/OptionReference.java,v
retrieving revision 1.1
diff -u -r1.1 OptionReference.java
--- build/org/eclipse/cdt/internal/core/build/managed/OptionReference.java 7 Apr 2003 20:56:27 -0000 1.1
+++ build/org/eclipse/cdt/internal/core/build/managed/OptionReference.java 14 Apr 2003 19:59:52 -0000
@@ -10,9 +10,145 @@
**********************************************************************/
package org.eclipse.cdt.internal.core.build.managed;
+import org.eclipse.cdt.core.build.managed.IConfiguration;
+import org.eclipse.cdt.core.build.managed.IOption;
+import org.eclipse.cdt.core.build.managed.IOptionCategory;
+import org.eclipse.cdt.core.build.managed.ITool;
+import org.eclipse.core.runtime.IConfigurationElement;
+
/**
*
*/
-public class OptionReference {
+public class OptionReference implements IOption {
+
+ private IOption option;
+ private ITool tool;
+
+ public OptionReference(IOption option, ITool tool) {
+ this.option = option;
+ this.tool = tool;
+ }
+
+ public OptionReference(ToolReference owner, IConfigurationElement element) {
+ this.tool = owner;
+
+ option = tool.getOption(element.getAttribute("id"));
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IOption#getApplicableValues()
+ */
+ public String[] getApplicableValues() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IOption#getCategory()
+ */
+ public IOptionCategory getCategory() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IBuildObject#getName()
+ */
+ public String getName() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IOption#getStringListValue()
+ */
+ public String[] getStringListValue() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IOption#getStringValue()
+ */
+ public String getStringValue() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IOption#getTool()
+ */
+ public ITool getTool() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IOption#getValueType()
+ */
+ public int getValueType() {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IOption#setCategory(org.eclipse.cdt.core.build.managed.IOptionCategory)
+ */
+ public void setCategory(IOptionCategory category) {
+ // TODO Auto-generated method stub
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IOption#setStringValue(org.eclipse.cdt.core.build.managed.IConfiguration, java.lang.String)
+ */
+ public IOption setValue(IConfiguration config, String value) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IOption#setStringValue(org.eclipse.cdt.core.build.managed.IConfiguration, java.lang.String[])
+ */
+ public IOption setValue(IConfiguration config, String[] value) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IBuildObject#getId()
+ */
+ public String getId() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IBuildObject#setId(java.lang.String)
+ */
+ public void setId(String id) {
+ // TODO Auto-generated method stub
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IBuildObject#setName(java.lang.String)
+ */
+ public void setName(String name) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public boolean references(IOption target) {
+ if (equals(target))
+ // we are the target
+ return true;
+ else if (option instanceof OptionReference)
+ // check the reference we are overriding
+ return ((OptionReference)option).references(target);
+ else
+ // the real reference
+ return option.equals(target);
+ }
}
Index: build/org/eclipse/cdt/internal/core/build/managed/ResourceBuildInfo.java
===================================================================
RCS file: build/org/eclipse/cdt/internal/core/build/managed/ResourceBuildInfo.java
diff -N build/org/eclipse/cdt/internal/core/build/managed/ResourceBuildInfo.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ build/org/eclipse/cdt/internal/core/build/managed/ResourceBuildInfo.java 14 Apr 2003 19:59:52 -0000
@@ -0,0 +1,73 @@
+/*
+ * Created on Apr 13, 2003
+ *
+ * To change the template for this generated file go to
+ * Window>Preferences>Java>Code Generation>Code and Comments
+ */
+package org.eclipse.cdt.internal.core.build.managed;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.core.resources.IResource;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+
+/**
+ * @author dschaefe
+ *
+ * To change the template for this generated type comment go to
+ * Window>Preferences>Java>Code Generation>Code and Comments
+ */
+public class ResourceBuildInfo {
+
+ private IResource owner;
+ private Map targetMap;
+ private List targets;
+
+ public ResourceBuildInfo() {
+ targetMap = new HashMap();
+ targets = new ArrayList();
+ }
+
+ public ResourceBuildInfo(IResource owner, Element element) {
+ this();
+
+ Node child = element.getFirstChild();
+ while (child != null) {
+ if (child.getNodeName().equals("target")) {
+ new Target(this, (Element)child);
+ }
+
+ child = child.getNextSibling();
+ }
+ }
+
+ public IResource getOwner() {
+ return owner;
+ }
+
+ public Target getTarget(String id) {
+ return (Target)targetMap.get(id);
+ }
+
+ public List getTargets() {
+ return targets;
+ }
+
+ public void addTarget(Target target) {
+ targetMap.put(target.getId(), target);
+ targets.add(target);
+ }
+
+ public void serialize(Document doc, Element element) {
+ for (int i = 0; i < targets.size(); ++i) {
+ Element targetElement = doc.createElement("target");
+ element.appendChild(targetElement);
+ ((Target)targets.get(i)).serialize(doc, targetElement);
+ }
+ }
+}
Index: build/org/eclipse/cdt/internal/core/build/managed/Target.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/build/org/eclipse/cdt/internal/core/build/managed/Target.java,v
retrieving revision 1.4
diff -u -r1.4 Target.java
--- build/org/eclipse/cdt/internal/core/build/managed/Target.java 9 Apr 2003 20:56:20 -0000 1.4
+++ build/org/eclipse/cdt/internal/core/build/managed/Target.java 14 Apr 2003 19:59:52 -0000
@@ -11,14 +11,20 @@
package org.eclipse.cdt.internal.core.build.managed;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import org.eclipse.cdt.core.build.managed.BuildException;
import org.eclipse.cdt.core.build.managed.IConfiguration;
import org.eclipse.cdt.core.build.managed.ITarget;
import org.eclipse.cdt.core.build.managed.ITool;
+import org.eclipse.cdt.core.build.managed.ManagedBuildManager;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
/**
*
@@ -28,7 +34,9 @@
private ITarget parent;
private IResource owner;
private List tools;
+ private Map toolMap;
private List configurations;
+ private boolean isAbstract = false;
private static final IConfiguration[] emptyConfigs = new IConfiguration[0];
@@ -37,22 +45,99 @@
}
/**
- * Resource is allowed to be null to represent a ISV target def.
- *
+ * Create a target owned by a resource based on a parent target
* @param parent
*/
public Target(IResource owner, ITarget parent) {
- this.owner = owner;
+ this(owner);
this.parent = parent;
- // Inherit the configs from the parent
+ inheritConfigs();
+
+ // Copy the parent's identity
+ setId(parent.getId());
+ setName(parent.getName());
+
+ // Hook me up
+ ResourceBuildInfo buildInfo = ManagedBuildManager.getBuildInfo(owner, true);
+ buildInfo.addTarget(this);
+ }
+
+ /**
+ * This constructor is called to create a target defined by an extension.
+ *
+ * @param element
+ */
+ public Target(IConfigurationElement element) {
+ // id
+ setId(element.getAttribute("id"));
+
+ // hook me up
+ ManagedBuildManager.addExtensionTarget(this);
+
+ // name
+ setName(element.getAttribute("name"));
+
+ // parent
+ String parentId = element.getAttribute("parent");
+ if (parentId != null) {
+ parent = ManagedBuildManager.getTarget(null, parentId);
+
+ // Inherit the configs from the parent
+ inheritConfigs();
+ }
+
+ // isAbstract
+ if ("true".equals(element.getAttribute("isAbstract")))
+ isAbstract = true;
+
+ IConfigurationElement[] targetElements = element.getChildren();
+ for (int k = 0; k < targetElements.length; ++k) {
+ IConfigurationElement targetElement = targetElements[k];
+ if (targetElement.getName().equals("tool")) {
+ new Tool(this, targetElement);
+ } else if (targetElement.getName().equals("configuration")) {
+ new Configuration(this, targetElement);
+ }
+ }
+
+ }
+
+ public Target(ResourceBuildInfo buildInfo, Element element) {
+ this(buildInfo.getOwner());
+
+ // id
+ setId(element.getAttribute("id"));
+
+ // hook me up
+ buildInfo.addTarget(this);
+
+ // name
+ setName(element.getAttribute("name"));
+
+ // parent
+ String parentId = element.getAttribute("parent");
+ if (parentId != null) {
+ parent = ManagedBuildManager.getTarget(null, parentId);
+
+ // Inherit the configs from the parent
+ inheritConfigs();
+ }
+
+ // isAbstract
+ if ("true".equals(element.getAttribute("isAbstract")))
+ isAbstract = true;
+
+ }
+ private void inheritConfigs() {
IConfiguration[] parentConfigs = parent.getConfigurations();
if (parentConfigs.length > 0)
configurations = new ArrayList(parentConfigs.length);
for (int i = 0; i < parentConfigs.length; ++i)
configurations.add(new Configuration(parentConfigs[i]));
+
}
-
+
public String getName() {
return (name == null && parent != null) ? parent.getName() : name;
}
@@ -91,14 +176,18 @@
return toolArray;
}
- public ITool createTool() {
- ITool tool = new Tool(this);
-
- if (tools == null)
+ public ITool getTool(String id) {
+ return (ITool)toolMap.get(id);
+ }
+
+ public void addTool(ITool tool) {
+ if (tools == null) {
tools = new ArrayList();
- tools.add(tool);
+ toolMap = new HashMap();
+ }
- return tool;
+ tools.add(tool);
+ toolMap.put(tool.getId(), tool);
}
public IConfiguration[] getConfigurations() {
@@ -108,6 +197,12 @@
return emptyConfigs;
}
+ public void addConfiguration(IConfiguration configuration) {
+ if (configurations == null)
+ configurations = new ArrayList();
+ configurations.add(configuration);
+ }
+
private void addLocalConfiguration(IConfiguration configuration) {
if (configurations == null)
configurations = new ArrayList();
@@ -141,6 +236,20 @@
IConfiguration config = new Configuration(parentConfig);
addLocalConfiguration(config);
return config;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.ITarget#isAbstract()
+ */
+ public boolean isAbstract() {
+ return isAbstract;
+ }
+
+ public void serialize(Document doc, Element element) {
+ element.setAttribute("id", getId());
+ element.setAttribute("name", getName());
+ if (parent != null)
+ element.setAttribute("parent", parent.getId());
}
}
Index: build/org/eclipse/cdt/internal/core/build/managed/Tool.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/build/org/eclipse/cdt/internal/core/build/managed/Tool.java,v
retrieving revision 1.3
diff -u -r1.3 Tool.java
--- build/org/eclipse/cdt/internal/core/build/managed/Tool.java 9 Apr 2003 20:56:20 -0000 1.3
+++ build/org/eclipse/cdt/internal/core/build/managed/Tool.java 14 Apr 2003 19:59:52 -0000
@@ -11,12 +11,16 @@
package org.eclipse.cdt.internal.core.build.managed;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
+import org.eclipse.cdt.core.build.managed.IConfiguration;
import org.eclipse.cdt.core.build.managed.IOption;
import org.eclipse.cdt.core.build.managed.IOptionCategory;
import org.eclipse.cdt.core.build.managed.ITarget;
import org.eclipse.cdt.core.build.managed.ITool;
+import org.eclipse.core.runtime.IConfigurationElement;
/**
* Represents a tool that can be invoked during a build.
@@ -27,8 +31,9 @@
private ITarget target;
private List options;
- private IOptionCategory topOptionCategory;
+ private Map optionMap;
private List childOptionCategories;
+ private Map categoryMap;
private static IOption[] emptyOptions = new IOption[0];
private static IOptionCategory[] emptyCategories = new IOptionCategory[0];
@@ -37,10 +42,52 @@
this.target = target;
}
+ public Tool(Target target, IConfigurationElement element) {
+ this(target);
+
+ // id
+ setId(element.getAttribute("id"));
+
+ // hook me up
+ target.addTool(this);
+
+ // name
+ setName(element.getAttribute("name"));
+
+ // set up the category map
+ categoryMap = new HashMap();
+ addOptionCategory(this);
+
+ // Check for options
+ IConfigurationElement[] toolElements = element.getChildren();
+ for (int l = 0; l < toolElements.length; ++l) {
+ IConfigurationElement toolElement = toolElements[l];
+ if (toolElement.getName().equals("option")) {
+ new Option(this, toolElement);
+ } else if (toolElement.getName().equals("optionCategory")) {
+ new OptionCategory(this, toolElement);
+ }
+ }
+ }
+
public ITarget getTarget() {
return target;
}
+ public IOptionCategory getOptionCategory(String id) {
+ return (IOptionCategory)categoryMap.get(id);
+ }
+
+ void addOptionCategory(IOptionCategory category) {
+ categoryMap.put(category.getId(), category);
+ }
+
+ void addChildCategory(IOptionCategory category) {
+ if (childOptionCategories == null)
+ childOptionCategories = new ArrayList();
+ childOptionCategories.add(category);
+ }
+
public IOption[] getOptions() {
if (options != null)
return (IOption[])options.toArray(new IOption[options.size()]);
@@ -48,19 +95,12 @@
return emptyOptions;
}
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.ITool#createOption()
- */
- public IOption createOption() {
- IOption option = new Option(this);
-
+ public void addOption(Option option) {
if (options == null)
options = new ArrayList();
options.add(option);
-
- return option;
}
-
+
public IOptionCategory getTopOptionCategory() {
return this;
}
@@ -105,17 +145,40 @@
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IOptionCategory#getOptions(org.eclipse.cdt.core.build.managed.ITool)
*/
- public IOption[] getOptions(ITool tool) {
- List myOptions = new ArrayList();
+ public IOption[] getOptions(IConfiguration configuration) {
+ ITool tool = this;
+ if (configuration != null) {
+ // TODO don't like this much
+ ITool[] tools = configuration.getTools();
+ for (int i = 0; i < tools.length; ++i) {
+ if (tools[i] instanceof ToolReference) {
+ if (((ToolReference)tools[i]).references(tool)) {
+ tool = tools[i];
+ break;
+ }
+ } else if (tools[i].equals(tool))
+ break;
+ }
+ }
+
IOption[] allOptions = tool.getOptions();
-
+ List myOptions = new ArrayList();
+
for (int i = 0; i < allOptions.length; ++i) {
IOption option = allOptions[i];
- if (option.getCategory() == null || option.getCategory().equals(this))
+ if (option.getCategory().equals(this))
myOptions.add(option);
}
-
+
return (IOption[])myOptions.toArray(new IOption[myOptions.size()]);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.ITool#getOption(java.lang.String)
+ */
+ public IOption getOption(String id) {
+ // TODO Auto-generated method stub
+ return null;
}
}
Index: build/org/eclipse/cdt/internal/core/build/managed/ToolReference.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/build/org/eclipse/cdt/internal/core/build/managed/ToolReference.java,v
retrieving revision 1.1
diff -u -r1.1 ToolReference.java
--- build/org/eclipse/cdt/internal/core/build/managed/ToolReference.java 7 Apr 2003 20:56:27 -0000 1.1
+++ build/org/eclipse/cdt/internal/core/build/managed/ToolReference.java 14 Apr 2003 19:59:53 -0000
@@ -10,9 +10,160 @@
**********************************************************************/
package org.eclipse.cdt.internal.core.build.managed;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.cdt.core.build.managed.IConfiguration;
+import org.eclipse.cdt.core.build.managed.IOption;
+import org.eclipse.cdt.core.build.managed.IOptionCategory;
+import org.eclipse.cdt.core.build.managed.ITarget;
+import org.eclipse.cdt.core.build.managed.ITool;
+import org.eclipse.core.runtime.IConfigurationElement;
+
/**
*
*/
-public class ToolReference {
+public class ToolReference implements ITool {
+
+ private ITool parent;
+ private IConfiguration owner;
+ private List optionReferences;
+ private Map optionRefMap;
+
+ public ToolReference(ITool parent, IConfiguration owner) {
+ this.parent = parent;
+ this.owner = owner;
+ }
+
+ public ToolReference(Configuration owner, IConfigurationElement element) {
+ this.owner = owner;
+
+ parent = ((Target)owner.getTarget()).getTool(element.getAttribute("id"));
+
+ owner.addToolReference(this);
+
+ IConfigurationElement[] toolElements = element.getChildren();
+ for (int m = 0; m < toolElements.length; ++m) {
+ IConfigurationElement toolElement = toolElements[m];
+ if (toolElement.getName().equals("optionRef")) {
+ new OptionReference(this, toolElement);
+ }
+ }
+ }
+
+ public ITool getTool() {
+ return parent;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.ITool#createOption()
+ */
+ public IOption createOption() {
+
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.ITool#getOptions()
+ */
+ public IOption[] getOptions() {
+ IOption[] options = parent.getOptions();
+
+ // Replace with our references
+ for (int i = 0; i < options.length; ++i) {
+ OptionReference ref = getOptionReference(options[i]);
+ if (ref != null)
+ options[i] = ref;
+ }
+
+ return options;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.ITool#getTarget()
+ */
+ public ITarget getTarget() {
+ return owner.getTarget();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.ITool#getTopOptionCategory()
+ */
+ public IOptionCategory getTopOptionCategory() {
+ return parent.getTopOptionCategory();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IBuildObject#getId()
+ */
+ public String getId() {
+ return parent.getId();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IBuildObject#getName()
+ */
+ public String getName() {
+ return parent.getName();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IBuildObject#setId(java.lang.String)
+ */
+ public void setId(String id) {
+ // Not allowed
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IBuildObject#setName(java.lang.String)
+ */
+ public void setName(String name) {
+ // Not allowed
+ }
+
+ public boolean references(ITool target) {
+ if (equals(target))
+ // we are the target
+ return true;
+ else if (parent instanceof ToolReference)
+ // check the reference we are overriding
+ return ((ToolReference)parent).references(target);
+ else
+ // the real reference
+ return parent.equals(target);
+ }
+
+ private OptionReference getOptionReference(IOption option) {
+ if (optionReferences != null)
+ for (int i = 0; i < optionReferences.size(); ++i) {
+ OptionReference optionRef = (OptionReference)optionReferences.get(i);
+ if (optionRef.references(option))
+ return optionRef;
+ }
+ return null;
+ }
+
+ public void addOptionReference(OptionReference optionRef) {
+ if (optionReferences == null)
+ optionReferences = new ArrayList();
+ optionReferences.add(optionRef);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.ITool#getOption(java.lang.String)
+ */
+ public IOption getOption(String id) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.ITool#createOption(org.eclipse.cdt.core.build.managed.IConfiguration)
+ */
+ public IOption createOption(IConfiguration config) {
+ // TODO Auto-generated method stub
+ return null;
+ }
}
Index: plugin.xml
===================================================================
RCS file: /home/tools/org.eclipse.cdt.ui.tests/plugin.xml,v
retrieving revision 1.7
diff -u -r1.7 plugin.xml
--- plugin.xml 9 Apr 2003 20:56:21 -0000 1.7
+++ plugin.xml 14 Apr 2003 20:00:09 -0000
@@ -94,11 +94,8 @@
</target>
<target
name="Test Root"
+ isAbstract="false"
id="test.root">
- <configuration
- name="Root Config"
- id="root.config">
- </configuration>
<tool
name="Root Tool"
id="root.tool">
@@ -117,10 +114,26 @@
id="childOption">
</option>
</tool>
+ <configuration
+ name="Root Config"
+ id="root.config">
+ </configuration>
+ <configuration
+ name="Root Override Config"
+ id="root.override.config">
+ <toolRef
+ id="root.tool">
+ <optionRef
+ value="x"
+ id="topOption">
+ </optionRef>
+ </toolRef>
+ </configuration>
</target>
<target
name="Test Sub"
parent="test.root"
+ isAbstract="false"
id="test.sub">
<configuration
name="Sub Config"
Index: build/org/eclipse/cdt/core/build/managed/tests/AllBuildTests.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.ui.tests/build/org/eclipse/cdt/core/build/managed/tests/AllBuildTests.java,v
retrieving revision 1.4
diff -u -r1.4 AllBuildTests.java
--- build/org/eclipse/cdt/core/build/managed/tests/AllBuildTests.java 9 Apr 2003 20:56:21 -0000 1.4
+++ build/org/eclipse/cdt/core/build/managed/tests/AllBuildTests.java 14 Apr 2003 20:00:09 -0000
@@ -14,12 +14,19 @@
import junit.framework.TestCase;
import junit.framework.TestSuite;
+import org.eclipse.cdt.core.build.managed.BuildException;
import org.eclipse.cdt.core.build.managed.IConfiguration;
import org.eclipse.cdt.core.build.managed.IOption;
import org.eclipse.cdt.core.build.managed.IOptionCategory;
import org.eclipse.cdt.core.build.managed.ITarget;
import org.eclipse.cdt.core.build.managed.ITool;
import org.eclipse.cdt.core.build.managed.ManagedBuildManager;
+import org.eclipse.cdt.internal.core.build.managed.ToolReference;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
/**
*
@@ -34,6 +41,7 @@
TestSuite suite = new TestSuite();
suite.addTest(new AllBuildTests("testExtensions"));
+ suite.addTest(new AllBuildTests("testProject"));
return suite;
}
@@ -59,34 +67,7 @@
if (target.getName().equals("Test Root")) {
testRoot = target;
- // Tools
- ITool[] tools = testRoot.getTools();
- // Root Tool
- ITool rootTool = tools[0];
- assertEquals("Root Tool", rootTool.getName());
- // Options
- IOption[] options = rootTool.getOptions();
- assertEquals(2, options.length);
- assertEquals("Option in Top", options[0].getName());
- assertEquals("Option in Category", options[1].getName());
- // Option Categories
- IOptionCategory topCategory = rootTool.getTopOptionCategory();
- assertEquals("Root Tool", topCategory.getName());
- options = topCategory.getOptions(rootTool);
- assertEquals(1, options.length);
- assertEquals("Option in Top", options[0].getName());
- IOptionCategory[] categories = topCategory.getChildCategories();
- assertEquals(1, categories.length);
- assertEquals("Category", categories[0].getName());
- options = categories[0].getOptions(rootTool);
- assertEquals(1, options.length);
- assertEquals("Option in Category", options[0].getName());
-
- // Configs
- IConfiguration[] configs = testRoot.getConfigurations();
- // Root Config
- IConfiguration rootConfig = configs[0];
- assertEquals("Root Config", rootConfig.getName());
+ checkRootTarget(testRoot);
} else if (target.getName().equals("Test Sub")) {
testSub = target;
@@ -105,8 +86,9 @@
// Root Config
IConfiguration rootConfig = configs[0];
assertEquals("Root Config", rootConfig.getName());
+ assertEquals("Root Override Config", configs[1].getName());
// Sub Config
- IConfiguration subConfig = configs[1];
+ IConfiguration subConfig = configs[2];
assertEquals("Sub Config", subConfig.getName());
}
}
@@ -114,4 +96,97 @@
assertNotNull(testRoot);
assertNotNull(testSub);
}
+
+ public void testProject() throws CoreException, BuildException {
+ // Create new project
+ IProject project = createProject("BuildTest");
+
+ assertEquals(0, ManagedBuildManager.getTargets(project).length);
+
+ // Find the base target definition
+ ITarget targetDef = ManagedBuildManager.getTarget(project, "test.root");
+ assertNotNull(targetDef);
+
+ // Create the target for our project
+ ITarget newTarget = ManagedBuildManager.createTarget(project, targetDef);
+ assertEquals(newTarget.getName(), targetDef.getName());
+ assertFalse(newTarget.equals(targetDef));
+
+ ITarget[] targets = ManagedBuildManager.getTargets(project);
+ assertEquals(1, targets.length);
+ ITarget target = targets[0];
+ assertEquals(target, newTarget);
+ assertFalse(target.equals(targetDef));
+
+ checkRootTarget(target);
+
+ // Save, close, reopen and test again
+ ManagedBuildManager.saveBuildInfo(project);
+ project.close(null);
+ ManagedBuildManager.removeBuildInfo(project);
+ project.open(null);
+
+ targets = ManagedBuildManager.getTargets(project);
+ assertEquals(1, targets.length);
+ checkRootTarget(targets[0]);
+ }
+
+ IProject createProject(String name) throws CoreException {
+ IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
+ IProject project = root.getProject(name);
+ if (!project.exists()) {
+ project.create(null);
+ } else {
+ project.refreshLocal(IResource.DEPTH_INFINITE, null);
+ }
+
+ if (!project.isOpen()) {
+ project.open(null);
+ }
+
+ //CCorePlugin.getDefault().convertProjectToC(project, null, CCorePlugin.PLUGIN_ID + ".make", true);
+
+ return project;
+ }
+
+ private void checkRootTarget(ITarget target) {
+ // Tools
+ ITool[] tools = target.getTools();
+ // Root Tool
+ ITool rootTool = tools[0];
+ assertEquals("Root Tool", rootTool.getName());
+ // Options
+ IOption[] options = rootTool.getOptions();
+ assertEquals(2, options.length);
+ assertEquals("Option in Top", options[0].getName());
+ assertEquals("Option in Category", options[1].getName());
+ // Option Categories
+ IOptionCategory topCategory = rootTool.getTopOptionCategory();
+ assertEquals("Root Tool", topCategory.getName());
+ options = topCategory.getOptions(null);
+ assertEquals(1, options.length);
+ assertEquals("Option in Top", options[0].getName());
+ IOptionCategory[] categories = topCategory.getChildCategories();
+ assertEquals(1, categories.length);
+ assertEquals("Category", categories[0].getName());
+ options = categories[0].getOptions(null);
+ assertEquals(1, options.length);
+ assertEquals("Option in Category", options[0].getName());
+
+ // Configs
+ IConfiguration[] configs = target.getConfigurations();
+ // Root Config
+ IConfiguration rootConfig = configs[0];
+ assertEquals("Root Config", rootConfig.getName());
+ // Tools
+ tools = rootConfig.getTools();
+ assertEquals(1, tools.length);
+ assertEquals("Root Tool", tools[0].getName());
+ // Root Override Config
+ assertEquals("Root Override Config", configs[1].getName());
+ tools = configs[1].getTools();
+ assertTrue(tools[0] instanceof ToolReference);
+ options = tools[0].getOptions();
+ }
+
}