1
0
Fork 0
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:
Doug Schaefer 2003-04-21 19:37:47 +00:00
parent eaf3aacd4e
commit ae94fe7955
6 changed files with 68 additions and 14 deletions

View file

@ -45,6 +45,14 @@ public interface ITarget extends IBuildObject {
*/
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
* the tools defined for that target and options set at their defaults.

View file

@ -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) {
element.setAttribute("id", id);
element.setAttribute("name", name);
if (name != null)
element.setAttribute("name", name);
if (parent != null)
element.setAttribute("parent", parent.getId());

View file

@ -48,7 +48,7 @@ public class OptionReference implements IOption {
*/
public OptionReference(ToolReference owner, IConfigurationElement element) {
this.owner = owner;
option = owner.getOption(element.getAttribute("id"));
option = owner.getTool().getOption(element.getAttribute("id"));
owner.addOptionReference(this);
}
@ -61,7 +61,7 @@ public class OptionReference implements IOption {
*/
public OptionReference(ToolReference owner, Element element) {
this.owner = owner;
option = owner.getOption(element.getAttribute("id"));
option = owner.getTool().getOption(element.getAttribute("id"));
owner.addOptionReference(this);
}

View file

@ -23,6 +23,7 @@ import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IConfigurationElement;
import org.w3c.dom.Document;
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 Map toolMap;
private List configurations;
private Map configMap;
private boolean isAbstract = false;
private static final IConfiguration[] emptyConfigs = new IConfiguration[0];
@ -78,8 +80,13 @@ public class Target extends BuildObject implements ITarget {
// parent
String parentId = element.getAttribute("parent");
if (parentId != null)
if (parentId != null) {
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
if ("true".equals(element.getAttribute("isAbstract")))
@ -123,6 +130,16 @@ public class Target extends BuildObject implements ITarget {
// isAbstract
if ("true".equals(element.getAttribute("isAbstract")))
isAbstract = true;
Node child = element.getFirstChild();
while (child != null) {
if (child.getNodeName().equals("configuration")) {
new Configuration(this, (Element)child);
}
child = child.getNextSibling();
}
}
@ -137,6 +154,7 @@ public class Target extends BuildObject implements ITarget {
for (int i = 0; i < configurations.size(); ++i) {
Configuration config = (Configuration)configurations.get(i);
Element configElement = doc.createElement("configuration");
element.appendChild(configElement);
config.serealize(doc, configElement);
}
}
@ -200,16 +218,17 @@ public class Target extends BuildObject implements ITarget {
return emptyConfigs;
}
public void addConfiguration(IConfiguration configuration) {
if (configurations == null)
configurations = new ArrayList();
configurations.add(configuration);
public IConfiguration getConfiguration(String id) {
return (IConfiguration)configMap.get(id);
}
private void addLocalConfiguration(IConfiguration configuration) {
if (configurations == null)
public void addConfiguration(IConfiguration configuration) {
if (configurations == null) {
configurations = new ArrayList();
configMap = new HashMap();
}
configurations.add(configuration);
configMap.put(configuration.getId(), configuration);
}
/* (non-Javadoc)

View file

@ -96,9 +96,12 @@ public class Tool extends BuildObject implements ITool, IOptionCategory {
}
public void addOption(Option option) {
if (options == null)
if (options == null) {
options = new ArrayList();
optionMap = new HashMap();
}
options.add(option);
optionMap.put(option.getId(), option);
}
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)
*/
public IOption getOption(String id) {
// TODO Auto-generated method stub
return null;
return (IOption)optionMap.get(id);
}
}

View file

@ -118,6 +118,11 @@ public class AllBuildTests extends TestCase {
assertEquals(target, newTarget);
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);
// Save, close, reopen and test again