Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Gvozdev2011-11-14 13:12:38 -0500
committerAndrew Gvozdev2011-11-14 14:41:55 -0500
commitf04bd57f837ba147fc3ad4fcedd60ad8c481a12d (patch)
treeceefaaaa286dbd94442895037dc1f0c05945f4bb /build/org.eclipse.cdt.managedbuilder.core
parent7f438e269a654630b386900056de3bcd83f9ccad (diff)
downloadorg.eclipse.cdt-f04bd57f837ba147fc3ad4fcedd60ad8c481a12d.tar.gz
org.eclipse.cdt-f04bd57f837ba147fc3ad4fcedd60ad8c481a12d.tar.xz
org.eclipse.cdt-f04bd57f837ba147fc3ad4fcedd60ad8c481a12d.zip
bug 259768: "Use optimal jobs number" highly misleading.
Builder.getParallelizationNum() to return always positive value
Diffstat (limited to 'build/org.eclipse.cdt.managedbuilder.core')
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IMultiConfiguration.java27
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/InternalBuildRunner.java2
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/buildmodel/ParallelBuilder.java2
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Builder.java106
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Configuration.java10
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/newmake/core/IMakeCommonBuildInfo.java18
6 files changed, 75 insertions, 90 deletions
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IMultiConfiguration.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IMultiConfiguration.java
index f1307bb6ba..98498c8cb4 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IMultiConfiguration.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IMultiConfiguration.java
@@ -14,7 +14,6 @@ import org.eclipse.cdt.core.settings.model.ICMultiItemsHolder;
import org.eclipse.cdt.managedbuilder.buildproperties.IBuildProperty;
import org.eclipse.cdt.managedbuilder.buildproperties.IBuildPropertyValue;
import org.eclipse.cdt.managedbuilder.internal.core.Builder;
-import org.eclipse.cdt.newmake.core.IMakeCommonBuildInfo;
/**
* This class is to combine multiple configurations to one to support
@@ -26,12 +25,13 @@ import org.eclipse.cdt.newmake.core.IMakeCommonBuildInfo;
public interface IMultiConfiguration extends IConfiguration, ICMultiItemsHolder {
/**
- * Check if the configuration's builder is operating in parallel mode.
- * @return {@code true} if parallel mode is enabled, {@code false} otherwise.
+ * Check if all configurations' builders are operating in parallel mode.
+ * @return {@code true} if parallel mode is enabled for all configurations,
+ * {@code false} otherwise.
*/
boolean getParallelDef();
/**
- * Set parallel execution mode for the configuration's builder.
+ * Set same parallel execution mode for all configurations' builders.
* @see Builder#setParallelBuildOn(boolean)
*
* @param parallel - the flag to enable or disable parallel mode.
@@ -39,18 +39,16 @@ public interface IMultiConfiguration extends IConfiguration, ICMultiItemsHolder
void setParallelDef(boolean parallel);
/**
- * Returns maximum number of parallel threads/jobs used by the configuration's builder.
- * Note that this function can return negative value to indicate "optimal" number.
- *
+ * Returns maximum number of parallel threads/jobs used by the configurations' builders.
* @see #setParallelDef(boolean)
- * @see Builder#getParallelizationNum()
*
- * @return - maximum number of parallel threads or jobs used by the builder or negative number.
- * For exact interpretation see table in {@link IMakeCommonBuildInfo#getParallelizationNum()}
+ * @return - maximum number of parallel threads or jobs used by each builder or 0 if the numbers
+ * don't match.
*/
int getParallelNumber();
+
/**
- * Sets maximum number of parallel threads/jobs to be used by builder.
+ * Sets maximum number of parallel threads/jobs to be used by each builder.
* Note that the number will be set only if the builder is in "parallel"
* mode.
*
@@ -61,10 +59,9 @@ public interface IMultiConfiguration extends IConfiguration, ICMultiItemsHolder
void setParallelNumber(int jobs);
/**
- * returns the Internal Builder parallel mode
- * if true, internal builder will work in parallel mode
- * otherwise it will use only one thread
- * @return boolean
+ * Check if all configurations' internal builders are operating in parallel mode.
+ * @return {@code true} if parallel mode is enabled for all configurations,
+ * {@code false} otherwise.
*
* @deprecated since CDT 9.0. Use {@link #getParallelDef()}
*/
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 502c13732d..8c2cf096a4 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
@@ -65,7 +65,7 @@ public class InternalBuildRunner extends AbstractBuildRunner {
public boolean invokeBuild(int kind, IProject project, IConfiguration configuration,
IBuilder builder, IConsole console, IMarkerGenerator markerGenerator,
IncrementalProjectBuilder projectBuilder, IProgressMonitor monitor) throws CoreException {
- boolean isParallel = Math.abs(builder.getParallelizationNum()) > 1;
+ boolean isParallel = builder.getParallelizationNum() > 1;
// boolean buildIncrementaly = true;
boolean resumeOnErr = !builder.isStopOnError();
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 7dfcedf63c..814e0310bf 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
@@ -206,7 +206,7 @@ public class ParallelBuilder {
if(cwd == null) cwd = des.getDefaultBuildDirLocation();
int threads = 1;
if (cfg instanceof Configuration) {
- threads = Math.abs(((Configuration)cfg).getParallelNumber());
+ threads = ((Configuration)cfg).getParallelNumber();
}
ParallelBuilder builder = new ParallelBuilder(cwd, dirs, out, err, monitor, resumeOnErrors, buildIncrementally);
builder.enqueueAll(des);
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Builder.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Builder.java
index 22172cf3b8..b9e27e02f9 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Builder.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Builder.java
@@ -67,6 +67,7 @@ import org.eclipse.cdt.managedbuilder.makegen.gnu.GnuMakefileGenerator;
import org.eclipse.cdt.newmake.core.IMakeCommonBuildInfo;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IncrementalProjectBuilder;
+import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IExtension;
@@ -123,7 +124,7 @@ public class Builder extends HoldsOptions implements IBuilder, IMatchKeyProvider
// parallelization
private String parallelBuildCmd;
private Boolean isParallelBuildEnabled;
- private Integer parallelJobsNumber; // negative number denotes "optimal" value, see getOptimalParallelJobNum()
+ private Integer parallelNumberAttribute; // negative number denotes "optimal" value, see getOptimalParallelJobNum()
private boolean isTest;
@@ -331,7 +332,7 @@ public class Builder extends HoldsOptions implements IBuilder, IMatchKeyProvider
ignoreErrCmd = builder.ignoreErrCmd;
isParallelBuildEnabled = builder.isParallelBuildEnabled;
- parallelJobsNumber = builder.parallelJobsNumber;
+ parallelNumberAttribute = builder.parallelNumberAttribute;
parallelBuildCmd = builder.parallelBuildCmd;
if(builder.outputEntries != null){
@@ -381,9 +382,9 @@ public class Builder extends HoldsOptions implements IBuilder, IMatchKeyProvider
} catch (CoreException e) {
}
}
- if (getParallelizationNum() != builder.getParallelizationNum() && supportsParallelBuild()) {
+ if (getParallelizationNumAttribute() != builder.getParallelizationNumAttribute() && supportsParallelBuild()) {
try {
- setParallelizationNum(builder.getParallelizationNum());
+ setParallelizationNum(builder.getParallelizationNumAttribute());
} catch (CoreException e) {
}
}
@@ -631,29 +632,29 @@ public class Builder extends HoldsOptions implements IBuilder, IMatchKeyProvider
private void decodeParallelizationNumber(String value) {
if (VALUE_OPTIMAL.equals(value)) {
- parallelJobsNumber = -getOptimalParallelJobNum();
+ parallelNumberAttribute = -getOptimalParallelJobNum();
} else if (VALUE_UNLIMITED.equals(value)) {
if (!isInternalBuilder()) {
- parallelJobsNumber = Integer.MAX_VALUE;
+ parallelNumberAttribute = Integer.MAX_VALUE;
} else {
ManagedBuilderCorePlugin.error("'unlimited' number of jobs is not allowed for Internal Builder, switching to 'optimal'");
- parallelJobsNumber = -getOptimalParallelJobNum();
+ parallelNumberAttribute = -getOptimalParallelJobNum();
}
} else {
try {
- parallelJobsNumber = Integer.decode(value);
+ parallelNumberAttribute = Integer.decode(value);
} catch (NumberFormatException e) {
ManagedBuilderCorePlugin.log(e);
- parallelJobsNumber = getOptimalParallelJobNum();
+ parallelNumberAttribute = getOptimalParallelJobNum();
}
- if (parallelJobsNumber <= 0) {
+ if (parallelNumberAttribute <= 0) {
// compatibility with legacy representation - it was that inconsistent
if (isInternalBuilder()) {
// "optimal" for Internal Builder
- parallelJobsNumber = -getOptimalParallelJobNum();
+ parallelNumberAttribute = -getOptimalParallelJobNum();
} else {
// unlimited for External Builder
- parallelJobsNumber = Integer.MAX_VALUE;
+ parallelNumberAttribute = Integer.MAX_VALUE;
}
}
}
@@ -918,8 +919,8 @@ public class Builder extends HoldsOptions implements IBuilder, IMatchKeyProvider
if (isParallelBuildEnabled != null)
element.setAttribute(ATTRIBUTE_PARALLEL_BUILD_ON, isParallelBuildEnabled.toString());
- if (isParallelBuildOn() && parallelJobsNumber != null)
- element.setAttribute(ATTRIBUTE_PARALLELIZATION_NUMBER, encodeParallelizationNumber(parallelJobsNumber));
+ if (isParallelBuildOn() && parallelNumberAttribute != null)
+ element.setAttribute(ATTRIBUTE_PARALLELIZATION_NUMBER, encodeParallelizationNumber(parallelNumberAttribute));
// Note: build file generator cannot be specified in a project file because
// an IConfigurationElement is needed to load it!
@@ -1016,8 +1017,8 @@ public class Builder extends HoldsOptions implements IBuilder, IMatchKeyProvider
if (isParallelBuildEnabled != null)
element.setAttribute(ATTRIBUTE_PARALLEL_BUILD_ON, isParallelBuildEnabled.toString());
- if (isParallelBuildOn() && parallelJobsNumber != null)
- element.setAttribute(ATTRIBUTE_PARALLELIZATION_NUMBER, encodeParallelizationNumber(parallelJobsNumber));
+ if (isParallelBuildOn() && parallelNumberAttribute != null)
+ element.setAttribute(ATTRIBUTE_PARALLELIZATION_NUMBER, encodeParallelizationNumber(parallelNumberAttribute));
// Note: build file generator cannot be specified in a project file because
// an IConfigurationElement is needed to load it!
@@ -1095,10 +1096,11 @@ public class Builder extends HoldsOptions implements IBuilder, IMatchKeyProvider
public String getArguments() {
String args = getArgumentsAttribute();
String stopOnErrCmd = getStopOnErrCmd(isStopOnError());
- String parallelCmd = isParallelBuildOn() ? getParallelizationCmd(getParallelizationNum()) : EMPTY_STRING;
+ int parallelNum = getParallelizationNum();
+ String parallelCmd = isParallelBuildOn() ? getParallelizationCmd(parallelNum) : EMPTY_STRING;
String reversedStopOnErrCmd = getStopOnErrCmd(!isStopOnError());
- String reversedParallelBuildCmd = !isParallelBuildOn() ? getParallelizationCmd(getParallelizationNum()) : EMPTY_STRING;
+ String reversedParallelBuildCmd = !isParallelBuildOn() ? getParallelizationCmd(parallelNum) : EMPTY_STRING;
args = removeCmd(args, reversedStopOnErrCmd);
args = removeCmd(args, reversedParallelBuildCmd);
@@ -1167,16 +1169,14 @@ public class Builder extends HoldsOptions implements IBuilder, IMatchKeyProvider
return index;
}
- public String getParallelizationCmd(int num){
+ public String getParallelizationCmd(int num) {
String pattern = getParrallelBuildCmd();
- if(pattern.length() == 0){
- return EMPTY_STRING;
- }if(num == 0){
+ if (pattern.length() == 0 || num == 0) {
return EMPTY_STRING;
}
// "unlimited" number of jobs results in not adding the number to parallelization cmd
// that behavior corresponds that of "make" flag "-j".
- return processParallelPattern(pattern, num == Integer.MAX_VALUE, Math.abs(num));
+ return processParallelPattern(pattern, num == Integer.MAX_VALUE, num);
}
/**
@@ -1188,6 +1188,8 @@ public class Builder extends HoldsOptions implements IBuilder, IMatchKeyProvider
* <br>Where # is num or empty if {@code empty} is {@code true})
*/
private String processParallelPattern(String pattern, boolean empty, int num){
+ Assert.isTrue(num > 0);
+
int start = pattern.indexOf(PARALLEL_PATTERN_NUM_START);
int end = -1;
boolean hasStartChar = false;
@@ -2527,46 +2529,40 @@ public class Builder extends HoldsOptions implements IBuilder, IMatchKeyProvider
}
/**
- * {@inheritDoc}
- *
- * Returns the number of parallel jobs to be used for a build.
+ * Returns the internal representation of maximum number of parallel jobs
+ * to be used for a build.
* Note that "optimal" value is represented by negative number.
- * See the table at {@link IMakeCommonBuildInfo#getParallelizationNum()}.
+ *
+ * The value of the number is encoded as follows:
+ * <pre>
+ * Status Returns
+ * No parallel 1
+ * Optimal -CPU# (negative number of processors)
+ * Specific >0 (positive number)
+ * Unlimited Integer.MAX (N/A for Internal Builder)
+ * </pre>
*/
- @Override
- public int getParallelizationNum() {
+ public int getParallelizationNumAttribute() {
if (!isParallelBuildOn())
return 1;
-
- if(parallelJobsNumber == null){
- if(superClass != null){
- return ((Builder)superClass).getParallelizationNum();
- }
- return 1;
- }
- return parallelJobsNumber.intValue();
- }
-
- public int getParallelizationNumAttribute(){
- if(parallelJobsNumber == null){
+
+ if(parallelNumberAttribute == null){
if(superClass != null){
return ((Builder)superClass).getParallelizationNumAttribute();
}
return 1;
}
- return parallelJobsNumber.intValue();
+ return parallelNumberAttribute.intValue();
+ }
+
+ @Override
+ public int getParallelizationNum() {
+ return Math.abs(getParallelizationNumAttribute());
}
- /**
- * {@inheritDoc}
- *
- * @param jobs - maximum number of jobs or threads. If the number is 0
- * or negative, negative "optimal" number will be set, see
- * {@link #getOptimalParallelJobNum()}.
- */
@Override
public void setParallelizationNum(int jobs) throws CoreException {
- if (isParallelBuildOn() && (parallelJobsNumber == null || parallelJobsNumber != jobs)) {
+ if (isParallelBuildOn() && (parallelNumberAttribute == null || parallelNumberAttribute != jobs)) {
String curCmd = getParallelizationCmd(getParallelizationNum());
String args = getArgumentsAttribute();
String updatedArgs = removeCmd(args, curCmd);
@@ -2579,10 +2575,10 @@ public class Builder extends HoldsOptions implements IBuilder, IMatchKeyProvider
jobs = -1;
}
if (jobs > 0) {
- parallelJobsNumber = jobs;
+ parallelNumberAttribute = jobs;
} else {
// "optimal"
- parallelJobsNumber = -getOptimalParallelJobNum();
+ parallelNumberAttribute = -getOptimalParallelJobNum();
}
setDirty(true);
}
@@ -2647,7 +2643,7 @@ public class Builder extends HoldsOptions implements IBuilder, IMatchKeyProvider
*
* @param on - the flag to enable or disable parallel mode.
* <br>{@code true} to enable, in this case the maximum number of jobs
- * will be set to negative "optimal" number, see {@link #getOptimalParallelJobNum()}.
+ * will be set to "optimal" number, see {@link #getOptimalParallelJobNum()}.
* <br>{@code false} to disable, the number of jobs will be set to 1.
*/
@Override
@@ -2668,9 +2664,9 @@ public class Builder extends HoldsOptions implements IBuilder, IMatchKeyProvider
if (isParallelBuildEnabled) {
// "optimal"
- parallelJobsNumber = -getOptimalParallelJobNum();
+ parallelNumberAttribute = -getOptimalParallelJobNum();
} else {
- parallelJobsNumber = 1;
+ parallelNumberAttribute = 1;
}
setDirty(true);
}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Configuration.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Configuration.java
index 271b1c94ae..5d552fc959 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Configuration.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Configuration.java
@@ -2273,8 +2273,8 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild
* mode.
*
* @param jobs - maximum number of jobs or threads. If the number is 0
- * or negative, negative "optimal" number will be set, see
- * {@link Builder#getOptimalParallelJobNum()}.
+ * or negative, "optimal" number will be set,
+ * see {@link Builder#getOptimalParallelJobNum()}.
*/
public void setParallelNumber(int jobs){
try {
@@ -2286,13 +2286,9 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild
/**
* Returns maximum number of parallel threads/jobs used by the configuration's builder.
- * Note that this function can return negative value to indicate "optimal" number.
- *
* @see #setParallelDef(boolean)
- * @see Builder#getParallelizationNum()
*
- * @return - maximum number of parallel threads or jobs used by the builder or negative number.
- * For exact interpretation see table in {@link IMakeCommonBuildInfo#getParallelizationNum()}
+ * @return - maximum number of parallel threads or jobs used by the builder.
*/
public int getParallelNumber(){
return getBuilder().getParallelizationNum();
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/newmake/core/IMakeCommonBuildInfo.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/newmake/core/IMakeCommonBuildInfo.java
index 3d1a919d7f..553c78170b 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/newmake/core/IMakeCommonBuildInfo.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/newmake/core/IMakeCommonBuildInfo.java
@@ -44,15 +44,7 @@ public interface IMakeCommonBuildInfo {
boolean supportsStopOnError(boolean on);
/**
- * @return the current number of parallel jobs.
- * The value of the number is encoded as follows:
- * <pre>
- * Status Returns
- * No parallel 1
- * Unlimited Integer.MAX (N/A for Internal Builder)
- * Optimal -CPU# (negative number of processors)
- * Specific >0 (positive number)
- * </pre>
+ * @return the maximum number of parallel jobs to be used for build.
*/
int getParallelizationNum();
@@ -61,21 +53,25 @@ public interface IMakeCommonBuildInfo {
* Note that the number will be set only if the builder is in "parallel"
* mode.
*
- * @param jobs - number of jobs according table {@link #getParallelizationNum()}.
+ * @param jobs - maximum number of jobs.
* Any number <=0 is treated as setting "optimal" property,
- * the value of the number itself is ignored.
+ * the value of the number itself is ignored in this case.
*/
void setParallelizationNum(int jobs) throws CoreException;
+
/**
* @return {@code true} if builder supports parallel build,
* {@code false} otherwise.
*/
+
boolean supportsParallelBuild();
+
/**
* @return {@code true} if builder support for parallel build is enabled,
* {@code false} otherwise.
*/
boolean isParallelBuildOn();
+
/**
* Set parallel execution mode for the builder.
* @see Builder#setParallelBuildOn(boolean)

Back to the top