1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Patch for Sean Evoy:

Core 
1.	Added 2 new option types: Boolean and enumerated 
2.	Changed the IOption interface to get new option type values 
3.	In plugin manifest and IOption interface added concept of a default enumerated value to support on-going GUI work 
4.	In plugin manifest and IOption, added field to map the actual command line argument with the option for makefile generation.

Tests 
1.	Changed the plugin.xml manifest to match the new option types 
2.	AllBuildTests.java updated to test new option types and fields added in core
This commit is contained in:
Doug Schaefer 2003-05-21 16:30:00 +00:00
parent 1885198194
commit 7b1c64d5fe
8 changed files with 726 additions and 414 deletions

View file

@ -16,36 +16,10 @@ package org.eclipse.cdt.core.build.managed;
public interface IOption extends IBuildObject {
// Type for the value of the option
public static final int STRING = 0;
public static final int STRING_LIST = 1;
/**
* Returns the tool defining this option.
*
* @return
*/
public ITool getTool();
/**
* Returns the category for this option.
*
* @return
*/
public IOptionCategory getCategory();
/**
* Returns the name of this option.
*
* @return
*/
public String getName();
/**
* Get the type for the value of the option.
*
* @return
*/
public int getValueType();
public static final int BOOLEAN = 0;
public static final int ENUMERATED = 1;
public static final int STRING = 2;
public static final int STRING_LIST = 3;
/**
* If this option is defined as an enumeration, this function returns
@ -57,11 +31,42 @@ public interface IOption extends IBuildObject {
public String [] getApplicableValues();
/**
* Returns the current value for this option if it is a String
* @return the value for a boolean option.
*/
public boolean getBooleanValue() throws BuildException;
/**
* Returns the category for this option.
*
* @return
*/
public String getStringValue() throws BuildException;
public IOptionCategory getCategory();
/**
* @return a String containing the actual command line option
* associated with the <code>IOption</code>
*/
public String getCommand();
/**
* @return a <code>String</code> containing the default value for the
* enumerated option.
*/
public String getDefaultEnumName ();
/**
* @return <code>String</code> containing the command associated with the
* enumeration name.
*/
public String getEnumCommand (String name);
/**
* Returns the name of this option.
*
* @return
*/
public String getName();
/**
* Returns the current value for this option if it is a List of Strings.
@ -69,5 +74,25 @@ public interface IOption extends IBuildObject {
* @return
*/
public String [] getStringListValue() throws BuildException;
/**
* Returns the current value for this option if it is a String
*
* @return
*/
public String getStringValue() throws BuildException;
/**
* Returns the tool defining this option.
*
* @return
*/
public ITool getTool();
/**
* Get the type for the value of the option.
*
* @return
*/
public int getValueType();
}

View file

@ -11,7 +11,9 @@
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;
@ -27,10 +29,12 @@ public class Option extends BuildObject implements IOption {
private ITool tool;
private IOptionCategory category;
private List enumValues;
private int valueType;
private Object value;
private Map enumCommands;
private String defaultEnumName;
private String command;
private static final String[] emptyStrings = new String[0];
@ -55,25 +59,53 @@ public class Option extends BuildObject implements IOption {
if (categoryId != null)
setCategory(tool.getOptionCategory(categoryId));
// command
command = element.getAttribute("command");
// valueType
String valueTypeStr = element.getAttribute("valueType");
if (valueTypeStr == null || valueTypeStr.equals("string"))
valueType = IOption.STRING;
else if (valueTypeStr.equals("stringList"))
valueType = IOption.STRING_LIST;
else if (valueTypeStr.equals("boolean"))
valueType = IOption.BOOLEAN;
else
valueType = IOption.ENUMERATED;
// value
enumCommands = new HashMap();
switch (valueType) {
case IOption.BOOLEAN:
// Convert the string to a boolean
value = new Boolean(element.getAttribute("defaultValue"));
break;
case IOption.STRING:
value = element.getAttribute("value");
// Just get the value out of the option directly
value = element.getAttribute("defaultValue");
break;
case IOption.ENUMERATED:
List enumList = new ArrayList();
IConfigurationElement[] enumElements = element.getChildren("optionEnum");
for (int i = 0; i < enumElements.length; ++i) {
String optName = enumElements[i].getAttribute("name");
String optCommand = enumElements[i].getAttribute("command");
enumList.add(optName);
enumCommands.put(optName, optCommand);
Boolean isDefault = new Boolean(enumElements[i].getAttribute("isDefault"));
if (isDefault.booleanValue()) {
defaultEnumName = optName;
}
}
value = enumList;
break;
case IOption.STRING_LIST:
List valueList = new ArrayList();
value = valueList;
IConfigurationElement[] valueElements = element.getChildren("optionValue");
for (int i = 0; i < valueElements.length; ++i) {
valueList.add(valueElements[i].getAttribute("value"));
}
value = valueList;
break;
}
}
@ -82,11 +114,17 @@ public class Option extends BuildObject implements IOption {
* @see org.eclipse.cdt.core.build.managed.IOption#getApplicableValues()
*/
public String[] getApplicableValues() {
List enumValues = (List)value;
return enumValues != null
? (String[])enumValues.toArray(new String[enumValues.size()])
: emptyStrings;
}
public boolean getBooleanValue() {
Boolean bool = (Boolean) value;
return bool.booleanValue();
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IOption#getCategory()
*/
@ -94,6 +132,27 @@ public class Option extends BuildObject implements IOption {
return category != null ? category : getTool().getTopOptionCategory();
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IOption#getCommand()
*/
public String getCommand() {
return command;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IOption#getDefaultEnumValue()
*/
public String getDefaultEnumName() {
return defaultEnumName;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IOption#getEnumCommand(java.lang.String)
*/
public String getEnumCommand(String name) {
return (String) enumCommands.get(name);
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IOption#getStringListValue()
*/
@ -125,6 +184,13 @@ public class Option extends BuildObject implements IOption {
return valueType;
}
/* (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;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IOption#setStringValue(org.eclipse.cdt.core.build.managed.IConfiguration, java.lang.String)
*/
@ -163,11 +229,4 @@ public class Option extends BuildObject implements IOption {
}
}
/* (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;
}
}

View file

@ -11,7 +11,10 @@
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.IOption;
@ -30,6 +33,9 @@ public class OptionReference implements IOption {
private IOption option;
private ToolReference owner;
private Object value;
private String defaultEnumName;
private String command;
private Map enumCommands;
/**
* Created internally.
@ -57,9 +63,28 @@ public class OptionReference implements IOption {
owner.addOptionReference(this);
// value
enumCommands = new HashMap();
switch (option.getValueType()) {
case IOption.BOOLEAN:
value = new Boolean(element.getAttribute("defaultValue"));
break;
case IOption.STRING:
value = element.getAttribute("value");
value = element.getAttribute("defaultValue");
break;
case IOption.ENUMERATED:
List enumList = new ArrayList();
IConfigurationElement[] enumElements = element.getChildren("optionEnum");
for (int i = 0; i < enumElements.length; ++i) {
String optName = enumElements[i].getAttribute("name");
String optCommand = enumElements[i].getAttribute("command");
enumList.add(optName);
enumCommands.put(optName, optCommand);
Boolean isDefault = new Boolean(enumElements[i].getAttribute("isDefault"));
if (isDefault.booleanValue()) {
defaultEnumName = optName;
}
}
value = enumList;
break;
case IOption.STRING_LIST:
List valueList = new ArrayList();
@ -67,6 +92,7 @@ public class OptionReference implements IOption {
for (int i = 0; i < valueElements.length; ++i) {
valueList.add(valueElements[i].getAttribute("value"));
}
value = valueList;
break;
}
}
@ -85,6 +111,7 @@ public class OptionReference implements IOption {
// value
switch (option.getValueType()) {
case IOption.BOOLEAN:
case IOption.STRING:
value = element.getAttribute("value");
break;
@ -94,6 +121,7 @@ public class OptionReference implements IOption {
for (int i = 0; i < nodes.getLength(); ++i) {
valueList.add(((Element)nodes.item(i)).getAttribute("value"));
}
value = valueList;
break;
}
@ -110,16 +138,26 @@ public class OptionReference implements IOption {
// value
switch (option.getValueType()) {
case IOption.BOOLEAN:
case IOption.STRING:
element.setAttribute("value", (String)value);
break;
case IOption.STRING_LIST:
List valueList = (List)value;
for (int i = 0; i < valueList.size(); ++i) {
List stringList = (List)value;
for (int i = 0; i < stringList.size(); ++i) {
Element valueElement = doc.createElement("optionValue");
valueElement.setAttribute("value", (String)valueList.get(i));
valueElement.setAttribute("value", (String)stringList.get(i));
element.appendChild(valueElement);
}
break;
case IOption.ENUMERATED:
List enumList = (List)value;
for (int i = 0; i < enumList.size(); ++i) {
Element valueElement = doc.createElement("optionEnum");
valueElement.setAttribute("value", (String)enumList.get(i));
element.appendChild(valueElement);
}
break;
}
}
@ -137,6 +175,42 @@ public class OptionReference implements IOption {
return option.getCategory();
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IOption#getCommand()
*/
public String getCommand() {
return option.getCommand();
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IOption#getDefaultEnumValue()
*/
public String getDefaultEnumName() {
if (value == null) {
return option.getDefaultEnumName();
} else {
return defaultEnumName;
}
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IOption#getEnumCommand(java.lang.String)
*/
public String getEnumCommand(String name) {
if (value == null) {
return option.getEnumCommand(name);
} else {
return (String)enumCommands.get(name);
}
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IBuildObject#getId()
*/
public String getId() {
return option.getId();
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IBuildObject#getName()
*/
@ -144,6 +218,21 @@ public class OptionReference implements IOption {
return option.getName();
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IOption#getBooleanValue()
*/
public boolean getBooleanValue() throws BuildException {
if (value == null){
return option.getBooleanValue();
}
else if (getValueType() == IOption.BOOLEAN) {
Boolean bool = (Boolean) value;
return bool.booleanValue();
} else {
throw new BuildException("bad value type");
}
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IOption#getStringListValue()
*/
@ -186,13 +275,6 @@ public class OptionReference implements IOption {
return option.getValueType();
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IBuildObject#getId()
*/
public String getId() {
return option.getId();
}
public boolean references(IOption target) {
if (equals(target))
// we are the target

View file

@ -14,3 +14,7 @@ ProcessList.name=Process List
makeproject.name=Make Project
genericmake.name=Generic Make
makebuildmodel.name=Make Builder
ManagedBuildNature.name=Managed C/C++ Build Nature
GeneratedMakefileCBuilder.name=Generated Makefile C/C++ Builder

View file

@ -252,5 +252,29 @@
pattern="*.exe">
</ignore>
</extension>
<extension
id="managedBuildNature"
name="%ManagedBuildNature.name"
point="org.eclipse.core.resources.natures">
<requires-nature
id="org.eclipse.cdt.core.cnature">
</requires-nature>
<runtime>
<run
class="org.eclipse.cdt.core.ManagedCProjectNature">
</run>
</runtime>
</extension>
<extension
id="generatedMakefileCBuilder"
name="%GeneratedMakefileCBuilder.name"
point="org.eclipse.core.resources.builders">
<builder
hasNature="true">
<run
class="org.eclipse.cdt.internal.core.GeneratedMakefileCBuilder">
</run>
</builder>
</extension>
</plugin>

View file

@ -1,343 +1,397 @@
<?xml version='1.0' encoding='UTF-8'?>
<!-- Schema file written by PDE -->
<schema targetNamespace="org.eclipse.cdt.core">
<annotation>
<appInfo>
<meta.schema plugin="org.eclipse.cdt.core" id="ManagedBuildTools" name="Managed Build Tools"/>
</appInfo>
<documentation>
[Enter description of this extension point.]
</documentation>
</annotation>
<element name="extension">
<complexType>
<sequence>
<element ref="target"/>
<element ref="tool"/>
<element ref="configuration"/>
</sequence>
<attribute name="point" type="string" use="required">
<annotation>
<documentation>
</documentation>
</annotation>
</attribute>
<attribute name="id" type="string">
<annotation>
<documentation>
</documentation>
</annotation>
</attribute>
<attribute name="name" type="string">
<annotation>
<documentation>
</documentation>
</annotation>
</attribute>
</complexType>
</element>
<element name="tool">
<complexType>
<sequence>
<element ref="option"/>
<element ref="optionCategory"/>
</sequence>
<attribute name="id" type="string" use="required">
<annotation>
<documentation>
</documentation>
</annotation>
</attribute>
<attribute name="name" type="string" use="required">
<annotation>
<documentation>
</documentation>
</annotation>
</attribute>
<attribute name="sources" type="string">
<annotation>
<documentation>
</documentation>
</annotation>
</attribute>
<attribute name="outputs" type="string">
<annotation>
<documentation>
</documentation>
</annotation>
</attribute>
<attribute name="dependencyCalculator" type="string">
<annotation>
<documentation>
</documentation>
<appInfo>
<meta.attribute kind="java"/>
</appInfo>
</annotation>
</attribute>
</complexType>
</element>
<element name="option">
<complexType>
<sequence>
<element ref="optionEnum"/>
<element ref="optionValue"/>
</sequence>
<attribute name="id" type="string" use="required">
<annotation>
<documentation>
</documentation>
</annotation>
</attribute>
<attribute name="name" type="string" use="required">
<annotation>
<documentation>
</documentation>
</annotation>
</attribute>
<attribute name="valueType" use="default" value="string">
<annotation>
<documentation>
</documentation>
</annotation>
<simpleType>
<restriction base="string">
<enumeration value="string">
</enumeration>
<enumeration value="stringList">
</enumeration>
</restriction>
</simpleType>
</attribute>
<attribute name="value" type="string">
<annotation>
<documentation>
</documentation>
</annotation>
</attribute>
<attribute name="category" type="string">
<annotation>
<documentation>
This is the id of the option category for this option. The id can be the id of the tool which is also a category.
</documentation>
</annotation>
</attribute>
</complexType>
</element>
<element name="optionEnum">
<complexType>
<attribute name="id" type="string" use="required">
<annotation>
<documentation>
</documentation>
</annotation>
</attribute>
<attribute name="name" type="string" use="required">
<annotation>
<documentation>
</documentation>
</annotation>
</attribute>
</complexType>
</element>
<element name="configuration">
<complexType>
<sequence>
<element ref="toolRef"/>
</sequence>
<attribute name="id" type="string" use="required">
<annotation>
<documentation>
</documentation>
</annotation>
</attribute>
<attribute name="name" type="string" use="required">
<annotation>
<documentation>
</documentation>
</annotation>
</attribute>
</complexType>
</element>
<element name="toolRef">
<complexType>
<sequence>
<element ref="optionRef"/>
</sequence>
<attribute name="id" type="string" use="required">
<annotation>
<documentation>
</documentation>
</annotation>
</attribute>
</complexType>
</element>
<element name="optionRef">
<complexType>
<attribute name="id" type="string" use="required">
<annotation>
<documentation>
</documentation>
</annotation>
</attribute>
<attribute name="value" type="string">
<annotation>
<documentation>
</documentation>
</annotation>
</attribute>
</complexType>
</element>
<element name="target">
<annotation>
<documentation>
Represents a type of resource that is the target of the build process, for example, a Linux Library. A target contains a sequence of tool definitions and configurations. Targets are arranged in an inheritance hierarchy where a target inherits the list of tools from it&apos;s parent and can add to or override tools in this list.
</documentation>
</annotation>
<complexType>
<sequence>
<element ref="tool"/>
<element ref="configuration"/>
</sequence>
<attribute name="id" type="string" use="required">
<annotation>
<documentation>
</documentation>
</annotation>
</attribute>
<attribute name="name" type="string" use="required">
<annotation>
<documentation>
</documentation>
</annotation>
</attribute>
<attribute name="isAbstract" type="boolean" use="default" value="false">
<annotation>
<documentation>
This is a UI property. If set to true, users should not be able to create project configurations targeted at this target.
</documentation>
</annotation>
</attribute>
<attribute name="parent" type="string">
<annotation>
<documentation>
The id of a target that this tool inherits from.
</documentation>
</annotation>
</attribute>
</complexType>
</element>
<element name="optionCategory">
<complexType>
<attribute name="id" type="string">
<annotation>
<documentation>
</documentation>
</annotation>
</attribute>
<attribute name="name" type="string">
<annotation>
<documentation>
</documentation>
</annotation>
</attribute>
<attribute name="owner" type="string">
<annotation>
<documentation>
</documentation>
</annotation>
</attribute>
</complexType>
</element>
<element name="optionValue">
<complexType>
<attribute name="value" type="string" use="required">
<annotation>
<documentation>
</documentation>
</annotation>
</attribute>
</complexType>
</element>
<annotation>
<appInfo>
<meta.section type="since"/>
</appInfo>
<documentation>
[Enter the first release in which this extension point appears.]
</documentation>
</annotation>
<annotation>
<appInfo>
<meta.section type="examples"/>
</appInfo>
<documentation>
[Enter extension point usage example here.]
</documentation>
</annotation>
<annotation>
<appInfo>
<meta.section type="apiInfo"/>
</appInfo>
<documentation>
[Enter API information here.]
</documentation>
</annotation>
<annotation>
<appInfo>
<meta.section type="implementation"/>
</appInfo>
<documentation>
[Enter information about supplied implementation of this extension point.]
</documentation>
</annotation>
<annotation>
<appInfo>
<meta.section type="copyright"/>
</appInfo>
<documentation>
</documentation>
</annotation>
</schema>
<?xml version='1.0' encoding='UTF-8'?>
<!-- Schema file written by PDE -->
<schema targetNamespace="org.eclipse.cdt.core">
<annotation>
<appInfo>
<meta.schema plugin="org.eclipse.cdt.core" id="ManagedBuildTools" name="Managed Build Tools"/>
</appInfo>
<documentation>
Describes targets, configurations, and toolchains for the build system.
</documentation>
</annotation>
<element name="extension">
<complexType>
<sequence>
<element ref="target"/>
<element ref="tool"/>
<element ref="configuration"/>
</sequence>
<attribute name="point" type="string" use="required">
<annotation>
<documentation>
</documentation>
</annotation>
</attribute>
<attribute name="id" type="string">
<annotation>
<documentation>
</documentation>
</annotation>
</attribute>
<attribute name="name" type="string">
<annotation>
<documentation>
</documentation>
</annotation>
</attribute>
</complexType>
</element>
<element name="tool">
<complexType>
<sequence>
<element ref="option"/>
<element ref="optionCategory"/>
</sequence>
<attribute name="id" type="string" use="required">
<annotation>
<documentation>
</documentation>
</annotation>
</attribute>
<attribute name="name" type="string" use="required">
<annotation>
<documentation>
</documentation>
</annotation>
</attribute>
<attribute name="sources" type="string">
<annotation>
<documentation>
</documentation>
</annotation>
</attribute>
<attribute name="outputs" type="string">
<annotation>
<documentation>
</documentation>
</annotation>
</attribute>
<attribute name="dependencyCalculator" type="string">
<annotation>
<documentation>
</documentation>
<appInfo>
<meta.attribute kind="java"/>
</appInfo>
</annotation>
</attribute>
</complexType>
</element>
<element name="option">
<complexType>
<sequence>
<element ref="optionEnum"/>
<element ref="optionValue"/>
</sequence>
<attribute name="id" type="string" use="required">
<annotation>
<documentation>
A unique identifier for the option.
</documentation>
</annotation>
</attribute>
<attribute name="name" type="string" use="required">
<annotation>
<documentation>
A descriptive name for the option.
</documentation>
</annotation>
</attribute>
<attribute name="valueType" use="default" value="string">
<annotation>
<documentation>
An option can be one of the following types; &apos;string&apos; for catch-all entries for options that cannot be easily defined any other way, &apos;string list&apos; for entries that consist of a list of values such as defined symbols or paths, &apos;boolean&apos; for options that have two values, and &apos;enumerated&apos; for options that are one-of a list of values.
</documentation>
</annotation>
<simpleType>
<restriction base="string">
<enumeration value="string">
</enumeration>
<enumeration value="stringList">
</enumeration>
<enumeration value="boolean">
</enumeration>
<enumeration value="enumerated">
</enumeration>
</restriction>
</simpleType>
</attribute>
<attribute name="value" type="string">
<annotation>
<documentation>
Overridden value assigned to the option by the end user.
</documentation>
</annotation>
</attribute>
<attribute name="category" type="string">
<annotation>
<documentation>
This is the id of the option category for this option. The id can be the id of the tool which is also a category.
</documentation>
</annotation>
</attribute>
<attribute name="defaultValue" type="string">
<annotation>
<documentation>
Specifies the default value for the option if the &apos;value&apos; field is blank. For enumerated options the optionEnums will be searched for the default. For string list options, all defined optionValues will be treated as defaults. For boolean values, specify truth using the string &apos;true&apos;. All other strings will be treated as false.
</documentation>
</annotation>
</attribute>
<attribute name="command" type="string">
<annotation>
<documentation>
An optional value that specifies the actual command that will be passed to the tool on the command line.
</documentation>
</annotation>
</attribute>
</complexType>
</element>
<element name="optionEnum">
<annotation>
<documentation>
Defines a single value of an enumerated option.
</documentation>
</annotation>
<complexType>
<attribute name="id" type="string" use="required">
<annotation>
<documentation>
Unique identifier for the option enumeration.
</documentation>
</annotation>
</attribute>
<attribute name="name" type="string" use="required">
<annotation>
<documentation>
A descriptive name for the enumeration.
</documentation>
</annotation>
</attribute>
<attribute name="isDefault" type="boolean">
<annotation>
<documentation>
Flags this enumerated value as the default to apply to the option if the user has not changed the setting.
</documentation>
</annotation>
</attribute>
<attribute name="command" type="string">
<annotation>
<documentation>
The command that the enumerated value translates to on the command line.
</documentation>
</annotation>
</attribute>
</complexType>
</element>
<element name="configuration">
<complexType>
<sequence>
<element ref="toolRef"/>
</sequence>
<attribute name="id" type="string" use="required">
<annotation>
<documentation>
</documentation>
</annotation>
</attribute>
<attribute name="name" type="string" use="required">
<annotation>
<documentation>
</documentation>
</annotation>
</attribute>
</complexType>
</element>
<element name="toolRef">
<complexType>
<sequence>
<element ref="optionRef"/>
</sequence>
<attribute name="id" type="string" use="required">
<annotation>
<documentation>
</documentation>
</annotation>
</attribute>
</complexType>
</element>
<element name="optionRef">
<complexType>
<attribute name="id" type="string" use="required">
<annotation>
<documentation>
</documentation>
</annotation>
</attribute>
<attribute name="defaultValue" type="string">
<annotation>
<documentation>
</documentation>
</annotation>
</attribute>
<attribute name="command" type="string">
<annotation>
<documentation>
</documentation>
</annotation>
</attribute>
</complexType>
</element>
<element name="target">
<annotation>
<documentation>
Represents a type of resource that is the target of the build process, for example, a Linux Library. A target contains a sequence of tool definitions and configurations. Targets are arranged in an inheritance hierarchy where a target inherits the list of tools from it&apos;s parent and can add to or override tools in this list.
</documentation>
</annotation>
<complexType>
<sequence>
<element ref="tool"/>
<element ref="configuration"/>
</sequence>
<attribute name="id" type="string" use="required">
<annotation>
<documentation>
</documentation>
</annotation>
</attribute>
<attribute name="name" type="string" use="required">
<annotation>
<documentation>
</documentation>
</annotation>
</attribute>
<attribute name="isAbstract" type="boolean" use="default" value="false">
<annotation>
<documentation>
This is a UI property. If set to true, users should not be able to create project configurations targeted at this target.
</documentation>
</annotation>
</attribute>
<attribute name="parent" type="string">
<annotation>
<documentation>
The id of a target that this tool inherits from.
</documentation>
</annotation>
</attribute>
</complexType>
</element>
<element name="optionCategory">
<annotation>
<documentation>
An optional, but useful, mechanism for grouping options together.
</documentation>
</annotation>
<complexType>
<attribute name="id" type="string">
<annotation>
<documentation>
</documentation>
</annotation>
</attribute>
<attribute name="name" type="string">
<annotation>
<documentation>
</documentation>
</annotation>
</attribute>
<attribute name="owner" type="string">
<annotation>
<documentation>
</documentation>
</annotation>
</attribute>
</complexType>
</element>
<element name="optionValue">
<annotation>
<documentation>
A value for defining individual elements of a string list option.
</documentation>
</annotation>
<complexType>
<attribute name="value" type="string" use="required">
<annotation>
<documentation>
</documentation>
</annotation>
</attribute>
</complexType>
</element>
<annotation>
<appInfo>
<meta.section type="since"/>
</appInfo>
<documentation>
CDT 1.1
</documentation>
</annotation>
<annotation>
<appInfo>
<meta.section type="examples"/>
</appInfo>
<documentation>
[Enter extension point usage example here.]
</documentation>
</annotation>
<annotation>
<appInfo>
<meta.section type="apiInfo"/>
</appInfo>
<documentation>
[Enter API information here.]
</documentation>
</annotation>
<annotation>
<appInfo>
<meta.section type="implementation"/>
</appInfo>
<documentation>
[Enter information about supplied implementation of this extension point.]
</documentation>
</annotation>
<annotation>
<appInfo>
<meta.section type="copyright"/>
</appInfo>
<documentation>
</documentation>
</annotation>
</schema>

View file

@ -172,27 +172,51 @@ public class AllBuildTests extends TestCase {
// Root Tool
ITool rootTool = tools[0];
assertEquals("Root Tool", rootTool.getName());
// Options
// 4 Options are defined in the root tool
IOption[] options = rootTool.getOptions();
assertEquals(2, options.length);
assertEquals("Option in Top", options[0].getName());
assertEquals(4, options.length);
// First option is a 2-element list
assertEquals("List Option in Top", options[0].getName());
assertEquals(IOption.STRING_LIST, options[0].getValueType());
String[] valueList = options[0].getStringListValue();
assertEquals(2, valueList.length);
assertEquals("a", valueList[0]);
assertEquals("b", valueList[1]);
assertEquals("Option in Category", options[1].getName());
assertEquals("x", options[1].getStringValue());
assertEquals(options[0].getCommand(), "-L");
// Next option is a boolean in top
assertEquals("Boolean Option in Top", options[1].getName());
assertEquals(IOption.BOOLEAN, options[1].getValueType());
assertEquals(false, options[1].getBooleanValue());
assertEquals("-b", options[1].getCommand());
// Next option is a string category
assertEquals("String Option in Category", options[2].getName());
assertEquals(IOption.STRING, options[2].getValueType());
assertEquals("x", options[2].getStringValue());
// Final option is an enumerated
assertEquals("Enumerated Option in Category", options[3].getName());
assertEquals(IOption.ENUMERATED, options[3].getValueType());
assertEquals("Default Enum", options[3].getDefaultEnumName());
valueList = options[3].getApplicableValues();
assertEquals(2, valueList.length);
assertEquals("Default Enum", valueList[0]);
assertEquals("Another Enum", valueList[1]);
assertEquals("-e1", options[3].getEnumCommand(valueList[0]));
assertEquals("-e2", options[3].getEnumCommand(valueList[1]));
// Option Categories
IOptionCategory topCategory = rootTool.getTopOptionCategory();
assertEquals("Root Tool", topCategory.getName());
options = topCategory.getOptions(null);
assertEquals(1, options.length);
assertEquals("Option in Top", options[0].getName());
assertEquals(2, options.length);
assertEquals("List Option in Top", options[0].getName());
assertEquals("Boolean Option in Top", options[1].getName());
IOptionCategory[] categories = topCategory.getChildCategories();
assertEquals(1, categories.length);
assertEquals("Category", categories[0].getName());
options = categories[0].getOptions(null);
assertEquals(1, options.length);
assertEquals("Option in Category", options[0].getName());
assertEquals(2, options.length);
assertEquals("String Option in Category", options[0].getName());
assertEquals("Enumerated Option in Category", options[1].getName());
// Configs
IConfiguration[] configs = target.getConfigurations();
@ -205,15 +229,18 @@ public class AllBuildTests extends TestCase {
assertEquals("Root Tool", tools[0].getName());
topCategory = tools[0].getTopOptionCategory();
options = topCategory.getOptions(configs[0]);
assertEquals(1, options.length);
assertEquals("Option in Top", options[0].getName());
assertEquals(2, options.length);
assertEquals("List Option in Top", options[0].getName());
valueList = options[0].getStringListValue();
assertEquals("a", valueList[0]);
assertEquals("b", valueList[1]);
assertEquals("Boolean Option in Top", options[1].getName());
categories = topCategory.getChildCategories();
options = categories[0].getOptions(configs[0]);
assertEquals("Option in Category", options[0].getName());
assertEquals(2, options.length);
assertEquals("String Option in Category", options[0].getName());
assertEquals(oicValue, options[0].getStringValue());
assertEquals("Enumerated Option in Category", options[1].getName());
// Root Override Config
assertEquals("Root Override Config", configs[1].getName());
tools = configs[1].getTools();
@ -222,15 +249,24 @@ public class AllBuildTests extends TestCase {
assertEquals("Root Tool", tools[0].getName());
topCategory = tools[0].getTopOptionCategory();
options = topCategory.getOptions(configs[1]);
assertEquals(1, options.length);
assertEquals("Option in Top", options[0].getName());
assertEquals(2, options.length);
assertEquals("List Option in Top", options[0].getName());
valueList = options[0].getStringListValue();
assertEquals("a", valueList[0]);
assertEquals("b", valueList[1]);
assertEquals("Boolean Option in Top", options[1].getName());
categories = topCategory.getChildCategories();
options = categories[0].getOptions(configs[1]);
assertEquals("Option in Category", options[0].getName());
assertEquals(2, options.length);
assertEquals("String Option in Category", options[0].getName());
assertEquals("y", options[0].getStringValue());
assertEquals("Enumerated Option in Category", options[1].getName());
valueList = options[1].getApplicableValues();
assertEquals(2, valueList.length);
assertEquals("Default Enum", valueList[0]);
assertEquals("Another Enum", valueList[1]);
assertEquals("-e1", options[1].getEnumCommand(valueList[0]));
assertEquals("-e2", options[1].getEnumCommand(valueList[1]));
}
}

View file

@ -105,7 +105,8 @@
id="category">
</optionCategory>
<option
name="Option in Top"
name="List Option in Top"
command="-L"
valueType="stringList"
id="topOption">
<optionValue
@ -116,12 +117,38 @@
</optionValue>
</option>
<option
name="Option in Category"
defaultValue="false"
name="Boolean Option in Top"
command="-b"
valueType="boolean"
id="topBoolOption">
</option>
<option
defaultValue="x"
name="String Option in Category"
category="category"
value="x"
valueType="string"
id="childOption">
</option>
<option
name="Enumerated Option in Category"
category="category"
valueType="enumerated"
id="child.enumerated.option">
<optionEnum
name="Default Enum"
value="s"
isDefault="true"
command="-e1"
id="default.enum.option">
</optionEnum>
<optionEnum
name="Another Enum"
value="t"
command="-e2"
id="another.enum.option">
</optionEnum>
</option>
</tool>
<configuration
name="Root Config"
@ -133,6 +160,7 @@
<toolRef
id="root.tool">
<optionRef
defaultValue="y"
value="y"
id="childOption">
</optionRef>