Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDoug Schaefer2003-04-14 16:02:39 -0400
committerDoug Schaefer2003-04-14 16:02:39 -0400
commite6d765afcd31cc243b9874bc6a7169b68a37b40f (patch)
tree472bfcede0c52590c73fbc312676cfd318c7dd1a /core/org.eclipse.cdt.core/build
parent5eb714f36fc7e3850703b41fa8724841fb814753 (diff)
downloadorg.eclipse.cdt-e6d765afcd31cc243b9874bc6a7169b68a37b40f.tar.gz
org.eclipse.cdt-e6d765afcd31cc243b9874bc6a7169b68a37b40f.tar.xz
org.eclipse.cdt-e6d765afcd31cc243b9874bc6a7169b68a37b40f.zip
Work on the Build Model.
- Model is maturing - Loading/saving moved into the objects themselves - Project build info saved to/loaded from a file
Diffstat (limited to 'core/org.eclipse.cdt.core/build')
-rw-r--r--core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/build/managed/IOption.java6
-rw-r--r--core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/build/managed/IOptionCategory.java13
-rw-r--r--core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/build/managed/ITarget.java30
-rw-r--r--core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/build/managed/ITool.java6
-rw-r--r--core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/build/managed/ManagedBuildManager.java232
-rw-r--r--core/org.eclipse.cdt.core/build/org/eclipse/cdt/internal/core/build/managed/Configuration.java60
-rw-r--r--core/org.eclipse.cdt.core/build/org/eclipse/cdt/internal/core/build/managed/Option.java81
-rw-r--r--core/org.eclipse.cdt.core/build/org/eclipse/cdt/internal/core/build/managed/OptionCategory.java56
-rw-r--r--core/org.eclipse.cdt.core/build/org/eclipse/cdt/internal/core/build/managed/OptionReference.java138
-rw-r--r--core/org.eclipse.cdt.core/build/org/eclipse/cdt/internal/core/build/managed/ResourceBuildInfo.java73
-rw-r--r--core/org.eclipse.cdt.core/build/org/eclipse/cdt/internal/core/build/managed/Target.java131
-rw-r--r--core/org.eclipse.cdt.core/build/org/eclipse/cdt/internal/core/build/managed/Tool.java93
-rw-r--r--core/org.eclipse.cdt.core/build/org/eclipse/cdt/internal/core/build/managed/ToolReference.java153
13 files changed, 888 insertions, 184 deletions
diff --git a/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/build/managed/IOption.java b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/build/managed/IOption.java
index 6ce56a5add..e3fa082a65 100644
--- a/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/build/managed/IOption.java
+++ b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/build/managed/IOption.java
@@ -85,7 +85,8 @@ public interface IOption extends IBuildObject {
* @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 @@ public interface IOption extends IBuildObject {
* @param config
* @param value
*/
- public IOption setStringValue(IConfiguration config, String[] value);
+ public IOption setValue(IConfiguration config, String[] value)
+ throws BuildException;
}
diff --git a/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/build/managed/IOptionCategory.java b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/build/managed/IOptionCategory.java
index 780286266e..4ba523abd7 100644
--- a/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/build/managed/IOptionCategory.java
+++ b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/build/managed/IOptionCategory.java
@@ -23,20 +23,13 @@ public interface IOptionCategory extends IBuildObject {
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.
diff --git a/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/build/managed/ITarget.java b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/build/managed/ITarget.java
index f8d1125d25..cb2c9dd479 100644
--- a/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/build/managed/ITarget.java
+++ b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/build/managed/ITarget.java
@@ -19,6 +19,12 @@ import org.eclipse.core.resources.IResource;
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 interface ITarget extends IBuildObject {
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;
-
}
diff --git a/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/build/managed/ITool.java b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/build/managed/ITool.java
index cd336f98d9..5878ce765b 100644
--- a/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/build/managed/ITool.java
+++ b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/build/managed/ITool.java
@@ -27,12 +27,12 @@ public interface ITool extends IBuildObject {
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.
diff --git a/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/build/managed/ManagedBuildManager.java b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/build/managed/ManagedBuildManager.java
index 92689e7281..e98142f39a 100644
--- a/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/build/managed/ManagedBuildManager.java
+++ b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/build/managed/ManagedBuildManager.java
@@ -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.IConfigurationElement;
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 @@ import org.eclipse.core.runtime.QualifiedName;
*/
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 @@ public class ManagedBuildManager {
// 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 @@ public class ManagedBuildManager {
* @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 @@ public class ManagedBuildManager {
* @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 @@ public class ManagedBuildManager {
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 @@ public class ManagedBuildManager {
}
// 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 @@ public class ManagedBuildManager {
* @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 @@ public class ManagedBuildManager {
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);
}
}
diff --git a/core/org.eclipse.cdt.core/build/org/eclipse/cdt/internal/core/build/managed/Configuration.java b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/internal/core/build/managed/Configuration.java
index fb30338428..4b3cd43176 100644
--- a/core/org.eclipse.cdt.core/build/org/eclipse/cdt/internal/core/build/managed/Configuration.java
+++ b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/internal/core/build/managed/Configuration.java
@@ -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 @@ public class Configuration extends BuildObject implements IConfiguration {
private ITarget target;
private IConfiguration parent;
- private List toolReference;
+ private List toolReferences;
public Configuration(Target target) {
this.target = target;
@@ -34,6 +36,27 @@ public class Configuration extends BuildObject implements IConfiguration {
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 @@ public class Configuration extends BuildObject implements IConfiguration {
* @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 @@ public class Configuration extends BuildObject implements IConfiguration {
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);
+ }
}
diff --git a/core/org.eclipse.cdt.core/build/org/eclipse/cdt/internal/core/build/managed/Option.java b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/internal/core/build/managed/Option.java
index 44e0cb3d42..e444c50552 100644
--- a/core/org.eclipse.cdt.core/build/org/eclipse/cdt/internal/core/build/managed/Option.java
+++ b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/internal/core/build/managed/Option.java
@@ -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 @@ public class Option extends BuildObject implements IOption {
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 @@ public class Option extends BuildObject implements IOption {
* @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)
diff --git a/core/org.eclipse.cdt.core/build/org/eclipse/cdt/internal/core/build/managed/OptionCategory.java b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/internal/core/build/managed/OptionCategory.java
index fe6f5125a5..41b4af476a 100644
--- a/core/org.eclipse.cdt.core/build/org/eclipse/cdt/internal/core/build/managed/OptionCategory.java
+++ b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/internal/core/build/managed/OptionCategory.java
@@ -13,9 +13,11 @@ 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.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 @@ public class OptionCategory extends BuildObject implements IOptionCategory {
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 @@ public class OptionCategory extends BuildObject implements IOptionCategory {
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 @@ public class OptionCategory extends BuildObject implements IOptionCategory {
/* (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()]);
}
diff --git a/core/org.eclipse.cdt.core/build/org/eclipse/cdt/internal/core/build/managed/OptionReference.java b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/internal/core/build/managed/OptionReference.java
index 64eb468b4d..16e4b7b715 100644
--- a/core/org.eclipse.cdt.core/build/org/eclipse/cdt/internal/core/build/managed/OptionReference.java
+++ b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/internal/core/build/managed/OptionReference.java
@@ -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);
+ }
}
diff --git a/core/org.eclipse.cdt.core/build/org/eclipse/cdt/internal/core/build/managed/ResourceBuildInfo.java b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/internal/core/build/managed/ResourceBuildInfo.java
new file mode 100644
index 0000000000..fbfd352afc
--- /dev/null
+++ b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/internal/core/build/managed/ResourceBuildInfo.java
@@ -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);
+ }
+ }
+}
diff --git a/core/org.eclipse.cdt.core/build/org/eclipse/cdt/internal/core/build/managed/Target.java b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/internal/core/build/managed/Target.java
index 1163de980c..3eab91f50f 100644
--- a/core/org.eclipse.cdt.core/build/org/eclipse/cdt/internal/core/build/managed/Target.java
+++ b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/internal/core/build/managed/Target.java
@@ -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 @@ public class Target extends BuildObject implements ITarget {
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 @@ public class Target extends BuildObject implements ITarget {
}
/**
- * 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 @@ public class Target extends BuildObject implements ITarget {
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 @@ public class Target extends BuildObject implements ITarget {
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();
@@ -143,4 +238,18 @@ public class Target extends BuildObject implements ITarget {
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());
+ }
+
}
diff --git a/core/org.eclipse.cdt.core/build/org/eclipse/cdt/internal/core/build/managed/Tool.java b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/internal/core/build/managed/Tool.java
index 7be57edd7c..7020c24d0e 100644
--- a/core/org.eclipse.cdt.core/build/org/eclipse/cdt/internal/core/build/managed/Tool.java
+++ b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/internal/core/build/managed/Tool.java
@@ -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 @@ public class Tool extends BuildObject implements ITool, IOptionCategory {
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 @@ public class Tool extends BuildObject implements ITool, IOptionCategory {
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 @@ public class Tool extends BuildObject implements ITool, IOptionCategory {
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 @@ public class Tool extends BuildObject implements ITool, IOptionCategory {
/* (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;
+ }
+
}
diff --git a/core/org.eclipse.cdt.core/build/org/eclipse/cdt/internal/core/build/managed/ToolReference.java b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/internal/core/build/managed/ToolReference.java
index b0608b98d8..f261c89cdd 100644
--- a/core/org.eclipse.cdt.core/build/org/eclipse/cdt/internal/core/build/managed/ToolReference.java
+++ b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/internal/core/build/managed/ToolReference.java
@@ -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;
+ }
}

Back to the top