[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[cdt-patch] Applied Patch: update new build model
|
Added the abillity to create a configuration
on and ITarget and set an option for an IConfiguration.
These aren't stored in the build file,
yet.
If you don't know what I'm talking about,
don't worry. We'll be putting out a description of this prototype
in early May.
Doug Schaefer
Rational Software - IBM Software Group
Ottawa, Ontario, Canada
Index: build/org/eclipse/cdt/core/build/managed/IBuildObject.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/build/org/eclipse/cdt/core/build/managed/IBuildObject.java,v
retrieving revision 1.1
diff -u -r1.1 IBuildObject.java
--- build/org/eclipse/cdt/core/build/managed/IBuildObject.java 9 Apr 2003 20:56:20 -0000 1.1
+++ build/org/eclipse/cdt/core/build/managed/IBuildObject.java 17 Apr 2003 18:40:27 -0000
@@ -16,10 +16,6 @@
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.4
diff -u -r1.4 IConfiguration.java
--- build/org/eclipse/cdt/core/build/managed/IConfiguration.java 9 Apr 2003 20:56:20 -0000 1.4
+++ build/org/eclipse/cdt/core/build/managed/IConfiguration.java 17 Apr 2003 18:40:27 -0000
@@ -37,4 +37,19 @@
*/
public ITool[] getTools();
+ /**
+ * Sets an option value for this configuration.
+ *
+ * @param option
+ * @param value
+ */
+ public void setOption(IOption option, String value)
+ throws BuildException;
+
+ /**
+ * Sets an option value for this configuration.
+ * @param option
+ */
+ public void setOption(IOption option, String[] value)
+ throws BuildException;
}
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.4
diff -u -r1.4 IOption.java
--- build/org/eclipse/cdt/core/build/managed/IOption.java 14 Apr 2003 20:02:38 -0000 1.4
+++ build/org/eclipse/cdt/core/build/managed/IOption.java 17 Apr 2003 18:40:27 -0000
@@ -34,13 +34,6 @@
public IOptionCategory getCategory();
/**
- * Set the option category for this option.
- *
- * @param category
- */
- public void setCategory(IOptionCategory category);
-
- /**
* Returns the name of this option.
*
* @return
@@ -68,35 +61,13 @@
*
* @return
*/
- public String getStringValue();
+ public String getStringValue() throws BuildException;
/**
* Returns the current value for this option if it is a List of Strings.
*
* @return
*/
- public String [] getStringListValue();
+ public String [] getStringListValue() throws BuildException;
- /**
- * Sets the value for this option in a given configuration.
- * A new instance of the option for the configuration may be created.
- * The appropriate new option is returned.
- *
- * @param config
- * @param value
- */
- public IOption setValue(IConfiguration config, String value)
- throws BuildException;
-
- /**
- * Sets the value for this option in a given configuration.
- * A new instance of the option for the configuration may be created.
- * The appropriate new option is returned.
- *
- * @param config
- * @param value
- */
- public IOption setValue(IConfiguration config, String[] value)
- throws BuildException;
-
}
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.5
diff -u -r1.5 ITarget.java
--- build/org/eclipse/cdt/core/build/managed/ITarget.java 14 Apr 2003 20:02:38 -0000 1.5
+++ build/org/eclipse/cdt/core/build/managed/ITarget.java 17 Apr 2003 18:40:27 -0000
@@ -45,4 +45,24 @@
*/
public IConfiguration[] getConfigurations();
+ /**
+ * Creates a new configuration for the target. It is populated with
+ * the tools defined for that target and options set at their defaults.
+ *
+ * @param id id for this configuration.
+ * @return
+ */
+ public IConfiguration createConfiguration(String id);
+
+ /**
+ * Creates a configuration for the target populated with the tools and
+ * options settings from the parent configuration. As options and tools
+ * change in the parent, unoverridden values are updated in the child
+ * config as well.
+ *
+ * @param parent
+ * @param id
+ * @return
+ */
+ public IConfiguration createConfiguration(IConfiguration parent, String id);
}
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.5
diff -u -r1.5 ManagedBuildManager.java
--- build/org/eclipse/cdt/core/build/managed/ManagedBuildManager.java 14 Apr 2003 20:02:38 -0000 1.5
+++ build/org/eclipse/cdt/core/build/managed/ManagedBuildManager.java 17 Apr 2003 18:40:27 -0000
@@ -123,7 +123,7 @@
}
/**
- * Adds a new target to the resource based on the parentTarget.
+ * Creates a new target for the resource based on the parentTarget.
*
* @param resource
* @param parentTarget
@@ -155,6 +155,26 @@
return new Target(resource, parentTarget);
}
+ /**
+ * Set the string value for an option for a given config.
+ *
+ * @param config
+ * @param option
+ * @param value
+ */
+ public static void setOption(IConfiguration config, IOption option, String value) {
+ }
+
+ /**
+ * Set the string array value for an option for a given config.
+ *
+ * @param config
+ * @param option
+ * @param value
+ */
+ public static void setOption(IConfiguration config, IOption option, String[] value) {
+
+ }
/**
* Saves the build information associated with a project and all resources
* in the project to the build info file.
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.5
diff -u -r1.5 Configuration.java
--- build/org/eclipse/cdt/internal/core/build/managed/Configuration.java 14 Apr 2003 20:02:38 -0000 1.5
+++ build/org/eclipse/cdt/internal/core/build/managed/Configuration.java 17 Apr 2003 18:40:27 -0000
@@ -13,11 +13,15 @@
import java.util.ArrayList;
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.ITarget;
import org.eclipse.cdt.core.build.managed.ITool;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IConfigurationElement;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
/**
*
@@ -27,17 +31,29 @@
private ITarget target;
private IConfiguration parent;
private List toolReferences;
-
- public Configuration(Target target) {
+
+ /**
+ * A fresh new configuration for a target.
+ * @param target
+ * @param id
+ */
+ public Configuration(Target target, String id) {
+ this.id = id;
this.target = target;
+
+ target.addConfiguration(this);
}
- public Configuration(IConfiguration parent) {
+ public Configuration(Target target, IConfiguration parent, String id) {
+ this.id = id;
+ this.target = target;
this.parent = parent;
+
+ target.addConfiguration(this);
}
public Configuration(Target target, IConfigurationElement element) {
- this(target);
+ this.target = target;
// id
setId(element.getAttribute("id"));
@@ -57,6 +73,20 @@
}
}
+ public void serealize(Document doc, Element element) {
+ element.setAttribute("id", id);
+ element.setAttribute("name", name);
+ if (parent != null)
+ element.setAttribute("parent", parent.getId());
+
+ if (toolReferences != null)
+ for (int i = 0; i < toolReferences.size(); ++i) {
+ ToolReference toolRef = (ToolReference)toolReferences.get(i);
+ Element toolRefElement = doc.createElement("toolRef");
+ toolRef.serealize(doc, toolRefElement);
+ }
+ }
+
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IConfiguration#getName()
*/
@@ -124,4 +154,37 @@
toolReferences = new ArrayList();
toolReferences.add(toolRef);
}
+
+ public OptionReference createOptionReference(IOption option) {
+ if (option instanceof OptionReference) {
+ OptionReference optionRef = (OptionReference)option;
+ ToolReference toolRef = optionRef.getToolReference();
+ if (toolRef.getConfiguration().equals(this))
+ return optionRef;
+ else {
+ toolRef = new ToolReference(this, toolRef);
+ return toolRef.createOptionReference(option);
+ }
+ } else {
+ ToolReference toolRef = getToolReference(option.getTool());
+ if (toolRef == null)
+ toolRef = new ToolReference(this, option.getTool());
+ return toolRef.createOptionReference(option);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IConfiguration#setOption(org.eclipse.cdt.core.build.managed.IOption, java.lang.String)
+ */
+ public void setOption(IOption option, String value) throws BuildException {
+ createOptionReference(option).setValue(value);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IConfiguration#setOption(org.eclipse.cdt.core.build.managed.IOption, java.lang.String[])
+ */
+ public void setOption(IOption option, String[] value) throws BuildException {
+ createOptionReference(option).setValue(value);
+ }
+
}
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.2
diff -u -r1.2 OptionReference.java
--- build/org/eclipse/cdt/internal/core/build/managed/OptionReference.java 14 Apr 2003 20:02:38 -0000 1.2
+++ build/org/eclipse/cdt/internal/core/build/managed/OptionReference.java 17 Apr 2003 18:40:27 -0000
@@ -10,11 +10,13 @@
**********************************************************************/
package org.eclipse.cdt.internal.core.build.managed;
-import org.eclipse.cdt.core.build.managed.IConfiguration;
+import org.eclipse.cdt.core.build.managed.BuildException;
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;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
/**
*
@@ -22,121 +24,127 @@
public class OptionReference implements IOption {
private IOption option;
- private ITool tool;
+ private ToolReference owner;
+ private Object value;
- public OptionReference(IOption option, ITool tool) {
+ /**
+ * Created internally.
+ *
+ * @param owner
+ * @param option
+ */
+ public OptionReference(ToolReference owner, IOption option) {
+ this.owner = owner;
this.option = option;
- this.tool = tool;
+
+ owner.addOptionReference(this);
}
+ /**
+ * Created from extension.
+ *
+ * @param owner
+ * @param element
+ */
public OptionReference(ToolReference owner, IConfigurationElement element) {
- this.tool = owner;
+ this.owner = owner;
+ option = owner.getOption(element.getAttribute("id"));
- option = tool.getOption(element.getAttribute("id"));
+ owner.addOptionReference(this);
}
+ /**
+ * Created from project file.
+ *
+ * @param owner
+ * @param element
+ */
+ public OptionReference(ToolReference owner, Element element) {
+ this.owner = owner;
+ option = owner.getOption(element.getAttribute("id"));
+
+ owner.addOptionReference(this);
+ }
+
+ /**
+ * Write out to project file.
+ *
+ * @param doc
+ * @param element
+ */
+ public void serealize(Document doc, Element element) {
+ element.setAttribute("id", option.getId());
+ option = owner.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;
+ return option.getApplicableValues();
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IOption#getCategory()
*/
public IOptionCategory getCategory() {
- // TODO Auto-generated method stub
- return null;
+ return option.getCategory();
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IBuildObject#getName()
*/
public String getName() {
- // TODO Auto-generated method stub
- return null;
+ return option.getName();
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IOption#getStringListValue()
*/
- public String[] getStringListValue() {
- // TODO Auto-generated method stub
- return null;
+ public String[] getStringListValue() throws BuildException {
+ if (value == null)
+ return option.getStringListValue();
+ else if (getValueType() == IOption.STRING_LIST)
+ return (String[])value;
+ else
+ throw new BuildException("bad value type");
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IOption#getStringValue()
*/
- public String getStringValue() {
- // TODO Auto-generated method stub
- return null;
+ public String getStringValue() throws BuildException {
+ if (value == null)
+ return option.getStringValue();
+ else if (getValueType() == IOption.STRING)
+ return (String)value;
+ else
+ throw new BuildException("bad value type");
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IOption#getTool()
*/
public ITool getTool() {
- // TODO Auto-generated method stub
- return null;
+ return owner;
}
+ public ToolReference getToolReference() {
+ return owner;
+ }
+
/* (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;
+ return option.getValueType();
}
/* (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
-
+ return option.getId();
}
public boolean references(IOption target) {
@@ -151,4 +159,17 @@
return option.equals(target);
}
+ public void setValue(String value) throws BuildException {
+ if (getValueType() == IOption.STRING)
+ this.value = value;
+ else
+ throw new BuildException("bad value type");
+ }
+
+ public void setValue(String [] value) throws BuildException {
+ if (getValueType() == IOption.STRING_LIST)
+ this.value = value;
+ else
+ throw new BuildException("bad value type");
+ }
}
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.5
diff -u -r1.5 Target.java
--- build/org/eclipse/cdt/internal/core/build/managed/Target.java 14 Apr 2003 20:02:38 -0000 1.5
+++ build/org/eclipse/cdt/internal/core/build/managed/Target.java 17 Apr 2003 18:40:27 -0000
@@ -15,12 +15,10 @@
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;
@@ -45,15 +43,15 @@
}
/**
- * Create a target owned by a resource based on a parent target
+ * Create a target owned by a resource based on a parent target
+ *
+ * @param owner
* @param parent
*/
public Target(IResource owner, ITarget parent) {
this(owner);
this.parent = parent;
- inheritConfigs();
-
// Copy the parent's identity
setId(parent.getId());
setName(parent.getName());
@@ -80,13 +78,9 @@
// parent
String parentId = element.getAttribute("parent");
- if (parentId != null) {
+ if (parentId != null)
parent = ManagedBuildManager.getTarget(null, parentId);
- // Inherit the configs from the parent
- inheritConfigs();
- }
-
// isAbstract
if ("true".equals(element.getAttribute("isAbstract")))
isAbstract = true;
@@ -103,6 +97,12 @@
}
+ /**
+ * Create target from project file
+ *
+ * @param buildInfo
+ * @param element
+ */
public Target(ResourceBuildInfo buildInfo, Element element) {
this(buildInfo.getOwner());
@@ -117,27 +117,30 @@
// parent
String parentId = element.getAttribute("parent");
- if (parentId != null) {
+ 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 void serialize(Document doc, Element element) {
+ element.setAttribute("id", getId());
+ element.setAttribute("name", getName());
+ if (parent != null)
+ element.setAttribute("parent", parent.getId());
+ element.setAttribute("isAbstract", isAbstract ? "true" : "false");
+ if (configurations != null)
+ for (int i = 0; i < configurations.size(); ++i) {
+ Configuration config = (Configuration)configurations.get(i);
+ Element configElement = doc.createElement("configuration");
+ config.serealize(doc, configElement);
+ }
}
-
+
public String getName() {
return (name == null && parent != null) ? parent.getName() : name;
}
@@ -209,47 +212,25 @@
configurations.add(configuration);
}
- public IConfiguration createConfiguration()
- throws BuildException
- {
- IConfiguration config = new Configuration(this);
- addLocalConfiguration(config);
- return config;
- }
-
- public IConfiguration createConfiguration(IConfiguration parentConfig)
- throws BuildException
- {
- IResource parentOwner = parentConfig.getOwner();
-
- if (owner instanceof IProject) {
- // parent must be owned by the same project
- if (!owner.equals(parentOwner))
- throw new BuildException("addConfiguration: parent must be in same project");
- } else {
- // parent must be owned by the project
- if (!owner.getProject().equals(parentOwner))
- throw new BuildException("addConfiguration: parent must be in owning project");
- }
-
- // Validation passed
- 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());
+
+ /* (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) {
+ return new Configuration(this, parent, id);
}
}
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.2
diff -u -r1.2 ToolReference.java
--- build/org/eclipse/cdt/internal/core/build/managed/ToolReference.java 14 Apr 2003 20:02:38 -0000 1.2
+++ build/org/eclipse/cdt/internal/core/build/managed/ToolReference.java 17 Apr 2003 18:40:27 -0000
@@ -20,6 +20,8 @@
import org.eclipse.cdt.core.build.managed.ITarget;
import org.eclipse.cdt.core.build.managed.ITool;
import org.eclipse.core.runtime.IConfigurationElement;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
/**
*
@@ -31,11 +33,25 @@
private List optionReferences;
private Map optionRefMap;
- public ToolReference(ITool parent, IConfiguration owner) {
- this.parent = parent;
+ /**
+ * Created on the fly.
+ *
+ * @param owner
+ * @param parent
+ */
+ public ToolReference(Configuration owner, ITool parent) {
this.owner = owner;
+ this.parent = parent;
+
+ owner.addToolReference(this);
}
+ /**
+ * Created from extension.
+ *
+ * @param owner
+ * @param element
+ */
public ToolReference(Configuration owner, IConfigurationElement element) {
this.owner = owner;
@@ -51,6 +67,24 @@
}
}
}
+
+ public ToolReference(Configuration owner, Element element) {
+ }
+
+ public void serealize(Document doc, Element element) {
+ element.setAttribute("id", parent.getId());
+
+ if (optionReferences != null)
+ for (int i = 0; i < optionReferences.size(); ++i) {
+ OptionReference optionRef = (OptionReference)optionReferences.get(i);
+ Element optionRefElement = doc.createElement("optionRef");
+ optionRef.serealize(doc, optionRefElement);
+ }
+ }
+
+ public IConfiguration getConfiguration() {
+ return owner;
+ }
public ITool getTool() {
return parent;
@@ -144,6 +178,10 @@
return null;
}
+ public OptionReference createOptionReference(IOption option) {
+ return new OptionReference(this, option);
+ }
+
public void addOptionReference(OptionReference optionRef) {
if (optionReferences == null)
optionReferences = new ArrayList();
@@ -154,14 +192,6 @@
* @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;
}