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

bug 259768: "Use optimal jobs number" highly misleading.

Builder.getParallelizationNum() to return always positive value
This commit is contained in:
Andrew Gvozdev 2011-11-14 13:12:38 -05:00
parent 7f438e269a
commit f04bd57f83
8 changed files with 176 additions and 177 deletions

View file

@ -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()}
*/

View file

@ -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();

View file

@ -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);

View file

@ -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);
}

View file

@ -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();

View file

@ -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)

View file

@ -25,7 +25,6 @@ import org.eclipse.cdt.managedbuilder.internal.core.Configuration;
import org.eclipse.cdt.managedbuilder.internal.core.MultiConfiguration;
import org.eclipse.cdt.managedbuilder.internal.ui.Messages;
import org.eclipse.cdt.newmake.core.IMakeBuilderInfo;
import org.eclipse.cdt.newmake.core.IMakeCommonBuildInfo;
import org.eclipse.cdt.ui.newui.AbstractCPropertyTab;
import org.eclipse.cdt.ui.newui.ICPropertyProvider;
import org.eclipse.core.runtime.CoreException;
@ -231,12 +230,12 @@ public class BuildBehaviourTab extends AbstractCBuildPropertyTab {
* 0: isStopOnError
* 1: supportsStopOnError(true)
* 2: bld.supportsStopOnError(false)
* 3: cfg.getParallelDef()
* 3: N/A
* Mode 2:
* 0: b.isAutoBuildEnable()
* 1: b.isIncrementalBuildEnabled()
* 2: b.isCleanBuildEnabled()
* 3: getParallelDef()
* 3: N/A
*/
static int[] calc3states(ICPropertyProvider p, IConfiguration mcfg, int mode) {
if (p.isMultiCfg() && mcfg instanceof ICMultiItemsHolder) {
@ -253,8 +252,7 @@ public class BuildBehaviourTab extends AbstractCBuildPropertyTab {
(m1 ? bldr0.supportsStopOnError(true) : bldr0.isIncrementalBuildEnabled() );
b[2] = m0 ? bldr0.canKeepEnvironmentVariablesInBuildfile() :
(m1 ? bldr0.supportsStopOnError(false) : bldr0.isCleanBuildEnabled());
b[3] = m0 ? bldr0.keepEnvironmentVariablesInBuildfile() :
(m1 ? ((Configuration)cfgs[0]).getParallelDef() : getParallelDef(mcfg));
b[3] = m0 ? bldr0.keepEnvironmentVariablesInBuildfile() : false;
for (int i=1; i<cfgs.length; i++) {
IBuilder bldr = cfgs[i].getBuilder();
if (b[0] != (m0 ? bldr.isManagedBuildOn() :
@ -266,9 +264,7 @@ public class BuildBehaviourTab extends AbstractCBuildPropertyTab {
if (b[2] != (m0 ? bldr.canKeepEnvironmentVariablesInBuildfile() :
(m1 ? bldr.supportsStopOnError(false) : bldr.isCleanBuildEnabled())))
res[2] = TRI_UNKNOWN;
if ((b[3] != (m0 ? bldr.keepEnvironmentVariablesInBuildfile() :
(m1 ? ((Configuration)cfgs[i]).getParallelDef() : getParallelDef(mcfg))))
|| ((IMultiConfiguration) mcfg).getParallelNumber() == 0) {
if (b[3] != (m0 ? bldr.keepEnvironmentVariablesInBuildfile() : false)) {
res[3] = TRI_UNKNOWN;
}
}
@ -304,60 +300,22 @@ public class BuildBehaviourTab extends AbstractCBuildPropertyTab {
bldr.supportsStopOnError(false));
}
// Parallel build
boolean isParallelSupported = bldr.supportsParallelBuild();
boolean isExternalBuilder = ! isInternalBuilderEnabled();
b_parallel.setVisible(isParallelSupported);
b_parallelOptimal.setVisible(isParallelSupported);
b_parallelSpecific.setVisible(isParallelSupported);
b_parallelUnlimited.setVisible(isParallelSupported && isExternalBuilder);
s_parallelNumber.setVisible(isParallelSupported);
if (isParallelSupported) {
if (extStates == null) {
setTriSelection(b_parallel, getParallelDef());
} else {
setTriSelection(b_parallel, extStates[3]);
}
boolean isParallelSelected = b_parallel.getSelection();
int optimalParallelNumber = bldr.getOptimalParallelJobNum();
b_parallelOptimal.setText(MessageFormat.format(Messages.BuilderSettingsTab_UseOptimalJobs, optimalParallelNumber));
b_parallelOptimal.setEnabled(isParallelSelected);
b_parallelSpecific.setEnabled(isParallelSelected);
b_parallelUnlimited.setEnabled(isParallelSelected && isExternalBuilder);
extStates = calc3states(page, icfg, 2);
if (extStates == null) {
setTriSelection(b_autoBuild, bldr.isAutoBuildEnable());
setTriSelection(b_cmdBuild, bldr.isIncrementalBuildEnabled());
setTriSelection(b_cmdClean, bldr.isCleanBuildEnabled());
} else { // multiple configurations selected
setTriSelection(b_autoBuild, extStates[0]);
setTriSelection(b_cmdBuild, extStates[1]);
setTriSelection(b_cmdClean, extStates[2]);
}
if ((extStates == null || extStates[3] != TRI_UNKNOWN) && isParallelSelected) {
// single configuration or matching multiple configurations here
int parallelNumber = getParallelNumber();
boolean isOptimal = parallelNumber <= 0;
boolean isUnlimited = parallelNumber == Integer.MAX_VALUE;
b_parallelOptimal.setSelection(isOptimal);
b_parallelSpecific.setSelection(!isOptimal && !isUnlimited);
b_parallelUnlimited.setSelection(isUnlimited);
s_parallelNumber.setEnabled(b_parallelSpecific.getEnabled() && b_parallelSpecific.getSelection());
s_parallelNumber.setSelection(s_parallelNumber.isEnabled() ? parallelNumber : optimalParallelNumber);
} else {
b_parallelOptimal.setSelection(true);
b_parallelSpecific.setSelection(false);
b_parallelUnlimited.setSelection(false);
s_parallelNumber.setEnabled(false);
s_parallelNumber.setSelection(optimalParallelNumber);
}
}
updateParallelBlock();
// Build commands
extStates = calc3states(page, icfg, 2);
if (extStates != null) {
// multiple configurations selected
setTriSelection(b_autoBuild, extStates[0]);
setTriSelection(b_cmdBuild, extStates[1]);
setTriSelection(b_cmdClean, extStates[2]);
} else {
setTriSelection(b_autoBuild, bldr.isAutoBuildEnable());
setTriSelection(b_cmdBuild, bldr.isIncrementalBuildEnabled());
setTriSelection(b_cmdClean, bldr.isCleanBuildEnabled());
}
if (page.isMultiCfg()) {
MultiConfiguration mc = (MultiConfiguration)icfg;
t_autoBuild.setText(mc.getBuildAttribute(IBuilder.BUILD_TARGET_AUTO, EMPTY_STR));
@ -377,7 +335,7 @@ public class BuildBehaviourTab extends AbstractCBuildPropertyTab {
((Control)t_cmdBuild.getData()).setVisible(external);
t_cmdClean.setVisible(external);
((Control)t_cmdClean.getData()).setVisible(external);
if (external) {
checkPressed(b_autoBuild, false);
checkPressed(b_cmdBuild, false);
@ -386,6 +344,86 @@ public class BuildBehaviourTab extends AbstractCBuildPropertyTab {
canModify = true;
}
private void updateParallelBlock() {
// note: for multi-config selection bldr is from Active cfg
boolean isAnyInternalBuilder = bldr.isInternalBuilder();
boolean isAnyExternalBuilder = ! bldr.isInternalBuilder();
boolean isParallelSupported = bldr.supportsParallelBuild();
boolean isParallelOn = bldr.isParallelBuildOn();
int triSelection = isParallelOn ? TRI_YES : TRI_NO;
int parallelizationNumInternal = bldr.getParallelizationNumAttribute();
int optimalParallelNumber = bldr.getOptimalParallelJobNum();
int parallelNumber = bldr.getParallelizationNum();
boolean isUnlimited = parallelizationNumInternal == Integer.MAX_VALUE;
if (icfg instanceof ICMultiItemsHolder) {
IConfiguration[] cfgs = (IConfiguration[])((ICMultiItemsHolder)icfg).getItems();
boolean isAnyParallelOn = isParallelOn;
boolean isAnyParallelSupported = isParallelSupported;
boolean isParallelDiffers = false;
for (IConfiguration cfg : cfgs) {
Builder builder = (Builder) cfg.getBuilder();
isParallelDiffers = isParallelDiffers
|| builder.isParallelBuildOn() != isParallelOn
|| builder.getParallelizationNumAttribute() != parallelizationNumInternal;
isAnyParallelOn = isAnyParallelOn || builder.isParallelBuildOn();
isAnyParallelSupported = isAnyParallelSupported || builder.supportsParallelBuild();
isAnyInternalBuilder = isAnyInternalBuilder || builder.isInternalBuilder();
isAnyExternalBuilder = isAnyExternalBuilder || !builder.isInternalBuilder();
}
// reset initial display to "optimal" to enhance user experience:
if ((!isParallelSupported && isAnyParallelSupported) // parallel is supported by other than Active cfg
|| (!isParallelOn && isAnyParallelOn) // prevent showing the 1 job as parallel in the spinner
|| (isUnlimited && isAnyInternalBuilder) // can't show "unlimited" as it won't be selectable if Internal Builder present
) {
isParallelSupported = true;
parallelizationNumInternal = -optimalParallelNumber;
parallelNumber = optimalParallelNumber;
isUnlimited = false;
}
if (isParallelSupported && isParallelDiffers) {
triSelection = TRI_UNKNOWN;
}
}
b_parallel.setVisible(isParallelSupported);
b_parallelOptimal.setVisible(isParallelSupported);
b_parallelSpecific.setVisible(isParallelSupported);
b_parallelUnlimited.setVisible(isParallelSupported && isAnyExternalBuilder);
s_parallelNumber.setVisible(isParallelSupported);
if (isParallelSupported) {
setTriSelection(b_parallel, triSelection);
boolean isParallelSelected = b_parallel.getSelection();
b_parallelOptimal.setText(MessageFormat.format(Messages.BuilderSettingsTab_UseOptimalJobs, optimalParallelNumber));
b_parallelOptimal.setEnabled(isParallelSelected);
b_parallelSpecific.setEnabled(isParallelSelected);
b_parallelUnlimited.setEnabled(isParallelSelected && !isAnyInternalBuilder);
if (isParallelSelected) {
boolean isOptimal = parallelizationNumInternal <= 0;
b_parallelOptimal.setSelection(isOptimal);
b_parallelSpecific.setSelection(!isOptimal && !isUnlimited);
b_parallelUnlimited.setSelection(isUnlimited);
s_parallelNumber.setEnabled(b_parallelSpecific.getEnabled() && b_parallelSpecific.getSelection());
s_parallelNumber.setSelection(s_parallelNumber.isEnabled() ? parallelNumber : optimalParallelNumber);
} else {
b_parallelOptimal.setSelection(true);
b_parallelSpecific.setSelection(false);
b_parallelUnlimited.setSelection(false);
s_parallelNumber.setEnabled(false);
s_parallelNumber.setSelection(optimalParallelNumber);
}
}
}
/**
* Sets up text + corresponding button
* Checkbox can be implemented either by Button or by TriButton
@ -489,7 +527,7 @@ public class BuildBehaviourTab extends AbstractCBuildPropertyTab {
}
b2.setStopOnError(b1.isStopOnError());
b2.setParallelBuildOn(b1.isParallelBuildOn());
b2.setParallelizationNum(b1.getParallelizationNum());
b2.setParallelizationNum(((Builder) b1).getParallelizationNumAttribute());
if (b2.canKeepEnvironmentVariablesInBuildfile())
b2.setKeepEnvironmentVariablesInBuildfile(b1.keepEnvironmentVariablesInBuildfile());
((Builder)b2).setBuildPath(((Builder)b1).getBuildPathAttribute());
@ -531,22 +569,6 @@ public class BuildBehaviourTab extends AbstractCBuildPropertyTab {
updateData(getResDesc());
}
private static boolean getParallelDef(IConfiguration cfg) {
if (cfg instanceof Configuration)
return ((Configuration)cfg).getParallelDef();
if (cfg instanceof IMultiConfiguration)
return ((IMultiConfiguration)cfg).getParallelDef();
return false;
}
private boolean getParallelDef() {
if (icfg instanceof Configuration)
return ((Configuration)icfg).getParallelDef();
if (icfg instanceof IMultiConfiguration)
return ((IMultiConfiguration)icfg).getParallelDef();
return false;
}
private void setParallelDef(boolean def) {
if (icfg instanceof Configuration)
((Configuration)icfg).setParallelDef(def);
@ -554,16 +576,6 @@ public class BuildBehaviourTab extends AbstractCBuildPropertyTab {
((IMultiConfiguration)icfg).setParallelDef(def);
}
/**
* @see IMakeCommonBuildInfo#getParallelizationNum() for interpretation of the number.
*/
private int getParallelNumber() {
if (icfg instanceof Configuration)
return ((Configuration)icfg).getParallelNumber();
if (icfg instanceof IMultiConfiguration)
return ((IMultiConfiguration)icfg).getParallelNumber();
return 0;
}
private void setParallelNumber(int num) {
if (icfg instanceof Configuration)
((Configuration)icfg).setParallelNumber(num);

View file

@ -87,6 +87,7 @@ public class BuilderSettingsTab extends AbstractCBuildPropertyTab {
setupLabel(g1, Messages.BuilderSettingsTab_5, 1, GridData.BEGINNING);
t_buildCmd = setupBlock(g1, b_useDefault);
t_buildCmd.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
if (! canModify)
return;
@ -111,6 +112,7 @@ public class BuilderSettingsTab extends AbstractCBuildPropertyTab {
setupLabel(group_dir, Messages.BuilderSettingsTab_22, 1, GridData.BEGINNING);
t_dir = setupText(group_dir, 1, GridData.FILL_HORIZONTAL);
t_dir.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
if (canModify)
setBuildPath(t_dir.getText());