Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSean Evoy2004-06-23 15:21:42 -0400
committerSean Evoy2004-06-23 15:21:42 -0400
commit687d76251710a95ddf1a41c3c66ef0c4ad7d1982 (patch)
tree5360884e0e59d08285dd5d30882f5b9ca2d408ea /build/org.eclipse.cdt.managedbuilder.core
parent3783f1b7be1539ac0ba2299da955d8526e74a498 (diff)
downloadorg.eclipse.cdt-687d76251710a95ddf1a41c3c66ef0c4ad7d1982.tar.gz
org.eclipse.cdt-687d76251710a95ddf1a41c3c66ef0c4ad7d1982.tar.xz
org.eclipse.cdt-687d76251710a95ddf1a41c3c66ef0c4ad7d1982.zip
Fix for bug 66739 - Created a shared lib project does not set shared flag in configs. There was a gap in the ever-increasingly complex inheritance behaviour of the ToolReferences. The commands supplied by the ToolReferences were being ignored if the configuration supplied its own ToolReferences. Searching is more comprehensive now, the tool reference is creating a copy of itself more thoroughly, and the JUnit tests have been updated to reflect this.
Diffstat (limited to 'build/org.eclipse.cdt.managedbuilder.core')
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ITool.java5
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Configuration.java54
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Target.java2
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ToolReference.java57
4 files changed, 92 insertions, 26 deletions
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ITool.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ITool.java
index 74764229969..e0f7b7889b3 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ITool.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ITool.java
@@ -72,8 +72,9 @@ public interface ITool extends IBuildObject {
/**
* This is a deprecated method for retrieving an <code>IOption</code> from
- * the receiver based on an ID. It is preferred that you use the newer method
- * @see org.eclipse.cdt.core.build.managed.ITool#getOption(java.lang.String)
+ * the receiver based on an ID. It is preferred that you use the newer method
+ * <code>getOptionById</code>
+ * @see org.eclipse.cdt.core.build.managed.ITool#getOptionById(java.lang.String)
*
* @param id unique identifier of the option to search for
* @return <code>IOption</code>
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Configuration.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Configuration.java
index e1f0ac094e7..4b2d76b3371 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Configuration.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Configuration.java
@@ -104,9 +104,10 @@ public class Configuration extends BuildObject implements IConfiguration {
// Check that the tool and the project match
IProject project = (IProject) target.getOwner();
- // Get the tool references from the parent
- List parentToolRefs = ((Configuration)parentConfig).getLocalToolReferences();
- Iterator iter = parentToolRefs.listIterator();
+ // Get the tool references from the target and parent
+ List allToolRefs = new Vector(target.getLocalToolReferences());
+ allToolRefs.addAll(((Configuration)parentConfig).getLocalToolReferences());
+ Iterator iter = allToolRefs.listIterator();
while (iter.hasNext()) {
ToolReference toolRef = (ToolReference)iter.next();
@@ -231,33 +232,58 @@ public class Configuration extends BuildObject implements IConfiguration {
* @return
*/
private OptionReference createOptionReference(IOption option) {
+ ToolReference searchRef = null;
+ ToolReference answer = null;
// The option may already be a reference created to hold user settings
if (option instanceof OptionReference) {
// The option reference belongs to an existing tool reference
OptionReference optionRef = (OptionReference)option;
- ToolReference toolRef = optionRef.getToolReference();
+ searchRef = optionRef.getToolReference();
+
// That tool reference may belong to a target or to the configuration
- if (toolRef.ownedByConfiguration(this))
+ if (searchRef.ownedByConfiguration(this))
return optionRef;
else {
- // Make a copy so the settings can be saved
- toolRef = new ToolReference(this, toolRef);
- return toolRef.createOptionReference(option);
+ // All this means is that the tool ref does not belong to the receiver.
+ // The receiver may also have a reference to the tool
+ if ((answer = findLocalReference(searchRef)) == null) {
+ // Otherwise, create one and save the option setting in it
+ answer = new ToolReference(this, searchRef);
+ }
+ return answer.createOptionReference(option);
}
} else {
// Find out if a tool reference already exists
- ToolReference toolRef = (ToolReference) getToolReference(option.getTool());
- if (toolRef == null) {
- toolRef = new ToolReference(this, option.getTool());
+ searchRef = (ToolReference) getToolReference(option.getTool());
+ if (searchRef == null) {
+ answer = new ToolReference(this, option.getTool());
} else {
// The reference may belong to the target
- if (!toolRef.ownedByConfiguration(this)) {
- toolRef = new ToolReference(this, toolRef);
+ if (!searchRef.ownedByConfiguration(this)) {
+ answer = new ToolReference(this, searchRef);
+ } else {
+ answer = searchRef;
}
}
+ return answer.createOptionReference(option);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @param toolRef
+ * @return
+ */
+ private ToolReference findLocalReference(ToolReference toolRef) {
+ Iterator iter = getLocalToolReferences().iterator();
- return toolRef.createOptionReference(option);
+ while (iter.hasNext()) {
+ ToolReference ref = (ToolReference)iter.next();
+ if (toolRef.getTool().equals(ref.getTool())) {
+ return ref;
+ }
}
+
+ return null;
}
/* (non-Javadoc)
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Target.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Target.java
index cfadb475490..d02ee97bf90 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Target.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Target.java
@@ -502,7 +502,7 @@ public class Target extends BuildObject implements ITarget {
*
* @return List
*/
- private List getLocalToolReferences() {
+ protected List getLocalToolReferences() {
if (toolReferences == null) {
toolReferences = new ArrayList();
}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ToolReference.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ToolReference.java
index 37c59a48a6f..f36cb2a77d7 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ToolReference.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ToolReference.java
@@ -24,6 +24,7 @@ import org.eclipse.cdt.managedbuilder.core.IOptionCategory;
import org.eclipse.cdt.managedbuilder.core.ITool;
import org.eclipse.cdt.managedbuilder.core.IToolReference;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
+import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
@@ -149,15 +150,19 @@ public class ToolReference implements IToolReference {
* Created a tool reference on the fly based on an existing tool or tool reference.
*
* @param owner The <code>BuildObject</code> the receiver will be added to.
- * @param parent The <code>ITool</code>tool the reference will be based on.
+ * @param tool The <code>ITool</code>tool the reference will be based on.
*/
- public ToolReference(BuildObject owner, ITool parent) {
- this.parent = parent;
+ public ToolReference(BuildObject owner, ITool tool) {
this.owner = owner;
- command = parent.getToolCommand();
- outputFlag = parent.getOutputFlag();
- outputPrefix = parent.getOutputPrefix();
- String[] extensions = parent.getOutputExtensions();
+ if (tool instanceof ToolReference) {
+ parent = ((ToolReference)tool).getTool();
+ } else {
+ parent = tool;
+ }
+ command = tool.getToolCommand();
+ outputFlag = tool.getOutputFlag();
+ outputPrefix = tool.getOutputPrefix();
+ String[] extensions = tool.getOutputExtensions();
outputExtensions = new String();
if (extensions != null) {
for (int index = 0; index < extensions.length; ++index) {
@@ -169,6 +174,34 @@ public class ToolReference implements IToolReference {
}
}
+ // Create a copy of the option references of the parent in the receiver
+ if (tool instanceof ToolReference) {
+ List parentRefs = ((ToolReference)tool).getOptionReferenceList();
+ Iterator iter = parentRefs.iterator();
+ while (iter.hasNext()) {
+ IOption parent = (IOption)iter.next();
+ OptionReference clone = createOptionReference(parent);
+ try {
+ switch (parent.getValueType()) {
+ case IOption.BOOLEAN:
+ clone.setValue(parent.getBooleanValue());
+ break;
+ case IOption.STRING:
+ clone.setValue(parent.getStringValue());
+ case IOption.ENUMERATED:
+ clone.setValue(parent.getSelectedEnum());
+ break;
+ default:
+ clone.setValue(parent.getStringListValue());
+ break;
+ }
+ } catch (BuildException e) {
+ ManagedBuilderCorePlugin.log(e);
+ continue;
+ }
+ }
+ }
+
if (owner instanceof Configuration) {
((Configuration)owner).addToolReference(this);
} else if (owner instanceof Target) {
@@ -250,7 +283,14 @@ public class ToolReference implements IToolReference {
public OptionReference createOptionReference(IOption option) {
// Check if the option reference already exists
OptionReference ref = getOptionReference(option);
- if (ref == null) {
+ // It is possible that the search will return an option reference
+ // that is supplied by another element of the build model, not the caller.
+ // For example, if the search is starated by a configuration and the target
+ // the caller belongs to has an option reference for the option, it
+ // will be returned. While this is correct behaviour for a search, the
+ // caller will need to create a clone for itself, so make sure the tool
+ // reference of the search result is owned by the caller
+ if (ref == null || !ref.getToolReference().owner.equals(this.owner)) {
ref = new OptionReference(this, option);
}
return ref;
@@ -504,7 +544,6 @@ public class ToolReference implements IToolReference {
public List getOptionReferenceList() {
if (optionReferences == null) {
optionReferences = new ArrayList();
- optionReferences.clear();
}
return optionReferences;
}

Back to the top