Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDoug Schaefer2003-07-25 13:31:01 -0400
committerDoug Schaefer2003-07-25 13:31:01 -0400
commit3a2ed3957a53250c08f7c378f74506da58999e8a (patch)
treeff12cd8c2dc592e85b11bbf4e960f340c093b127 /core/org.eclipse.cdt.core/build
parent1be03f5cfc276d79dfbae867efe75e8e84276328 (diff)
downloadorg.eclipse.cdt-3a2ed3957a53250c08f7c378f74506da58999e8a.tar.gz
org.eclipse.cdt-3a2ed3957a53250c08f7c378f74506da58999e8a.tar.xz
org.eclipse.cdt-3a2ed3957a53250c08f7c378f74506da58999e8a.zip
Patch for Sean Evoy:
- I added the ability to build when there are inter-project dependencies (first iteration; I would like to try another way). There is also some changes to how libraries are handled. Change logs describe the changes and the AllBuildTests has been updated to reflect these changes.
Diffstat (limited to 'core/org.eclipse.cdt.core/build')
-rw-r--r--core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/build/managed/IManagedBuildInfo.java25
-rw-r--r--core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/build/managed/IOption.java9
-rw-r--r--core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/build/managed/ITool.java17
-rw-r--r--core/org.eclipse.cdt.core/build/org/eclipse/cdt/internal/core/build/managed/ManagedBuildInfo.java68
-rw-r--r--core/org.eclipse.cdt.core/build/org/eclipse/cdt/internal/core/build/managed/Option.java19
-rw-r--r--core/org.eclipse.cdt.core/build/org/eclipse/cdt/internal/core/build/managed/OptionReference.java20
-rw-r--r--core/org.eclipse.cdt.core/build/org/eclipse/cdt/internal/core/build/managed/Tool.java26
-rw-r--r--core/org.eclipse.cdt.core/build/org/eclipse/cdt/internal/core/build/managed/ToolReference.java15
8 files changed, 187 insertions, 12 deletions
diff --git a/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/build/managed/IManagedBuildInfo.java b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/build/managed/IManagedBuildInfo.java
index baf3146f5c..dd3640b0d6 100644
--- a/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/build/managed/IManagedBuildInfo.java
+++ b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/build/managed/IManagedBuildInfo.java
@@ -80,12 +80,13 @@ public interface IManagedBuildInfo {
/**
* Answers the flag to be passed to the build tool to produce a specific output
* or an empty <code>String</code> if there is no special flag. For example, the
- * GCC tools use the -o flag to produce a named output, for example
+ * GCC tools use the '-o' flag to produce a named output, for example
* gcc -c foo.c -o foo.o
*
+ * @param outputExt
* @return
*/
- public String getOutputFlag();
+ public String getOutputFlag(String outputExt);
/**
* Get the target specified in the argument.
@@ -96,6 +97,16 @@ public interface IManagedBuildInfo {
public ITarget getTarget(String id);
/**
+ * Answers the prefix that should be prepended to the name of the build
+ * artifact. For example, a library foo, should have the prefix 'lib' and
+ * the extension '.a', so the final goal would be 'libfoo.a'
+ *
+ * @param extension
+ * @return
+ */
+ public String getOutputPrefix(String outputExtension);
+
+ /**
* Get all of the targets associated with the receiver.
*
* @return
@@ -123,6 +134,14 @@ public interface IManagedBuildInfo {
public String getFlagsForTarget(String extension);
/**
+ * Answers the libraries the project links in.
+ *
+ * @param extension
+ * @return
+ */
+ public String[] getLibsForTarget(String extension);
+
+ /**
* Answers a string array containing the arguments to be passed to
* make. For example, if the user has selected a build that stops
* at the first error, the array would contain {"k"}.
@@ -170,6 +189,4 @@ public interface IManagedBuildInfo {
*/
public void setDefaultTarget(ITarget target);
-
-
}
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 2e442ea3dd..c4042236d2 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
@@ -21,6 +21,7 @@ public interface IOption extends IBuildObject {
public static final int STRING_LIST = 3;
public static final int INCLUDE_PATH = 4;
public static final int PREPROCESSOR_SYMBOLS = 5;
+ public static final int LIBRARIES = 6;
/**
* If this option is defined as an enumeration, this function returns
@@ -81,6 +82,13 @@ public interface IOption extends IBuildObject {
/**
+ * Answers an array or <code>String</code>s containing the libraries
+ * that must be linked into the project.
+ * @return
+ */
+ public String[] getLibraries() throws BuildException ;
+
+ /**
* Answers a <code>String</code> containing the selected enumeration in an
* enumerated option. For an option that has not been changed by the user,
* the receiver will answer with the default defined in the plugin manifest.
@@ -121,4 +129,5 @@ public interface IOption extends IBuildObject {
* @return
*/
public int getValueType();
+
}
diff --git a/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/build/managed/ITool.java b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/build/managed/ITool.java
index 89751c5d8e..e7cef1c63c 100644
--- a/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/build/managed/ITool.java
+++ b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/build/managed/ITool.java
@@ -48,6 +48,22 @@ public interface ITool extends IBuildObject {
public String getOutputExtension(String inputExtension);
/**
+ * Answers the argument that must be passed to a specific tool in order to
+ * control the name of the output artifact. For example, the GCC compile and
+ * linker use '-o', while the archiver does not.
+ *
+ * @return
+ */
+ public String getOutputFlag();
+
+ /**
+ * Answers the prefix that the tool should prepend to the name of the build artifact.
+ * For example, a librarian usually prepends 'lib' to the target.a
+ * @return
+ */
+ public String getOutputPrefix();
+
+ /**
* Return the target that defines this tool, if applicable
* @return
*/
@@ -85,5 +101,6 @@ public interface ITool extends IBuildObject {
* @return
*/
public boolean producesFileType(String outputExtension);
+
}
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 3f6f451d67..4aa43626f6 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
@@ -229,6 +229,40 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
}
/* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#getLibsForTarget(java.lang.String)
+ */
+ public String[] getLibsForTarget(String extension) {
+ ArrayList libs = new ArrayList();
+ // Get all the tools for the current config
+ IConfiguration config = getDefaultConfiguration(getDefaultTarget());
+ ITool[] tools = config.getTools();
+ for (int index = 0; index < tools.length; index++) {
+ ITool tool = tools[index];
+ if (tool.producesFileType(extension)) {
+ IOption[] opts = tool.getOptions();
+ // Look for the lib option type
+ for (int i = 0; i < opts.length; i++) {
+ IOption option = opts[i];
+ if (option.getValueType() == IOption.LIBRARIES) {
+ try {
+ String command = option.getCommand();
+ String[] allLibs = option.getLibraries();
+ for (int j = 0; j < allLibs.length; j++) {
+ String string = allLibs[j];
+ libs.add(command + string);
+ }
+ } catch (BuildException e) {
+ continue;
+ }
+ }
+ }
+ }
+ }
+ libs.trimToSize();
+ return (String[])libs.toArray(new String[libs.size()]);
+ }
+
+ /* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#getMakeArguments()
*/
public String[] getMakeArguments() {
@@ -266,10 +300,35 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#getOutputFlag()
*/
- public String getOutputFlag() {
- // TODO Stop hard-coding this
- String flag = new String("-o");
- return flag;
+ public String getOutputFlag(String outputExt) {
+ // Get all the tools for the current config
+ String flags = new String();
+ IConfiguration config = getDefaultConfiguration(getDefaultTarget());
+ ITool[] tools = config.getTools();
+ for (int index = 0; index < tools.length; index++) {
+ ITool tool = tools[index];
+ if (tool.producesFileType(outputExt)) {
+ flags = tool.getOutputFlag();
+ }
+ }
+ return flags;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#getOutputPrefix(java.lang.String)
+ */
+ public String getOutputPrefix(String outputExtension) {
+ // Get all the tools for the current config
+ String flags = new String();
+ IConfiguration config = getDefaultConfiguration(getDefaultTarget());
+ ITool[] tools = config.getTools();
+ for (int index = 0; index < tools.length; index++) {
+ ITool tool = tools[index];
+ if (tool.producesFileType(outputExtension)) {
+ flags = tool.getOutputPrefix();
+ }
+ }
+ return flags;
}
public IResource getOwner() {
@@ -406,5 +465,4 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
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 d9209a9c2a..17a7cbfef3 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
@@ -77,6 +77,8 @@ public class Option extends BuildObject implements IOption {
valueType = IOption.ENUMERATED;
else if (valueTypeStr.equals("includePath"))
valueType = IOption.INCLUDE_PATH;
+ else if (valueTypeStr.equals("libs"))
+ valueType = IOption.LIBRARIES;
else
valueType = IOption.PREPROCESSOR_SYMBOLS;
@@ -109,6 +111,7 @@ public class Option extends BuildObject implements IOption {
case IOption.STRING_LIST:
case IOption.INCLUDE_PATH:
case IOption.PREPROCESSOR_SYMBOLS:
+ case IOption.LIBRARIES:
List valueList = new ArrayList();
IConfigurationElement[] valueElements = element.getChildren("optionValue");
for (int i = 0; i < valueElements.length; ++i) {
@@ -185,6 +188,19 @@ public class Option extends BuildObject implements IOption {
}
/* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IOption#getLibraries()
+ */
+ public String[] getLibraries() throws BuildException {
+ if (valueType != IOption.LIBRARIES) {
+ throw new BuildException("bad value type");
+ }
+ List v = (List)value;
+ return v != null
+ ? (String[])v.toArray(new String[v.size()])
+ : EMPTY_STRING_ARRAY;
+ }
+
+ /* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IOption#getDefaultEnumValue()
*/
public String getSelectedEnum() throws BuildException {
@@ -265,7 +281,8 @@ public class Option extends BuildObject implements IOption {
{
if (valueType != IOption.STRING_LIST
|| valueType != IOption.INCLUDE_PATH
- || valueType != IOption.PREPROCESSOR_SYMBOLS)
+ || valueType != IOption.PREPROCESSOR_SYMBOLS
+ || valueType != IOption.LIBRARIES)
throw new BuildException("Bad value for type");
if (config == null) {
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 0228a7408d..e4db4b0530 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
@@ -82,6 +82,7 @@ public class OptionReference implements IOption {
case IOption.STRING_LIST:
case IOption.INCLUDE_PATH:
case IOption.PREPROCESSOR_SYMBOLS:
+ case IOption.LIBRARIES:
List valueList = new ArrayList();
IConfigurationElement[] valueElements = element.getChildren("optionValue");
for (int i = 0; i < valueElements.length; ++i) {
@@ -116,6 +117,7 @@ public class OptionReference implements IOption {
case IOption.STRING_LIST:
case IOption.INCLUDE_PATH:
case IOption.PREPROCESSOR_SYMBOLS:
+ case IOption.LIBRARIES:
List valueList = new ArrayList();
NodeList nodes = element.getElementsByTagName("optionValue");
for (int i = 0; i < nodes.getLength(); ++i) {
@@ -151,6 +153,7 @@ public class OptionReference implements IOption {
case IOption.STRING_LIST:
case IOption.INCLUDE_PATH:
case IOption.PREPROCESSOR_SYMBOLS:
+ case IOption.LIBRARIES:
ArrayList stringList = (ArrayList)value;
ListIterator iter = stringList.listIterator();
while (iter.hasNext()) {
@@ -227,6 +230,20 @@ public class OptionReference implements IOption {
}
/* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IOption#getLibraries()
+ */
+ public String[] getLibraries() throws BuildException {
+ if (value == null)
+ return option.getLibraries();
+ else if (getValueType() == IOption.LIBRARIES) {
+ ArrayList list = (ArrayList)value;
+ return (String[]) list.toArray(new String[list.size()]);
+ }
+ else
+ throw new BuildException("bad value type");
+ }
+
+ /* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IBuildObject#getName()
*/
public String getName() {
@@ -346,7 +363,8 @@ public class OptionReference implements IOption {
public void setValue(String [] value) throws BuildException {
if (getValueType() == IOption.STRING_LIST
|| getValueType() == IOption.INCLUDE_PATH
- || getValueType() == IOption.PREPROCESSOR_SYMBOLS) {
+ || getValueType() == IOption.PREPROCESSOR_SYMBOLS
+ || getValueType() == IOption.LIBRARIES) {
// Just replace what the option reference is holding onto
this.value = new ArrayList(Arrays.asList(value));
}
diff --git a/core/org.eclipse.cdt.core/build/org/eclipse/cdt/internal/core/build/managed/Tool.java b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/internal/core/build/managed/Tool.java
index 38144dee07..5564b5b72b 100644
--- a/core/org.eclipse.cdt.core/build/org/eclipse/cdt/internal/core/build/managed/Tool.java
+++ b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/internal/core/build/managed/Tool.java
@@ -44,6 +44,8 @@ public class Tool extends BuildObject implements ITool, IOptionCategory {
private String command;
private List inputExtensions;
private String outputExtension;
+ private String outputFlag;
+ private String outputPrefix;
public Tool(Target target) {
this.target = target;
@@ -86,6 +88,16 @@ public class Tool extends BuildObject implements ITool, IOptionCategory {
command = element.getAttribute("command") == null ?
new String() :
element.getAttribute("command");
+
+ // Get the flag to control output
+ outputFlag = element.getAttribute("outputFlag") == null ?
+ new String() :
+ element.getAttribute("outputFlag");
+
+ // Get the output prefix
+ outputPrefix = element.getAttribute("outputPrefix") == null ?
+ new String() :
+ element.getAttribute("outputPrefix");
// set up the category map
categoryMap = new HashMap();
@@ -178,6 +190,20 @@ public class Tool extends BuildObject implements ITool, IOptionCategory {
}
/* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.ITool#getOutputFlag()
+ */
+ public String getOutputFlag() {
+ return outputFlag == null ? new String() : outputFlag;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.ITool#getOutputPrefix()
+ */
+ public String getOutputPrefix() {
+ return outputPrefix == null ? new String() : outputPrefix;
+ }
+
+ /* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IOptionCategory#getOwner()
*/
public IOptionCategory getOwner() {
diff --git a/core/org.eclipse.cdt.core/build/org/eclipse/cdt/internal/core/build/managed/ToolReference.java b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/internal/core/build/managed/ToolReference.java
index c388d54088..3ce12a2890 100644
--- a/core/org.eclipse.cdt.core/build/org/eclipse/cdt/internal/core/build/managed/ToolReference.java
+++ b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/internal/core/build/managed/ToolReference.java
@@ -220,6 +220,20 @@ public class ToolReference implements ITool {
}
/* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.ITool#getOutputFlag()
+ */
+ public String getOutputFlag() {
+ return parent.getOutputFlag();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.ITool#getOutputPrefix()
+ */
+ public String getOutputPrefix() {
+ return parent.getOutputPrefix();
+ }
+
+ /* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.ITool#getTarget()
*/
public ITarget getTarget() {
@@ -322,5 +336,4 @@ public class ToolReference implements ITool {
return parent.getOutputExtension(inputExtension);
}
-
}

Back to the top