1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-23 17:05:26 +02:00

Committing the changes needed by our partners to better support a variety of tool references. A class hierarchy of tool references has been introduced. The base class is an abstract tool reference. Unqualified tool references, like those used in the manifest or project files will be continue to be treated as tool references. However, we now have some flexibility for the future should a more refined type of tool reference be needed; for example, a dynamic tool that reads a configuration file to determine what environment it is targetting.

This commit is contained in:
Sean Evoy 2004-03-08 16:42:21 +00:00
parent 7ddc725965
commit 6bd526e1b6
8 changed files with 170 additions and 126 deletions

View file

@ -1,3 +1,13 @@
2004-03-08 Sean Evoy
Committing the changes needed by our partners to better support a variety
of tool references. A class hierarchy of tool references has been introduced.
The base class is an abstract tool reference. Unqualified tool references,
like those used in the manifest or project files will be continue to be
treated as tool references. However, we now have some flexibility for the
future should a more refined type of tool reference be needed; for example,
a dynamic tool that reads a configuration file to determine what environment
it is targetting.
2004-03-05 Sean Evoy
Fix for bug 53856: "Option reference not reporting built-in includes
paths to scanner"

View file

@ -0,0 +1,103 @@
package org.eclipse.cdt.managedbuilder.core;
/**********************************************************************
* Copyright (c) 2004 TimeSys Corporation and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* TimeSys Corporation - initial API and implementation
**********************************************************************/
public abstract class AbstractToolReference implements IToolReference {
protected ITool parent;
public AbstractToolReference() {
}
public AbstractToolReference(ITool parent) {
this.parent = parent;
}
public boolean references(ITool target) {
if (equals(target)) {
// we are the target
return true;
}
else if (parent instanceof IToolReference) {
// check the reference we are overriding
return ((IToolReference)parent).references(target);
}
else if (target instanceof IToolReference) {
return parent.equals(((IToolReference)target).getTool());
}
else {
// the real reference
return parent.equals(target);
}
}
public ITool getTool() {
return parent;
}
public boolean buildsFileType(String extension) {
return parent.buildsFileType(extension);
}
public int getNatureFilter() {
return parent.getNatureFilter();
}
public IOption getOption(String id) {
return parent.getOption(id);
}
public IOption[] getOptions() {
return parent.getOptions();
}
public String getOutputExtension(String inputExtension) {
return parent.getOutputExtension(inputExtension);
}
public String getOutputFlag() {
return parent.getOutputFlag();
}
public String getOutputPrefix() {
return parent.getOutputPrefix();
}
public String getToolCommand() {
return parent.getToolCommand();
}
public String getToolFlags() throws BuildException {
return parent.getToolFlags();
}
public IOptionCategory getTopOptionCategory() {
return parent.getTopOptionCategory();
}
public boolean isHeaderFile(String ext) {
return parent.isHeaderFile(ext);
}
public boolean producesFileType(String outputExtension) {
return parent.producesFileType(outputExtension);
}
public String getId() {
return parent.getId();
}
public String getName() {
return parent.getName();
}
}

View file

@ -149,6 +149,14 @@ public interface ITarget extends IBuildObject {
*/
public ITool[] getTools();
/**
* Answers the tool in the receiver with the ID specified in the argument,
* or <code>null</code>
*
* @param id
* @return
*/
public ITool getTool(String id);
/**
* Answers true if the receiver has a make command that differs from its

View file

@ -0,0 +1,31 @@
/**********************************************************************
* Copyright (c) 2004 TimeSys Corporation and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* TimeSys Corporation - initial API and implementation
**********************************************************************/
package org.eclipse.cdt.managedbuilder.core;
public interface IToolReference extends ITool {
/**
* Answers <code>true</code> if the reference is a reference to the
* tool specified in the argument.
*
* @param target the tool that should be tested
* @return boolean
*/
public boolean references(ITool tool);
/**
* Answers the tool that the reference has been created for.
*
* @return
*/
public ITool getTool();
}

View file

@ -17,6 +17,7 @@ import org.eclipse.cdt.managedbuilder.core.IConfiguration;
import org.eclipse.cdt.managedbuilder.core.IOption;
import org.eclipse.cdt.managedbuilder.core.IOptionCategory;
import org.eclipse.cdt.managedbuilder.core.ITool;
import org.eclipse.cdt.managedbuilder.core.IToolReference;
import org.eclipse.core.runtime.IConfigurationElement;
/**
@ -95,8 +96,8 @@ public class OptionCategory extends BuildObject implements IOptionCategory {
// TODO don't like this much
ITool[] tools = configuration.getTools();
for (int i = 0; i < tools.length; ++i) {
if (tools[i] instanceof ToolReference) {
if (((ToolReference)tools[i]).references(tool)) {
if (tools[i] instanceof IToolReference) {
if (((IToolReference)tools[i]).references(tool)) {
tool = tools[i];
break;
}

View file

@ -475,9 +475,8 @@ public class Target extends BuildObject implements ITarget {
|| (makeArguments != null && !makeArguments.equals(parent.getMakeArguments())));
}
/**
* @param id
* @return ITool
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.ITarget#getTool(java.lang.String)
*/
public ITool getTool(String id) {
ITool result = null;

View file

@ -22,6 +22,7 @@ import org.eclipse.cdt.managedbuilder.core.IConfiguration;
import org.eclipse.cdt.managedbuilder.core.IOption;
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.core.runtime.IConfigurationElement;
@ -267,8 +268,8 @@ public class Tool extends BuildObject implements ITool, IOptionCategory {
// TODO don't like this much
ITool[] tools = configuration.getTools();
for (int i = 0; i < tools.length; ++i) {
if (tools[i] instanceof ToolReference) {
if (((ToolReference)tools[i]).references(tool)) {
if (tools[i] instanceof IToolReference) {
if (((IToolReference)tools[i]).references(tool)) {
tool = tools[i];
break;
}

View file

@ -14,11 +14,11 @@ import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.eclipse.cdt.managedbuilder.core.AbstractToolReference;
import org.eclipse.cdt.managedbuilder.core.BuildException;
import org.eclipse.cdt.managedbuilder.core.IBuildObject;
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
import org.eclipse.cdt.managedbuilder.core.IOption;
import org.eclipse.cdt.managedbuilder.core.IOptionCategory;
import org.eclipse.cdt.managedbuilder.core.ITool;
import org.eclipse.core.runtime.IConfigurationElement;
import org.w3c.dom.Document;
@ -26,11 +26,10 @@ import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
public class ToolReference implements ITool {
public class ToolReference extends AbstractToolReference {
private String command;
private List optionReferences;
private IBuildObject owner;
private ITool parent;
/**
* Create a new tool reference based on information contained in
@ -44,11 +43,15 @@ public class ToolReference implements ITool {
this.owner = owner;
if (owner instanceof Configuration) {
Target parentTarget = (Target) ((Configuration)owner).getTarget();
parent = ((Target)parentTarget.getParent()).getTool(element.getAttribute(ID));
if (parent == null) {
Target parentTarget = (Target) ((Configuration)owner).getTarget();
parent = ((Target)parentTarget.getParent()).getTool(element.getAttribute(ID));
}
((Configuration)owner).addToolReference(this);
} else if (owner instanceof Target) {
parent = ((Target)((Target)owner).getParent()).getTool(element.getAttribute(ID));
if (parent == null) {
parent = ((Target)((Target)owner).getParent()).getTool(element.getAttribute(ID));
}
((Target)owner).addToolReference(this);
}
@ -99,8 +102,8 @@ public class ToolReference implements ITool {
* @param parent The <code>ITool</code>tool the reference will be based on.
*/
public ToolReference(BuildObject owner, ITool parent) {
super(parent);
this.owner = owner;
this.parent = parent;
if (owner instanceof Configuration) {
((Configuration)owner).addToolReference(this);
@ -118,14 +121,6 @@ public class ToolReference implements ITool {
getOptionReferenceList().add(optionRef);
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.ITool#handlesFileType(java.lang.String)
*/
public boolean buildsFileType(String extension) {
// The tool reference does not override this value
return parent.buildsFileType(extension);
}
/**
* Answers a reference to the option. If the reference does not exist,
* a new reference is created.
@ -142,15 +137,6 @@ public class ToolReference implements ITool {
return ref;
}
/**
* Answers the tool the receiver is a reference to.
*
* @return
*/
public ITool getTool() {
return parent;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.ITool#getToolCommand()
*/
@ -240,58 +226,11 @@ public class ToolReference implements ITool {
return options;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.ITool#getOutputFlag()
*/
public String getOutputFlag() {
// The tool reference does not override this value
return parent.getOutputFlag();
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.ITool#getOutputPrefix()
*/
public String getOutputPrefix() {
// The tool reference does not override this value
return parent.getOutputPrefix();
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.ITool#getTopOptionCategory()
*/
public IOptionCategory getTopOptionCategory() {
return parent.getTopOptionCategory();
}
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.ITool#isHeaderFile(java.lang.String)
*/
public boolean isHeaderFile(String ext) {
// The tool reference does not override this value
return parent.isHeaderFile(ext);
}
protected List getAllOptionRefs() {
// First get all the option references this tool reference contains
return ((Configuration)owner).getOptionReferences(parent);
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IBuildObject#getId()
*/
public String getId() {
// The tool reference does not override this value
return parent.getId();
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IBuildObject#getName()
*/
public String getName() {
// The tool reference does not override this value
return parent.getName();
}
/* (non-javadoc)
* Answers an option reference that overrides the option, or <code>null</code>
*
@ -318,13 +257,6 @@ public class ToolReference implements ITool {
return optionReferences;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.ITool#getNatureFilter()
*/
public int getNatureFilter() {
// The tool reference does not override this value
return parent.getNatureFilter();
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.ITool#getOption(java.lang.String)
@ -334,14 +266,6 @@ public class ToolReference implements ITool {
return null;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.ITool#getOutput(java.lang.String)
*/
public String getOutputExtension(String inputExtension) {
// The tool reference does not override this value
return parent.getOutputExtension(inputExtension);
}
/**
* Answers <code>true</code> if the owner of the receiver matches
* the argument.
@ -356,39 +280,6 @@ public class ToolReference implements ITool {
return false;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.ITool#producesFileType(java.lang.String)
*/
public boolean producesFileType(String outputExtension) {
// The tool reference does not override this value
return parent.producesFileType(outputExtension);
}
/**
* Answers <code>true</code> if the reference is a reference to the
* tool specified in the argument.
*
* @param target the tool that should be tested
* @return boolean
*/
public boolean references(ITool target) {
if (equals(target)) {
// we are the target
return true;
}
else if (parent instanceof ToolReference) {
// check the reference we are overriding
return ((ToolReference)parent).references(target);
}
else if (target instanceof ToolReference) {
return parent.equals(((ToolReference)target).parent);
}
else {
// the real reference
return parent.equals(target);
}
}
/**
* Persist receiver to project file.
*