mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Fleshing out the build model.
This commit is contained in:
parent
0028dec189
commit
663cef492f
16 changed files with 538 additions and 125 deletions
|
@ -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);
|
||||||
|
|
||||||
|
}
|
|
@ -15,16 +15,10 @@ import org.eclipse.core.resources.IResource;
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public interface IConfiguration {
|
public interface IConfiguration extends IBuildObject {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the name of this configuration
|
* Returns the target for this configuration.
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public String getName();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the platform for this configuration.
|
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
@ -36,14 +30,6 @@ public interface IConfiguration {
|
||||||
*/
|
*/
|
||||||
public IResource getOwner();
|
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.
|
* Returns the tools that are used in this configuration.
|
||||||
*
|
*
|
||||||
|
|
|
@ -13,7 +13,7 @@ package org.eclipse.cdt.core.build.managed;
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public interface IOption {
|
public interface IOption extends IBuildObject {
|
||||||
|
|
||||||
// Type for the value of the option
|
// Type for the value of the option
|
||||||
public static final int STRING = 0;
|
public static final int STRING = 0;
|
||||||
|
@ -33,6 +33,13 @@ public interface IOption {
|
||||||
*/
|
*/
|
||||||
public IOptionCategory getCategory();
|
public IOptionCategory getCategory();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the option category for this option.
|
||||||
|
*
|
||||||
|
* @param category
|
||||||
|
*/
|
||||||
|
public void setCategory(IOptionCategory category);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the name of this option.
|
* Returns the name of this option.
|
||||||
*
|
*
|
||||||
|
|
|
@ -13,21 +13,7 @@ package org.eclipse.cdt.core.build.managed;
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public interface IOptionCategory {
|
public interface IOptionCategory extends IBuildObject {
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the name of the option category.
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public String getName();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the options that have been assigned to this category.
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public IOption[] getOptions();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the list of children of this node in the option category tree
|
* Returns the list of children of this node in the option category tree
|
||||||
|
@ -36,7 +22,33 @@ public interface IOptionCategory {
|
||||||
*/
|
*/
|
||||||
public IOptionCategory[] getChildCategories();
|
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.
|
||||||
|
*
|
||||||
|
* @param tool
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
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();
|
public IOptionCategory getOwner();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the tool that ultimately owns this category.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
public ITool getTool();
|
public ITool getTool();
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,21 +16,7 @@ import org.eclipse.core.resources.IResource;
|
||||||
* This class represents targets for the managed build process. A target
|
* This class represents targets for the managed build process. A target
|
||||||
* is some type of resource built using a given collection of tools.
|
* 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.
|
* Gets the resource that this target is applied to.
|
||||||
|
@ -47,6 +33,13 @@ public interface ITarget {
|
||||||
*/
|
*/
|
||||||
public ITool[] getTools();
|
public ITool[] getTools();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new tool.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public ITool createTool();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns all of the configurations defined by this target.
|
* Returns all of the configurations defined by this target.
|
||||||
* @return
|
* @return
|
||||||
|
@ -54,21 +47,20 @@ public interface ITarget {
|
||||||
public IConfiguration[] getConfigurations();
|
public IConfiguration[] getConfigurations();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new configuration for the given resource.
|
* Creates a new configuration for this target.
|
||||||
*
|
*
|
||||||
* @param resource
|
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public IConfiguration addConfiguration(IResource resource)
|
public IConfiguration createConfiguration()
|
||||||
throws BuildException;
|
throws BuildException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new configuration for the given resource based on the parent config
|
* Creates a new configuration based on the parent config for this target.
|
||||||
* @param resource
|
*
|
||||||
* @param parentConfig
|
* @param parentConfig
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public IConfiguration addConfiguration(IResource resource, IConfiguration parentConfig)
|
public IConfiguration createConfiguration(IConfiguration parentConfig)
|
||||||
throws BuildException;
|
throws BuildException;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,14 +13,7 @@ package org.eclipse.cdt.core.build.managed;
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
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 the target that defines this tool, if applicable
|
||||||
|
@ -28,17 +21,19 @@ public interface ITool {
|
||||||
*/
|
*/
|
||||||
public ITarget getTarget();
|
public ITarget getTarget();
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the tool that this tool inherits properties from.
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public ITool getParent();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the options that may be customized for this tool.
|
* Returns the options that may be customized for this tool.
|
||||||
*/
|
*/
|
||||||
public IOption[] getOptions();
|
public IOption[] getOptions();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new option for this tool. Generally, this should only be
|
||||||
|
* done by the extension and project data loaders.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public IOption createOption();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Options are organized into categories for UI purposes.
|
* Options are organized into categories for UI purposes.
|
||||||
* These categories are organized into a tree. This is the root
|
* These categories are organized into a tree. This is the root
|
||||||
|
|
|
@ -11,7 +11,9 @@
|
||||||
package org.eclipse.cdt.core.build.managed;
|
package org.eclipse.cdt.core.build.managed;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
import org.eclipse.cdt.internal.core.build.managed.Configuration;
|
import org.eclipse.cdt.internal.core.build.managed.Configuration;
|
||||||
|
@ -138,6 +140,15 @@ public class ManagedBuildManager {
|
||||||
return newTarget;
|
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 stuff
|
||||||
|
|
||||||
private static List extensionTargets;
|
private static List extensionTargets;
|
||||||
|
@ -147,6 +158,7 @@ public class ManagedBuildManager {
|
||||||
return;
|
return;
|
||||||
|
|
||||||
extensionTargets = new ArrayList();
|
extensionTargets = new ArrayList();
|
||||||
|
Map targetMap = new HashMap();
|
||||||
|
|
||||||
IExtensionPoint extensionPoint
|
IExtensionPoint extensionPoint
|
||||||
= CCorePlugin.getDefault().getDescriptor().getExtensionPoint("ManagedBuildInfo");
|
= CCorePlugin.getDefault().getDescriptor().getExtensionPoint("ManagedBuildInfo");
|
||||||
|
@ -157,17 +169,49 @@ public class ManagedBuildManager {
|
||||||
for (int j = 0; j < elements.length; ++j) {
|
for (int j = 0; j < elements.length; ++j) {
|
||||||
IConfigurationElement element = elements[j];
|
IConfigurationElement element = elements[j];
|
||||||
if (element.getName().equals("target")) {
|
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"));
|
target.setName(element.getAttribute("name"));
|
||||||
extensionTargets.add(target);
|
extensionTargets.add(target);
|
||||||
|
targetMap.put(element.getAttribute("id"), target);
|
||||||
|
|
||||||
IConfigurationElement[] targetElements = element.getChildren();
|
IConfigurationElement[] targetElements = element.getChildren();
|
||||||
for (int k = 0; k < targetElements.length; ++k) {
|
for (int k = 0; k < targetElements.length; ++k) {
|
||||||
IConfigurationElement targetElement = targetElements[k];
|
IConfigurationElement targetElement = targetElements[k];
|
||||||
if (targetElement.getName().equals("tool")) {
|
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")) {
|
} 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.
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -20,9 +20,8 @@ import org.eclipse.core.resources.IResource;
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class Configuration implements IConfiguration {
|
public class Configuration extends BuildObject implements IConfiguration {
|
||||||
|
|
||||||
private String name;
|
|
||||||
private ITarget target;
|
private ITarget target;
|
||||||
private IConfiguration parent;
|
private IConfiguration parent;
|
||||||
private List toolReference;
|
private List toolReference;
|
||||||
|
@ -42,13 +41,6 @@ public class Configuration implements IConfiguration {
|
||||||
return (name == null && parent != null) ? parent.getName() : name;
|
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)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.build.managed.IConfiguration#getTools()
|
* @see org.eclipse.cdt.core.build.managed.IConfiguration#getTools()
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -10,9 +10,90 @@
|
||||||
**********************************************************************/
|
**********************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.build.managed;
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,9 +10,79 @@
|
||||||
**********************************************************************/
|
**********************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.build.managed;
|
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()]);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,21 +17,21 @@ import org.eclipse.cdt.core.build.managed.BuildException;
|
||||||
import org.eclipse.cdt.core.build.managed.IConfiguration;
|
import org.eclipse.cdt.core.build.managed.IConfiguration;
|
||||||
import org.eclipse.cdt.core.build.managed.ITarget;
|
import org.eclipse.cdt.core.build.managed.ITarget;
|
||||||
import org.eclipse.cdt.core.build.managed.ITool;
|
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.IProject;
|
||||||
import org.eclipse.core.resources.IResource;
|
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 ITarget parent;
|
||||||
private IResource owner;
|
private IResource owner;
|
||||||
private List tools;
|
private List tools;
|
||||||
private List configurations;
|
private List configurations;
|
||||||
|
|
||||||
|
private static final IConfiguration[] emptyConfigs = new IConfiguration[0];
|
||||||
|
|
||||||
public Target(IResource owner) {
|
public Target(IResource owner) {
|
||||||
this.owner = owner;
|
this.owner = owner;
|
||||||
}
|
}
|
||||||
|
@ -61,10 +61,6 @@ public class Target implements ITarget {
|
||||||
return parent;
|
return parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setName(String name) {
|
|
||||||
this.name = name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public IResource getOwner() {
|
public IResource getOwner() {
|
||||||
return owner;
|
return owner;
|
||||||
}
|
}
|
||||||
|
@ -95,53 +91,55 @@ public class Target implements ITarget {
|
||||||
return toolArray;
|
return toolArray;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addTool(ITool tool){
|
public ITool createTool() {
|
||||||
|
ITool tool = new Tool(this);
|
||||||
|
|
||||||
if (tools == null)
|
if (tools == null)
|
||||||
tools = new ArrayList();
|
tools = new ArrayList();
|
||||||
tools.add(tool);
|
tools.add(tool);
|
||||||
|
|
||||||
|
return tool;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IConfiguration[] getConfigurations() {
|
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)
|
if (configurations == null)
|
||||||
configurations = new ArrayList();
|
configurations = new ArrayList();
|
||||||
configurations.add(configuration);
|
configurations.add(configuration);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
public IConfiguration createConfiguration()
|
||||||
* @see org.eclipse.cdt.core.build.managed.ITarget#addConfiguration(org.eclipse.core.resources.IResource)
|
|
||||||
*/
|
|
||||||
public IConfiguration addConfiguration(IResource resource)
|
|
||||||
throws BuildException
|
throws BuildException
|
||||||
{
|
{
|
||||||
Target target = (Target)ManagedBuildManager.addTarget(resource, this);
|
IConfiguration config = new Configuration(this);
|
||||||
IConfiguration config = new Configuration(target);
|
addLocalConfiguration(config);
|
||||||
target.addConfiguration(config);
|
return config;
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public IConfiguration addConfiguration(IResource resource, IConfiguration parentConfig)
|
public IConfiguration createConfiguration(IConfiguration parentConfig)
|
||||||
throws BuildException
|
throws BuildException
|
||||||
{
|
{
|
||||||
IResource parentOwner = parentConfig.getOwner();
|
IResource parentOwner = parentConfig.getOwner();
|
||||||
|
|
||||||
if (resource instanceof IProject) {
|
if (owner instanceof IProject) {
|
||||||
// parent must be owned by the same project
|
// 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");
|
throw new BuildException("addConfiguration: parent must be in same project");
|
||||||
} else {
|
} else {
|
||||||
// parent must be owned by the project
|
// 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");
|
throw new BuildException("addConfiguration: parent must be in owning project");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Validation passed
|
// Validation passed
|
||||||
Target target = (Target)ManagedBuildManager.addTarget(resource, this);
|
|
||||||
IConfiguration config = new Configuration(parentConfig);
|
IConfiguration config = new Configuration(parentConfig);
|
||||||
target.addConfiguration(config);
|
addLocalConfiguration(config);
|
||||||
return config;
|
return config;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,50 +10,112 @@
|
||||||
**********************************************************************/
|
**********************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.build.managed;
|
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.IOption;
|
||||||
import org.eclipse.cdt.core.build.managed.IOptionCategory;
|
import org.eclipse.cdt.core.build.managed.IOptionCategory;
|
||||||
import org.eclipse.cdt.core.build.managed.ITarget;
|
import org.eclipse.cdt.core.build.managed.ITarget;
|
||||||
import org.eclipse.cdt.core.build.managed.ITool;
|
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 ITarget target;
|
||||||
|
private List options;
|
||||||
|
private IOptionCategory topOptionCategory;
|
||||||
|
private List childOptionCategories;
|
||||||
|
|
||||||
public Tool(String name) {
|
private static IOption[] emptyOptions = new IOption[0];
|
||||||
this.name = name;
|
private static IOptionCategory[] emptyCategories = new IOptionCategory[0];
|
||||||
}
|
|
||||||
|
|
||||||
public Tool(String name, Target target) {
|
public Tool(Target target) {
|
||||||
this(name);
|
|
||||||
this.target = target;
|
this.target = target;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName() {
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ITarget getTarget() {
|
public ITarget getTarget() {
|
||||||
return target;
|
return target;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IOption[] getOptions() {
|
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() {
|
public IOptionCategory getTopOptionCategory() {
|
||||||
|
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.IOptionCategory#createChildCategory()
|
||||||
|
*/
|
||||||
|
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;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.build.managed.ITool#getParent()
|
* @see org.eclipse.cdt.core.build.managed.IOptionCategory#getTool()
|
||||||
*/
|
*/
|
||||||
public ITool getParent() {
|
public ITool getTool() {
|
||||||
// TODO Auto-generated method stub
|
return this;
|
||||||
return null;
|
}
|
||||||
|
|
||||||
|
/* (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()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -272,6 +272,13 @@
|
||||||
</documentation>
|
</documentation>
|
||||||
</annotation>
|
</annotation>
|
||||||
</attribute>
|
</attribute>
|
||||||
|
<attribute name="owner" type="string">
|
||||||
|
<annotation>
|
||||||
|
<documentation>
|
||||||
|
|
||||||
|
</documentation>
|
||||||
|
</annotation>
|
||||||
|
</attribute>
|
||||||
</complexType>
|
</complexType>
|
||||||
</element>
|
</element>
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,11 @@ import junit.framework.Test;
|
||||||
import junit.framework.TestCase;
|
import junit.framework.TestCase;
|
||||||
import junit.framework.TestSuite;
|
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.ITarget;
|
||||||
|
import org.eclipse.cdt.core.build.managed.ITool;
|
||||||
import org.eclipse.cdt.core.build.managed.ManagedBuildManager;
|
import org.eclipse.cdt.core.build.managed.ManagedBuildManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -43,7 +47,8 @@ public class AllBuildTests extends TestCase {
|
||||||
* defined in this plugin
|
* defined in this plugin
|
||||||
*/
|
*/
|
||||||
public void testExtensions() {
|
public void testExtensions() {
|
||||||
boolean testRootFound = false;
|
ITarget testRoot = null;
|
||||||
|
ITarget testSub = null;
|
||||||
|
|
||||||
// Note secret null parameter which means just extensions
|
// Note secret null parameter which means just extensions
|
||||||
ITarget[] targets = ManagedBuildManager.getDefinedTargets(null);
|
ITarget[] targets = ManagedBuildManager.getDefinedTargets(null);
|
||||||
|
@ -52,10 +57,61 @@ public class AllBuildTests extends TestCase {
|
||||||
ITarget target = targets[i];
|
ITarget target = targets[i];
|
||||||
|
|
||||||
if (target.getName().equals("Test Root")) {
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,6 +36,7 @@
|
||||||
name="Compiler"
|
name="Compiler"
|
||||||
id="linux.compiler">
|
id="linux.compiler">
|
||||||
<optionCategory
|
<optionCategory
|
||||||
|
owner="linux.compiler"
|
||||||
name="Optimization Options"
|
name="Optimization Options"
|
||||||
id="linux.compiler.optimization">
|
id="linux.compiler.optimization">
|
||||||
</optionCategory>
|
</optionCategory>
|
||||||
|
@ -94,6 +95,41 @@
|
||||||
<target
|
<target
|
||||||
name="Test Root"
|
name="Test Root"
|
||||||
id="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>
|
</target>
|
||||||
</extension>
|
</extension>
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue