1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-30 21:55:31 +02:00

Patch for Sean Evoy:

This patch contains some minor UI changes and a big chunk of work to add 
built-in symbols and includes search paths to a tool specification. 

The UI change is a switch from dynamically resizing the property page when 
an option category is selected from the list, but rather using a scrolled 
edit area. Now, if the option set is larger than the viewable area, a 
horizontal and/or vertical scrollbar is displayed.

In terms of built-ins, there is no UI support to change the values just 
yet. That is coming, but I wanted to get the framework and some 
definitions in place so that the indexer and scanner can start using them.
This commit is contained in:
Doug Schaefer 2003-08-20 17:52:32 +00:00
parent 5fd96de2e5
commit cc710063b4
15 changed files with 587 additions and 219 deletions

View file

@ -1,3 +1,24 @@
2003-08-19 Sean Evoy
In order to properly support the indexing feature, the scanner has to
function as well as the version that ships with the toolset if possible.
This is made difficult by the fact that we are trying to be tool-agnostic.
One of the things that the scanner should take into account when it runs
is the "built-in" symbols and search paths that are defined for a compiler
in a given toolchain. While we need to come up with a standard mechanism
for the CDT in the future, the managed build system can provide a work-around
in the near-term. The easiest solution is to add an optional attribute to a
list element that flags the item as a built-in value. When clients like
the indexer query the build model, they will receive the union of the built-in
values and the user-defined values.
Added built-in information to the existing plugin definition. Also added a
new include path and defined symol for updated test cases.
* plugin.xml
Updated the test cases to check that built-ins defined in the plugin manifest
are properly read and dealt with during project creation and persisting settings.
* build/org/eclipse/cdt/core/build/managed/tests/ManagedBuildTests.java
2003-08-14 John Camelon
Removed warnings from AutomatedIntegrationSuite.java (removing implicit accessor generation).

View file

@ -114,8 +114,8 @@ public class ManagedBuildTests extends TestCase {
*/
public void testScannerInfoInterface(){
// These are the expected path settings
final String[] expectedPaths = {"/usr/include", "/opt/gnome/include", "/home/tester/include"};
final String[] expectedPaths = {"/usr/gnu/include", "/usr/include", "/opt/gnome/include", "C:\\home\\tester/include"};
// Open the test project
IProject project = null;
try {
@ -159,18 +159,23 @@ public class ManagedBuildTests extends TestCase {
// Check the build information right away
IScannerInfo currentSettings = provider.getScannerInformation(project);
Map currentSymbols = currentSettings.getDefinedSymbols();
assertTrue(currentSymbols.isEmpty());
// It should simply contain the built-in
assertTrue(currentSymbols.containsKey("BUILTIN"));
assertEquals((String)currentSymbols.get("BUILTIN"), "");
String[] currentPaths = currentSettings.getIncludePaths();
assertTrue(Arrays.equals(expectedPaths, currentPaths));
// Now subscribe (note that the method will be called after a change
provider.subscribe(project, new IScannerInfoChangeListener () {
public void changeNotification(IResource project, IScannerInfo info) {
// Test the symbols
// Test the symbols: expect "BUILTIN" from the manifest, and "DEBUG" and "GNOME=ME"
// from the overidden settings
Map definedSymbols = info.getDefinedSymbols();
assertTrue(definedSymbols.containsKey("BUILTIN"));
assertTrue(definedSymbols.containsKey("DEBUG"));
assertTrue(definedSymbols.containsKey("GNOME"));
assertTrue(definedSymbols.containsValue("ME"));
assertEquals((String)definedSymbols.get("BUILTIN"), "");
assertEquals((String)definedSymbols.get("DEBUG"), "");
assertEquals((String)definedSymbols.get("GNOME"), "ME");
// Test the includes path
@ -502,13 +507,16 @@ public class ManagedBuildTests extends TestCase {
// 4 Options are defined in the root tool
IOption[] options = rootTool.getOptions();
assertEquals(4, options.length);
// First option is a 2-element list
// First option is a 3-element list with 1 built-in
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]);
String[] builtInList = options[0].getBuiltIns();
assertEquals(1, builtInList.length);
assertEquals("c", builtInList[0]);
assertEquals(options[0].getCommand(), "-L");
// Next option is a boolean in top
assertEquals("Boolean Option in Top", options[1].getName());
@ -647,17 +655,25 @@ public class ManagedBuildTests extends TestCase {
assertEquals(2, incPath.length);
assertEquals("/usr/include", incPath[0]);
assertEquals("/opt/gnome/include", incPath[1]);
String[] builtInPaths = subOpts[0].getBuiltIns();
assertEquals(1, builtInPaths.length);
assertEquals("/usr/gnu/include", builtInPaths[0]);
assertEquals("-I", subOpts[0].getCommand());
// There are no user-defined preprocessor symbols
assertEquals("Defined Symbols", subOpts[1].getName());
assertEquals(IOption.PREPROCESSOR_SYMBOLS, subOpts[1].getValueType());
String[] defdSymbols = subOpts[1].getDefinedSymbols();
assertEquals(0, defdSymbols.length);
assertEquals("-D", subOpts[1].getCommand());
// But there is a builtin
String[] builtInSymbols = subOpts[1].getBuiltIns();
assertEquals(1, builtInSymbols.length);
assertEquals("BUILTIN", builtInSymbols[0]);
assertEquals("More Includes", subOpts[2].getName());
assertEquals(IOption.INCLUDE_PATH, subOpts[2].getValueType());
String[] moreIncPath = subOpts[2].getIncludePaths();
assertEquals(1, moreIncPath.length);
assertEquals("/home/tester/include", moreIncPath[0]);
assertEquals("C:\\home\\tester/include", moreIncPath[0]);
assertEquals("-I", subOpts[2].getCommand());
// Get the configs for this target

View file

@ -56,7 +56,12 @@
value="a">
</listOptionValue>
<listOptionValue
value="b">
value="b"
builtIn="false">
</listOptionValue>
<listOptionValue
value="c"
builtIn="true">
</listOptionValue>
</option>
<option
@ -142,12 +147,20 @@
<listOptionValue
value="/opt/gnome/include">
</listOptionValue>
<listOptionValue
value="/usr/gnu/include"
builtIn="true">
</listOptionValue>
</option>
<option
name="Defined Symbols"
command="-D"
valueType="definedSymbols"
id="sub.tool.opt.def.symbols">
<listOptionValue
value="BUILTIN"
builtIn="true">
</listOptionValue>
</option>
<option
name="More Includes"
@ -155,7 +168,8 @@
valueType="includePath"
id="sub.tool.opts.inc.paths.more">
<listOptionValue
value="/home/tester/include">
value="C:\home\tester/include"
builtIn="false">
</listOptionValue>
</option>
</tool>

View file

@ -1,3 +1,35 @@
2003-08-19 Sean Evoy
In order to properly support the indexing feature, the scanner has to
function as well as the version that ships with the toolset if possible.
This is made difficult by the fact that we are trying to be tool-agnostic.
One of the things that the scanner should take into account when it runs
is the "built-in" symbols and search paths that are defined for a compiler
in a given toolchain. While we need to come up with a standard mechanism
for the CDT in the future, the managed build system can provide a work-around
in the near-term. The easiest solution is to add an optional attribute to a
list element that flags the item as a built-in value. When clients like
the indexer query the build model, they will receive the union of the built-in
values and the user-defined values.
Updated the comment for the IScannerInfo::getIncludesPaths() method to
explain the content of the return value.
* parser/org/eclipse/cdt/core/parser/IScannerInfo.java
Added code to answer the built-ins when IScannerInfo methods are called.
* build/org/eclipse/cdt/internal/core/build/managed/ManagedBuildInfo.java
Updated the schema to include the new attribute
* schema/ManagedBuildTools.exsd
Added a public method to extract the built-in values for an option.
* build/org/eclipse/cdt/core/build/managed/IOption.java
Added the code to read, store and persist the built-in list values
differently than standard list elements. Also added code to answer
those built-ins to conform to the interface change.
* build/org/eclipse/cdt/internal/core/build/managed/Option.java
* build/org/eclipse/cdt/internal/core/build/managed/OptionReference.java
2003-08-13 Sean Evoy
Changed text generated into makefile comments from the rather abstract
term 'module' to the more meaningful 'subdirectory'.

View file

@ -23,7 +23,7 @@ public interface IOption extends IBuildObject {
public static final int PREPROCESSOR_SYMBOLS = 5;
public static final int LIBRARIES = 6;
// Schema element names for options
// Schema attribute names for option elements
public static final String CATEGORY = "category";
public static final String COMMAND = "command";
public static final String DEFAULT_VALUE = "defaultValue";
@ -37,7 +37,10 @@ public interface IOption extends IBuildObject {
public static final String TYPE_STRING = "string";
public static final String TYPE_STR_LIST = "stringList";
public static final String VALUE_TYPE = "valueType";
public static final String VALUE = "value";
// Schema attribute names for listOptionValue elements
public static final String LIST_ITEM_VALUE = "value";
public static final String LIST_ITEM_BUILTIN = "builtIn";
/**
@ -56,6 +59,16 @@ public interface IOption extends IBuildObject {
* @throws BuildException
*/
public boolean getBooleanValue() throws BuildException;
/**
* Answers an array of strings containing the built-in values
* defined for a stringList, includePaths, definedSymbols, or libs
* option. If none have been defined, the array will be empty but
* never <code>null</code>.
*
* @return
*/
public String[] getBuiltIns();
/**
* Returns the category for this option.

View file

@ -14,14 +14,15 @@ package org.eclipse.cdt.internal.core.build.managed;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;
import java.util.Map;
import org.eclipse.cdt.core.build.managed.BuildException;
import org.eclipse.cdt.core.build.managed.IConfiguration;
import org.eclipse.cdt.core.build.managed.IOption;
import org.eclipse.cdt.core.build.managed.IManagedBuildInfo;
import org.eclipse.cdt.core.build.managed.IOption;
import org.eclipse.cdt.core.build.managed.ITarget;
import org.eclipse.cdt.core.build.managed.ITool;
import org.eclipse.cdt.core.parser.IScannerInfo;
@ -80,7 +81,7 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IResourceBuildInfo#addTarget(org.eclipse.cdt.core.build.managed.ITarget)
* @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#addTarget(org.eclipse.cdt.core.build.managed.ITarget)
*/
public void addTarget(ITarget target) {
targetMap.put(target.getId(), target);
@ -104,7 +105,7 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IResourceBuildInfo#getBuildArtifactName()
* @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#getBuildArtifactName()
*/
public String getBuildArtifactName() {
// Get the default target and use its value
@ -133,7 +134,7 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IResourceBuildInfo#getDefaultConfiguration()
* @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#getDefaultConfiguration()
*/
public IConfiguration getDefaultConfiguration(ITarget target) {
// Get the default config associated with the defalt target
@ -150,7 +151,7 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IResourceBuildInfo#getDefaultTarget()
* @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#getDefaultTarget()
*/
public ITarget getDefaultTarget() {
if (defaultTarget == null) {
@ -160,7 +161,53 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IResourceBuildInfo#getFlagsForSource(java.lang.String)
* @see org.eclipse.cdt.core.build.managed.IScannerInfo#getDefinedSymbols()
*/
public Map getDefinedSymbols() {
// Return the defined symbols for the default configuration
HashMap symbols = new HashMap();
IConfiguration config = getDefaultConfiguration(getDefaultTarget());
ITool[] tools = config.getTools();
for (int i = 0; i < tools.length; i++) {
ITool tool = tools[i];
IOption[] opts = tool.getOptions();
for (int j = 0; j < opts.length; j++) {
IOption option = opts[j];
if (option.getValueType() == IOption.PREPROCESSOR_SYMBOLS) {
try {
ArrayList symbolList = new ArrayList();
symbolList.addAll(Arrays.asList(option.getBuiltIns()));
symbolList.addAll(Arrays.asList(option.getDefinedSymbols()));
Iterator iter = symbolList.listIterator();
while (iter.hasNext()) {
String symbol = (String) iter.next();
if (symbol.length() == 0){
continue;
}
String key = new String();
String value = new String();
int index = symbol.indexOf("=");
if (index != -1) {
key = symbol.substring(0, index).trim();
value = symbol.substring(index + 1).trim();
} else {
key = symbol.trim();
}
symbols.put(key, value);
}
} catch (BuildException e) {
// we should never get here
continue;
}
}
}
}
return symbols;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#getFlagsForSource(java.lang.String)
*/
public String getFlagsForSource(String extension) {
// Get all the tools for the current config
@ -183,7 +230,7 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IResourceBuildInfo#getToolFlags(java.lang.String)
* @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#getToolFlags(java.lang.String)
*/
public String getFlagsForTarget(String extension) {
// Treat null extensions as an empty string
@ -199,7 +246,8 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
try {
flags = tool.getToolFlags();
} catch (BuildException e) {
// TODO: handle exception
// Somehow the model is out of sync for this item. Keep iterating
continue;
}
return flags;
}
@ -222,9 +270,12 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
IOption option = opts[j];
if (option.getValueType() == IOption.INCLUDE_PATH) {
try {
// Get all the built-in paths from the option
paths.addAll(Arrays.asList(option.getBuiltIns()));
// Get all the user-defined paths from the option
paths.addAll(Arrays.asList(option.getIncludePaths()));
} catch (BuildException e) {
// we should never get here
// we should never get here, but continue anyway
continue;
}
}
@ -289,7 +340,7 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IResourceBuildInfo#getOutputExtension(java.lang.String)
* @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#getOutputExtension(java.lang.String)
*/
public String getOutputExtension(String resourceExtension) {
// Get all the tools for the current config
@ -349,21 +400,21 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
return owner;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IResourceBuildInfo#getTarget(org.eclipse.cdt.core.build.managed.IConfiguration)
* @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#getTarget(org.eclipse.cdt.core.build.managed.IConfiguration)
*/
public ITarget getTarget(String id) {
return (ITarget) targetMap.get(id);
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IResourceBuildInfo#getTargets(org.eclipse.cdt.core.build.managed.IConfiguration)
* @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#getTargets(org.eclipse.cdt.core.build.managed.IConfiguration)
*/
public List getTargets() {
return targets;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IResourceBuildInfo#getToolForSource(java.lang.String)
* @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#getToolForSource(java.lang.String)
*/
public String getToolForSource(String extension) {
// Get all the tools for the current config
@ -379,7 +430,7 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IResourceBuildInfo#getToolInvocation(java.lang.String)
* @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#getToolInvocation(java.lang.String)
*/
public String getToolForTarget(String extension) {
// Treat a null argument as an empty string
@ -418,7 +469,7 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IResourceBuildInfo#setDefaultConfiguration(org.eclipse.cdt.core.build.managed.IConfiguration)
* @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#setDefaultConfiguration(org.eclipse.cdt.core.build.managed.IConfiguration)
*/
public void setDefaultConfiguration(IConfiguration configuration) {
// Get the target associated with the argument
@ -429,7 +480,7 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IResourceBuildInfo#setDefaultTarget(org.eclipse.cdt.core.build.managed.ITarget)
* @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#setDefaultTarget(org.eclipse.cdt.core.build.managed.ITarget)
*/
public void setDefaultTarget(ITarget target) {
if (defaultTarget != null && defaultTarget.getId().equals(target.getId())) {
@ -438,47 +489,4 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
defaultTarget = target;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IScannerInfo#getDefinedSymbols()
*/
public Map getDefinedSymbols() {
// Return the defined symbols for the default configuration
HashMap symbols = new HashMap();
IConfiguration config = getDefaultConfiguration(getDefaultTarget());
ITool[] tools = config.getTools();
for (int i = 0; i < tools.length; i++) {
ITool tool = tools[i];
IOption[] opts = tool.getOptions();
for (int j = 0; j < opts.length; j++) {
IOption option = opts[j];
if (option.getValueType() == IOption.PREPROCESSOR_SYMBOLS) {
try {
String[] symbolList = option.getDefinedSymbols();
for (int k = 0; k < symbolList.length; k++) {
String symbol = symbolList[k];
if (symbol.length() == 0){
continue;
}
String key = new String();
String value = new String();
int index = symbol.indexOf("=");
if (index != -1) {
key = symbol.substring(0, index).trim();
value = symbol.substring(index + 1).trim();
} else {
key = symbol.trim();
}
symbols.put(key, value);
}
} catch (BuildException e) {
// we should never get here
continue;
}
}
}
}
return symbols;
}
}

View file

@ -26,18 +26,20 @@ import org.eclipse.core.runtime.IConfigurationElement;
*
*/
public class Option extends BuildObject implements IOption {
private ITool tool;
private IOptionCategory category;
private int valueType;
private Object value;
private Map enumCommands;
private String defaultEnumName;
private String command;
private static final String[] EMPTY_STRING_ARRAY = new String[0];
// Static default return values
private static final String EMPTY_STRING = new String();
private static final String[] EMPTY_STRING_ARRAY = new String[0];
// Private bookeeping attributes
private List builtIns;
private IOptionCategory category;
private String command;
private String defaultEnumName;
private Map enumCommands;
private ITool tool;
private Object value;
private int valueType;
public Option(ITool tool) {
this.tool = tool;
@ -103,7 +105,7 @@ public class Option extends BuildObject implements IOption {
enumCommands.put(optName, optCommand);
Boolean isDefault = new Boolean(enumElements[i].getAttribute(IOption.IS_DEFAULT));
if (isDefault.booleanValue()) {
defaultEnumName = optName;
defaultEnumName = optName;
}
}
value = enumList;
@ -113,9 +115,17 @@ public class Option extends BuildObject implements IOption {
case IOption.PREPROCESSOR_SYMBOLS:
case IOption.LIBRARIES:
List valueList = new ArrayList();
builtIns = new ArrayList();
IConfigurationElement[] valueElements = element.getChildren(IOption.LIST_VALUE);
for (int i = 0; i < valueElements.length; ++i) {
valueList.add(valueElements[i].getAttribute(IOption.VALUE));
IConfigurationElement valueElement = valueElements[i];
Boolean isBuiltIn = new Boolean(valueElement.getAttribute(IOption.LIST_ITEM_BUILTIN));
if (isBuiltIn.booleanValue()) {
builtIns.add(valueElement.getAttribute(IOption.LIST_ITEM_VALUE));
}
else {
valueList.add(valueElement.getAttribute(IOption.LIST_ITEM_VALUE));
}
}
value = valueList;
break;
@ -139,6 +149,16 @@ public class Option extends BuildObject implements IOption {
return bool.booleanValue();
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IOption#getBuiltIns()
*/
public String[] getBuiltIns() {
// Return the list of built-ins as an array
return builtIns == null ?
EMPTY_STRING_ARRAY:
(String[])builtIns.toArray(new String[builtIns.size()]);
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IOption#getCategory()
*/

View file

@ -30,6 +30,8 @@ import org.w3c.dom.NodeList;
*/
public class OptionReference implements IOption {
// List of built-in values a tool defines
private List builtIns;
// Used for all option references that override the command
private String command;
// The option this reference overrides
@ -48,6 +50,7 @@ public class OptionReference implements IOption {
public OptionReference(ToolReference owner, IOption option) {
this.owner = owner;
this.option = option;
// Until the option reference is changed, all values will be extracted from original option
owner.addOptionReference(this);
}
@ -84,10 +87,17 @@ public class OptionReference implements IOption {
case IOption.PREPROCESSOR_SYMBOLS:
case IOption.LIBRARIES:
List valueList = new ArrayList();
builtIns = new ArrayList();
IConfigurationElement[] valueElements = element.getChildren(IOption.LIST_VALUE);
for (int i = 0; i < valueElements.length; ++i) {
valueList.add(valueElements[i].getAttribute(IOption.VALUE));
}
IConfigurationElement valueElement = valueElements[i];
Boolean isBuiltIn = new Boolean(valueElement.getAttribute(IOption.LIST_ITEM_BUILTIN));
if (isBuiltIn.booleanValue()) {
builtIns.add(valueElement.getAttribute(IOption.LIST_ITEM_VALUE));
}
else {
valueList.add(valueElement.getAttribute(IOption.LIST_ITEM_VALUE));
} }
value = valueList;
break;
}
@ -119,11 +129,17 @@ public class OptionReference implements IOption {
case IOption.PREPROCESSOR_SYMBOLS:
case IOption.LIBRARIES:
List valueList = new ArrayList();
builtIns = new ArrayList();
NodeList nodes = element.getElementsByTagName(IOption.LIST_VALUE);
for (int i = 0; i < nodes.getLength(); ++i) {
Node node = nodes.item(i);
if (node.getNodeType() == Node.ELEMENT_NODE) {
valueList.add(((Element)node).getAttribute(IOption.VALUE));
Boolean isBuiltIn = new Boolean(((Element)node).getAttribute(IOption.LIST_ITEM_BUILTIN));
if (isBuiltIn.booleanValue()) {
builtIns.add(((Element)node).getAttribute(IOption.LIST_ITEM_VALUE));
} else {
valueList.add(((Element)node).getAttribute(IOption.LIST_ITEM_VALUE));
}
}
}
value = valueList;
@ -158,9 +174,20 @@ public class OptionReference implements IOption {
ListIterator iter = stringList.listIterator();
while (iter.hasNext()) {
Element valueElement = doc.createElement(IOption.LIST_VALUE);
valueElement.setAttribute(IOption.VALUE, (String)iter.next());
valueElement.setAttribute(IOption.LIST_ITEM_VALUE, (String)iter.next());
valueElement.setAttribute(IOption.LIST_ITEM_BUILTIN, "false");
element.appendChild(valueElement);
}
// Serialize the built-ins that have been overridden
if (builtIns != null) {
iter = builtIns.listIterator();
while (iter.hasNext()) {
Element valueElement = doc.createElement(IOption.LIST_VALUE);
valueElement.setAttribute(IOption.LIST_ITEM_VALUE, (String)iter.next());
valueElement.setAttribute(IOption.LIST_ITEM_BUILTIN, "true");
element.appendChild(valueElement);
}
}
break;
}
}
@ -266,6 +293,17 @@ public class OptionReference implements IOption {
}
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IOption#getBuiltIns()
*/
public String[] getBuiltIns() {
// Return any overridden built-ins here, or the default set
// from the option this is a reference to
return builtIns == null ?
option.getBuiltIns():
(String[])builtIns.toArray(new String[builtIns.size()]);
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IOption#getDefaultEnumValue()
*/
@ -371,5 +409,4 @@ public class OptionReference implements IOption {
else
throw new BuildException("bad value type");
}
}

View file

@ -29,9 +29,12 @@ public interface IScannerInfo {
public Map getDefinedSymbols();
/**
* Answers a <code>String</code> array containing all the known include
* search paths. If there are no paths defined, the receiver will
* return an empty array, never <code>null</code>
* Answers a <code>String</code> array containing the union of all the
* built-in include search paths followed by the user-defined include
* search paths.
*
* If there are no paths defined, the receiver will return an empty
* array, never <code>null</code>
*
* @return
*/

View file

@ -166,13 +166,6 @@ Two additional types exist to flag options of special relevance to the build mod
</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>
@ -263,6 +256,11 @@ Two additional types exist to flag options of special relevance to the build mod
</element>
<element name="toolReference">
<annotation>
<documentation>
This is reserved for future use. It currently gets instantiated for saving tool settings.
</documentation>
</annotation>
<complexType>
<sequence>
<element ref="optionReference"/>
@ -437,6 +435,13 @@ Two additional types exist to flag options of special relevance to the build mod
</documentation>
</annotation>
</attribute>
<attribute name="builtIn" type="boolean">
<annotation>
<documentation>
This attribute flags the list value as a built-in value as opposed to something the user has entered. Built-ins will not be passed to clients that generate command lines (like the makefile generator). However, clients that need to take these settings into account (like the indexing service), will receive these settings. These values will appear grey in the UI.
</documentation>
</annotation>
</attribute>
</complexType>
</element>

View file

@ -5,6 +5,22 @@
* src/org/eclipse/cdt/internal/ui/cview/CView.java
* src/org/eclipse/cdt/internal/ui/cview/CViewDragAdapter.java
2003-08-19 Sean Evoy
Switched the property page edit area to a scrolled composite instead of resizing
for large option sets. This actually makes the selection event code simpler.
* build/org/eclipse/cdt/ui/build/properties/BuildPropertyPage.java
I added an accessor method for getting the internal Map in the settings store.
The code was vulnerable because there was never a check to make sure the
Map had been instantiated before use.
* build/org/eclipse/cdt/ui/build/properties/BuildToolsSettingsStore.java
Added some builtin symbols and include paths for the Gnu compilers.
* plugin.xml
Fixed a spelling error in a category name.
* plugin.properties
2003-08-14 Sean Evoy
Added initial toolchain description for Solaris and Linux targets using Gnu tools.
* plugin.xml

View file

@ -33,6 +33,7 @@ import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.SashForm;
import org.eclipse.swt.custom.ScrolledComposite;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Point;
@ -87,7 +88,8 @@ public class BuildPropertyPage extends PropertyPage implements IWorkbenchPropert
private SashForm sashForm;
private Group sashGroup;
private Composite settingsPageContainer;
private ScrolledComposite containerSC;
/*
* Bookeeping variables
*/
@ -150,36 +152,6 @@ public class BuildPropertyPage extends PropertyPage implements IWorkbenchPropert
configToPageListMap = new HashMap();
}
protected void constrainShellSize() {
// limit the shell size to the display size
Shell shell = getShell();
Point size = shell.getSize();
Rectangle bounds = shell.getDisplay().getClientArea();
int newX = Math.min(size.x, bounds.width);
int newY = Math.min(size.y, bounds.height);
if (size.x != newX || size.y != newY)
shell.setSize(newX, newY);
// move the shell origin as required
Point loc = shell.getLocation();
//Choose the position between the origin of the client area and
//the bottom right hand corner
int x =
Math.max(
bounds.x,
Math.min(loc.x, bounds.x + bounds.width - size.x));
int y =
Math.max(
bounds.y,
Math.min(loc.y, bounds.y + bounds.height - size.y));
shell.setLocation(x, y);
// record opening shell size
if (lastShellSize == null)
lastShellSize = getShell().getSize();
}
protected Control createContents(Composite parent) {
// Initialize the key data
targets = ManagedBuildManager.getTargets(getProject());
@ -272,9 +244,17 @@ public class BuildPropertyPage extends PropertyPage implements IWorkbenchPropert
* Add the tabs relevant to the project to edit area tab folder.
*/
protected void createEditArea(Composite parent) {
containerSC = new ScrolledComposite(parent, SWT.H_SCROLL | SWT.V_SCROLL);
containerSC.setExpandHorizontal(true);
containerSC.setExpandVertical(true);
// Add a container for the build settings page
settingsPageContainer = new Composite(parent, SWT.NULL);
settingsPageContainer = new Composite(containerSC, SWT.NULL);
settingsPageContainer.setLayout(new PageLayout());
containerSC.setContent(settingsPageContainer);
containerSC.setMinSize(settingsPageContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT));
settingsPageContainer.layout();
}
protected void createSelectionArea (Composite parent) {
@ -323,36 +303,6 @@ public class BuildPropertyPage extends PropertyPage implements IWorkbenchPropert
currentSettingsPage.createControl(settingsPageContainer);
}
}
// Force calculation of the page's description label because
// label can be wrapped.
Point contentSize = currentSettingsPage.computeSize();
// Do we need resizing. Computation not needed if the
// first page is inserted since computing the dialog's
// size is done by calling dialog.open().
// Also prevent auto resize if the user has manually resized
Shell shell = getShell();
Point shellSize = shell.getSize();
if (oldPage != null) {
Rectangle rect = settingsPageContainer.getClientArea();
Point containerSize = new Point(rect.width, rect.height);
int hdiff = contentSize.x - containerSize.x;
int vdiff = contentSize.y - containerSize.y;
if (hdiff > 0 || vdiff > 0) {
if (shellSize.equals(getLastShellSize())) {
hdiff = Math.max(0, hdiff);
vdiff = Math.max(0, vdiff);
setShellSize(shellSize.x + hdiff, shellSize.y + vdiff);
lastShellSize = shell.getSize();
} else {
currentSettingsPage.setSize(containerSize);
}
} else if (hdiff < 0 || vdiff < 0) {
currentSettingsPage.setSize(containerSize);
}
}
// Make all the other pages invisible
Control[] children = settingsPageContainer.getChildren();
@ -364,6 +314,10 @@ public class BuildPropertyPage extends PropertyPage implements IWorkbenchPropert
currentSettingsPage.setVisible(true);
if (oldPage != null)
oldPage.setVisible(false);
// Set the size of the scrolled area
containerSC.setMinSize(currentSettingsPage.computeSize());
settingsPageContainer.layout();
}
/* (non-Javadoc)
@ -535,18 +489,6 @@ public class BuildPropertyPage extends PropertyPage implements IWorkbenchPropert
handleConfigSelection();
}
/**
* Changes the shell size to the given size, ensuring that
* it is no larger than the display bounds.
*
* @param width the shell width
* @param height the shell height
*/
private void setShellSize(int width, int height) {
getShell().setSize(width, height);
constrainShellSize();
}
/**
* @see org.eclipse.jface.preference.IPreferencePageContainer#updateButtons()
*/

View file

@ -13,6 +13,7 @@ package org.eclipse.cdt.ui.build.properties;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.StringTokenizer;
import org.eclipse.cdt.core.build.managed.BuildException;
@ -30,7 +31,7 @@ public class BuildToolsSettingsStore implements IPreferenceStore {
// List of listeners on the property store
private ListenerList listenerList;
private HashMap optionMap;
private Map optionMap;
private boolean dirtyFlag;
private IConfiguration owner;
@ -55,13 +56,15 @@ public class BuildToolsSettingsStore implements IPreferenceStore {
* @see org.eclipse.jface.preference.IPreferenceStore#contains(java.lang.String)
*/
public boolean contains(String name) {
return optionMap.containsKey(name);
return getOptionMap().containsKey(name);
}
/**
* Answers a <code>String</code> containing the strings passed in the
* argument separated by the DEFAULT_SEPERATOR
*
* @param items An array of strings
* @return a String containing the strings passed in the argument separated by the
* DEFAULT_SEPERATOR
* @return
*/
public static String createList(String[] items) {
StringBuffer path = new StringBuffer(""); //$NON-NLS-1$
@ -95,7 +98,7 @@ public class BuildToolsSettingsStore implements IPreferenceStore {
* @see org.eclipse.jface.preference.IPreferenceStore#getBoolean(java.lang.String)
*/
public boolean getBoolean(String name) {
Object b = optionMap.get(name);
Object b = getOptionMap().get(name);
if (b instanceof Boolean)
{
return ((Boolean)b).booleanValue();
@ -173,6 +176,19 @@ public class BuildToolsSettingsStore implements IPreferenceStore {
return getDefaultLong(name);
}
/* (non-javadoc)
* Answers the map containing the strings associated with each option
* ID.
*
* @return
*/
private Map getOptionMap() {
if (optionMap == null) {
optionMap = new HashMap();
}
return optionMap;
}
private void getOptionsForCategory(IOptionCategory cat) {
IOptionCategory [] children = cat.getChildCategories();
// If there are child categories, add their options
@ -180,9 +196,6 @@ public class BuildToolsSettingsStore implements IPreferenceStore {
getOptionsForCategory(children[i]);
}
// Else get the options for this category and add them to the map
if (optionMap == null) {
optionMap = new HashMap();
}
IOption [] options = cat.getOptions(owner);
for (int j = 0; j < options.length; ++j) {
IOption opt = options[j];
@ -197,12 +210,12 @@ public class BuildToolsSettingsStore implements IPreferenceStore {
// Exception occurs if there's an option value type mismatch
break;
}
optionMap.put(name, value);
getOptionMap().put(name, value);
break;
case IOption.ENUMERATED :
value = createList(opt.getApplicableValues());
optionMap.put(name, value);
getOptionMap().put(name, value);
break;
case IOption.STRING :
@ -211,7 +224,7 @@ public class BuildToolsSettingsStore implements IPreferenceStore {
} catch (BuildException e) {
break;
}
optionMap.put(name, value);
getOptionMap().put(name, value);
break;
case IOption.STRING_LIST :
@ -220,7 +233,7 @@ public class BuildToolsSettingsStore implements IPreferenceStore {
} catch (BuildException e) {
break;
}
optionMap.put(name, value);
getOptionMap().put(name, value);
break;
case IOption.INCLUDE_PATH :
try {
@ -228,7 +241,7 @@ public class BuildToolsSettingsStore implements IPreferenceStore {
} catch (BuildException e) {
break;
}
optionMap.put(name, value);
getOptionMap().put(name, value);
break;
case IOption.PREPROCESSOR_SYMBOLS :
try {
@ -236,7 +249,7 @@ public class BuildToolsSettingsStore implements IPreferenceStore {
} catch (BuildException e) {
break;
}
optionMap.put(name, value);
getOptionMap().put(name, value);
break;
case IOption.LIBRARIES :
try {
@ -244,7 +257,7 @@ public class BuildToolsSettingsStore implements IPreferenceStore {
} catch (BuildException e) {
break;
}
optionMap.put(name, value);
getOptionMap().put(name, value);
break;
default :
break;
@ -256,7 +269,7 @@ public class BuildToolsSettingsStore implements IPreferenceStore {
* @see org.eclipse.jface.preference.IPreferenceStore#getString(java.lang.String)
*/
public String getString(String name) {
Object s = optionMap.get(name);
Object s = getOptionMap().get(name);
if ( s instanceof String )
{
@ -297,7 +310,7 @@ public class BuildToolsSettingsStore implements IPreferenceStore {
for (int index = 0; index < tools.length; ++index) {
ITool tool = tools[index];
IOptionCategory cat = tool.getTopOptionCategory();
getOptionsForCategory(cat);
getOptionsForCategory(cat);
}
}
@ -305,10 +318,10 @@ public class BuildToolsSettingsStore implements IPreferenceStore {
* @see org.eclipse.jface.preference.IPreferenceStore#putValue(java.lang.String, java.lang.String)
*/
public void putValue(String name, String value) {
Object oldValue = optionMap.get(name);
Object oldValue = getOptionMap().get(name);
if (oldValue == null || !oldValue.equals(value))
{
optionMap.put(name, value);
getOptionMap().put(name, value);
setDirty(true);
}
}
@ -397,7 +410,7 @@ public class BuildToolsSettingsStore implements IPreferenceStore {
Object oldValue = getString(name);
if (oldValue == null || !oldValue.equals(value))
{
optionMap.put(name, value);
getOptionMap().put(name, value);
setDirty(true);
firePropertyChangeEvent(name, oldValue, value);
}
@ -410,10 +423,11 @@ public class BuildToolsSettingsStore implements IPreferenceStore {
boolean oldValue = getBoolean(name);
if (oldValue != value)
{
optionMap.put(name, new Boolean(value));
getOptionMap().put(name, new Boolean(value));
setDirty(true);
firePropertyChangeEvent(name, new Boolean(oldValue), new Boolean(value));
}
}
}

View file

@ -97,11 +97,10 @@ ToolName.linker = Linker
OptionCategory.Preproc = Preprocessor
OptionCategory.Dirs = Directories
OptionCategory.General = General
OptionCategory.CLSum = Command Line Summary
OptionCategory.Optimize=Optimization
OptionCategory.Debug=Debugging
OptionCategory.Warn=Warnings
OptionCategory.Misc=Miscelaneous
OptionCategory.Misc=Miscellaneous
OptionCategory.Libs=Libraries
# C/C++ Search

View file

@ -642,15 +642,131 @@
id="cygwin.compiler.category.preprocessor">
</optionCategory>
<option
name="Defined Symbols"
defaultValue="false"
name="Do not search system directories (-nostdinc)"
category="cygwin.compiler.category.preprocessor"
command="-nostdinc"
valueType="boolean"
id="cygwin.gnu.compiler.preprocessor.nostdinc">
</option>
<option
defaultValue="false"
name="Preprocess only (-E)"
category="cygwin.compiler.category.preprocessor"
command="-E"
valueType="boolean"
id="cygwin.gnu.compiler.preprocessor.preprocess">
</option>
<option
name="Answers (-A)"
category="cygwin.compiler.category.preprocessor"
command="-A"
valueType="stringList"
id="cygwin.gnu.preprocessor.answers">
</option>
<optionCategory
owner="org.eclipse.cdt.build.tool.cygwin.compiler"
name="Symbols"
id="cygwin.gnu.compiler.category.symbols">
</optionCategory>
<option
name="Defined symbols (-D)"
category="cygwin.gnu.compiler.category.symbols"
command="-D"
valueType="definedSymbols"
id="cygwin.preprocessor.def.symbols">
<listOptionValue
value="_X86_=1"
builtIn="true">
</listOptionValue>
<listOptionValue
value="__OPTIMIZE__"
builtIn="true">
</listOptionValue>
<listOptionValue
value="__STDC_HOSTED__=1"
builtIn="true">
</listOptionValue>
<listOptionValue
value="i386"
builtIn="true">
</listOptionValue>
<listOptionValue
value="__i386"
builtIn="true">
</listOptionValue>
<listOptionValue
value="__i386__"
builtIn="true">
</listOptionValue>
<listOptionValue
value="__tune_i686__"
builtIn="true">
</listOptionValue>
<listOptionValue
value="__tune_pentiumpro__"
builtIn="true">
</listOptionValue>
<listOptionValue
value="__tune_pentium2__"
builtIn="true">
</listOptionValue>
<listOptionValue
value="__tune_pentium3__"
builtIn="true">
</listOptionValue>
<listOptionValue
value="__stdcall=__attribute__((__stdcall__))"
builtIn="true">
</listOptionValue>
<listOptionValue
value="__fastcall=__attribute__((__fastcall__))"
builtIn="true">
</listOptionValue>
<listOptionValue
value="__cdecl=__attribute__((__cdecl__))"
builtIn="true">
</listOptionValue>
<listOptionValue
value="_stdcall=__attribute__((__stdcall__))"
builtIn="true">
</listOptionValue>
<listOptionValue
value="_fastcall=__attribute__((__fastcall__))"
builtIn="true">
</listOptionValue>
<listOptionValue
value="_cdecl=__attribute__((__cdecl__))"
builtIn="true">
</listOptionValue>
<listOptionValue
value="__declspec(x)=__attribute__((x))"
builtIn="true">
</listOptionValue>
<listOptionValue
value="__CYGWIN32__"
builtIn="true">
</listOptionValue>
<listOptionValue
value="__CYGWIN__"
builtIn="true">
</listOptionValue>
<listOptionValue
value="unix"
builtIn="true">
</listOptionValue>
<listOptionValue
value="__unix__"
builtIn="true">
</listOptionValue>
<listOptionValue
value="__unix"
builtIn="true">
</listOptionValue>
</option>
<option
name="Undefined Symbols"
category="cygwin.compiler.category.preprocessor"
name="Undefined symbols (-U)"
category="cygwin.gnu.compiler.category.symbols"
command="-U"
valueType="stringList"
id="cygwin.preprocessor.undef.symbol">
@ -728,6 +844,10 @@
command="-I"
valueType="includePath"
id="cygwin.compiler.general.include.paths">
<listOptionValue
value="C:\cygwin\usr\include\w32api"
builtIn="true">
</listOptionValue>
</option>
<option
defaultValue="false"
@ -737,16 +857,6 @@
valueType="boolean"
id="cygwin.compiler.general.verbose">
</option>
<optionCategory
owner="org.eclipse.cdt.build.tool.cygwin.compiler"
name="%OptionCategory.CLSum"
id="cygwin.compiler.category.commandline">
</optionCategory>
<option
name="Compiler Command Line"
category="cygwin.compiler.category.commandline"
id="cygwin.compiler.commandline.args">
</option>
</tool>
</target>
<target
@ -795,16 +905,6 @@
valueType="libs"
id="cygwin.link.libs">
</option>
<optionCategory
owner="org.eclipse.cdt.build.tool.cygwin.link"
name="%OptionCategory.CLSum"
id="cygwin.linker.category.commandline">
</optionCategory>
<option
name="Linker Command Line"
category="cygwin.linker.category.commandline"
id="cygwin.linker.commandline.args">
</option>
</tool>
</target>
<target
@ -984,6 +1084,66 @@
command="-D"
valueType="definedSymbols"
id="linux.gnu.compiler.preprocessor.def">
<listOptionValue
value="__ELF__"
builtIn="true">
</listOptionValue>
<listOptionValue
value="unix"
builtIn="true">
</listOptionValue>
<listOptionValue
value="__gnu_linux__"
builtIn="true">
</listOptionValue>
<listOptionValue
value="linux"
builtIn="true">
</listOptionValue>
<listOptionValue
value="__unix__"
builtIn="true">
</listOptionValue>
<listOptionValue
value="__linux__"
builtIn="true">
</listOptionValue>
<listOptionValue
value="__unix"
builtIn="true">
</listOptionValue>
<listOptionValue
value="__linux"
builtIn="true">
</listOptionValue>
<listOptionValue
value="__OPTIMIZE__"
builtIn="true">
</listOptionValue>
<listOptionValue
value="__STDC_HOSTED__=1"
builtIn="true">
</listOptionValue>
<listOptionValue
value="_GNU_SOURCE"
builtIn="true">
</listOptionValue>
<listOptionValue
value="i386"
builtIn="true">
</listOptionValue>
<listOptionValue
value="__i386"
builtIn="true">
</listOptionValue>
<listOptionValue
value="__i386__"
builtIn="true">
</listOptionValue>
<listOptionValue
value="__tune_i386__"
builtIn="true">
</listOptionValue>
</option>
<optionCategory
owner="cdt.build.tool.linux.gnu.compiler"
@ -994,8 +1154,16 @@
name="Include search paths (-I)"
category="linux.gnu.compiler.category.dirs"
command="-I"
valueType="stringList"
valueType="includePath"
id="linux.gnu.compiler.dirs.incpaths">
<listOptionValue
value="/usr/local/include"
builtIn="true">
</listOptionValue>
<listOptionValue
value="/usr/include"
builtIn="true">
</listOptionValue>
</option>
<optionCategory
owner="cdt.build.tool.linux.gnu.compiler"
@ -1441,6 +1609,58 @@
command="-D"
valueType="definedSymbols"
id="solaris.gnu.compiler.preprocessor.def">
<listOptionValue
builtIn="true"
value="sun">
</listOptionValue>
<listOptionValue
builtIn="true"
value="sparc">
</listOptionValue>
<listOptionValue
builtIn="true"
value="unix">
</listOptionValue>
<listOptionValue
builtIn="true"
value="__svr4__">
</listOptionValue>
<listOptionValue
builtIn="true"
value="__SVR4">
</listOptionValue>
<listOptionValue
builtIn="true"
value="__GCC_NEW_VARARGS__">
</listOptionValue>
<listOptionValue
builtIn="true"
value="__sun__">
</listOptionValue>
<listOptionValue
builtIn="true"
value="__sparc__">
</listOptionValue>
<listOptionValue
builtIn="true"
value="__unix__">
</listOptionValue>
<listOptionValue
builtIn="true"
value="__sun">
</listOptionValue>
<listOptionValue
builtIn="true"
value="__sparc">
</listOptionValue>
<listOptionValue
builtIn="true"
value="__unix">
</listOptionValue>
<listOptionValue
builtIn="true"
value="__OPTIMIZE__">
</listOptionValue>
</option>
<optionCategory
owner="cdt.build.tool.solaris.gnu.compiler"
@ -1451,8 +1671,16 @@
name="Include search paths (-I)"
category="solaris.gnu.compiler.category.dirs"
command="-I"
valueType="stringList"
valueType="includePath"
id="solaris.gnu.compiler.dirs.incpaths">
<listOptionValue
value="/usr/local/include"
builtIn="true">
</listOptionValue>
<listOptionValue
builtIn="true"
value="/usr/include">
</listOptionValue>
</option>
<optionCategory
owner="cdt.build.tool.solaris.gnu.compiler"