1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Fix (part 2) for bugzilla 76080.

The original fix had two problems. When a source folder had only one file deleted, a complete rebuild was required because the output folder was removed. Now the generator checks.
The parent folder could be deleted accidentally, so that has also been resolved.
Finally, the dependency generator pattern ahs been simplified and now uses a Gnu make-supplied macro for calculating the directory component of a file.
This commit is contained in:
Sean Evoy 2005-01-26 22:31:15 +00:00
parent 47c65486a6
commit 3dbe65030b
2 changed files with 44 additions and 20 deletions

View file

@ -80,9 +80,7 @@ public class DefaultGCCDependencyCalculator implements IManagedDependencyGenerat
IManagedBuilderMakefileGenerator.WHITESPACE + IManagedBuilderMakefileGenerator.WHITESPACE +
depRule + depRule +
IManagedBuilderMakefileGenerator.WHITESPACE + IManagedBuilderMakefileGenerator.WHITESPACE +
IManagedBuilderMakefileGenerator.SINGLE_QUOTE + "$(dir $@)" + //$NON-NLS-1$
relativePath +
IManagedBuilderMakefileGenerator.SINGLE_QUOTE +
IManagedBuilderMakefileGenerator.WHITESPACE + IManagedBuilderMakefileGenerator.WHITESPACE +
">" + //$NON-NLS-1$ ">" + //$NON-NLS-1$
IManagedBuilderMakefileGenerator.WHITESPACE + IManagedBuilderMakefileGenerator.WHITESPACE +

View file

@ -119,8 +119,8 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
if (!generator.isGeneratedResource(resource)) { if (!generator.isGeneratedResource(resource)) {
// This is a source file so just add its container // This is a source file so just add its container
if (info.buildsFileType(ext)) { if (info.buildsFileType(ext)) {
generator.appendDeletedSubdirectory(resource);
generator.appendDeletedFile(resource); generator.appendDeletedFile(resource);
generator.appendModifiedSubdirectory(resource);
} }
} }
break; break;
@ -128,7 +128,19 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
keepLooking = true; keepLooking = true;
break; break;
} }
} if (resource.getType() == IResource.PROJECT) { }
if (resource.getType() == IResource.FOLDER) {
// I only care about delete event
switch (delta.getKind()) {
case IResourceDelta.REMOVED:
if (!generator.isGeneratedResource(resource)) {
generator.appendDeletedSubdirectory((IContainer)resource);
}
default:
break;
}
}
if (resource.getType() == IResource.PROJECT) {
// If there is a zero-length delta, something the project depends on has changed so just call make // If there is a zero-length delta, something the project depends on has changed so just call make
IResourceDelta[] children = delta.getAffectedChildren(); IResourceDelta[] children = delta.getAffectedChildren();
if (children != null && children.length > 0) { if (children != null && children.length > 0) {
@ -743,26 +755,21 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
} }
/** /**
* Adds the container of the argument to a list of subdirectories that are part * Adds the container of the argument to a list of subdirectories that are to be
* of an incremental rebuild of the project. The makefile fragments for these * deleted. As a result, the directories that are generated for the output
* directories will be regenerated as a result of the build. * should be removed as well.
* *
* @param resource * @param resource
*/ */
protected void appendDeletedSubdirectory(IResource resource) { protected void appendDeletedSubdirectory(IContainer container) {
IContainer container = resource.getParent(); // No point in adding a folder if the parent is already there
// If the path contains a space relative to the project, reject it from the build IContainer parent = container.getParent();
if (resource.getProjectRelativePath().toString().indexOf(" ") != -1) { //$NON-NLS-1$ if (!getDeletedDirList().contains(container) &&
// Only add the container once !getDeletedDirList().contains(parent)) {
if (!getInvalidDirList().contains(container)) { getDeletedDirList().add(container);
getInvalidDirList().add(container);
}
} else {
if (!getDeletedDirList().contains(container)) {
getDeletedDirList().add(container);
}
} }
} }
/** /**
* If a file is removed from a source folder (either because of a delete * If a file is removed from a source folder (either because of a delete
* or move action on the part of the user), the makefilegenerator has to * or move action on the part of the user), the makefilegenerator has to
@ -1051,6 +1058,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
topBuildDir = createDirectory(info.getConfigurationName()); topBuildDir = createDirectory(info.getConfigurationName());
checkCancel(); checkCancel();
// Make sure that there is a makefile containing all the folders participating
IPath srcsFilePath = topBuildDir.addTrailingSeparator().append(SRCSFILE_NAME); IPath srcsFilePath = topBuildDir.addTrailingSeparator().append(SRCSFILE_NAME);
IFile srcsFileHandle = createFile(srcsFilePath); IFile srcsFileHandle = createFile(srcsFilePath);
populateSourcesMakefile(srcsFileHandle); populateSourcesMakefile(srcsFileHandle);
@ -1061,6 +1069,11 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
while (iter.hasNext()) { while (iter.hasNext()) {
IContainer subdirectory = (IContainer)iter.next(); IContainer subdirectory = (IContainer)iter.next();
if (!getModifiedList().contains(subdirectory)) { if (!getModifiedList().contains(subdirectory)) {
// Make sure the directory exists (it may have been deleted)
if (!subdirectory.exists()) {
appendDeletedSubdirectory(subdirectory);
continue;
}
// Make sure a fragment makefile exists // Make sure a fragment makefile exists
IPath fragmentPath = getBuildWorkingDir().append(subdirectory.getProjectRelativePath()).addTrailingSeparator().append(MODFILE_NAME); IPath fragmentPath = getBuildWorkingDir().append(subdirectory.getProjectRelativePath()).addTrailingSeparator().append(MODFILE_NAME);
IFile makeFragment = project.getFile(fragmentPath); IFile makeFragment = project.getFile(fragmentPath);
@ -1089,6 +1102,11 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
iter = getModifiedList().listIterator(); iter = getModifiedList().listIterator();
while (iter.hasNext()) { while (iter.hasNext()) {
IContainer subDir = (IContainer) iter.next(); IContainer subDir = (IContainer) iter.next();
// Make sure the directory exists (it may have been deleted)
if (!subDir.exists()) {
appendDeletedSubdirectory(subDir);
continue;
}
populateFragmentMakefile(subDir); populateFragmentMakefile(subDir);
checkCancel(); checkCancel();
} }
@ -1795,6 +1813,14 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
* @param subDir * @param subDir
*/ */
private void removeGeneratedDirectory(IContainer subDir) { private void removeGeneratedDirectory(IContainer subDir) {
try {
// The source directory isn't empty
if (subDir.exists() && subDir.members().length > 0) return;
} catch (CoreException e) {
// The resource doesn't exist so we should delete the output folder
}
// Figure out what the generated directory name is and delete it
IPath moduleRelativePath = subDir.getProjectRelativePath(); IPath moduleRelativePath = subDir.getProjectRelativePath();
IPath buildRoot = getBuildWorkingDir(); IPath buildRoot = getBuildWorkingDir();
if (buildRoot == null) { if (buildRoot == null) {