[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[cdt-patch] Final submission for bug 41826
|
Well,
I detailed the patch in the change log, but in short, the patch contains
the logic for managing the makefiles in the face of a header file
modification. There seems to be a problem (maybe with the dependency
calculation) for dependants in other projects when a header file is moved,
but other than that the builder seems to respond properly.
Sean Evoy
Rational Software - IBM Software Group
Ottawa, Ontario, Canada
Index: ChangeLog
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core.tests/ChangeLog,v
retrieving revision 1.127
diff -u -r1.127 ChangeLog
--- ChangeLog 30 Sep 2003 20:42:15 -0000 1.127
+++ ChangeLog 1 Oct 2003 02:31:49 -0000
@@ -1,3 +1,11 @@
+2003-09-30 Sean Evoy
+ Fix for bug 41826.
+ Updated the plugin file so that tool specifications have the new attribute
+ for header files. The test for the managed builder now insure that those
+ values are properly read.
+ * plugin.xml
+ * build/org/eclipse/cdt/core/build/managed/tests/ManagedBuildTests.java
+
2003-09-30 John Camelon
Updated CompleteParseASTTest::testBug42872()
Moved FailedCompleteParseASTTest::testBug43503() to CompleteParseASTTest::testBug43503A().
Index: plugin.xml
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core.tests/plugin.xml,v
retrieving revision 1.13
diff -u -r1.13 plugin.xml
--- plugin.xml 26 Sep 2003 19:54:28 -0000 1.13
+++ plugin.xml 1 Oct 2003 02:31:49 -0000
@@ -42,6 +42,7 @@
<tool
sources="foo,bar"
name="Root Tool"
+ headerExtensions="baz"
outputFlag="-r"
outputs="toor"
command="doIt"
@@ -160,6 +161,7 @@
<tool
sources="yarf"
name="Sub Tool"
+ headerExtensions="arf,barf"
outputs="bus"
outputPrefix="lib"
id="tool.sub">
Index: build/org/eclipse/cdt/core/build/managed/tests/ManagedBuildTests.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core.tests/build/org/eclipse/cdt/core/build/managed/tests/ManagedBuildTests.java,v
retrieving revision 1.11
diff -u -r1.11 ManagedBuildTests.java
--- build/org/eclipse/cdt/core/build/managed/tests/ManagedBuildTests.java 26 Sep 2003 19:54:28 -0000 1.11
+++ build/org/eclipse/cdt/core/build/managed/tests/ManagedBuildTests.java 1 Oct 2003 02:31:50 -0000
@@ -677,7 +677,8 @@
// Root Config
IConfiguration rootConfig = configs[0];
assertEquals("Root Config", rootConfig.getName());
- // Tools
+
+ // Tool elements
tools = rootConfig.getTools();
assertEquals(1, tools.length);
assertEquals("Root Tool", tools[0].getName());
@@ -687,6 +688,9 @@
assertTrue(tools[0].producesFileType("toor"));
assertEquals("doIt", tools[0].getToolCommand());
assertEquals("", tools[0].getOutputPrefix());
+ // The root tool defines one valid header file extension
+ assertTrue(rootTool.isHeaderFile("baz"));
+ assertTrue(tools[0].isHeaderFile("baz"));
// Partially Overriden Configuration
assertEquals("Root Override Config", configs[1].getName());
@@ -722,6 +726,7 @@
assertTrue(tools[0].buildsFileType("foo"));
assertTrue(tools[0].buildsFileType("bar"));
assertTrue(tools[0].producesFileType("toor"));
+ assertTrue(tools[0].isHeaderFile("baz"));
assertEquals("doIt", tools[0].getToolCommand());
// Completely Overridden configuration
@@ -813,6 +818,8 @@
assertTrue(subTool.producesFileType("bus"));
assertEquals("", subTool.getToolCommand());
assertEquals("lib", subTool.getOutputPrefix());
+ assertTrue(subTool.isHeaderFile("arf"));
+ assertTrue(subTool.isHeaderFile("barf"));
// Do a sanity check on the options
assertEquals("Include Paths", subOpts[0].getName());
Index: ChangeLog
===================================================================
RCS file: /home/tools/org.eclipse.cdt.managedbuilder.core/ChangeLog,v
retrieving revision 1.10
diff -u -r1.10 ChangeLog
--- ChangeLog 30 Sep 2003 02:14:44 -0000 1.10
+++ ChangeLog 1 Oct 2003 02:32:01 -0000
@@ -1,3 +1,31 @@
+2003-09-30 Sean Evoy
+ Fix for bug 41826.
+
+ Finished the use case for changing header files and triggering a build. I had
+ to add a new attribute to the build model schema to allow a build information
+ client to determine that a file is considered a header file.
+ * schema/ManagedBuildTools.exsd
+
+ The ITool, and its implementors now have a method to test if an extension is
+ considered to belong to a header file. The Tool also pays attention to the new
+ attribute when it reads itself in from the plugin file.
+ * src/org/eclipse/cdt/managedbuilder/core/ITool.java
+ * src/org/eclipse/cdt/managedbuilder/internal/core/Tool.java
+ * src/org/eclipse/cdt/managedbuilder/internal/core/ToolReference.java
+
+ There is a method for clients of this information on the BuildInfo interface and
+ its implementor.
+ * src/org/eclipse/cdt/managedbuilder/core/IManagedBuildInfo.java
+ * src/org/eclipse/cdt/managedbuilder/internal/core/ManagedBuildInfo.java
+
+ The builder had to be tweaked in order to behave correctly on a build of an
+ empty project or non-managed projects.
+ * src/org/eclipse/cdt/managedbuilder/internal/core/GeneratedMakefileBuilder.java
+
+ The makefile generator had to be tweaked to properly add folders that are effected
+ by header file changes.
+ * src/org/eclipse/cdt/managedbuilder/internal/core/MakefileGenerator.java
+
2003-09-26 Sean Evoy
A partial implementation for bug 41826. This patch contains the logic to properly
respond in the face of the following project changes:
Index: schema/ManagedBuildTools.exsd
===================================================================
RCS file: /home/tools/org.eclipse.cdt.managedbuilder.core/schema/ManagedBuildTools.exsd,v
retrieving revision 1.4
diff -u -r1.4 ManagedBuildTools.exsd
--- schema/ManagedBuildTools.exsd 26 Sep 2003 19:54:24 -0000 1.4
+++ schema/ManagedBuildTools.exsd 1 Oct 2003 02:32:01 -0000
@@ -104,13 +104,20 @@
<attribute name="dependencyCalculator" type="string">
<annotation>
<documentation>
- This is an optional field that specifies the class that provides the dependency calculation for a given tool.
+ This is an optional field that specifies the class that provides the dependency calculation for a given tool. This field is unused in CDT 1.2.
</documentation>
<appInfo>
<meta.attribute kind="java" basedOn="org.eclipse.cdt.internal.core.sourcedependency.ISourceDependency"/>
</appInfo>
</annotation>
</attribute>
+ <attribute name="headerExtensions" type="string">
+ <annotation>
+ <documentation>
+ A comma-separated list of file extensions that are used for header files. Since many other files depend on the interfaces defined in header files, the build system needs to be able to determine that a header file has changed to properly rebuild its dependents.
+ </documentation>
+ </annotation>
+ </attribute>
</complexType>
</element>
@@ -142,8 +149,8 @@
<attribute name="valueType" use="default" value="string">
<annotation>
<documentation>
- General options can be one of the following types; 'string' for catch-all entries for options that cannot be easily defined any other way, 'string list' for entries that consist of a list of values such as defined symbols or paths, 'boolean' for options that have two values, and 'enumerated' for options that are one-of a list of values.
-
+ General options can be one of the following types; 'string' for catch-all entries for options that cannot be easily defined any other way, 'string list' for entries that consist of a list of values such as defined symbols or paths, 'boolean' for options that have two values, and 'enumerated' for options that are one-of a list of values.
+
Additional special types exist to flag options of special relevance to the build model; 'include', 'libs', 'userObjs' and 'definedSymbols'. You can pre-populate with optionValues, and they will display in the UI the same way the 'stringList' options do. The build model will look specifically for these value types when clients query for include paths and preprocessor defines. The makefile generator will treat the libs and userObjs entries differently than other stringLists.
</documentation>
</annotation>
@@ -475,48 +482,48 @@
<meta.section type="examples"/>
</appInfo>
<documentation>
- The following is an example of the extension point usage:
-<p>
-<pre>
- <extension
- id="buildExample"
- name="Tools for Build Example"
- point="org.eclipse.cdt.core.ManagedBuildInfo">
- <target
- makeFlags="-k"
- isTest="false"
- cleanCommand="rm -rf"
- name="Executable"
- defaultExtension=".exe"
- isAbstract="false"
- makeCommand="make"
- id="example.target.executable">
- <tool
- sources="C"
- name="Compiler"
- outputFlag="-o"
- outputs="exe"
- command="g++"
- id="executable.compiler">
- <optionCategory
- owner="executable.compiler"
- name="Flags"
- id="compiler.category.flags">
- </optionCategory>
- <option
- defaultValue="-c"
- name="Compiler Flags"
- category="compiler.category.flags"
- valueType="string"
- id="category.flags.comp_flags">
- </option>
- </tool>
- <configuration
- name="Default"
- id="example.config.default">
- </configuration>
- </target>
- </extension>
+ The following is an example of the extension point usage:
+<p>
+<pre>
+ <extension
+ id="buildExample"
+ name="Tools for Build Example"
+ point="org.eclipse.cdt.core.ManagedBuildInfo">
+ <target
+ makeFlags="-k"
+ isTest="false"
+ cleanCommand="rm -rf"
+ name="Executable"
+ defaultExtension=".exe"
+ isAbstract="false"
+ makeCommand="make"
+ id="example.target.executable">
+ <tool
+ sources="C"
+ name="Compiler"
+ outputFlag="-o"
+ outputs="exe"
+ command="g++"
+ id="executable.compiler">
+ <optionCategory
+ owner="executable.compiler"
+ name="Flags"
+ id="compiler.category.flags">
+ </optionCategory>
+ <option
+ defaultValue="-c"
+ name="Compiler Flags"
+ category="compiler.category.flags"
+ valueType="string"
+ id="category.flags.comp_flags">
+ </option>
+ </tool>
+ <configuration
+ name="Default"
+ id="example.config.default">
+ </configuration>
+ </target>
+ </extension>
</pre>
</documentation>
</annotation>
@@ -544,7 +551,7 @@
<meta.section type="copyright"/>
</appInfo>
<documentation>
- Copyright (c) 2003 IBM Corporation and others.
+ Copyright (c) 2003 IBM 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 on the <a href="http://www.eclipse.org/legal/cpl-v10.html"> Eclipse</a> website.
</documentation>
</annotation>
Index: src/org/eclipse/cdt/managedbuilder/core/IManagedBuildInfo.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IManagedBuildInfo.java,v
retrieving revision 1.4
diff -u -r1.4 IManagedBuildInfo.java
--- src/org/eclipse/cdt/managedbuilder/core/IManagedBuildInfo.java 29 Sep 2003 01:42:26 -0000 1.4
+++ src/org/eclipse/cdt/managedbuilder/core/IManagedBuildInfo.java 1 Oct 2003 02:32:01 -0000
@@ -168,8 +168,8 @@
* Returns a <code>String</code> containing the command-line invocation
* for the tool associated with the source extension.
*
- * @param extension
- * @return
+ * @param extension the file extension of the file to be built
+ * @return String
*/
public String getToolForSource(String extension);
@@ -183,7 +183,10 @@
public String getToolForTarget(String extension);
/**
- * @param extension
+ * Answers a <code>String</code> array containing the contents of the
+ * user objects option, if one is defined for the target.
+ *
+ * @param extension the file ecxtension of the build target
* @return
*/
public String[] getUserObjectsForTarget(String extension);
@@ -191,11 +194,20 @@
/**
* Answers true if the build model has been changed by the user.
*
- * @return
+ * @return boolean
*/
public boolean isDirty();
/**
+ * Answers <code>true</code> if the extension matches one of the special
+ * file extensions the tools for the target consider to be a header file.
+ *
+ * @param ext the file extension of the resource
+ * @return boolean
+ */
+ public boolean isHeaderFile(String ext);
+
+ /**
* Set the dirty flag for the build model to the value of the argument.
*
* @param isDirty
@@ -216,5 +228,4 @@
* @param target
*/
public void setDefaultTarget(ITarget target);
-
}
Index: src/org/eclipse/cdt/managedbuilder/core/ITool.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ITool.java,v
retrieving revision 1.1
diff -u -r1.1 ITool.java
--- src/org/eclipse/cdt/managedbuilder/core/ITool.java 15 Sep 2003 20:44:24 -0000 1.1
+++ src/org/eclipse/cdt/managedbuilder/core/ITool.java 1 Oct 2003 02:32:01 -0000
@@ -24,27 +24,30 @@
public static final String OUTPUT_PREFIX = "outputPrefix"; //$NON-NLS-1$
public static final String OUTPUTS = "outputs"; //$NON-NLS-1$
public static final String SOURCES = "sources"; //$NON-NLS-1$
+ public static final String INTERFACE_EXTS = "headerExtensions"; //$NON-NLS-1$
public static final String WHITE_SPACE = " "; //$NON-NLS-1$
/**
* Return <code>true</code> if the receiver builds files with the
* specified extension, else <code>false</code>.
*
- * @param extension
- * @return
+ * @param extension file extension of the source
+ * @return boolean
*/
public boolean buildsFileType(String extension);
/**
* Get a particular option.
*
- * @param id
- * @return
+ * @param id unique identifier of the option to search for
+ * @return IOption
*/
public IOption getOption(String id);
/**
- * Returns the options that may be customized for this tool.
+ * Answers the options that may be customized for this tool.
+ *
+ * @return IOption[]
*/
public IOption[] getOptions();
@@ -53,7 +56,7 @@
* or <code>null</code> if the tool does not understand that extension.
*
* @param inputExtension The extension of the source file.
- * @return
+ * @return String
*/
public String getOutputExtension(String inputExtension);
@@ -62,27 +65,27 @@
* control the name of the output artifact. For example, the GCC compile and
* linker use '-o', while the archiver does not.
*
- * @return
+ * @return String
*/
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
+ * @return String
*/
public String getOutputPrefix();
/**
* Return the target that defines this tool, if applicable
- * @return
- */
+ * @return ITarget
+ */
public ITarget getTarget();
/**
* Answers the command-line invocation defined for the receiver.
*
- * @return
+ * @return String
*/
public String getToolCommand();
@@ -90,7 +93,7 @@
* Answers the additional command line arguments the user has specified for
* the tool.
*
- * @return
+ * @return String
*/
public String getToolFlags() throws BuildException ;
@@ -99,18 +102,26 @@
* These categories are organized into a tree. This is the root
* of that tree.
*
- * @return
+ * @return IOptionCategory
*/
public IOptionCategory getTopOptionCategory();
/**
+ * Answers <code>true</code> if the tool considers the file extension to be
+ * one associated with a header file.
+ *
+ * @param ext file extension of the source
+ * @return boolean
+ */
+ public boolean isHeaderFile(String ext);
+
+ /**
* Answers <code>true</code> if the receiver builds a file with the extension specified
* in the argument, else <code>false</code>.
*
- * @param outputExtension
- * @return
+ * @param outputExtension extension of the file being produced by a tool
+ * @return boolean
*/
public boolean producesFileType(String outputExtension);
-
}
Index: src/org/eclipse/cdt/managedbuilder/internal/core/GeneratedMakefileBuilder.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/GeneratedMakefileBuilder.java,v
retrieving revision 1.6
diff -u -r1.6 GeneratedMakefileBuilder.java
--- src/org/eclipse/cdt/managedbuilder/internal/core/GeneratedMakefileBuilder.java 30 Sep 2003 02:14:44 -0000 1.6
+++ src/org/eclipse/cdt/managedbuilder/internal/core/GeneratedMakefileBuilder.java 1 Oct 2003 02:32:02 -0000
@@ -36,6 +36,7 @@
import org.eclipse.core.resources.IResourceDelta;
import org.eclipse.core.resources.IResourceDeltaVisitor;
import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.resources.IncrementalProjectBuilder;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
@@ -127,7 +128,10 @@
for (int i = 0; i < deps.length; i++) {
IProject project = deps[i];
IManagedBuildInfo depInfo = ManagedBuildManager.getBuildInfo(project);
- depInfo.setDirty(false);
+ // May not be a managed project
+ if (depInfo != null) {
+ depInfo.setDirty(false);
+ }
}
// Ask build mechanism to compute deltas for project dependencies next time
@@ -183,11 +187,14 @@
// Throw the exception back to the builder
throw e;
}
- IPath topBuildDir = generator.getTopBuildDir();
// Now call make
- invokeMake(true, topBuildDir.removeFirstSegments(1), info, monitor);
- monitor.worked(1);
+ IPath topBuildDir = generator.getTopBuildDir();
+ if (topBuildDir != null) {
+ invokeMake(true, topBuildDir.removeFirstSegments(1), info, monitor);
+ } else {
+ monitor.done();
+ }
}
/* (non-javadoc)
@@ -280,8 +287,6 @@
// Run the build
IPath buildDir = new Path(info.getConfigurationName());
invokeMake(false, buildDir, info, monitor);
-
- monitor.worked(1);
}
protected void invokeMake(boolean fullBuild, IPath buildDir, IManagedBuildInfo info, IProgressMonitor monitor) {
@@ -292,6 +297,21 @@
}
try {
+ // Figure out the working directory for the build and make sure there is a makefile there
+ IPath workingDirectory = getWorkingDirectory().append(buildDir);
+ IWorkspace workspace = currentProject.getWorkspace();
+ if (workspace == null) {
+ return;
+ }
+ IWorkspaceRoot root = workspace.getRoot();
+ if (root == null) {
+ return;
+ }
+ IPath makefile = workingDirectory.addTrailingSeparator().append(MakefileGenerator.MAKEFILE_NAME);
+ if (root.getFileForLocation(makefile) == null) {
+ return;
+ }
+
// Flag to the user that make is about to be called
IPath makeCommand = new Path(info.getMakeCommand());
if (makeCommand != null) {
@@ -313,8 +333,6 @@
removeAllMarkers(project);
}
- IPath workingDirectory = getWorkingDirectory().append(buildDir);
-
// Get the arguments to be passed to make from build model
ArrayList makeArgs = new ArrayList();
String args = info.getMakeArguments();
Index: src/org/eclipse/cdt/managedbuilder/internal/core/MakefileGenerator.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/MakefileGenerator.java,v
retrieving revision 1.8
diff -u -r1.8 MakefileGenerator.java
--- src/org/eclipse/cdt/managedbuilder/internal/core/MakefileGenerator.java 30 Sep 2003 02:14:44 -0000 1.8
+++ src/org/eclipse/cdt/managedbuilder/internal/core/MakefileGenerator.java 1 Oct 2003 02:32:02 -0000
@@ -44,6 +44,7 @@
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.core.runtime.Path;
@@ -61,10 +62,10 @@
// String constants for makefile contents
protected static final String COLON = ":";
- protected static final String DEPFILE_NAME = "module.dep"; //$NON-NLS-1$
+ protected static final String DEPFILE_NAME = "subdir.dep"; //$NON-NLS-1$
protected static final String DOT = ".";
protected static final String MAKEFILE_NAME = "makefile"; //$NON-NLS-1$
- protected static final String MODFILE_NAME = "module.mk"; //$NON-NLS-1$
+ protected static final String MODFILE_NAME = "subdir.mk"; //$NON-NLS-1$
protected static final String LINEBREAK = "\\";
protected static final String NEWLINE = System.getProperty("line.separator");
protected static final String SEMI_COLON = ";";
@@ -81,10 +82,9 @@
protected IProject project;
protected List ruleList;
protected IPath topBuildDir;
-
private String target;
-
private String extension;
+
/**
* This class is used to recursively walk the project and determine which
* modules contribute buildable source files.
@@ -142,6 +142,61 @@
this.info = info;
}
+ /* (non-javadoc)
+ * Answers a list of resource names in the workspace that depend on the resource
+ * specified in the argument.
+ *
+ * @param resource the root of the dependency tree
+ * @return IResource[]
+ */
+ private IResource[] findDependencies(IResource resource) {
+ PathCollector pathCollector = new PathCollector();
+ ICSearchScope scope = SearchEngine.createWorkspaceScope();
+ CSearchPattern pattern = CSearchPattern.createPattern(resource.getLocation().toOSString(), ICSearchConstants.INCLUDE, ICSearchConstants.REFERENCES, ICSearchConstants.EXACT_MATCH, true);
+ IndexManager indexManager = CCorePlugin.getDefault().getCoreModel().getIndexManager();
+ indexManager.performConcurrentJob(
+ new PatternSearchJob(
+ (CSearchPattern) pattern,
+ scope,
+ pathCollector,
+ indexManager),
+ ICSearchConstants.WAIT_UNTIL_READY_TO_SEARCH,
+ null);
+
+ // We will get back an array of resource names relative to the workspace
+ String[] deps = pathCollector.getPaths();
+
+ // Convert them to something useful
+ List depList = new ArrayList();
+ IResource res = null;
+ IWorkspaceRoot root = null;
+ if (generator.project != null) {
+ root = generator.project.getWorkspace().getRoot();
+ }
+ for (int index = 0; index < deps.length; ++index) {
+ res = root.findMember(deps[index]);
+ if (res != null) {
+ depList.add(res);
+ }
+ }
+
+ return (IResource[]) depList.toArray(new IResource[depList.size()]);
+ }
+
+ private void handleHeaderDependency(IResource resource, boolean moved) {
+ // If this is a move and the resource is external to the project, touch that resource
+ if (resource.getProject().equals(generator.project)) {
+ generator.appendModifiedSubdirectory(resource);
+ } else {
+ if (moved) {
+ try {
+ resource.touch(new NullProgressMonitor());
+ } catch (CoreException e) {
+ }
+ }
+ }
+ }
+
/* (non-Javadoc)
* @see org.eclipse.core.resources.IResourceDeltaVisitor#visit(org.eclipse.core.resources.IResourceDelta)
*/
@@ -153,40 +208,53 @@
// What kind of resource change has occurred
if (resource.getType() == IResource.FILE) {
String ext = resource.getFileExtension();
+ boolean moved = false;
switch (delta.getKind()) {
case IResourceDelta.ADDED:
- case IResourceDelta.REMOVED:
- // Add the container of the resource and any resources that depend on it
+ moved = delta.getFlags() == IResourceDelta.MOVED_TO;
+ if (!generator.isGeneratedResource(resource)) {
+ // This is a source file so just add its container
if (info.buildsFileType(ext)) {
- if (!generator.isGeneratedResource(resource)) {
- // Here's the container
+ generator.appendModifiedSubdirectory(resource);
+ } else if (info.isHeaderFile(ext)) {
+ // Add the container of the resource and any resources that depend on it
+ generator.appendModifiedSubdirectory(resource);
+ IResource[] deps = findDependencies(resource);
+ for (int i = 0; i < deps.length; ++i){
+ handleHeaderDependency(deps[i], moved);
+ }
+ }
+ }
+ break;
+ case IResourceDelta.REMOVED:
+ moved = delta.getFlags() == IResourceDelta.MOVED_FROM;
+ if (!generator.isGeneratedResource(resource)) {
+ // This is a source file so just add its container
+ if (info.buildsFileType(ext)) {
+ generator.appendModifiedSubdirectory(resource);
+ } else if (info.isHeaderFile(ext)) {
+ // Add the container of the resource and any resources that depend on it
generator.appendModifiedSubdirectory(resource);
- // and all the dependents
- PathCollector pathCollector = new PathCollector();
- ICSearchScope scope = SearchEngine.createWorkspaceScope();
- CSearchPattern pattern = CSearchPattern.createPattern(resource.getLocation().toOSString(),ICSearchConstants.INCLUDE, ICSearchConstants.REFERENCES,ICSearchConstants.EXACT_MATCH,true);
- IndexManager indexManager = CCorePlugin.getDefault().getCoreModel().getIndexManager();
- indexManager.performConcurrentJob(
- new PatternSearchJob(
- (CSearchPattern) pattern,
- scope,
- pathCollector,
- indexManager
- ),
- ICSearchConstants.WAIT_UNTIL_READY_TO_SEARCH,
- null );
- String[] deps = pathCollector.getPaths();
- if (deps.length > 0 ) {
- for (int i=0; i<deps.length; i++){
- generator.appendModifiedSubdirectory(resource);
- }
+ IResource[] deps = findDependencies(resource);
+ for (int i = 0; i < deps.length; ++i){
+ handleHeaderDependency(deps[i], moved);
}
}
}
break;
case IResourceDelta.CHANGED:
- if (info.buildsFileType(ext)) {
- keepLooking = true;
+ if (!generator.isGeneratedResource(resource)) {
+ if (info.buildsFileType(ext)) {
+ keepLooking = true;
+ } else if (info.isHeaderFile(ext)) {
+ // Add the container of the resource and any resources that depend on it
+ generator.appendModifiedSubdirectory(resource);
+ IResource[] deps= findDependencies(resource);
+ for (int i = 0; i < deps.length; ++i){
+ handleHeaderDependency(deps[i], moved);
+ }
+ // That does it for this directory, so don't bother to keep looking
+ }
}
break;
default:
@@ -360,7 +428,7 @@
// Now add the makefile instruction to include all the subdirectory makefile fragments
buffer.append(NEWLINE);
buffer.append(ManagedBuilderCorePlugin.getResourceString(MOD_INCL) + NEWLINE);
- buffer.append("-include ${patsubst %, %/module.mk, $(SUBDIRS)}" + NEWLINE);
+ buffer.append("-include ${patsubst %, %/subdir.mk, $(SUBDIRS)}" + NEWLINE);
buffer.append(NEWLINE + NEWLINE);
return buffer;
@@ -521,7 +589,7 @@
buffer.append(".PHONY: all clean deps" + NEWLINE + NEWLINE);
buffer.append(ManagedBuilderCorePlugin.getResourceString(DEP_INCL) + NEWLINE);
- buffer.append("-include ${patsubst %, %/module.dep, $(SUBDIRS)}" + NEWLINE);
+ buffer.append("-include ${patsubst %, %/subdir.dep, $(SUBDIRS)}" + NEWLINE);
return buffer;
}
@@ -581,7 +649,7 @@
* Adds the container of the argument to the list of folders in the project that
* contribute source files to the build. The resource visitor has already established
* that the build model knows how to build the files. It has also checked that
- * the resouce is not generated as part of the build.
+ * the resource is not generated as part of the build.
*
* @param resource
*/
@@ -590,6 +658,7 @@
if (!getSubdirList().contains(container)) {
getSubdirList().add(container);
}
+
}
/**
@@ -788,7 +857,7 @@
public IPath getTopBuildDir() {
return topBuildDir;
}
-
+
/**
* Answers <code>true</code> if the argument is found in a generated container
* @param resource
@@ -870,10 +939,15 @@
// Visit the resources in the project
ResourceProxyVisitor visitor = new ResourceProxyVisitor(this, info);
project.accept(visitor, IResource.NONE);
-
+
// See if the user has cancelled the build
checkCancel();
+ // Populate the makefile if any source files have been found in the project
+ if (getSubdirList().isEmpty()) {
+ return;
+ }
+
// Create the top-level directory for the build output
topBuildDir = createDirectory(info.getConfigurationName());
@@ -881,7 +955,6 @@
IPath makefilePath = topBuildDir.addTrailingSeparator().append(MAKEFILE_NAME);
IFile makefileHandle = createFile(makefilePath);
- // Populate the makefile
populateTopMakefile(makefileHandle, true);
checkCancel();
Index: src/org/eclipse/cdt/managedbuilder/internal/core/ManagedBuildInfo.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ManagedBuildInfo.java,v
retrieving revision 1.5
diff -u -r1.5 ManagedBuildInfo.java
--- src/org/eclipse/cdt/managedbuilder/internal/core/ManagedBuildInfo.java 29 Sep 2003 01:42:26 -0000 1.5
+++ src/org/eclipse/cdt/managedbuilder/internal/core/ManagedBuildInfo.java 1 Oct 2003 02:32:02 -0000
@@ -539,6 +539,22 @@
return isDirty;
}
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo#isHeaderFile(java.lang.String)
+ */
+ public boolean isHeaderFile(String ext) {
+ // Check to see if there is a rule to build a file with this extension
+ IConfiguration config = getDefaultConfiguration(getDefaultTarget());
+ ITool[] tools = config.getTools();
+ for (int index = 0; index < tools.length; index++) {
+ ITool tool = tools[index];
+ if (tool.isHeaderFile(ext)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
/**
* Write the contents of the build model to the persistent store specified in the
* argument.
Index: src/org/eclipse/cdt/managedbuilder/internal/core/Tool.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Tool.java,v
retrieving revision 1.2
diff -u -r1.2 Tool.java
--- src/org/eclipse/cdt/managedbuilder/internal/core/Tool.java 29 Sep 2003 01:42:26 -0000 1.2
+++ src/org/eclipse/cdt/managedbuilder/internal/core/Tool.java 1 Oct 2003 02:32:02 -0000
@@ -36,16 +36,17 @@
private static final IOptionCategory[] EMPTY_CATEGORIES = new IOptionCategory[0];
private static final IOption[] EMPTY_OPTIONS = new IOption[0];
- private ITarget target;
- private List options;
- private Map optionMap;
- private List childOptionCategories;
private Map categoryMap;
+ private List childOptionCategories;
private String command;
private List inputExtensions;
+ private List interfaceExtensions;
+ private Map optionMap;
+ private List options;
private String outputExtension;
private String outputFlag;
private String outputPrefix;
+ private ITarget target;
public Tool(Target target) {
this.target = target;
@@ -78,7 +79,17 @@
while (tokenizer.hasMoreElements()) {
getInputExtensions().add(tokenizer.nextElement());
}
-
+
+ // Get the interface (header file) extensions
+ String headers = element.getAttribute(INTERFACE_EXTS);
+ if (headers == null) {
+ headers = new String();
+ }
+ tokenizer = new StringTokenizer(headers, DEFAULT_SEPARATOR);
+ while (tokenizer.hasMoreElements()) {
+ getInterfaceExtensions().add(tokenizer.nextElement());
+ }
+
// Get the output extension
outputExtension = element.getAttribute(ITool.OUTPUTS) == null ?
new String() :
@@ -170,7 +181,10 @@
}
/* (non-Javadoc)
- * @return
+ * Safe accessor method to retrieve the list of valid source extensions
+ * the receiver know how to build.
+ *
+ * @return List
*/
private List getInputExtensions() {
if (inputExtensions == null) {
@@ -178,6 +192,13 @@
}
return inputExtensions;
}
+
+ private List getInterfaceExtensions() {
+ if (interfaceExtensions == null) {
+ interfaceExtensions = new ArrayList();
+ }
+ return interfaceExtensions;
+ }
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IOptionCategory#createChildCategory()
@@ -348,6 +369,16 @@
}
}
return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.ITool#isHeaderFile(java.lang.String)
+ */
+ public boolean isHeaderFile(String ext) {
+ if (ext == null) {
+ return false;
+ }
+ return getInterfaceExtensions().contains(ext);
}
/* (non-Javadoc)
Index: src/org/eclipse/cdt/managedbuilder/internal/core/ToolReference.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ToolReference.java,v
retrieving revision 1.2
diff -u -r1.2 ToolReference.java
--- src/org/eclipse/cdt/managedbuilder/internal/core/ToolReference.java 26 Sep 2003 00:20:12 -0000 1.2
+++ src/org/eclipse/cdt/managedbuilder/internal/core/ToolReference.java 1 Oct 2003 02:32:02 -0000
@@ -257,6 +257,13 @@
}
/* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.ITool#isHeaderFile(java.lang.String)
+ */
+ public boolean isHeaderFile(String ext) {
+ return parent.isHeaderFile(ext);
+ }
+
+ /* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.ITool#producesFileType(java.lang.String)
*/
public boolean producesFileType(String outputExtension) {
Index: ChangeLog
===================================================================
RCS file: /home/tools/org.eclipse.cdt.managedbuilder.ui/ChangeLog,v
retrieving revision 1.6
diff -u -r1.6 ChangeLog
--- ChangeLog 26 Sep 2003 19:54:33 -0000 1.6
+++ ChangeLog 1 Oct 2003 02:32:13 -0000
@@ -1,3 +1,10 @@
+2003-09-30 Sean Evoy
+ Fix for bug 41826.
+
+ Updated the tool specifications for Win32, Linux, and Solaris so that header
+ file extension info is available.
+ * plugin.xml
+
2003-09-25 Sean Evoy
For bug (really an enhancement request)43756, I added the word default to a
widget label to try and make it clear that a new configuration will be based
Index: plugin.xml
===================================================================
RCS file: /home/tools/org.eclipse.cdt.managedbuilder.ui/plugin.xml,v
retrieving revision 1.7
diff -u -r1.7 plugin.xml
--- plugin.xml 26 Sep 2003 19:54:33 -0000 1.7
+++ plugin.xml 1 Oct 2003 02:32:13 -0000
@@ -79,6 +79,7 @@
<tool
sources="c,cc,cpp,cxx,C"
name="%ToolName.compiler"
+ headerExtensions="h,H,hpp"
outputFlag="-o"
outputs="o"
command="g++"
@@ -219,13 +220,29 @@
id="cygwin.preprocessor.undef.symbol">
</option>
<optionCategory
- owner="org.eclipse.cdt.build.tool.cygwin.compiler"
- name="%OptionCategory.General"
- id="cygwin.compiler.category.general">
+ name="%OptionCategory.Dirs"
+ id="cygwin.gnu.compiler.category.dirs"
+ owner="org.eclipse.cdt.build.tool.cygwin.compiler">
+ </optionCategory>
+ <option
+ name="Include Paths"
+ category="cygwin.gnu.compiler.category.dirs"
+ command="-I"
+ valueType="includePath"
+ id="cygwin.compiler.general.include.paths">
+ <listOptionValue
+ value="C:\cygwin\usr\include\w32api"
+ builtIn="true">
+ </listOptionValue>
+ </option>
+ <optionCategory
+ name="%OptionCategory.Optimize"
+ id="cygwin.gnu.compiler.category.optimization"
+ owner="org.eclipse.cdt.build.tool.cygwin.compiler">
</optionCategory>
<option
name="Optimization Level"
- category="cygwin.compiler.category.general"
+ category="cygwin.gnu.compiler.category.optimization"
valueType="enumerated"
id="cygwin.compiler.general.optimization.level">
<enumeratedOptionValue
@@ -252,8 +269,19 @@
</enumeratedOptionValue>
</option>
<option
+ category="cygwin.gnu.compiler.category.optimization"
+ name="Other optimization flags"
+ id="cygwin.compiler.optimization.flags"
+ valueType="string">
+ </option>
+ <optionCategory
+ name="%OptionCategory.Debug"
+ id="cygwin.gnu.compiler.category.debug"
+ owner="org.eclipse.cdt.build.tool.cygwin.compiler">
+ </optionCategory>
+ <option
name="Debug Level"
- category="cygwin.compiler.category.general"
+ category="cygwin.gnu.compiler.category.debug"
valueType="enumerated"
id="cygwin.compiler.debugging.level">
<enumeratedOptionValue
@@ -280,15 +308,26 @@
</enumeratedOptionValue>
</option>
<option
- name="Include Paths"
- category="cygwin.compiler.category.general"
- command="-I"
- valueType="includePath"
- id="cygwin.compiler.general.include.paths">
- <listOptionValue
- value="C:\cygwin\usr\include\w32api"
- builtIn="true">
- </listOptionValue>
+ category="cygwin.gnu.compiler.category.debug"
+ name="Other debugging flags"
+ id="cygwin.gnu.compiler.debugging.other"
+ valueType="string">
+ </option>
+ <option
+ category="cygwin.gnu.compiler.category.debug"
+ id="cygwin.gnu.compiler.debugging.prof"
+ command="-p"
+ name="Generate prof information (-p)"
+ defaultValue="false"
+ valueType="boolean">
+ </option>
+ <option
+ category="cygwin.gnu.compiler.category.debug"
+ id="cygwin.gnu.compiler.debugging.gprof"
+ command="-pg"
+ name="Generate gprof information (-pg)"
+ defaultValue="false"
+ valueType="boolean">
</option>
<optionCategory
owner="org.eclipse.cdt.build.tool.cygwin.compiler"
@@ -783,6 +822,7 @@
<tool
sources="c,C,cc,cxx,cpp"
name="%ToolName.compiler"
+ headerExtensions="h,H,hpp"
outputFlag="-o"
outputs="o"
command="g++"
@@ -1403,6 +1443,7 @@
<tool
sources="c,C,cc,cxx,cpp"
name="%ToolName.compiler"
+ headerExtensions="h,H,hpp"
outputFlag="-o"
outputs="o"
command="g++"