Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDoug Schaefer2003-08-20 13:52:32 -0400
committerDoug Schaefer2003-08-20 13:52:32 -0400
commitcc710063b44a0d6ca4702f2fbbb1dfbe4e3f384e (patch)
tree87ed578768ea424d28943d5216d5fda8c1ae2034 /core/org.eclipse.cdt.core/build
parent5fd96de2e53d63d1ebd12fead0c8d4dd7df4f281 (diff)
downloadorg.eclipse.cdt-cc710063b44a0d6ca4702f2fbbb1dfbe4e3f384e.tar.gz
org.eclipse.cdt-cc710063b44a0d6ca4702f2fbbb1dfbe4e3f384e.tar.xz
org.eclipse.cdt-cc710063b44a0d6ca4702f2fbbb1dfbe4e3f384e.zip
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.
Diffstat (limited to 'core/org.eclipse.cdt.core/build')
-rw-r--r--core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/build/managed/IOption.java17
-rw-r--r--core/org.eclipse.cdt.core/build/org/eclipse/cdt/internal/core/build/managed/ManagedBuildInfo.java126
-rw-r--r--core/org.eclipse.cdt.core/build/org/eclipse/cdt/internal/core/build/managed/Option.java40
-rw-r--r--core/org.eclipse.cdt.core/build/org/eclipse/cdt/internal/core/build/managed/OptionReference.java47
4 files changed, 154 insertions, 76 deletions
diff --git a/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/build/managed/IOption.java b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/build/managed/IOption.java
index 006044796e..496a2ace23 100644
--- a/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/build/managed/IOption.java
+++ b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/build/managed/IOption.java
@@ -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.
diff --git a/core/org.eclipse.cdt.core/build/org/eclipse/cdt/internal/core/build/managed/ManagedBuildInfo.java b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/internal/core/build/managed/ManagedBuildInfo.java
index 2b4addc6bc..66a70cff94 100644
--- a/core/org.eclipse.cdt.core/build/org/eclipse/cdt/internal/core/build/managed/ManagedBuildInfo.java
+++ b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/internal/core/build/managed/ManagedBuildInfo.java
@@ -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;
- }
-
}
diff --git a/core/org.eclipse.cdt.core/build/org/eclipse/cdt/internal/core/build/managed/Option.java b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/internal/core/build/managed/Option.java
index e3e5cd5956..c0fa51a4c9 100644
--- a/core/org.eclipse.cdt.core/build/org/eclipse/cdt/internal/core/build/managed/Option.java
+++ b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/internal/core/build/managed/Option.java
@@ -26,18 +26,20 @@ import org.eclipse.core.runtime.IConfigurationElement;
*
*/
public class Option extends BuildObject implements IOption {
+ // Static default return values
+ private static final String EMPTY_STRING = new String();
+ private static final String[] EMPTY_STRING_ARRAY = new String[0];
- private ITool tool;
+ // Private bookeeping attributes
+ private List builtIns;
private IOptionCategory category;
-
- private int valueType;
- private Object value;
- private Map enumCommands;
- private String defaultEnumName;
private String command;
+ private String defaultEnumName;
+ private Map enumCommands;
+ private ITool tool;
+ private Object value;
+ private int valueType;
- private static final String[] EMPTY_STRING_ARRAY = new String[0];
- private static final String EMPTY_STRING = new String();
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;
@@ -140,6 +150,16 @@ public class Option extends BuildObject implements IOption {
}
/* (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()
*/
public IOptionCategory getCategory() {
diff --git a/core/org.eclipse.cdt.core/build/org/eclipse/cdt/internal/core/build/managed/OptionReference.java b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/internal/core/build/managed/OptionReference.java
index f1c1549242..e52d5e829d 100644
--- a/core/org.eclipse.cdt.core/build/org/eclipse/cdt/internal/core/build/managed/OptionReference.java
+++ b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/internal/core/build/managed/OptionReference.java
@@ -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;
}
}
@@ -267,6 +294,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()
*/
public String getSelectedEnum() throws BuildException {
@@ -371,5 +409,4 @@ public class OptionReference implements IOption {
else
throw new BuildException("bad value type");
}
-
}

Back to the top