Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSamuel Hultgren2018-04-13 15:37:32 +0000
committerDoug Schaefer2018-04-17 15:53:41 +0000
commitc2b5e840872a122209f418e066c4184fca2c0575 (patch)
tree2d0bac2b8f09a221ce54b9dad09cf13f7ceaf190
parent40daa34fdae211b842e79f20d03e9c0fcf2d1349 (diff)
downloadorg.eclipse.cdt-c2b5e840872a122209f418e066c4184fca2c0575.tar.gz
org.eclipse.cdt-c2b5e840872a122209f418e066c4184fca2c0575.tar.xz
org.eclipse.cdt-c2b5e840872a122209f418e066c4184fca2c0575.zip
Bug 217674 - Added incremental build support
When building a project with parallel builder using internal builder, the entire project is rebuilt even if an incremental build was issued. Store the rebuild state so that next build knows what has already been compiled. Change-Id: I1d1836f072bf13b03423fde7b5c427d41e47391e Signed-off-by: Samuel Hultgren <samuel.hultgren@st.com>
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/InternalBuildRunner.java3
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/buildmodel/ParallelBuilder.java97
2 files changed, 96 insertions, 4 deletions
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/InternalBuildRunner.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/InternalBuildRunner.java
index 564d231f7e..5e50830cb2 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/InternalBuildRunner.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/InternalBuildRunner.java
@@ -9,6 +9,7 @@
* Wind River Systems - Initial API and implementation
* James Blackburn (Broadcom Corp.)
* IBM Corporation
+ * Samuel Hultgren (STMicroelectronics) - bug #217674
*******************************************************************************/
package org.eclipse.cdt.managedbuilder.core;
@@ -130,7 +131,7 @@ public class InternalBuildRunner extends AbstractBuildRunner {
if (dBuilder != null) {
status = dBuilder.build(stdout, stderr, new SubProgressMonitor(monitor, TICKS_EXECUTE_COMMAND, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK));
} else {
- status = ParallelBuilder.build(des, null, null, stdout, stderr, new SubProgressMonitor(monitor, TICKS_EXECUTE_COMMAND, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK), resumeOnErr, buildIncrementaly);
+ status = ParallelBuilder.build(des, null, null, stdout, stderr, new SubProgressMonitor(monitor, TICKS_EXECUTE_COMMAND, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK), resumeOnErr, buildIncrementaly, cBS);
// Bug 403670:
// Make sure the build configuration's rebuild status is updated with the result of
// this successful build. In the non-parallel case this happens within dBuilder.build
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/buildmodel/ParallelBuilder.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/buildmodel/ParallelBuilder.java
index 12ee11940b..a51a3114b7 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/buildmodel/ParallelBuilder.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/buildmodel/ParallelBuilder.java
@@ -7,6 +7,7 @@
*
* Contributors:
* Intel Corporation - Initial API and implementation
+ * Samuel Hultgren (STMicroelectronics) - bug #217674
*******************************************************************************/
package org.eclipse.cdt.managedbuilder.internal.buildmodel;
@@ -62,6 +63,8 @@ public class ParallelBuilder {
protected HashSet<BuildQueueElement> unsorted = new HashSet<BuildQueueElement>();
protected HashMap<IBuildStep, BuildQueueElement> queueHash = new HashMap<IBuildStep, BuildQueueElement>();
protected LinkedList<BuildQueueElement> queue = new LinkedList<BuildQueueElement>();
+ private IResourceRebuildStateContainer fRebuildStateContainer;
+ private IBuildDescription fDes;
/**
* This class implements queue element
@@ -202,9 +205,33 @@ public class ParallelBuilder {
* compilation errors encountered
* @return the status of the operation, one of {@link ParallelBuilder#STATUS_OK},
* {@link ParallelBuilder#STATUS_ERROR}, {@link ParallelBuilder#STATUS_CANCELED}, or {@link
- * ParallelBuilder#STATUS_INVALID}. *
+ * ParallelBuilder#STATUS_INVALID}.
+ * @see #build(IBuildDescription, IPath, GenDirInfo, OutputStream, OutputStream, IProgressMonitor, boolean, boolean, IResourceRebuildStateContainer)
*/
static public int build(IBuildDescription des, IPath cwd, GenDirInfo dirs, OutputStream out, OutputStream err, IProgressMonitor monitor, boolean resumeOnErrors, boolean buildIncrementally) {
+ return build(des, cwd, dirs, out, err, monitor, resumeOnErrors, buildIncrementally, null);
+ }
+
+ /**
+ * Build process is divided into following steps:
+ * 1. Resources enqueueing & levelling
+ * 2. Queue sorting
+ * 3. Queue dispatching
+ *
+ * @param des Build description
+ * @param cwd Working directory
+ * @param dirs GenDirInfo?
+ * @param out Output stream
+ * @param err Error output stream
+ * @param monitor Progress monitor
+ * @param resumeOnErrors If true, build process will not stop when
+ * compilation errors encountered
+ * @param rs Rebuild state container
+ * @return the status of the operation, one of {@link ParallelBuilder#STATUS_OK},
+ * {@link ParallelBuilder#STATUS_ERROR}, {@link ParallelBuilder#STATUS_CANCELED}, or {@link
+ * ParallelBuilder#STATUS_INVALID}.
+ */
+ static public int build(IBuildDescription des, IPath cwd, GenDirInfo dirs, OutputStream out, OutputStream err, IProgressMonitor monitor, boolean resumeOnErrors, boolean buildIncrementally, IResourceRebuildStateContainer rs) {
IConfiguration cfg = des.getConfiguration();
if(dirs == null) dirs = new GenDirInfo(cfg);
if(cwd == null) cwd = des.getDefaultBuildDirLocation();
@@ -212,7 +239,9 @@ public class ParallelBuilder {
if (cfg instanceof Configuration) {
threads = ((Configuration)cfg).getParallelNumber();
}
- ParallelBuilder builder = new ParallelBuilder(cwd, dirs, out, err, monitor, resumeOnErrors, buildIncrementally);
+
+ ParallelBuilder builder = new ParallelBuilder(cwd, dirs, out, err, monitor, resumeOnErrors, buildIncrementally, rs, des);
+ builder.initRebuildStates();
builder.enqueueAll(des);
builder.sortQueue();
monitor.beginTask("", builder.queue.size()); //$NON-NLS-1$
@@ -220,13 +249,56 @@ public class ParallelBuilder {
int status = builder.dispatch(buildProcessManager);
lastThreadsUsed = buildProcessManager.getThreadsUsed();
monitor.done();
+
+ if (status == IBuildModelBuilder.STATUS_OK) {
+ builder.clearRebuildStates();
+ }
+
return status;
}
+ private void initRebuildStates() {
+ if (fRebuildStateContainer == null) {
+ return;
+ }
+
+ fRebuildStateContainer.setState(0);
+
+ IBuildResource[] rcs = fDes.getResources();
+ putAll(fRebuildStateContainer, rcs, IRebuildState.NEED_REBUILD, true);
+ }
+
+ private void clearRebuildStates() {
+ if (fRebuildStateContainer == null) {
+ return;
+ }
+
+ fRebuildStateContainer.setState(0);
+ }
+
+ private static void putAll(IResourceRebuildStateContainer cbs, IBuildResource[] rcs, int state, boolean rebuildRcOnly) {
+ for (IBuildResource rc : rcs) {
+ if (rebuildRcOnly && !rc.needsRebuild()) {
+ continue;
+ }
+
+ if (!rc.isProjectResource()) {
+ continue;
+ }
+
+ IPath fullPath = rc.getFullPath();
+ if (fullPath == null) {
+ continue;
+ }
+
+ cbs.setStateForFullPath(fullPath, state);
+ }
+ }
+
/**
* Initializes parallel builder
*/
- protected ParallelBuilder(IPath _cwd, GenDirInfo _dirs, OutputStream _out, OutputStream _err, IProgressMonitor _monitor, boolean _resumeOnErrors, boolean _buildIncrementally) {
+ protected ParallelBuilder(IPath _cwd, GenDirInfo _dirs, OutputStream _out, OutputStream _err, IProgressMonitor _monitor, boolean _resumeOnErrors, boolean _buildIncrementally, IResourceRebuildStateContainer _fRebuildStateContainer, IBuildDescription _fDes) {
cwd = _cwd;
dirs = _dirs;
out = _out;
@@ -234,6 +306,8 @@ public class ParallelBuilder {
monitor = _monitor;
resumeOnErrors = _resumeOnErrors;
buildIncrementally = _buildIncrementally;
+ fRebuildStateContainer = _fRebuildStateContainer;
+ fDes = _fDes;
}
/**
@@ -483,6 +557,23 @@ public class ParallelBuilder {
catch (CoreException e) {}
}
}
+
+ clearStepRebuildStep(step);
+ }
+
+ /**
+ * Clear rebuild state for the step
+ */
+ protected void clearStepRebuildStep(IBuildStep step) {
+ if (fRebuildStateContainer == null) {
+ return;
+ }
+
+ // Clear the rebuildstate for the step
+ IBuildResource outres[] = step.getOutputResources();
+ putAll(fRebuildStateContainer, outres, 0, false);
+ IBuildResource inres[] = step.getInputResources();
+ putAll(fRebuildStateContainer, inres, 0, false);
}

Back to the top