Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[cdt-patch] New Makefile Generator Enhancements

Hi All,
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.

Sean Evoy
Rational Software - IBM Software Group
Ottawa, Ontario, Canada
Index: ChangeLog
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/ChangeLog,v
retrieving revision 1.115
diff -u -r1.115 ChangeLog
--- ChangeLog	25 Jul 2003 01:57:51 -0000	1.115
+++ ChangeLog	25 Jul 2003 17:13:18 -0000
@@ -1,3 +1,57 @@
+2003-07-24 Sean Evoy
+	*src/org/eclipse/cdt/internal/core/MakefileGenerator.java:
+	Added code to place interproject dependencies in target build rule, 
+	added code to properly put output prefixes on library names, and 
+	added code to put library link arguments at the end of the depednency list
+
+	* build/org/eclipse/cdt/core/build/managed/IManagedBuildInfo.java
+	* build/org/eclipse/cdt/core/build/managed/IOption.java
+	* build/org/eclipse/cdt/core/build/managed/ITool.java
+	* build/org/eclipse/cdt/internal/core/build/managed/ManagedBuildInfo.java
+	* build/org/eclipse/cdt/internal/core/build/managed/Option.java
+	* build/org/eclipse/cdt/internal/core/build/managed/OptionReference.java
+	* build/org/eclipse/cdt/internal/core/build/managed/Tool.java
+	* build/org/eclipse/cdt/internal/core/build/managed/ToolReference.java:
+	Added code to managed output prefixes for tools like the librarian. Added code
+	to manage the library options differently. Removed some hard-coding of tool 
+	information, such as the output flag.
+	
+	*schema/ManagedBuildTools.exsd:
+	New attributes on tool for output flag and prefix. New value type enum for option
+	to handle libs differently.
+	
+2003-07-24 Sean Evoy
+	Changes introduced to make the managed build system work with
+	multi-folder project.
+	
+	* src/org/eclipse/cdt/core/ManagedCProjectNature.java:
+	now removes the cbuilder from a project before it adds its 
+	own builder. This is a temporary fix to stop the managed build 
+	system from building a project twice. When the new StandardBuildNature 
+	is introduced, this code will be removed.
+
+	* src/org/eclipse/cdt/internal/core/CCorePluginResources.properties:
+	New builder messages added.
+	
+	* src/org/eclipse/cdt/internal/core/GeneratedMakefileBuilder.java:
+	Moved the actual directory and file creation to a delegate class.
+	
+	* src/org/eclipse/cdt/internal/core/MakefileGenerator.java:
+	New class that does the grunt work of creating build output directories 
+	and makefiles.
+	
+	* build/org/eclipse/cdt/core/build/managed/ManagedBuildManager.java:
+	Short-term changes to make it possible for build info clients to get the
+	path and symbol information. When a permanent mechanism is implemented
+	for clients to discover this information, these methods (IScannerInfoxxx) 
+	will be removed.
+	
+	* build/org/eclipse/cdt/core/build/managed/IManagedBuildInfo.java
+	* build/org/eclipse/cdt/internal/core/build/managed/ManagedBuildInfo.java:
+	Some minor changes have been made to extract more information from the 
+	build model. Currently, the values are hard-coded to simplify some integration
+	testing. This will be addressed in the next patch.
+	
 2003-07-24 Alain Magloire
 
 	* utils/org/eclipse/cdt/utils/Elf.java:
Index: build/org/eclipse/cdt/core/build/managed/IManagedBuildInfo.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/build/org/eclipse/cdt/core/build/managed/IManagedBuildInfo.java,v
retrieving revision 1.2
diff -u -r1.2 IManagedBuildInfo.java
--- build/org/eclipse/cdt/core/build/managed/IManagedBuildInfo.java	25 Jul 2003 14:40:04 -0000	1.2
+++ build/org/eclipse/cdt/core/build/managed/IManagedBuildInfo.java	25 Jul 2003 17:13:18 -0000
@@ -80,12 +80,13 @@
 	/**
 	 * 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 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 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 void setDefaultTarget(ITarget target);
 
-
-	
 }
Index: build/org/eclipse/cdt/core/build/managed/IOption.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/build/org/eclipse/cdt/core/build/managed/IOption.java,v
retrieving revision 1.8
diff -u -r1.8 IOption.java
--- build/org/eclipse/cdt/core/build/managed/IOption.java	23 Jun 2003 14:36:31 -0000	1.8
+++ build/org/eclipse/cdt/core/build/managed/IOption.java	25 Jul 2003 17:13:18 -0000
@@ -21,6 +21,7 @@
 	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 @@
 		
 
 	/**
+	 * 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 @@
 	 * @return
 	 */
 	public int getValueType();
+
 }
Index: build/org/eclipse/cdt/core/build/managed/ITool.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/build/org/eclipse/cdt/core/build/managed/ITool.java,v
retrieving revision 1.4
diff -u -r1.4 ITool.java
--- build/org/eclipse/cdt/core/build/managed/ITool.java	9 Jun 2003 19:22:15 -0000	1.4
+++ build/org/eclipse/cdt/core/build/managed/ITool.java	25 Jul 2003 17:13:18 -0000
@@ -48,6 +48,22 @@
 	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 @@
 	 * @return
 	 */
 	public boolean producesFileType(String outputExtension);
+
 	
 }
Index: build/org/eclipse/cdt/internal/core/build/managed/ManagedBuildInfo.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/build/org/eclipse/cdt/internal/core/build/managed/ManagedBuildInfo.java,v
retrieving revision 1.2
diff -u -r1.2 ManagedBuildInfo.java
--- build/org/eclipse/cdt/internal/core/build/managed/ManagedBuildInfo.java	25 Jul 2003 14:40:04 -0000	1.2
+++ build/org/eclipse/cdt/internal/core/build/managed/ManagedBuildInfo.java	25 Jul 2003 17:13:18 -0000
@@ -229,6 +229,40 @@
 	}
 
 	/* (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 @@
 	/* (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() {
@@ -405,6 +464,5 @@
 		}
 		return symbols; 
 	}
-
 
 }
Index: build/org/eclipse/cdt/internal/core/build/managed/Option.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/build/org/eclipse/cdt/internal/core/build/managed/Option.java,v
retrieving revision 1.7
diff -u -r1.7 Option.java
--- build/org/eclipse/cdt/internal/core/build/managed/Option.java	23 Jun 2003 14:36:31 -0000	1.7
+++ build/org/eclipse/cdt/internal/core/build/managed/Option.java	25 Jul 2003 17:13:18 -0000
@@ -77,6 +77,8 @@
 			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 @@
 			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 @@
 	}
 
 	/* (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 @@
 	{
 		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) {
Index: build/org/eclipse/cdt/internal/core/build/managed/OptionReference.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/build/org/eclipse/cdt/internal/core/build/managed/OptionReference.java,v
retrieving revision 1.9
diff -u -r1.9 OptionReference.java
--- build/org/eclipse/cdt/internal/core/build/managed/OptionReference.java	23 Jun 2003 14:36:31 -0000	1.9
+++ build/org/eclipse/cdt/internal/core/build/managed/OptionReference.java	25 Jul 2003 17:13:18 -0000
@@ -82,6 +82,7 @@
 			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 @@
 			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 @@
 			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 @@
 	}
 
 	/* (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 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));
 		}
Index: build/org/eclipse/cdt/internal/core/build/managed/Tool.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/build/org/eclipse/cdt/internal/core/build/managed/Tool.java,v
retrieving revision 1.7
diff -u -r1.7 Tool.java
--- build/org/eclipse/cdt/internal/core/build/managed/Tool.java	23 Jun 2003 14:36:31 -0000	1.7
+++ build/org/eclipse/cdt/internal/core/build/managed/Tool.java	25 Jul 2003 17:13:18 -0000
@@ -44,6 +44,8 @@
 	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 @@
 		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();
@@ -175,6 +187,20 @@
 		childOptionCategories.add(category);
 		
 		return category;
+	}
+
+	/* (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)
Index: build/org/eclipse/cdt/internal/core/build/managed/ToolReference.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/build/org/eclipse/cdt/internal/core/build/managed/ToolReference.java,v
retrieving revision 1.7
diff -u -r1.7 ToolReference.java
--- build/org/eclipse/cdt/internal/core/build/managed/ToolReference.java	23 Jun 2003 14:36:31 -0000	1.7
+++ build/org/eclipse/cdt/internal/core/build/managed/ToolReference.java	25 Jul 2003 17:13:19 -0000
@@ -220,6 +220,20 @@
 	}
 
 	/* (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() {
@@ -321,6 +335,5 @@
 	public String getOutputExtension(String inputExtension) {
 		return parent.getOutputExtension(inputExtension);
 	}
-
 
 }
Index: schema/ManagedBuildTools.exsd
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/schema/ManagedBuildTools.exsd,v
retrieving revision 1.8
diff -u -r1.8 ManagedBuildTools.exsd
--- schema/ManagedBuildTools.exsd	4 Jul 2003 18:36:45 -0000	1.8
+++ schema/ManagedBuildTools.exsd	25 Jul 2003 17:13:19 -0000
@@ -42,6 +42,11 @@
    </element>
 
    <element name="tool">
+      <annotation>
+         <documentation>
+            Defines a tool used in the build process.
+         </documentation>
+      </annotation>
       <complexType>
          <sequence>
             <element ref="option"/>
@@ -92,6 +97,20 @@
                </documentation>
             </annotation>
          </attribute>
+         <attribute name="outputFlag" type="string">
+            <annotation>
+               <documentation>
+                  An optional flag for tools that allow users to specify a name for the artifact of the tool. For example, the GCC compiler and linker tools typically allow the user to specify the name of the output with the &apos;-o&apos; flag, whereas the archiver that creates libraries does not.
+               </documentation>
+            </annotation>
+         </attribute>
+         <attribute name="outputPrefix" type="string">
+            <annotation>
+               <documentation>
+                  Some tools produce files with a special prefix that must be specified. For example, a librarian on POSIX systems expects the output to be lib&lt;target&gt;.a so &apos;lib&apos; would be the prefix.
+               </documentation>
+            </annotation>
+         </attribute>
       </complexType>
    </element>
 
@@ -118,8 +137,8 @@
          <attribute name="valueType" use="default" value="string">
             <annotation>
                <documentation>
-                  General options can be one of the following types; &apos;string&apos; for catch-all entries for options that cannot be easily defined any other way, &apos;string list&apos; for entries that consist of a list of values such as defined symbols or paths, &apos;boolean&apos; for options that have two values, and &apos;enumerated&apos; for options that are one-of a list of values.
-
+                  General options can be one of the following types; &apos;string&apos; for catch-all entries for options that cannot be easily defined any other way, &apos;string list&apos; for entries that consist of a list of values such as defined symbols or paths, &apos;boolean&apos; for options that have two values, and &apos;enumerated&apos; for options that are one-of a list of values.
+
 Two additional types exist to flag options of special relevance to the build model; &apos;include&apos;, and &apos;definedSymbols&apos;. You can pre-populate with optionValues, and they will display in the UI the same way the &apos;StringList&apos; options do. The build model will look specifically for these value types when clients query for include paths and preprocessor defines.
                </documentation>
             </annotation>
@@ -136,6 +155,8 @@
                   <enumeration value="includePath">
                   </enumeration>
                   <enumeration value="definedSymbols">
+                  </enumeration>
+                  <enumeration value="libs">
                   </enumeration>
                </restriction>
             </simpleType>
Index: src/org/eclipse/cdt/internal/core/MakefileGenerator.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/MakefileGenerator.java,v
retrieving revision 1.1
diff -u -r1.1 MakefileGenerator.java
--- src/org/eclipse/cdt/internal/core/MakefileGenerator.java	25 Jul 2003 14:40:04 -0000	1.1
+++ src/org/eclipse/cdt/internal/core/MakefileGenerator.java	25 Jul 2003 17:13:20 -0000
@@ -19,6 +19,7 @@
 
 import org.eclipse.cdt.core.CCorePlugin;
 import org.eclipse.cdt.core.build.managed.IManagedBuildInfo;
+import org.eclipse.cdt.core.build.managed.ManagedBuildManager;
 import org.eclipse.cdt.core.search.ICSearchConstants;
 import org.eclipse.cdt.internal.core.model.Util;
 import org.eclipse.cdt.internal.core.sourcedependency.DependencyManager;
@@ -197,10 +198,6 @@
 		buffer.append("RM := ");
 		buffer.append(info.getCleanCommand() + NEWLINE);
 		
-		// Add the macro for the output flag
-		buffer.append("OUTPUT_FLAG := ");
-		buffer.append(info.getOutputFlag() + NEWLINE);
-
 		buffer.append(CCorePlugin.getResourceString(SRC_LISTS) + NEWLINE);
 		buffer.append("C_SRCS := " + NEWLINE);
 		buffer.append("CC_SRCS := " + NEWLINE);
@@ -296,24 +293,53 @@
 		String extension = temp.getFileExtension();
 		
 		/*
-		 * Write out the taqrget rule as:
-		 * <target>.<extension>: $(CC_SRCS:$(ROOT)/%.cpp=%.o) $(C_SRCS:$(ROOT)/%.c=%.o)
-		 * 		$(BUILD_TOOL) $(FLAGS) $(OUTPUT_FLAG) $@ $^ $(LIB_DEPS)
+		 * Write out the target rule as:
+		 * <prefix><target>.<extension>: $(CC_SRCS:$(ROOT)/%.cpp=%.o) $(C_SRCS:$(ROOT)/%.c=%.o)
+		 * 		<cd <Proj_Dep_1/build_dir>; make all> 
+		 * 		<cd <Proj_Dep_.../build_dir>; make all> 
+		 * 		<cd <Proj_Dep_n/build_dir>; make all> 
+		 * 		$(BUILD_TOOL) $(FLAGS) $(OUTPUT_FLAG) $(OUTPUT_PREFIX)$@ $^ $(LIB_DEPS)
 		 */
 		String cmd = info.getToolForTarget(extension);
 		String flags = info.getFlagsForTarget(extension);
-		buffer.append(target + COLON + WHITESPACE + "$(CC_SRCS:$(ROOT)/%.cpp=%.o) $(C_SRCS:$(ROOT)/%.c=%.o)" + NEWLINE);
-		buffer.append(TAB + cmd + WHITESPACE + flags + WHITESPACE + "$(OUTPUT_FLAG) $@" + WHITESPACE + "$^" + WHITESPACE + NEWLINE);
+		String outflag = info.getOutputFlag(extension);
+		String outputPrefix = info.getOutputPrefix(extension);
+
+		buffer.append(outputPrefix + target + COLON + WHITESPACE + "$(CC_SRCS:$(ROOT)/%.cpp=%.o) $(C_SRCS:$(ROOT)/%.c=%.o)" + NEWLINE);
+		IProject[] deps;
+		try {
+			deps = project.getReferencedProjects();
+			for (int i = 0; i < deps.length; i++) {
+				IProject dep = deps[i];
+				String buildDir = dep.getLocation().toString();
+				if (ManagedBuildManager.manages(dep)) {
+					IManagedBuildInfo depInfo = ManagedBuildManager.getBuildInfo(dep);
+					buildDir += SEPARATOR + depInfo.getConfigurationName();
+				}
+				buffer.append(TAB + "cd" + WHITESPACE + buildDir + SEMI_COLON + WHITESPACE + "make all" + NEWLINE);
+			}
+		} catch (CoreException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+
+		buffer.append(TAB + cmd + WHITESPACE + flags + WHITESPACE + outflag + WHITESPACE + outputPrefix + "$@" + WHITESPACE + "$^");
+		String[] libraries = info.getLibsForTarget(extension);
+		for (int i = 0; i < libraries.length; i++) {
+			String lib = libraries[i];
+			buffer.append(WHITESPACE + lib);
+		}
+		buffer.append(NEWLINE);
 		buffer.append(NEWLINE);
 
 		// TODO Generate 'all' for now but determine the real rules from UI
-		buffer.append("all: " + target + NEWLINE);
+		buffer.append("all: " + outputPrefix + target + NEWLINE);
 		buffer.append(NEWLINE);
 		
 		// Always add a clean target
 		buffer.append(".PHONY: clean" + NEWLINE);
 		buffer.append("clean:" + NEWLINE);
-		buffer.append(TAB + "$(RM)" + WHITESPACE + "${addprefix ., $(CC_SRCS:$(ROOT)%.cpp=%.o)} ${addprefix ., $(C_SRCS:$(ROOT)%.c=%.o)}" + WHITESPACE + target + NEWLINE);
+		buffer.append(TAB + "$(RM)" + WHITESPACE + "${addprefix ., $(CC_SRCS:$(ROOT)%.cpp=%.o)} ${addprefix ., $(C_SRCS:$(ROOT)%.c=%.o)}" + WHITESPACE + outputPrefix + target + NEWLINE);
 		buffer.append(NEWLINE);
 		
 		buffer.append(NEWLINE + CCorePlugin.getResourceString(DEP_INCL) + NEWLINE);
@@ -329,7 +355,9 @@
 		String buildFlags = null;
 		String inputExtension = null;
 		String outputExtension = null;
-
+		String outflag = null;
+		String outputPrefix = null;
+		
 		// Is there a special rule for this file
 		if (false) {
 		} 
@@ -361,8 +389,9 @@
 			buffer.append(rule + NEWLINE);
 			cmd = info.getToolForSource(inputExtension);
 			buildFlags = info.getFlagsForSource(inputExtension);
-			
-			buffer.append(TAB + cmd + WHITESPACE + buildFlags + WHITESPACE + "$(OUTPUT_FLAG) $@" + WHITESPACE + "$<" + NEWLINE + NEWLINE);
+			outflag = info.getOutputFlag(outputExtension);
+			outputPrefix = info.getOutputPrefix(outputExtension);
+			buffer.append(TAB + cmd + WHITESPACE + buildFlags + WHITESPACE + outflag + WHITESPACE + outputPrefix + "$@" + WHITESPACE + "$<" + NEWLINE + NEWLINE);
 		}
 	}
 	
Index: plugin.xml
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core.tests/plugin.xml,v
retrieving revision 1.3
diff -u -r1.3 plugin.xml
--- plugin.xml	24 Jun 2003 19:56:34 -0000	1.3
+++ plugin.xml	25 Jul 2003 17:13:41 -0000
@@ -35,6 +35,7 @@
          <tool
                sources="foo,bar"
                name="Root Tool"
+               outputFlag="-r"
                outputs="toor"
                command="doIt"
                id="root.tool">
@@ -119,7 +120,10 @@
                id="sub.config">
          </configuration>
          <tool
+               sources="yarf"
                name="Sub Tool"
+               outputPrefix="lib"
+               outputs="bus"
                id="tool.sub">
             <option
                   name="Include Paths"
Index: build/org/eclipse/cdt/core/build/managed/tests/AllBuildTests.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core.tests/build/org/eclipse/cdt/core/build/managed/tests/AllBuildTests.java,v
retrieving revision 1.3
diff -u -r1.3 AllBuildTests.java
--- build/org/eclipse/cdt/core/build/managed/tests/AllBuildTests.java	4 Jul 2003 18:36:47 -0000	1.3
+++ build/org/eclipse/cdt/core/build/managed/tests/AllBuildTests.java	25 Jul 2003 17:13:41 -0000
@@ -528,20 +528,12 @@
 		tools = rootConfig.getTools();
 		assertEquals(1, tools.length);
 		assertEquals("Root Tool", tools[0].getName());
-		topCategory = tools[0].getTopOptionCategory();
-		options = topCategory.getOptions(configs[0]);
-		assertEquals(2, options.length);
-		assertEquals("List Option in Top", options[0].getName());
-		valueList = options[0].getStringListValue();
-		assertEquals("a", valueList[0]);
-		assertEquals("b", valueList[1]);
-		assertEquals("Boolean Option in Top", options[1].getName());
-		categories = topCategory.getChildCategories();
-		options = categories[0].getOptions(configs[0]);
-		assertEquals(2, options.length);
-		assertEquals("String Option in Category", options[0].getName());
-		assertEquals(oicValue, options[0].getStringValue());
-		assertEquals("Enumerated Option in Category", options[1].getName());
+		assertEquals("-r", tools[0].getOutputFlag());
+		assertTrue(tools[0].buildsFileType("foo"));
+		assertTrue(tools[0].buildsFileType("bar"));
+		assertTrue(tools[0].producesFileType("toor"));
+		assertEquals("doIt", tools[0].getToolCommand());
+		assertEquals("", tools[0].getOutputPrefix());
 
 		// Root Override Config
 		assertEquals("Root Override Config", configs[1].getName());
@@ -569,6 +561,13 @@
 		assertEquals("Another Enum", valueList[1]);
 		assertEquals("-e1", options[1].getEnumCommand(valueList[0]));
 		assertEquals("-e2", options[1].getEnumCommand(valueList[1]));
+		assertEquals(1, tools.length);
+		assertEquals("Root Tool", tools[0].getName());
+		assertEquals("-r", tools[0].getOutputFlag());
+		assertTrue(tools[0].buildsFileType("foo"));
+		assertTrue(tools[0].buildsFileType("bar"));
+		assertTrue(tools[0].producesFileType("toor"));
+		assertEquals("doIt", tools[0].getToolCommand());
 	}
 
 	/*
@@ -595,6 +594,11 @@
 		// Confirm that it has three options
 		IOption[] subOpts = subTool.getOptions();
 		assertEquals(3, subOpts.length);
+		assertEquals("", subTool.getOutputFlag());
+		assertTrue(subTool.buildsFileType("yarf"));
+		assertTrue(subTool.producesFileType("bus"));
+		assertEquals("", subTool.getToolCommand());
+		assertEquals("lib", subTool.getOutputPrefix());
 
 		// Do a sanity check on the options 
 		assertEquals("Include Paths", subOpts[0].getName());
Index: ChangeLog
===================================================================
RCS file: /home/tools/org.eclipse.cdt.ui/ChangeLog,v
retrieving revision 1.127
diff -u -r1.127 ChangeLog
--- ChangeLog	24 Jul 2003 17:20:07 -0000	1.127
+++ ChangeLog	25 Jul 2003 17:14:04 -0000
@@ -1,3 +1,13 @@
+2003-07-24 Sean Evoy
+	* plugin.xml:
+	Added new attributes to tools and changed the value type enum for 
+	libraries options. Also added a new flags option to archiver tool 
+	in the Cygwin static library target specification.
+	
+	* build/org/eclipse/cdt/ui/build/properties/BuildToolSettingsPage.java
+	* build/org/eclipse/cdt/ui/build/properties/BuildToolsSettingsStore.java:
+	Changed to handle the libraries as a special option type.
+
 2003-07-24 Hoda Amer
 	This patch updates the CModelBuilder to use the AST instead of the DOM. 
 
Index: plugin.xml
===================================================================
RCS file: /home/tools/org.eclipse.cdt.ui/plugin.xml,v
retrieving revision 1.35
diff -u -r1.35 plugin.xml
--- plugin.xml	17 Jul 2003 20:15:18 -0000	1.35
+++ plugin.xml	25 Jul 2003 17:14:04 -0000
@@ -628,6 +628,7 @@
          <tool
                sources="c,cc,cpp,cxx,C"
                name="%ToolName.compiler"
+               outputFlag="-o"
                outputs="o"
                command="g++"
                id="org.eclipse.cdt.build.tool.cygwin.compiler">
@@ -761,6 +762,7 @@
          </configuration>
          <tool
                name="%ToolName.linker"
+               outputFlag="-o"
                outputs="exe"
                command="g++"
                id="org.eclipse.cdt.build.tool.cygwin.link">
@@ -787,7 +789,7 @@
                   name="Libraries"
                   category="cygwin.linker.category.general"
                   command="-l"
-                  valueType="stringList"
+                  valueType="libs"
                   id="cygwin.link.libs">
             </option>
             <optionCategory
@@ -819,6 +821,7 @@
          </configuration>
          <tool
                name="%ToolName.linker"
+               outputFlag="-o"
                outputs="dll.a"
                id="org.eclipse.cdt.build.tool.cygwin.solink">
             <optionCategory
@@ -844,7 +847,7 @@
                   name="Libraries"
                   category="cygwin.solink.category.general"
                   command="-l"
-                  valueType="stringList"
+                  valueType="libs"
                   id="cygwin.solink.libs">
             </option>
          </tool>
@@ -867,8 +870,21 @@
          <tool
                name="%ToolName.archiver"
                outputs="a"
+               outputPrefix="lib"
                command="ar"
                id="org.eclipse.cdt.build.tool.cygwin.ar">
+            <optionCategory
+                  owner="org.eclipse.cdt.build.tool.cygwin.ar"
+                  name="General"
+                  id="cygwin.ar.category.general">
+            </optionCategory>
+            <option
+                  defaultValue="-r"
+                  name="Archiver Flags"
+                  category="cygwin.ar.category.general"
+                  valueType="string"
+                  id="cygwin.ar.flags">
+            </option>
          </tool>
       </target>
       <target
@@ -878,6 +894,7 @@
             id="linux">
          <tool
                name="Compiler"
+               outputFlag="-o"
                id="linux.compiler">
             <optionCategory
                   owner="linux.compiler"
@@ -906,6 +923,7 @@
             id="linux.exec">
          <tool
                name="Linker"
+               outputFlag="-o"
                id="org.eclipse.cdt.ui.tests.tool.linux.link">
          </tool>
          <configuration
@@ -926,6 +944,7 @@
             id="linux.so">
          <tool
                name="Linker"
+               outputFlag="-o"
                id="org.eclipse.cdt.ui.tests.tool.linux.solink">
          </tool>
       </target>
@@ -973,7 +992,7 @@
             class="org.eclipse.cdt.internal.ui.search.ParentNameSorter"
             id="org.eclipse.search.internal.ui.ParentNameSorter">
       </sorter>
-	<sorter
+      <sorter
             pageId="org.eclipse.cdt.ui.CSearchPage"
             label="%PathNameSorter.label"
             icon="icons/full/clcl16/search_sortmatch.gif"
Index: build/org/eclipse/cdt/ui/build/properties/BuildToolSettingsPage.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.ui/build/org/eclipse/cdt/ui/build/properties/BuildToolSettingsPage.java,v
retrieving revision 1.2
diff -u -r1.2 BuildToolSettingsPage.java
--- build/org/eclipse/cdt/ui/build/properties/BuildToolSettingsPage.java	23 Jun 2003 14:36:26 -0000	1.2
+++ build/org/eclipse/cdt/ui/build/properties/BuildToolSettingsPage.java	25 Jul 2003 17:14:04 -0000
@@ -80,6 +80,7 @@
 				case IOption.STRING_LIST :
 				case IOption.INCLUDE_PATH :
 				case IOption.PREPROCESSOR_SYMBOLS :
+				case IOption.LIBRARIES :
 					BuildOptionListFieldEditor listField = new BuildOptionListFieldEditor(opt.getId(), opt.getName(), getFieldEditorParent());
 					addField(listField); 
 					break;
@@ -129,6 +130,7 @@
 				case IOption.STRING_LIST :
 				case IOption.INCLUDE_PATH :
 				case IOption.PREPROCESSOR_SYMBOLS :
+				case IOption.LIBRARIES :
 					String listStr = getPreferenceStore().getString(option.getId());
 					String[] listVal = BuildToolsSettingsStore.parseString(listStr);
 					ManagedBuildManager.setOption(configuration, option, listVal);
Index: build/org/eclipse/cdt/ui/build/properties/BuildToolsSettingsStore.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.ui/build/org/eclipse/cdt/ui/build/properties/BuildToolsSettingsStore.java,v
retrieving revision 1.2
diff -u -r1.2 BuildToolsSettingsStore.java
--- build/org/eclipse/cdt/ui/build/properties/BuildToolsSettingsStore.java	23 Jun 2003 14:36:26 -0000	1.2
+++ build/org/eclipse/cdt/ui/build/properties/BuildToolsSettingsStore.java	25 Jul 2003 17:14:05 -0000
@@ -238,7 +238,14 @@
 					}
 					optionMap.put(name, value);
 					break;
-					
+				case IOption.LIBRARIES :
+					try {
+						value = createList(opt.getLibraries());
+					} catch (BuildException e) {
+						break;
+					}
+					optionMap.put(name, value);
+					break;
 				default :
 					break;
 			}

Back to the top