mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-31 12:55:40 +02:00
Add IOptionApplicability callback
Add more multi-version tool-chain support
This commit is contained in:
parent
107015f427
commit
74d7f35845
3 changed files with 178 additions and 60 deletions
|
@ -377,7 +377,17 @@ public class BuildSettingsBlock extends AbstractCOptionPage {
|
||||||
if (builder.isExtensionElement()) {
|
if (builder.isExtensionElement()) {
|
||||||
IToolChain tc = selectedConfiguration.getToolChain();
|
IToolChain tc = selectedConfiguration.getToolChain();
|
||||||
int nnn = ManagedBuildManager.getRandomNumber();
|
int nnn = ManagedBuildManager.getRandomNumber();
|
||||||
String subId = builder.getId() + "." + nnn; //$NON-NLS-1$
|
String subId;
|
||||||
|
String tmpId;
|
||||||
|
String version;
|
||||||
|
|
||||||
|
tmpId = builder.getId();
|
||||||
|
version = ManagedBuildManager.getVersionFromIdAndVersion(tmpId);
|
||||||
|
if ( version != null) { // If the 'tmpId' contains version information
|
||||||
|
subId = ManagedBuildManager.getIdFromIdAndVersion(tmpId) + "." + nnn + "_" + version; //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
|
} else {
|
||||||
|
subId = tmpId + "." + nnn; //$NON-NLS-1$
|
||||||
|
}
|
||||||
String name = builder.getName() + "." + selectedConfiguration.getName(); //$NON-NLS-1$
|
String name = builder.getName() + "." + selectedConfiguration.getName(); //$NON-NLS-1$
|
||||||
tc.createBuilder(builder, subId, name, false);
|
tc.createBuilder(builder, subId, name, false);
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,6 +17,7 @@ import java.util.Collection;
|
||||||
|
|
||||||
import org.eclipse.cdt.managedbuilder.core.BuildException;
|
import org.eclipse.cdt.managedbuilder.core.BuildException;
|
||||||
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
|
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
|
||||||
|
import org.eclipse.cdt.managedbuilder.core.IOptionApplicability;
|
||||||
import org.eclipse.cdt.managedbuilder.core.IOption;
|
import org.eclipse.cdt.managedbuilder.core.IOption;
|
||||||
import org.eclipse.cdt.managedbuilder.core.IOptionCategory;
|
import org.eclipse.cdt.managedbuilder.core.IOptionCategory;
|
||||||
import org.eclipse.cdt.managedbuilder.core.IResourceConfiguration;
|
import org.eclipse.cdt.managedbuilder.core.IResourceConfiguration;
|
||||||
|
@ -27,13 +28,16 @@ import org.eclipse.jface.preference.FieldEditor;
|
||||||
import org.eclipse.jface.preference.StringFieldEditor;
|
import org.eclipse.jface.preference.StringFieldEditor;
|
||||||
import org.eclipse.jface.preference.DirectoryFieldEditor;
|
import org.eclipse.jface.preference.DirectoryFieldEditor;
|
||||||
import org.eclipse.jface.preference.FileFieldEditor;
|
import org.eclipse.jface.preference.FileFieldEditor;
|
||||||
|
import org.eclipse.jface.util.PropertyChangeEvent;
|
||||||
import org.eclipse.swt.graphics.Point;
|
import org.eclipse.swt.graphics.Point;
|
||||||
|
import org.eclipse.swt.widgets.Composite;
|
||||||
import java.lang.AssertionError;
|
import java.lang.AssertionError;
|
||||||
|
|
||||||
public class BuildOptionSettingsPage extends BuildSettingsPage {
|
public class BuildOptionSettingsPage extends BuildSettingsPage {
|
||||||
private Map fieldsMap = new HashMap();
|
private Map fieldsMap = new HashMap();
|
||||||
private IOptionCategory category;
|
private IOptionCategory category;
|
||||||
private boolean isItResourceConfigPage;
|
private boolean isItResourceConfigPage;
|
||||||
|
private Map fieldEditorsToParentMap = new HashMap();
|
||||||
|
|
||||||
public BuildOptionSettingsPage(IConfiguration configuration, IOptionCategory category) {
|
public BuildOptionSettingsPage(IConfiguration configuration, IOptionCategory category) {
|
||||||
// Cache the configuration and option category this page is created for
|
// Cache the configuration and option category this page is created for
|
||||||
|
@ -75,51 +79,84 @@ public class BuildOptionSettingsPage extends BuildSettingsPage {
|
||||||
ITool tool = (ITool)options[index][0];
|
ITool tool = (ITool)options[index][0];
|
||||||
if (tool == null) break; // The array may not be full
|
if (tool == null) break; // The array may not be full
|
||||||
IOption opt = (IOption)options[index][1];
|
IOption opt = (IOption)options[index][1];
|
||||||
|
|
||||||
|
// check to see if the option has an applicability calculator
|
||||||
|
IOptionApplicability applicabilityCalculator = opt.getApplicabilityCalculator();
|
||||||
|
|
||||||
|
// is the option visible?
|
||||||
|
if (applicabilityCalculator == null || applicabilityCalculator.isOptionVisible(tool)) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Figure out which type the option is and add a proper field
|
// Figure out which type the option is and add a proper field
|
||||||
// editor for it
|
// editor for it
|
||||||
switch (opt.getValueType()) {
|
switch (opt.getValueType()) {
|
||||||
case IOption.STRING :
|
case IOption.STRING:
|
||||||
// fix for PR 63973
|
// fix for PR 63973
|
||||||
// Check browse type.
|
// Check browse type.
|
||||||
// If browsing is set, use a field editor that has a browse button of
|
// If browsing is set, use a field editor that has a
|
||||||
// the appropriate type.
|
// browse button of
|
||||||
// Otherwise, use a regular text field.
|
// the appropriate type.
|
||||||
switch(opt.getBrowseType())
|
// Otherwise, use a regular text field.
|
||||||
{
|
switch (opt.getBrowseType()) {
|
||||||
case IOption.BROWSE_DIR :
|
case IOption.BROWSE_DIR:
|
||||||
DirectoryFieldEditor dirFieldEditor = new DirectoryFieldEditor(
|
Composite fieldEditorParent2 = getFieldEditorParent();
|
||||||
opt.getId(), opt.getName(), getFieldEditorParent());
|
DirectoryFieldEditor dirFieldEditor = new DirectoryFieldEditor(
|
||||||
addField(dirFieldEditor);
|
opt.getId(), opt.getName(), fieldEditorParent2);
|
||||||
fieldsMap.put(opt.getId(), dirFieldEditor);
|
|
||||||
break;
|
setFieldEditorEnablement(tool,
|
||||||
|
applicabilityCalculator, dirFieldEditor, fieldEditorParent2);
|
||||||
case IOption.BROWSE_FILE:
|
|
||||||
FileFieldEditor fileFieldEditor = new FileFieldEditor(
|
addField(dirFieldEditor);
|
||||||
opt.getId(), opt.getName(), getFieldEditorParent());
|
fieldsMap.put(opt.getId(), dirFieldEditor);
|
||||||
addField(fileFieldEditor);
|
fieldEditorsToParentMap.put(dirFieldEditor, fieldEditorParent2);
|
||||||
fieldsMap.put(opt.getId(), fileFieldEditor);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IOption.BROWSE_NONE:
|
case IOption.BROWSE_FILE:
|
||||||
StringFieldEditor stringField = new StringFieldEditor(
|
Composite fieldEditorParent3 = getFieldEditorParent();
|
||||||
opt.getId(), opt.getName(), getFieldEditorParent());
|
FileFieldEditor fileFieldEditor = new FileFieldEditor(
|
||||||
addField(stringField);
|
opt.getId(), opt.getName(), fieldEditorParent3);
|
||||||
fieldsMap.put(opt.getId(), stringField);
|
|
||||||
break;
|
setFieldEditorEnablement(tool,
|
||||||
|
applicabilityCalculator, fileFieldEditor, fieldEditorParent3);
|
||||||
default:
|
|
||||||
// should not be possible
|
addField(fileFieldEditor);
|
||||||
throw( new AssertionError()); }
|
fieldsMap.put(opt.getId(), fileFieldEditor);
|
||||||
// end fix for 63973
|
fieldEditorsToParentMap.put(fileFieldEditor, fieldEditorParent3);
|
||||||
break;
|
break;
|
||||||
case IOption.BOOLEAN :
|
|
||||||
BooleanFieldEditor booleanField = new BooleanFieldEditor(
|
case IOption.BROWSE_NONE:
|
||||||
opt.getId(), opt.getName(), getFieldEditorParent());
|
Composite fieldEditorParent4 = getFieldEditorParent();
|
||||||
addField(booleanField);
|
StringFieldEditor stringField = new StringFieldEditor(
|
||||||
fieldsMap.put(opt.getId(),booleanField);
|
opt.getId(), opt.getName(), fieldEditorParent4);
|
||||||
|
|
||||||
|
setFieldEditorEnablement(tool,
|
||||||
|
applicabilityCalculator, stringField, fieldEditorParent4);
|
||||||
|
|
||||||
|
addField(stringField);
|
||||||
|
fieldsMap.put(opt.getId(), stringField);
|
||||||
|
fieldEditorsToParentMap.put(stringField, fieldEditorParent4);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
// should not be possible
|
||||||
|
throw (new AssertionError());
|
||||||
|
}
|
||||||
|
// end fix for 63973
|
||||||
break;
|
break;
|
||||||
case IOption.ENUMERATED :
|
case IOption.BOOLEAN:
|
||||||
|
Composite fieldEditorParent5 = getFieldEditorParent();
|
||||||
|
BooleanFieldEditor booleanField = new BooleanFieldEditor(
|
||||||
|
opt.getId(), opt.getName(), fieldEditorParent5);
|
||||||
|
|
||||||
|
setFieldEditorEnablement(tool,
|
||||||
|
applicabilityCalculator, booleanField, fieldEditorParent5);
|
||||||
|
|
||||||
|
addField(booleanField);
|
||||||
|
fieldsMap.put(opt.getId(), booleanField);
|
||||||
|
fieldEditorsToParentMap.put(booleanField, fieldEditorParent5);
|
||||||
|
break;
|
||||||
|
case IOption.ENUMERATED:
|
||||||
String selId;
|
String selId;
|
||||||
String sel;
|
String sel;
|
||||||
try {
|
try {
|
||||||
|
@ -130,37 +167,47 @@ public class BuildOptionSettingsPage extends BuildSettingsPage {
|
||||||
// wrong
|
// wrong
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Composite fieldEditorParent6 = getFieldEditorParent();
|
||||||
BuildOptionComboFieldEditor comboField = new BuildOptionComboFieldEditor(
|
BuildOptionComboFieldEditor comboField = new BuildOptionComboFieldEditor(
|
||||||
opt.getId(), opt.getName(), opt
|
opt.getId(), opt.getName(), opt.getApplicableValues(), sel, fieldEditorParent6);
|
||||||
.getApplicableValues(), sel,
|
|
||||||
getFieldEditorParent());
|
setFieldEditorEnablement(tool,
|
||||||
|
applicabilityCalculator, comboField, fieldEditorParent6);
|
||||||
|
|
||||||
addField(comboField);
|
addField(comboField);
|
||||||
fieldsMap.put(opt.getId(), comboField);
|
fieldsMap.put(opt.getId(), comboField);
|
||||||
|
fieldEditorsToParentMap.put(comboField, fieldEditorParent6);
|
||||||
break;
|
break;
|
||||||
case IOption.INCLUDE_PATH :
|
case IOption.INCLUDE_PATH:
|
||||||
case IOption.STRING_LIST :
|
case IOption.STRING_LIST:
|
||||||
case IOption.PREPROCESSOR_SYMBOLS :
|
case IOption.PREPROCESSOR_SYMBOLS:
|
||||||
case IOption.LIBRARIES :
|
case IOption.LIBRARIES:
|
||||||
case IOption.OBJECTS :
|
case IOption.OBJECTS:
|
||||||
FileListControlFieldEditor listField =
|
|
||||||
new FileListControlFieldEditor(
|
Composite fieldEditorParent7 = getFieldEditorParent();
|
||||||
opt.getId(),
|
FileListControlFieldEditor listField = new FileListControlFieldEditor(
|
||||||
opt.getName(),
|
opt.getId(), opt.getName(), fieldEditorParent7, opt.getBrowseType());
|
||||||
getFieldEditorParent(),
|
|
||||||
opt.getBrowseType());
|
setFieldEditorEnablement(tool,
|
||||||
|
applicabilityCalculator, listField, fieldEditorParent7);
|
||||||
|
|
||||||
addField(listField);
|
addField(listField);
|
||||||
fieldsMap.put(opt.getId(), listField);
|
fieldsMap.put(opt.getId(), listField);
|
||||||
|
fieldEditorsToParentMap.put(listField, fieldEditorParent7);
|
||||||
break;
|
break;
|
||||||
default :
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} catch (BuildException e) {}
|
} catch (BuildException e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Answers <code>true</code> if the settings page has been created for
|
* Answers <code>true</code> if the settings page has been created for the
|
||||||
* the option category specified in the argument.
|
* option category specified in the argument.
|
||||||
*
|
*
|
||||||
* @param category
|
* @param category
|
||||||
* @return
|
* @return
|
||||||
|
@ -290,4 +337,56 @@ public class BuildOptionSettingsPage extends BuildSettingsPage {
|
||||||
public void storeSettings() {
|
public void storeSettings() {
|
||||||
super.performOk();
|
super.performOk();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void setFieldEditorEnablement(ITool tool, IOptionApplicability optionApplicability,
|
||||||
|
FieldEditor fieldEditor, Composite parent) {
|
||||||
|
if (optionApplicability == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// if the option is not enabled then disable it
|
||||||
|
if (!optionApplicability.isOptionEnabled(tool)) {
|
||||||
|
fieldEditor.setEnabled(false, parent);
|
||||||
|
} else {
|
||||||
|
fieldEditor.setEnabled(true, parent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent)
|
||||||
|
*/
|
||||||
|
public void propertyChange(PropertyChangeEvent event) {
|
||||||
|
// allow superclass to handle as well
|
||||||
|
super.propertyChange(event);
|
||||||
|
|
||||||
|
// some option has changed on this page... update enabled/disabled state for all options
|
||||||
|
|
||||||
|
Object[][] options;
|
||||||
|
if (isItResourceConfigPage) {
|
||||||
|
options = category.getOptions(resConfig);
|
||||||
|
} else {
|
||||||
|
options = category.getOptions(configuration);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int index = 0; index < options.length; ++index) {
|
||||||
|
// Get the option
|
||||||
|
ITool tool = (ITool) options[index][0];
|
||||||
|
if (tool == null)
|
||||||
|
break; // The array may not be full
|
||||||
|
IOption opt = (IOption) options[index][1];
|
||||||
|
|
||||||
|
// is the option on this page?
|
||||||
|
if (fieldsMap.containsKey(opt.getId())) {
|
||||||
|
// check to see if the option has an applicability calculator
|
||||||
|
IOptionApplicability applicabilityCalculator = opt.getApplicabilityCalculator();
|
||||||
|
|
||||||
|
if (applicabilityCalculator != null) {
|
||||||
|
FieldEditor fieldEditor = (FieldEditor) fieldsMap.get(opt.getId());
|
||||||
|
Composite parent = (Composite) fieldEditorsToParentMap.get(fieldEditor);
|
||||||
|
setFieldEditorEnablement(tool, applicabilityCalculator, fieldEditor, parent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,7 @@ import java.util.Vector;
|
||||||
import org.eclipse.cdt.managedbuilder.core.BuildException;
|
import org.eclipse.cdt.managedbuilder.core.BuildException;
|
||||||
import org.eclipse.cdt.managedbuilder.core.IBuildObject;
|
import org.eclipse.cdt.managedbuilder.core.IBuildObject;
|
||||||
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
|
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
|
||||||
|
import org.eclipse.cdt.managedbuilder.core.IOptionApplicability;
|
||||||
import org.eclipse.cdt.managedbuilder.core.IManagedCommandLineGenerator;
|
import org.eclipse.cdt.managedbuilder.core.IManagedCommandLineGenerator;
|
||||||
import org.eclipse.cdt.managedbuilder.core.IManagedCommandLineInfo;
|
import org.eclipse.cdt.managedbuilder.core.IManagedCommandLineInfo;
|
||||||
import org.eclipse.cdt.managedbuilder.core.IOption;
|
import org.eclipse.cdt.managedbuilder.core.IOption;
|
||||||
|
@ -260,6 +261,11 @@ public class BuildToolSettingsPage extends BuildSettingsPage {
|
||||||
for (int k = 0; k < options.length; k++) {
|
for (int k = 0; k < options.length; k++) {
|
||||||
IOption option = options[k];
|
IOption option = options[k];
|
||||||
buf.setLength( 0 );
|
buf.setLength( 0 );
|
||||||
|
|
||||||
|
// check to see if the option has an applicability calculator
|
||||||
|
IOptionApplicability applicabilityCalculator = option.getApplicabilityCalculator();
|
||||||
|
if (applicabilityCalculator == null || applicabilityCalculator.isOptionUsedInCommandLine(tool)) {
|
||||||
|
|
||||||
try{
|
try{
|
||||||
switch (option.getValueType()) {
|
switch (option.getValueType()) {
|
||||||
case IOption.BOOLEAN :
|
case IOption.BOOLEAN :
|
||||||
|
@ -313,11 +319,14 @@ public class BuildToolSettingsPage extends BuildSettingsPage {
|
||||||
break;
|
break;
|
||||||
default :
|
default :
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
if( buf.toString().trim().length() > 0 ) flags.add( buf.toString().trim() );
|
if( buf.toString().trim().length() > 0 ) flags.add( buf.toString().trim() );
|
||||||
} catch (BuildMacroException e) {
|
} catch (BuildMacroException e) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String outputName = "temp"; //$NON-NLS-1$
|
String outputName = "temp"; //$NON-NLS-1$
|
||||||
|
|
Loading…
Add table
Reference in a new issue