mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
- Fixed the test failures that arose because the targets don't
automatically copy over their configs (however now they do for targets defined at the extension point). - Config elements and attributes are now saved in the cdtbuild file, but not any children.
This commit is contained in:
parent
eaf3aacd4e
commit
ae94fe7955
6 changed files with 68 additions and 14 deletions
|
@ -45,6 +45,14 @@ public interface ITarget extends IBuildObject {
|
||||||
*/
|
*/
|
||||||
public IConfiguration[] getConfigurations();
|
public IConfiguration[] getConfigurations();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the configuration with the given id, or null if not found.
|
||||||
|
*
|
||||||
|
* @param id
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public IConfiguration getConfiguration(String id);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new configuration for the target. It is populated with
|
* Creates a new configuration for the target. It is populated with
|
||||||
* the tools defined for that target and options set at their defaults.
|
* the tools defined for that target and options set at their defaults.
|
||||||
|
|
|
@ -73,9 +73,29 @@ public class Configuration extends BuildObject implements IConfiguration {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Configuration(Target target, Element element) {
|
||||||
|
this.target = target;
|
||||||
|
|
||||||
|
// id
|
||||||
|
setId(element.getAttribute("id"));
|
||||||
|
|
||||||
|
// hook me up
|
||||||
|
target.addConfiguration(this);
|
||||||
|
|
||||||
|
// name
|
||||||
|
if (element.hasAttribute("name"))
|
||||||
|
setName(element.getAttribute("name"));
|
||||||
|
|
||||||
|
if (element.hasAttribute("parent"))
|
||||||
|
parent = target.getParent().getConfiguration(element.getAttribute("parent"));
|
||||||
|
}
|
||||||
|
|
||||||
public void serealize(Document doc, Element element) {
|
public void serealize(Document doc, Element element) {
|
||||||
element.setAttribute("id", id);
|
element.setAttribute("id", id);
|
||||||
|
|
||||||
|
if (name != null)
|
||||||
element.setAttribute("name", name);
|
element.setAttribute("name", name);
|
||||||
|
|
||||||
if (parent != null)
|
if (parent != null)
|
||||||
element.setAttribute("parent", parent.getId());
|
element.setAttribute("parent", parent.getId());
|
||||||
|
|
||||||
|
|
|
@ -48,7 +48,7 @@ public class OptionReference implements IOption {
|
||||||
*/
|
*/
|
||||||
public OptionReference(ToolReference owner, IConfigurationElement element) {
|
public OptionReference(ToolReference owner, IConfigurationElement element) {
|
||||||
this.owner = owner;
|
this.owner = owner;
|
||||||
option = owner.getOption(element.getAttribute("id"));
|
option = owner.getTool().getOption(element.getAttribute("id"));
|
||||||
|
|
||||||
owner.addOptionReference(this);
|
owner.addOptionReference(this);
|
||||||
}
|
}
|
||||||
|
@ -61,7 +61,7 @@ public class OptionReference implements IOption {
|
||||||
*/
|
*/
|
||||||
public OptionReference(ToolReference owner, Element element) {
|
public OptionReference(ToolReference owner, Element element) {
|
||||||
this.owner = owner;
|
this.owner = owner;
|
||||||
option = owner.getOption(element.getAttribute("id"));
|
option = owner.getTool().getOption(element.getAttribute("id"));
|
||||||
|
|
||||||
owner.addOptionReference(this);
|
owner.addOptionReference(this);
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,7 @@ import org.eclipse.core.resources.IResource;
|
||||||
import org.eclipse.core.runtime.IConfigurationElement;
|
import org.eclipse.core.runtime.IConfigurationElement;
|
||||||
import org.w3c.dom.Document;
|
import org.w3c.dom.Document;
|
||||||
import org.w3c.dom.Element;
|
import org.w3c.dom.Element;
|
||||||
|
import org.w3c.dom.Node;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -34,6 +35,7 @@ public class Target extends BuildObject implements ITarget {
|
||||||
private List tools;
|
private List tools;
|
||||||
private Map toolMap;
|
private Map toolMap;
|
||||||
private List configurations;
|
private List configurations;
|
||||||
|
private Map configMap;
|
||||||
private boolean isAbstract = false;
|
private boolean isAbstract = false;
|
||||||
|
|
||||||
private static final IConfiguration[] emptyConfigs = new IConfiguration[0];
|
private static final IConfiguration[] emptyConfigs = new IConfiguration[0];
|
||||||
|
@ -78,8 +80,13 @@ public class Target extends BuildObject implements ITarget {
|
||||||
|
|
||||||
// parent
|
// parent
|
||||||
String parentId = element.getAttribute("parent");
|
String parentId = element.getAttribute("parent");
|
||||||
if (parentId != null)
|
if (parentId != null) {
|
||||||
parent = ManagedBuildManager.getTarget(null, parentId);
|
parent = ManagedBuildManager.getTarget(null, parentId);
|
||||||
|
// copy over the parents configs
|
||||||
|
IConfiguration[] parentConfigs = parent.getConfigurations();
|
||||||
|
for (int i = 0; i < parentConfigs.length; ++i)
|
||||||
|
addConfiguration(parentConfigs[i]);
|
||||||
|
}
|
||||||
|
|
||||||
// isAbstract
|
// isAbstract
|
||||||
if ("true".equals(element.getAttribute("isAbstract")))
|
if ("true".equals(element.getAttribute("isAbstract")))
|
||||||
|
@ -124,6 +131,16 @@ public class Target extends BuildObject implements ITarget {
|
||||||
if ("true".equals(element.getAttribute("isAbstract")))
|
if ("true".equals(element.getAttribute("isAbstract")))
|
||||||
isAbstract = true;
|
isAbstract = true;
|
||||||
|
|
||||||
|
Node child = element.getFirstChild();
|
||||||
|
while (child != null) {
|
||||||
|
if (child.getNodeName().equals("configuration")) {
|
||||||
|
new Configuration(this, (Element)child);
|
||||||
|
}
|
||||||
|
|
||||||
|
child = child.getNextSibling();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void serialize(Document doc, Element element) {
|
public void serialize(Document doc, Element element) {
|
||||||
|
@ -137,6 +154,7 @@ public class Target extends BuildObject implements ITarget {
|
||||||
for (int i = 0; i < configurations.size(); ++i) {
|
for (int i = 0; i < configurations.size(); ++i) {
|
||||||
Configuration config = (Configuration)configurations.get(i);
|
Configuration config = (Configuration)configurations.get(i);
|
||||||
Element configElement = doc.createElement("configuration");
|
Element configElement = doc.createElement("configuration");
|
||||||
|
element.appendChild(configElement);
|
||||||
config.serealize(doc, configElement);
|
config.serealize(doc, configElement);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -200,16 +218,17 @@ public class Target extends BuildObject implements ITarget {
|
||||||
return emptyConfigs;
|
return emptyConfigs;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addConfiguration(IConfiguration configuration) {
|
public IConfiguration getConfiguration(String id) {
|
||||||
if (configurations == null)
|
return (IConfiguration)configMap.get(id);
|
||||||
configurations = new ArrayList();
|
|
||||||
configurations.add(configuration);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addLocalConfiguration(IConfiguration configuration) {
|
public void addConfiguration(IConfiguration configuration) {
|
||||||
if (configurations == null)
|
if (configurations == null) {
|
||||||
configurations = new ArrayList();
|
configurations = new ArrayList();
|
||||||
|
configMap = new HashMap();
|
||||||
|
}
|
||||||
configurations.add(configuration);
|
configurations.add(configuration);
|
||||||
|
configMap.put(configuration.getId(), configuration);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
|
|
@ -96,9 +96,12 @@ public class Tool extends BuildObject implements ITool, IOptionCategory {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addOption(Option option) {
|
public void addOption(Option option) {
|
||||||
if (options == null)
|
if (options == null) {
|
||||||
options = new ArrayList();
|
options = new ArrayList();
|
||||||
|
optionMap = new HashMap();
|
||||||
|
}
|
||||||
options.add(option);
|
options.add(option);
|
||||||
|
optionMap.put(option.getId(), option);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IOptionCategory getTopOptionCategory() {
|
public IOptionCategory getTopOptionCategory() {
|
||||||
|
@ -177,8 +180,7 @@ public class Tool extends BuildObject implements ITool, IOptionCategory {
|
||||||
* @see org.eclipse.cdt.core.build.managed.ITool#getOption(java.lang.String)
|
* @see org.eclipse.cdt.core.build.managed.ITool#getOption(java.lang.String)
|
||||||
*/
|
*/
|
||||||
public IOption getOption(String id) {
|
public IOption getOption(String id) {
|
||||||
// TODO Auto-generated method stub
|
return (IOption)optionMap.get(id);
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -118,6 +118,11 @@ public class AllBuildTests extends TestCase {
|
||||||
assertEquals(target, newTarget);
|
assertEquals(target, newTarget);
|
||||||
assertFalse(target.equals(targetDef));
|
assertFalse(target.equals(targetDef));
|
||||||
|
|
||||||
|
// Copy over the configs
|
||||||
|
IConfiguration[] configs = targetDef.getConfigurations();
|
||||||
|
for (int i = 0; i < configs.length; ++i)
|
||||||
|
target.createConfiguration(configs[i], target.getId() + "." + i);
|
||||||
|
|
||||||
checkRootTarget(target);
|
checkRootTarget(target);
|
||||||
|
|
||||||
// Save, close, reopen and test again
|
// Save, close, reopen and test again
|
||||||
|
|
Loading…
Add table
Reference in a new issue