mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
A little more sanity to the new build model.
This commit is contained in:
parent
ef5944b36b
commit
9e35ee6963
9 changed files with 252 additions and 137 deletions
|
@ -0,0 +1,21 @@
|
||||||
|
/*
|
||||||
|
* 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 class BuildException extends Exception {
|
||||||
|
|
||||||
|
public BuildException(String msg) {
|
||||||
|
super(msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -10,7 +10,7 @@
|
||||||
**********************************************************************/
|
**********************************************************************/
|
||||||
package org.eclipse.cdt.core.build.managed;
|
package org.eclipse.cdt.core.build.managed;
|
||||||
|
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IResource;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -31,11 +31,10 @@ public interface IConfiguration {
|
||||||
public ITarget getTarget();
|
public ITarget getTarget();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the project owning this configuration
|
* Returns the resource that owns the target that owns the configuration.
|
||||||
* or null if this configuration is not associated with a project.
|
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public IProject getProject();
|
public IResource getOwner();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the configuration from which this configuration inherits
|
* Returns the configuration from which this configuration inherits
|
||||||
|
|
|
@ -15,6 +15,13 @@ package org.eclipse.cdt.core.build.managed;
|
||||||
*/
|
*/
|
||||||
public interface IOptionCategory {
|
public interface IOptionCategory {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the name of the option category.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public String getName();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the options that have been assigned to this category.
|
* Returns the options that have been assigned to this category.
|
||||||
*
|
*
|
||||||
|
@ -29,4 +36,7 @@ public interface IOptionCategory {
|
||||||
*/
|
*/
|
||||||
public IOptionCategory[] getChildCategories();
|
public IOptionCategory[] getChildCategories();
|
||||||
|
|
||||||
|
public IOptionCategory getOwner();
|
||||||
|
|
||||||
|
public ITool getTool();
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
**********************************************************************/
|
**********************************************************************/
|
||||||
package org.eclipse.cdt.core.build.managed;
|
package org.eclipse.cdt.core.build.managed;
|
||||||
|
|
||||||
import org.eclipse.core.resources.IProject;
|
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
|
||||||
|
@ -32,6 +32,13 @@ public interface ITarget {
|
||||||
*/
|
*/
|
||||||
public ITarget getParent();
|
public ITarget getParent();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the resource that this target is applied to.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public IResource getOwner();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the list of platform specific tools associated with this
|
* Returns the list of platform specific tools associated with this
|
||||||
* platform.
|
* platform.
|
||||||
|
@ -44,6 +51,24 @@ public interface ITarget {
|
||||||
* Returns all of the configurations defined by this target.
|
* Returns all of the configurations defined by this target.
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public IConfiguration[] getAvailableConfigurations(IProject project);
|
public IConfiguration[] getConfigurations();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new configuration for the given resource.
|
||||||
|
*
|
||||||
|
* @param resource
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public IConfiguration addConfiguration(IResource resource)
|
||||||
|
throws BuildException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new configuration for the given resource based on the parent config
|
||||||
|
* @param resource
|
||||||
|
* @param parentConfig
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public IConfiguration addConfiguration(IResource resource, IConfiguration parentConfig)
|
||||||
|
throws BuildException;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,6 @@ import org.eclipse.cdt.core.CCorePlugin;
|
||||||
import org.eclipse.cdt.internal.core.build.managed.Configuration;
|
import org.eclipse.cdt.internal.core.build.managed.Configuration;
|
||||||
import org.eclipse.cdt.internal.core.build.managed.Target;
|
import org.eclipse.cdt.internal.core.build.managed.Target;
|
||||||
import org.eclipse.cdt.internal.core.build.managed.Tool;
|
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.IProject;
|
||||||
import org.eclipse.core.resources.IResource;
|
import org.eclipse.core.resources.IResource;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
@ -32,82 +31,111 @@ import org.eclipse.core.runtime.QualifiedName;
|
||||||
*/
|
*/
|
||||||
public class ManagedBuildManager {
|
public class ManagedBuildManager {
|
||||||
|
|
||||||
private static final QualifiedName configProperty
|
private static final QualifiedName ownedTargetsProperty
|
||||||
= new QualifiedName(CCorePlugin.PLUGIN_ID, "config");
|
= new QualifiedName(CCorePlugin.PLUGIN_ID, "ownedTargets");
|
||||||
|
private static final QualifiedName definedTargetsProperty
|
||||||
|
= new QualifiedName(CCorePlugin.PLUGIN_ID, "definedTargets");
|
||||||
|
|
||||||
|
private static final ITarget[] emptyTargets = new ITarget[0];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the list of targets that are available to be used in
|
* Returns the list of targets that are defined by this project,
|
||||||
* conjunction with the given project. Generally this will include
|
* projects referenced by this project, and by the extensions.
|
||||||
* targets defined by extensions as well as targets defined by
|
|
||||||
* the project and all projects this project reference.
|
|
||||||
*
|
*
|
||||||
* @param project
|
* @param project
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static ITarget[] getTargets(IProject project) {
|
public static ITarget[] getDefinedTargets(IProject project) {
|
||||||
// Make sure the extensions are loaded
|
// Make sure the extensions are loaded
|
||||||
loadExtensions();
|
loadExtensions();
|
||||||
|
|
||||||
// Get the targets for this project and all referenced projects
|
// 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) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Create the array and copy the elements over
|
// Create the array and copy the elements over
|
||||||
ITarget[] targets = new ITarget[extensionTargets.size()];
|
int size = extensionTargets.size()
|
||||||
|
+ (definedTargets != null ? definedTargets.size() : 0);
|
||||||
|
|
||||||
|
ITarget[] targets = new ITarget[size];
|
||||||
|
|
||||||
|
int n = 0;
|
||||||
for (int i = 0; i < extensionTargets.size(); ++i)
|
for (int i = 0; i < extensionTargets.size(); ++i)
|
||||||
targets[i] = (ITarget)extensionTargets.get(i);
|
targets[n++] = (ITarget)extensionTargets.get(i);
|
||||||
|
|
||||||
|
if (definedTargets != null)
|
||||||
|
for (int i = 0; i < definedTargets.size(); ++i)
|
||||||
|
targets[n++] = (ITarget)definedTargets.get(i);
|
||||||
|
|
||||||
return targets;
|
return targets;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the list of configurations associated with the given project.
|
* Returns the targets owned by this project. If none are owned,
|
||||||
|
* an empty array is returned.
|
||||||
*
|
*
|
||||||
* @param project
|
* @param project
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static IConfiguration[] getConfigurations(IProject project) {
|
public static ITarget[] getTargets(IResource resource) {
|
||||||
return getResourceConfigs(project);
|
List targets = getOwnedTargetsProperty(resource);
|
||||||
|
|
||||||
|
if (targets != null) {
|
||||||
|
return (ITarget[])targets.toArray(new ITarget[targets.size()]);
|
||||||
|
} else {
|
||||||
|
return emptyTargets;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the list of configurations associated with a given file.
|
* Adds a new target to the resource based on the parentTarget.
|
||||||
*
|
*
|
||||||
* @param file
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public static IConfiguration[] getConfigurations(IFile file) {
|
|
||||||
// TODO not ready for prime time...
|
|
||||||
return getResourceConfigs(file);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Adds a configuration containing the tools defined by the target to
|
|
||||||
* the given project.
|
|
||||||
*
|
|
||||||
* @param target
|
|
||||||
* @param project
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public static IConfiguration addConfiguration(IProject project, ITarget target) {
|
|
||||||
Configuration config = new Configuration(project, target);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Adds a configuration inheriting from the given configuration.
|
|
||||||
*
|
|
||||||
* @param origConfig
|
|
||||||
* @param resource
|
* @param resource
|
||||||
|
* @param parentTarget
|
||||||
* @return
|
* @return
|
||||||
|
* @throws BuildException
|
||||||
*/
|
*/
|
||||||
public static IConfiguration addConfiguration(IProject project, IConfiguration parentConfig) {
|
public static ITarget addTarget(IResource resource, ITarget parentTarget)
|
||||||
if (parentConfig.getProject() != null)
|
throws BuildException
|
||||||
// Can only inherit from target configs
|
{
|
||||||
return null;
|
IResource owner = parentTarget.getOwner();
|
||||||
|
|
||||||
Configuration config = new Configuration(project, parentConfig);
|
if (owner != null && owner.equals(resource))
|
||||||
addResourceConfig(project, config);
|
// Already added
|
||||||
return config;
|
return parentTarget;
|
||||||
|
|
||||||
|
if (resource instanceof IProject) {
|
||||||
|
// Owner must be null
|
||||||
|
if (owner != null)
|
||||||
|
throw new BuildException("addTarget: owner not null");
|
||||||
|
} else {
|
||||||
|
// Owner must be owned by the project containing this resource
|
||||||
|
if (owner == null)
|
||||||
|
throw new BuildException("addTarget: null owner");
|
||||||
|
if (!owner.equals(resource.getProject()))
|
||||||
|
throw new BuildException("addTarget: owner not project");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Private stuff
|
// Private stuff
|
||||||
|
@ -129,59 +157,29 @@ 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(element.getAttribute("name"));
|
Target target = new Target(null);
|
||||||
|
target.setName(element.getAttribute("name"));
|
||||||
extensionTargets.add(target);
|
extensionTargets.add(target);
|
||||||
|
|
||||||
List configs = null;
|
|
||||||
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);
|
Tool tool = new Tool(targetElement.getAttribute("name"), target);
|
||||||
} else if (targetElement.getName().equals("configuration")) {
|
} else if (targetElement.getName().equals("configuration")) {
|
||||||
if (configs == null)
|
target.addConfiguration(new Configuration(target));
|
||||||
configs = new ArrayList();
|
|
||||||
configs.add(new Configuration(target));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (configs != null) {
|
|
||||||
IConfiguration[] configArray = new IConfiguration[configs.size()];
|
|
||||||
configArray = (IConfiguration[])configs.toArray(configArray);
|
|
||||||
target.setConfigurations(configArray);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final IConfiguration[] emptyConfigs = new IConfiguration[0];
|
private static List getOwnedTargetsProperty(IResource resource) {
|
||||||
|
|
||||||
private static IConfiguration[] getResourceConfigs(IResource resource) {
|
|
||||||
IConfiguration[] configs = null;
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
configs = (IConfiguration[])resource.getSessionProperty(configProperty);
|
return (List)resource.getSessionProperty(ownedTargetsProperty);
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (configs != null) ? configs : emptyConfigs;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void addResourceConfig(IResource resource, IConfiguration config) {
|
|
||||||
IConfiguration[] configs = getResourceConfigs(resource);
|
|
||||||
|
|
||||||
IConfiguration[] newConfigs = new IConfiguration[configs.length + 1];
|
|
||||||
for (int i = 0; i < configs.length; ++i)
|
|
||||||
newConfigs[i] = configs[i];
|
|
||||||
newConfigs[configs.length] = config;
|
|
||||||
|
|
||||||
try {
|
|
||||||
resource.setSessionProperty(configProperty, newConfigs);
|
|
||||||
} catch (CoreException e) {
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO save the config info to the project build file
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@ import java.util.List;
|
||||||
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.core.resources.IProject;
|
import org.eclipse.core.resources.IResource;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -24,7 +24,6 @@ public class Configuration implements IConfiguration {
|
||||||
|
|
||||||
private String name;
|
private String name;
|
||||||
private ITarget target;
|
private ITarget target;
|
||||||
private IProject project;
|
|
||||||
private IConfiguration parent;
|
private IConfiguration parent;
|
||||||
private List toolReference;
|
private List toolReference;
|
||||||
|
|
||||||
|
@ -32,13 +31,7 @@ public class Configuration implements IConfiguration {
|
||||||
this.target = target;
|
this.target = target;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Configuration(IProject project, ITarget target) {
|
public Configuration(IConfiguration parent) {
|
||||||
this.project = project;
|
|
||||||
this.target = target;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Configuration(IProject project, IConfiguration parent) {
|
|
||||||
this.project = project;
|
|
||||||
this.parent = parent;
|
this.parent = parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -79,10 +72,10 @@ public class Configuration implements IConfiguration {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.build.managed.IConfiguration#getProject()
|
* @see org.eclipse.cdt.core.build.managed.IConfiguration#getOwner()
|
||||||
*/
|
*/
|
||||||
public IProject getProject() {
|
public IResource getOwner() {
|
||||||
return (project == null && parent != null) ? parent.getProject() : project;
|
return getTarget().getOwner();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,10 +10,16 @@
|
||||||
**********************************************************************/
|
**********************************************************************/
|
||||||
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.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;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -21,21 +27,34 @@ import org.eclipse.core.resources.IProject;
|
||||||
public class Target implements ITarget {
|
public class Target implements ITarget {
|
||||||
|
|
||||||
private String name;
|
private String name;
|
||||||
private Target parent;
|
private ITarget parent;
|
||||||
private ITool[] tools;
|
private IResource owner;
|
||||||
private IConfiguration[] configurations;
|
private List tools;
|
||||||
|
private List configurations;
|
||||||
|
|
||||||
public Target(String name) {
|
public Target(IResource owner) {
|
||||||
this.name = name;
|
this.owner = owner;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Target(String name, Target parent) {
|
/**
|
||||||
this(name);
|
* Resource is allowed to be null to represent a ISV target def.
|
||||||
|
*
|
||||||
|
* @param parent
|
||||||
|
*/
|
||||||
|
public Target(IResource owner, ITarget parent) {
|
||||||
|
this.owner = owner;
|
||||||
this.parent = parent;
|
this.parent = parent;
|
||||||
|
|
||||||
|
// Inherit the configs from the parent
|
||||||
|
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() {
|
public String getName() {
|
||||||
return name;
|
return (name == null && parent != null) ? parent.getName() : name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ITarget getParent() {
|
public ITarget getParent() {
|
||||||
|
@ -46,21 +65,25 @@ public class Target implements ITarget {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public IResource getOwner() {
|
||||||
|
return owner;
|
||||||
|
}
|
||||||
|
|
||||||
private int getNumTools() {
|
private int getNumTools() {
|
||||||
int n = (tools == null) ? 0 : tools.length;
|
int n = (tools == null) ? 0 : tools.size();
|
||||||
if (parent != null)
|
if (parent != null)
|
||||||
n += parent.getNumTools();
|
n += ((Target)parent).getNumTools();
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
private int addToolsToArray(ITool[] toolArray, int start) {
|
private int addToolsToArray(ITool[] toolArray, int start) {
|
||||||
int n = start;
|
int n = start;
|
||||||
if (parent != null)
|
if (parent != null)
|
||||||
n = parent.addToolsToArray(toolArray, start);
|
n = ((Target)parent).addToolsToArray(toolArray, start);
|
||||||
|
|
||||||
if (tools != null) {
|
if (tools != null) {
|
||||||
for (int i = 0; i < tools.length; ++i)
|
for (int i = 0; i < tools.size(); ++i)
|
||||||
toolArray[n++] = (ITool)tools[i];
|
toolArray[n++] = (ITool)tools.get(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
return n;
|
return n;
|
||||||
|
@ -72,17 +95,54 @@ public class Target implements ITarget {
|
||||||
return toolArray;
|
return toolArray;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTools(ITool[] tools) {
|
public void addTool(ITool tool){
|
||||||
this.tools = tools;
|
if (tools == null)
|
||||||
|
tools = new ArrayList();
|
||||||
|
tools.add(tool);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setConfigurations(IConfiguration [] configurations) {
|
public IConfiguration[] getConfigurations() {
|
||||||
this.configurations = configurations;
|
return (IConfiguration[])configurations.toArray(new IConfiguration[configurations.size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IConfiguration[] getAvailableConfigurations(IProject project) {
|
public void addConfiguration(IConfiguration configuration) {
|
||||||
// TODO Auto-generated method stub
|
if (configurations == null)
|
||||||
|
configurations = new ArrayList();
|
||||||
|
configurations.add(configuration);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.build.managed.ITarget#addConfiguration(org.eclipse.core.resources.IResource)
|
||||||
|
*/
|
||||||
|
public IConfiguration addConfiguration(IResource resource)
|
||||||
|
throws BuildException
|
||||||
|
{
|
||||||
|
Target target = (Target)ManagedBuildManager.addTarget(resource, this);
|
||||||
|
IConfiguration config = new Configuration(target);
|
||||||
|
target.addConfiguration(config);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public IConfiguration addConfiguration(IResource resource, IConfiguration parentConfig)
|
||||||
|
throws BuildException
|
||||||
|
{
|
||||||
|
IResource parentOwner = parentConfig.getOwner();
|
||||||
|
|
||||||
|
if (resource instanceof IProject) {
|
||||||
|
// parent must be owned by the same project
|
||||||
|
if (!resource.equals(parentOwner))
|
||||||
|
throw new BuildException("addConfiguration: parent must be in same project");
|
||||||
|
} else {
|
||||||
|
// parent must be owned by the project
|
||||||
|
if (!resource.getProject().equals(parentOwner))
|
||||||
|
throw new BuildException("addConfiguration: parent must be in owning project");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Validation passed
|
||||||
|
Target target = (Target)ManagedBuildManager.addTarget(resource, this);
|
||||||
|
IConfiguration config = new Configuration(parentConfig);
|
||||||
|
target.addConfiguration(config);
|
||||||
|
return config;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,6 @@ import junit.framework.TestCase;
|
||||||
import junit.framework.TestSuite;
|
import junit.framework.TestSuite;
|
||||||
|
|
||||||
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;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -44,13 +43,19 @@ public class AllBuildTests extends TestCase {
|
||||||
* defined in this plugin
|
* defined in this plugin
|
||||||
*/
|
*/
|
||||||
public void testExtensions() {
|
public void testExtensions() {
|
||||||
// Note secret null parameter which means just extensions
|
boolean testRootFound = false;
|
||||||
ITarget[] targets = ManagedBuildManager.getTargets(null);
|
|
||||||
|
|
||||||
ITarget target = targets[0];
|
// Note secret null parameter which means just extensions
|
||||||
assertEquals(target.getName(), "Linux");
|
ITarget[] targets = ManagedBuildManager.getDefinedTargets(null);
|
||||||
ITool[] tools = target.getTools();
|
|
||||||
ITool tool = tools[0];
|
for (int i = 0; i < targets.length; ++i) {
|
||||||
assertEquals(tool.getName(), "Compiler");
|
ITarget target = targets[i];
|
||||||
|
|
||||||
|
if (target.getName().equals("Test Root")) {
|
||||||
|
testRootFound = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
assertTrue(testRootFound);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -91,6 +91,10 @@
|
||||||
id="org.eclipse.cdt.ui.tests.tool.linux.ar">
|
id="org.eclipse.cdt.ui.tests.tool.linux.ar">
|
||||||
</tool>
|
</tool>
|
||||||
</target>
|
</target>
|
||||||
|
<target
|
||||||
|
name="Test Root"
|
||||||
|
id="test.root">
|
||||||
|
</target>
|
||||||
</extension>
|
</extension>
|
||||||
|
|
||||||
</plugin>
|
</plugin>
|
||||||
|
|
Loading…
Add table
Reference in a new issue