From e37153ae8c4c43cd54d657cc2e8ea3ccb18548a2 Mon Sep 17 00:00:00 2001 From: John Dallaway Date: Mon, 26 Oct 2015 11:00:04 +0000 Subject: [PATCH] Bug 366039: Internal Builder reduced build step input resource count Change-Id: I7c7c8ba5d1bf7b96bbef66449ea6470f3c266f98 Signed-off-by: John Dallaway (cherry picked from commit e62e2772fe26628dbdc0cf86675983f7c399e7aa) --- .../internal/buildmodel/BuildDescription.java | 39 +++++++++++++++++-- 1 file changed, 35 insertions(+), 4 deletions(-) diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/buildmodel/BuildDescription.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/buildmodel/BuildDescription.java index 125cf36fae5..45c45fddb0b 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/buildmodel/BuildDescription.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/buildmodel/BuildDescription.java @@ -8,6 +8,7 @@ * Contributors: * Intel Corporation - Initial API and implementation * IBM Corporation + * John Dallaway - Handle reduced build step input resource count (bug 366039) *******************************************************************************/ package org.eclipse.cdt.managedbuilder.internal.buildmodel; @@ -329,18 +330,28 @@ public class BuildDescription implements IBuildDescription { } - if(!removed && !rebuild){ + if(!removed){ for (BuildResource rc : rcs) { if(rc.needsRebuild()){ if(DbgUtil.DEBUG) DbgUtil.trace("resource " + locationToRel(rc.getLocation()).toString() + " needs rebuild"); //$NON-NLS-1$ //$NON-NLS-2$ rebuild = true; - break; - } else if(rc.isRemoved()){ + } + if(rc.isRemoved()){ if(DbgUtil.DEBUG) DbgUtil.trace("resource " + locationToRel(rc.getLocation()).toString() + " is removed"); //$NON-NLS-1$ //$NON-NLS-2$ + + // Remove the obsolete input resource from the action (Bug #366039) + for (BuildIOType type : action.getPrimaryTypes(true)) { + for (BuildResource res : (BuildResource[]) type.getResources()) { + if (res.equals(rc)) { + action.removeResource(type, rc, true); + break; + } + } + } + rebuild = true; - break; } } } @@ -356,6 +367,9 @@ public class BuildDescription implements IBuildDescription { DbgUtil.trace("setting remove state for resource " + locationToRel(outRc.getLocation()).toString()); //$NON-NLS-1$ ((BuildResource)outRc).setRemoved(true); + + // Delete the obsolete output file (Bug #366039) + deleteResource(outRc); } } else if(rebuild){ @@ -379,6 +393,23 @@ public class BuildDescription implements IBuildDescription { } } + private void deleteResource(IBuildResource rc) { + if (rc.isProjectResource()) { + final IResource resource = ResourcesPlugin.getWorkspace().getRoot().findMember(rc.getFullPath()); + if ((resource != null) && resource.isDerived(IResource.CHECK_ANCESTORS)) { + if (DbgUtil.DEBUG) { + DbgUtil.trace("deleting resource " + locationToRel(rc.getLocation()).toString()); //$NON-NLS-1$ + } + try { + resource.delete(false, null); + } catch (CoreException e) { + ManagedBuilderCorePlugin.log(new Status(IStatus.WARNING, + ManagedBuilderCorePlugin.PLUGIN_ID, IStatus.OK, e.getMessage(), e)); + } + } + } + } + private class ToolOrderEstimation { private ITool fTool; private ITool fDeps[];