Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[cdt-patch] Applied Patch: Fleshing out the new build model

Starting to populate it from an extension point.  Check out the AllBuildTests class in ui.tests for how to use it and the ManagedBuildManager.loadExtensions method for how it is loaded from the extension point (which is currently extended in ui.tests.)

 

Doug Schaefer

Rational Software - IBM Software Group

Ottawa (Kanata), Ontario, Canada

 

Index: build/org/eclipse/cdt/core/build/managed/IBuildObject.java
===================================================================
RCS file: build/org/eclipse/cdt/core/build/managed/IBuildObject.java
diff -N build/org/eclipse/cdt/core/build/managed/IBuildObject.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ build/org/eclipse/cdt/core/build/managed/IBuildObject.java	9 Apr 2003 20:49:10 -0000
@@ -0,0 +1,25 @@
+/*
+ * Created on Apr 9, 2003
+ *
+ * To change the template for this generated file go to
+ * Window>Preferences>Java>Code Generation>Code and Comments
+ */
+package org.eclipse.cdt.core.build.managed;
+
+/**
+ * @author dschaefe
+ *
+ * To change the template for this generated type comment go to
+ * Window>Preferences>Java>Code Generation>Code and Comments
+ */
+public interface IBuildObject {
+
+	public String getId();
+
+	public void setId(String id);
+	
+	public String getName();
+	
+	public void setName(String name);
+		
+}
Index: build/org/eclipse/cdt/core/build/managed/IConfiguration.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/build/org/eclipse/cdt/core/build/managed/IConfiguration.java,v
retrieving revision 1.3
diff -u -r1.3 IConfiguration.java
--- build/org/eclipse/cdt/core/build/managed/IConfiguration.java	9 Apr 2003 15:14:55 -0000	1.3
+++ build/org/eclipse/cdt/core/build/managed/IConfiguration.java	9 Apr 2003 20:49:10 -0000
@@ -15,16 +15,10 @@
 /**
  * 
  */
-public interface IConfiguration {
+public interface IConfiguration extends IBuildObject {
 
 	/**
-	 * Returns the name of this configuration
-	 * @return
-	 */
-	public String getName();
-	
-	/**
-	 * Returns the platform for this configuration.
+	 * Returns the target for this configuration.
 	 * 
 	 * @return
 	 */
@@ -35,14 +29,6 @@
 	 * @return
 	 */
 	public IResource getOwner();
-	
-	/**
-	 * Returns the configuration from which this configuration inherits
-	 * properties.
-	 * 
-	 * @return
-	 */
-	public IConfiguration getParent();
 	
 	/**
 	 * Returns the tools that are used in this configuration.
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.2
diff -u -r1.2 IOption.java
--- build/org/eclipse/cdt/core/build/managed/IOption.java	7 Apr 2003 20:56:27 -0000	1.2
+++ build/org/eclipse/cdt/core/build/managed/IOption.java	9 Apr 2003 20:49:11 -0000
@@ -13,7 +13,7 @@
 /**
  * 
  */
-public interface IOption {
+public interface IOption extends IBuildObject {
 
 	// Type for the value of the option
 	public static final int STRING = 0;
@@ -32,6 +32,13 @@
 	 * @return
 	 */
 	public IOptionCategory getCategory();
+	
+	/**
+	 * Set the option category for this option.
+	 * 
+	 * @param category
+	 */
+	public void setCategory(IOptionCategory category);
 	
 	/**
 	 * Returns the name of this option.
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.2
diff -u -r1.2 IOptionCategory.java
--- build/org/eclipse/cdt/core/build/managed/IOptionCategory.java	9 Apr 2003 15:14:55 -0000	1.2
+++ build/org/eclipse/cdt/core/build/managed/IOptionCategory.java	9 Apr 2003 20:49:11 -0000
@@ -13,30 +13,42 @@
 /**
  * 
  */
-public interface IOptionCategory {
+public interface IOptionCategory extends IBuildObject {
 
 	/**
-	 * Returns the name of the option category.
+	 * Returns the list of children of this node in the option category tree
 	 * 
 	 * @return
 	 */
-	public String getName();
-
+	public IOptionCategory[] getChildCategories();
+	
 	/**
-	 * Returns the options that have been assigned to this category.
+	 * Returns a new child category for this category.
 	 * 
 	 * @return
 	 */
-	public IOption[] getOptions();
+	public IOptionCategory createChildCategory();
 	
 	/**
-	 * Returns the list of children of this node in the option category tree
+	 * Returns the options in this category for a given tool.
 	 * 
+	 * @param tool
 	 * @return
 	 */
-	public IOptionCategory[] getChildCategories();
+	public IOption[] getOptions(ITool tool);
 	
+	/**
+	 * Returns the category that owns this category, or null if this is the
+	 * top category for a tool.
+	 * 
+	 * @return
+	 */
 	public IOptionCategory getOwner();
 	
+	/**
+	 * Returns the tool that ultimately owns this category.
+	 * 
+	 * @return
+	 */
 	public ITool getTool();
 }
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.3
diff -u -r1.3 ITarget.java
--- build/org/eclipse/cdt/core/build/managed/ITarget.java	9 Apr 2003 15:14:55 -0000	1.3
+++ build/org/eclipse/cdt/core/build/managed/ITarget.java	9 Apr 2003 20:49:11 -0000
@@ -16,23 +16,9 @@
  * This class represents targets for the managed build process.  A target
  * is some type of resource built using a given collection of tools.
  */
-public interface ITarget {
+public interface ITarget extends IBuildObject {
 
 	/**
-	 * Gets the name for the target.
-	 * 
-	 * @return
-	 */
-	public String getName();
-	
-	/**
-	 * Gets the parent for the target.
-	 * 
-	 * @return
-	 */
-	public ITarget getParent();
-	
-	/**
 	 * Gets the resource that this target is applied to.
 	 * 
 	 * @return
@@ -48,27 +34,33 @@
 	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 the given resource.
+	 * Creates a new configuration for this target.
 	 * 
-	 * @param resource
 	 * @return
 	 */
-	public IConfiguration addConfiguration(IResource resource)
+	public IConfiguration createConfiguration()
 		throws BuildException;
 	
 	/**
-	 * Creates a new configuration for the given resource based on the parent config
-	 * @param resource
+	 * Creates a new configuration based on the parent config for this target.
+	 * 
 	 * @param parentConfig
 	 * @return
 	 */
-	public IConfiguration addConfiguration(IResource resource, IConfiguration parentConfig)
+	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.1
diff -u -r1.1 ITool.java
--- build/org/eclipse/cdt/core/build/managed/ITool.java	7 Apr 2003 02:47:01 -0000	1.1
+++ build/org/eclipse/cdt/core/build/managed/ITool.java	9 Apr 2003 20:49:11 -0000
@@ -13,31 +13,26 @@
 /**
  * 
  */
-public interface ITool {
+public interface ITool extends IBuildObject {
 
 	/**
-	 * Returns the name of the tool.
-	 * 
-	 * @return
-	 */
-	public String getName();
-	
-	/**
 	 * Return the target that defines this tool, if applicable
 	 * @return
 	 */
 	public ITarget getTarget();
 	
 	/**
-	 * Returns the tool that this tool inherits properties from.
-	 * @return
+	 * Returns the options that may be customized for this tool.
 	 */
-	public ITool getParent();
+	public IOption[] getOptions();
 	
 	/**
-	 * Returns the options that may be customized for this tool.
+	 * Creates a new option for this tool.  Generally, this should only be
+	 * done by the extension and project data loaders.
+	 * 
+	 * @return
 	 */
-	public IOption[] getOptions();
+	public IOption createOption();
 	
 	/**
 	 * 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.3
diff -u -r1.3 ManagedBuildManager.java
--- build/org/eclipse/cdt/core/build/managed/ManagedBuildManager.java	9 Apr 2003 15:14:55 -0000	1.3
+++ build/org/eclipse/cdt/core/build/managed/ManagedBuildManager.java	9 Apr 2003 20:49:11 -0000
@@ -11,7 +11,9 @@
 package org.eclipse.cdt.core.build.managed;
 
 import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 import org.eclipse.cdt.core.CCorePlugin;
 import org.eclipse.cdt.internal.core.build.managed.Configuration;
@@ -138,6 +140,15 @@
 		return newTarget;
 	}
 	
+	/**
+	 * Saves the build information associated with a project and all resources
+	 * in the project to the build info file.
+	 * 
+	 * @param project
+	 */
+	public static void saveBuildInfo(IProject project) {
+	}
+	
 	// Private stuff
 	
 	private static List extensionTargets;
@@ -147,6 +158,7 @@
 			return;
 			
 		extensionTargets = new ArrayList();
+		Map targetMap = new HashMap(); 
 		
 		IExtensionPoint extensionPoint
 			= CCorePlugin.getDefault().getDescriptor().getExtensionPoint("ManagedBuildInfo");
@@ -157,17 +169,49 @@
 			for (int j = 0; j < elements.length; ++j) {
 				IConfigurationElement element = elements[j];
 				if (element.getName().equals("target")) {
-					Target target = new Target(null);
+					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")) {
-							Tool tool = new Tool(targetElement.getAttribute("name"), target);
+							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")) {
-							target.addConfiguration(new Configuration(target));
+							try {
+								IConfiguration config = target.createConfiguration();
+								config.setName(targetElement.getAttribute("name"));
+							} catch (BuildException e) {
+								// Not sure what to do here.
+							}
 						}
 					}
 				}
Index: build/org/eclipse/cdt/internal/core/build/managed/BuildObject.java
===================================================================
RCS file: build/org/eclipse/cdt/internal/core/build/managed/BuildObject.java
diff -N build/org/eclipse/cdt/internal/core/build/managed/BuildObject.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ build/org/eclipse/cdt/internal/core/build/managed/BuildObject.java	9 Apr 2003 20:49:11 -0000
@@ -0,0 +1,50 @@
+/*
+ * Created on Apr 9, 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 org.eclipse.cdt.core.build.managed.IBuildObject;
+
+/**
+ * @author dschaefe
+ *
+ * To change the template for this generated type comment go to
+ * Window>Preferences>Java>Code Generation>Code and Comments
+ */
+public class BuildObject implements IBuildObject {
+
+	protected String id;
+	protected String name;
+	
+	/* (non-Javadoc)
+	 * @see org.eclipse.cdt.core.build.managed.IBuildObject#getId()
+	 */
+	public String getId() {
+		return id;
+	}
+
+	/* (non-Javadoc)
+	 * @see org.eclipse.cdt.core.build.managed.IBuildObject#setId(java.lang.String)
+	 */
+	public void setId(String id) {
+		this.id = id;
+	}
+
+	/* (non-Javadoc)
+	 * @see org.eclipse.cdt.core.build.managed.IBuildObject#getName()
+	 */
+	public String getName() {
+		return name;
+	}
+
+	/* (non-Javadoc)
+	 * @see org.eclipse.cdt.core.build.managed.IBuildObject#setName(java.lang.String)
+	 */
+	public void setName(String name) {
+		this.name = name;
+	}
+
+}
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.3
diff -u -r1.3 Configuration.java
--- build/org/eclipse/cdt/internal/core/build/managed/Configuration.java	9 Apr 2003 15:14:55 -0000	1.3
+++ build/org/eclipse/cdt/internal/core/build/managed/Configuration.java	9 Apr 2003 20:49:11 -0000
@@ -20,9 +20,8 @@
 /**
  * 
  */
-public class Configuration implements IConfiguration {
+public class Configuration extends BuildObject implements IConfiguration {
 
-	private String name;
 	private ITarget target;
 	private IConfiguration parent;
 	private List toolReference;
@@ -40,13 +39,6 @@
 	 */
 	public String getName() {
 		return (name == null && parent != null) ? parent.getName() : name;
-	}
-
-	/* (non-Javadoc)
-	 * @see org.eclipse.cdt.core.build.managed.IConfiguration#setName(java.lang.String)
-	 */
-	public void setName(String name) {
-		this.name = name;
 	}
 
 	/* (non-Javadoc)
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.1
diff -u -r1.1 Option.java
--- build/org/eclipse/cdt/internal/core/build/managed/Option.java	7 Apr 2003 20:56:27 -0000	1.1
+++ build/org/eclipse/cdt/internal/core/build/managed/Option.java	9 Apr 2003 20:49:11 -0000
@@ -10,9 +10,90 @@
  **********************************************************************/
 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;
+
 /**
  * 
  */
-public class Option {
+public class Option extends BuildObject implements IOption {
+
+	private ITool tool;
+	private IOptionCategory category;
+	
+	public Option(ITool tool) {
+		this.tool = tool;
+	}
+	
+	/* (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() {
+		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;
+	}
+
+	/* (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() {
+		return tool;
+	}
+
+	/* (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#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;
+	}
+
+	/* (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;
+	}
+
+	/* (non-Javadoc)
+	 * @see org.eclipse.cdt.core.build.managed.IOption#setCategory(org.eclipse.cdt.core.build.managed.IOptionCategory)
+	 */
+	public void setCategory(IOptionCategory category) {
+		this.category = category;
+	}
 
 }
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.1
diff -u -r1.1 OptionCategory.java
--- build/org/eclipse/cdt/internal/core/build/managed/OptionCategory.java	7 Apr 2003 20:56:27 -0000	1.1
+++ build/org/eclipse/cdt/internal/core/build/managed/OptionCategory.java	9 Apr 2003 20:49:11 -0000
@@ -10,9 +10,79 @@
  **********************************************************************/
 package org.eclipse.cdt.internal.core.build.managed;
 
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.cdt.core.build.managed.IOption;
+import org.eclipse.cdt.core.build.managed.IOptionCategory;
+import org.eclipse.cdt.core.build.managed.ITool;
+
 /**
  * 
  */
-public class OptionCategory {
+public class OptionCategory extends BuildObject implements IOptionCategory {
+
+	private IOptionCategory owner;
+	private List children;
+
+	private static final IOptionCategory[] emtpyCategories = new IOptionCategory[0];
+	
+	public OptionCategory(IOptionCategory owner) {
+		this.owner = owner;
+	}
+	
+	/* (non-Javadoc)
+	 * @see org.eclipse.cdt.core.build.managed.IOptionCategory#getChildCategories()
+	 */
+	public IOptionCategory[] getChildCategories() {
+		if (children != null)
+			return (IOptionCategory[])children.toArray(new IOptionCategory[children.size()]);
+		else
+			return emtpyCategories;
+	}
+
+	/* (non-Javadoc)
+	 * @see org.eclipse.cdt.core.build.managed.IOptionCategory#createChildCategory()
+	 */
+	public IOptionCategory createChildCategory() {
+		IOptionCategory category = new OptionCategory(this);
+		
+		if (children == null)
+			children = new ArrayList();
+		children.add(category);
+		
+		return category;
+	}
+
+	/* (non-Javadoc)
+	 * @see org.eclipse.cdt.core.build.managed.IOptionCategory#getOwner()
+	 */
+	public IOptionCategory getOwner() {
+		return owner;
+	}
+
+	/* (non-Javadoc)
+	 * @see org.eclipse.cdt.core.build.managed.IOptionCategory#getTool()
+	 */
+	public ITool getTool() {
+		// This will stop at the Tool's top category
+		return owner.getTool();
+	}
+
+	/* (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();
+		IOption[] allOptions = tool.getOptions();
+		
+		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/Target.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/build/org/eclipse/cdt/internal/core/build/managed/Target.java,v
retrieving revision 1.3
diff -u -r1.3 Target.java
--- build/org/eclipse/cdt/internal/core/build/managed/Target.java	9 Apr 2003 15:14:55 -0000	1.3
+++ build/org/eclipse/cdt/internal/core/build/managed/Target.java	9 Apr 2003 20:49:11 -0000
@@ -17,21 +17,21 @@
 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;
 
 /**
  * 
  */
-public class Target implements ITarget {
+public class Target extends BuildObject implements ITarget {
 
-	private String name;
 	private ITarget parent;
 	private IResource owner;
 	private List tools;
 	private List configurations;
 
+	private static final IConfiguration[] emptyConfigs = new IConfiguration[0];
+	
 	public Target(IResource owner) {
 		this.owner = owner;
 	}
@@ -61,10 +61,6 @@
 		return parent;
 	}
 	
-	public void setName(String name) {
-		this.name = name;
-	}
-
 	public IResource getOwner() {
 		return owner;
 	}
@@ -95,53 +91,55 @@
 		return toolArray;
 	}
 
-	public void addTool(ITool tool){
+	public ITool createTool() {
+		ITool tool = new Tool(this);
+		
 		if (tools == null)
 			tools = new ArrayList();
 		tools.add(tool);
+		
+		return tool;
 	}
 	
 	public IConfiguration[] getConfigurations() {
-		return (IConfiguration[])configurations.toArray(new IConfiguration[configurations.size()]);
+		if (configurations != null)
+			return (IConfiguration[])configurations.toArray(new IConfiguration[configurations.size()]);
+		else
+			return emptyConfigs;
 	}
 
-	public void addConfiguration(IConfiguration configuration) {
+	private void addLocalConfiguration(IConfiguration configuration) {
 		if (configurations == null)
 			configurations = new ArrayList();
 		configurations.add(configuration);
 	}
 	
-	/* (non-Javadoc)
-	 * @see org.eclipse.cdt.core.build.managed.ITarget#addConfiguration(org.eclipse.core.resources.IResource)
-	 */
-	public IConfiguration addConfiguration(IResource resource)
+	public IConfiguration createConfiguration()
 		throws BuildException
 	{
-		Target target = (Target)ManagedBuildManager.addTarget(resource, this);
-		IConfiguration config = new Configuration(target);
-		target.addConfiguration(config);
-		return null;
+		IConfiguration config = new Configuration(this);
+		addLocalConfiguration(config);
+		return config;
 	}
 
-	public IConfiguration addConfiguration(IResource resource, IConfiguration parentConfig)
+	public IConfiguration createConfiguration(IConfiguration parentConfig)
 		throws BuildException
 	{
 		IResource parentOwner = parentConfig.getOwner();
 		
-		if (resource instanceof IProject) {
+		if (owner instanceof IProject) {
 			// parent must be owned by the same project
-			if (!resource.equals(parentOwner))
+			if (!owner.equals(parentOwner))
 				throw new BuildException("addConfiguration: parent must be in same project");
 		} else {
 			// parent must be owned by the project
-			if (!resource.getProject().equals(parentOwner))
+			if (!owner.getProject().equals(parentOwner))
 				throw new BuildException("addConfiguration: parent must be in owning project");
 		}
 
 		// Validation passed
-		Target target = (Target)ManagedBuildManager.addTarget(resource, this);
 		IConfiguration config = new Configuration(parentConfig);
-		target.addConfiguration(config);
+		addLocalConfiguration(config);
 		return config;
 	}
 
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.2
diff -u -r1.2 Tool.java
--- build/org/eclipse/cdt/internal/core/build/managed/Tool.java	7 Apr 2003 20:56:27 -0000	1.2
+++ build/org/eclipse/cdt/internal/core/build/managed/Tool.java	9 Apr 2003 20:49:11 -0000
@@ -10,50 +10,112 @@
  **********************************************************************/
 package org.eclipse.cdt.internal.core.build.managed;
 
+import java.util.ArrayList;
+import java.util.List;
+
 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;
 
 /**
- * 
+ * Represents a tool that can be invoked during a build.
+ * Note that this class implements IOptionCategory to represent the top
+ * category.
  */
-public class Tool implements ITool {
+public class Tool extends BuildObject implements ITool, IOptionCategory {
 
-	private String name;
 	private ITarget target;
+	private List options;
+	private IOptionCategory topOptionCategory;
+	private List childOptionCategories;
 	
-	public Tool(String name) {
-		this.name = name;
-	}
+	private static IOption[] emptyOptions = new IOption[0];
+	private static IOptionCategory[] emptyCategories = new IOptionCategory[0];
 	
-	public Tool(String name, Target target) {
-		this(name);
+	public Tool(Target target) {
 		this.target = target;
 	}
 	
-	public String getName() {
-		return name;
-	}
-
 	public ITarget getTarget() {
 		return target;	
 	}
 	
 	public IOption[] getOptions() {
-		return null;
+		if (options != null)
+			return (IOption[])options.toArray(new IOption[options.size()]);
+		else
+			return emptyOptions;
+	}
+
+	/* (non-Javadoc)
+	 * @see org.eclipse.cdt.core.build.managed.ITool#createOption()
+	 */
+	public IOption createOption() {
+		IOption option = new Option(this);
+		
+		if (options == null)
+			options = new ArrayList();
+		options.add(option);
+		
+		return option;
 	}
 
 	public IOptionCategory getTopOptionCategory() {
-		return null;
+		return this;
+	}
+
+	/* (non-Javadoc)
+	 * @see org.eclipse.cdt.core.build.managed.IOptionCategory#getChildCategories()
+	 */
+	public IOptionCategory[] getChildCategories() {
+		if (childOptionCategories != null)
+			return (IOptionCategory[])childOptionCategories.toArray(new IOptionCategory[childOptionCategories.size()]);
+		else
+			return emptyCategories;
 	}
 
 	/* (non-Javadoc)
-	 * @see org.eclipse.cdt.core.build.managed.ITool#getParent()
+	 * @see org.eclipse.cdt.core.build.managed.IOptionCategory#createChildCategory()
 	 */
-	public ITool getParent() {
-		// TODO Auto-generated method stub
+	public IOptionCategory createChildCategory() {
+		IOptionCategory category = new OptionCategory(this);
+		
+		if (childOptionCategories == null)
+			childOptionCategories = new ArrayList();
+		childOptionCategories.add(category);
+		
+		return category;
+	}
+
+	/* (non-Javadoc)
+	 * @see org.eclipse.cdt.core.build.managed.IOptionCategory#getOwner()
+	 */
+	public IOptionCategory getOwner() {
 		return null;
+	}
+
+	/* (non-Javadoc)
+	 * @see org.eclipse.cdt.core.build.managed.IOptionCategory#getTool()
+	 */
+	public ITool getTool() {
+		return this;
+	}
+
+	/* (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();
+		IOption[] allOptions = tool.getOptions();
+		
+		for (int i = 0; i < allOptions.length; ++i) {
+			IOption option = allOptions[i];
+			if (option.getCategory() == null || option.getCategory().equals(this))
+				myOptions.add(option);
+		}
+		
+		return (IOption[])myOptions.toArray(new IOption[myOptions.size()]);
 	}
 
 }
Index: schema/ManagedBuildTools.exsd
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/schema/ManagedBuildTools.exsd,v
retrieving revision 1.2
diff -u -r1.2 ManagedBuildTools.exsd
--- schema/ManagedBuildTools.exsd	7 Apr 2003 20:56:27 -0000	1.2
+++ schema/ManagedBuildTools.exsd	9 Apr 2003 20:49:11 -0000
@@ -272,6 +272,13 @@
                </documentation>
             </annotation>
          </attribute>
+         <attribute name="owner" type="string">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+            </annotation>
+         </attribute>
       </complexType>
    </element>
 
Index: plugin.xml
===================================================================
RCS file: /home/tools/org.eclipse.cdt.ui.tests/plugin.xml,v
retrieving revision 1.6
diff -u -r1.6 plugin.xml
--- plugin.xml	9 Apr 2003 15:14:56 -0000	1.6
+++ plugin.xml	9 Apr 2003 20:51:47 -0000
@@ -36,6 +36,7 @@
                name="Compiler"
                id="linux.compiler">
             <optionCategory
+                  owner="linux.compiler"
                   name="Optimization Options"
                   id="linux.compiler.optimization">
             </optionCategory>
@@ -94,6 +95,41 @@
       <target
             name="Test Root"
             id="test.root">
+         <configuration
+               name="Root Config"
+               id="root.config">
+         </configuration>
+         <tool
+               name="Root Tool"
+               id="root.tool">
+            <optionCategory
+                  owner="root.tool"
+                  name="Category"
+                  id="category">
+            </optionCategory>
+            <option
+                  name="Option in Top"
+                  id="topOption">
+            </option>
+            <option
+                  name="Option in Category"
+                  category="category"
+                  id="childOption">
+            </option>
+         </tool>
+      </target>
+      <target
+            name="Test Sub"
+            parent="test.root"
+            id="test.sub">
+         <configuration
+               name="Sub Config"
+               id="sub.config">
+         </configuration>
+         <tool
+               name="Sub Tool"
+               id="tool.sub">
+         </tool>
       </target>
    </extension>
 
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.3
diff -u -r1.3 AllBuildTests.java
--- build/org/eclipse/cdt/core/build/managed/tests/AllBuildTests.java	9 Apr 2003 15:14:56 -0000	1.3
+++ build/org/eclipse/cdt/core/build/managed/tests/AllBuildTests.java	9 Apr 2003 20:51:47 -0000
@@ -14,7 +14,11 @@
 import junit.framework.TestCase;
 import junit.framework.TestSuite;
 
+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;
 
 /**
@@ -43,7 +47,8 @@
 	 * defined in this plugin
 	 */
 	public void testExtensions() {
-		boolean testRootFound = false;
+		ITarget testRoot = null;
+		ITarget testSub = null;
 		
 		// Note secret null parameter which means just extensions
 		ITarget[] targets = ManagedBuildManager.getDefinedTargets(null);
@@ -52,10 +57,61 @@
 			ITarget target = targets[i];
 			
 			if (target.getName().equals("Test Root")) {
-				testRootFound = true;
+				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());
+				
+			} else if (target.getName().equals("Test Sub")) {
+				testSub = target;
+				
+				// Tools
+				ITool[] tools = testSub.getTools();
+				// Root Tool
+				ITool rootTool = tools[0];
+				assertEquals("Root Tool", rootTool.getName());
+				// Sub Tool
+				ITool subTool = tools[1];
+				assertEquals("Sub Tool", subTool.getName());
+
+				// Configs
+				IConfiguration[] configs = testSub.getConfigurations();
+				// Root Config
+				IConfiguration rootConfig = configs[0];
+				assertEquals("Root Config", rootConfig.getName());
+				// Sub Config
+				IConfiguration subConfig = configs[1];
+				assertEquals("Sub Config", subConfig.getName());
 			}
 		}
 		
-		assertTrue(testRootFound);
+		assertNotNull(testRoot);
+		assertNotNull(testSub);
 	}
 }

Back to the top