mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Minor bug fixes and enhancements for Options & OptionHandlers
This commit is contained in:
parent
38e72c571b
commit
3c624f71bf
6 changed files with 123 additions and 40 deletions
|
@ -375,6 +375,13 @@ public interface IOption extends IBuildObject {
|
||||||
*/
|
*/
|
||||||
public String getValueHandlerExtraArgument();
|
public String getValueHandlerExtraArgument();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the value handlers extra argument specified for this tool
|
||||||
|
* @param extraArgument
|
||||||
|
* @since 3.0
|
||||||
|
*/
|
||||||
|
public void setValueHandlerExtraArgument(String extraArgument);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns <code>true</code> if this option was loaded from a manifest file,
|
* Returns <code>true</code> if this option was loaded from a manifest file,
|
||||||
* and <code>false</code> if it was loaded from a project (.cdtbuild) file.
|
* and <code>false</code> if it was loaded from a project (.cdtbuild) file.
|
||||||
|
|
|
@ -2479,7 +2479,7 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get options associated with tools under toolChain
|
// Get options associated with tools under toolChain
|
||||||
ITool[] tools = toolChain.getTools();
|
ITool[] tools = config.getFilteredTools();
|
||||||
for (int i = 0; i < tools.length; ++i) {
|
for (int i = 0; i < tools.length; ++i) {
|
||||||
IOption[] toolOptions = tools[i].getOptions();
|
IOption[] toolOptions = tools[i].getOptions();
|
||||||
for (int j = 0; j < toolOptions.length; ++j) {
|
for (int j = 0; j < toolOptions.length; ++j) {
|
||||||
|
|
|
@ -11,6 +11,8 @@
|
||||||
|
|
||||||
package org.eclipse.cdt.managedbuilder.core;
|
package org.eclipse.cdt.managedbuilder.core;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class implements the default managed option value handler for MBS.
|
* This class implements the default managed option value handler for MBS.
|
||||||
|
@ -49,7 +51,7 @@ public class ManagedOptionValueHandler implements
|
||||||
IOption option,
|
IOption option,
|
||||||
String extraArgument, int event)
|
String extraArgument, int event)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
// The following is for debug purposes and thus normally commented out
|
// The following is for debug purposes and thus normally commented out
|
||||||
String configLabel = "???"; //$NON-NLS-1$
|
String configLabel = "???"; //$NON-NLS-1$
|
||||||
String holderLabel = "???"; //$NON-NLS-1$
|
String holderLabel = "???"; //$NON-NLS-1$
|
||||||
|
@ -84,7 +86,7 @@ public class ManagedOptionValueHandler implements
|
||||||
option.getId() + ", " + //$NON-NLS-1$
|
option.getId() + ", " + //$NON-NLS-1$
|
||||||
"String = " + //$NON-NLS-1$
|
"String = " + //$NON-NLS-1$
|
||||||
extraArgument + ")"); //$NON-NLS-1$
|
extraArgument + ")"); //$NON-NLS-1$
|
||||||
*/
|
*/
|
||||||
// The event was not handled, thus return false
|
// The event was not handled, thus return false
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -95,12 +97,58 @@ public class ManagedOptionValueHandler implements
|
||||||
public boolean isDefaultValue(IBuildObject configuration,
|
public boolean isDefaultValue(IBuildObject configuration,
|
||||||
IHoldsOptions holder,
|
IHoldsOptions holder,
|
||||||
IOption option, String extraArgument) {
|
IOption option, String extraArgument) {
|
||||||
// Implement default behavior
|
// Get the default Value
|
||||||
if (option.getDefaultValue() == option.getValue()) {
|
Object defaultValue = option.getDefaultValue();
|
||||||
return true;
|
|
||||||
} else {
|
try {
|
||||||
return false;
|
// Figure out which type the option is and implement default behaviour for it.
|
||||||
}
|
switch (option.getValueType()) {
|
||||||
|
case IOption.STRING:
|
||||||
|
if (option.getStringValue().equals((String)defaultValue)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case IOption.BOOLEAN:
|
||||||
|
if (option.getBooleanValue() == ((Boolean)defaultValue).booleanValue()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case IOption.ENUMERATED:
|
||||||
|
if (option.getValue().toString().equals(defaultValue.toString())) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case IOption.INCLUDE_PATH:
|
||||||
|
if (Arrays.equals(option.getIncludePaths(), (String[])defaultValue)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case IOption.STRING_LIST:
|
||||||
|
if (Arrays.equals(option.getStringListValue(), (String[])defaultValue)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case IOption.PREPROCESSOR_SYMBOLS:
|
||||||
|
if (Arrays.equals(option.getDefinedSymbols(), (String[])defaultValue)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case IOption.LIBRARIES:
|
||||||
|
if (Arrays.equals(option.getLibraries(), (String[])defaultValue)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case IOption.OBJECTS:
|
||||||
|
if (Arrays.equals(option.getUserObjects(), (String[])defaultValue)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} catch (BuildException e) {
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
|
|
@ -195,39 +195,48 @@ public class Option extends BuildObject implements IOption {
|
||||||
enumCommands = new HashMap(option.enumCommands);
|
enumCommands = new HashMap(option.enumCommands);
|
||||||
enumNames = new HashMap(option.enumNames);
|
enumNames = new HashMap(option.enumNames);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (option.valueType != null) {
|
if (option.valueType != null) {
|
||||||
valueType = new Integer(option.valueType.intValue());
|
valueType = new Integer(option.valueType.intValue());
|
||||||
switch (valueType.intValue()) {
|
}
|
||||||
case BOOLEAN:
|
Integer vType = null;
|
||||||
if (option.value != null) {
|
try {
|
||||||
value = new Boolean(((Boolean)option.value).booleanValue());
|
vType = new Integer(option.getValueType());
|
||||||
}
|
if (vType != null) {
|
||||||
if (option.defaultValue != null) {
|
switch (vType.intValue()) {
|
||||||
defaultValue = new Boolean(((Boolean)option.defaultValue).booleanValue());
|
case BOOLEAN:
|
||||||
}
|
if (option.value != null) {
|
||||||
break;
|
value = new Boolean(((Boolean)option.value).booleanValue());
|
||||||
case STRING:
|
}
|
||||||
case ENUMERATED:
|
if (option.defaultValue != null) {
|
||||||
if (option.value != null) {
|
defaultValue = new Boolean(((Boolean)option.defaultValue).booleanValue());
|
||||||
value = new String((String)option.value);
|
}
|
||||||
}
|
break;
|
||||||
if (option.defaultValue != null) {
|
case STRING:
|
||||||
defaultValue = new String((String)option.defaultValue);
|
case ENUMERATED:
|
||||||
}
|
if (option.value != null) {
|
||||||
break;
|
value = new String((String)option.value);
|
||||||
case STRING_LIST:
|
}
|
||||||
case INCLUDE_PATH:
|
if (option.defaultValue != null) {
|
||||||
case PREPROCESSOR_SYMBOLS:
|
defaultValue = new String((String)option.defaultValue);
|
||||||
case LIBRARIES:
|
}
|
||||||
case OBJECTS:
|
break;
|
||||||
if (option.value != null) {
|
case STRING_LIST:
|
||||||
value = new ArrayList((ArrayList)option.value);
|
case INCLUDE_PATH:
|
||||||
}
|
case PREPROCESSOR_SYMBOLS:
|
||||||
if (option.defaultValue != null) {
|
case LIBRARIES:
|
||||||
defaultValue = new ArrayList((ArrayList)option.defaultValue);
|
case OBJECTS:
|
||||||
}
|
if (option.value != null) {
|
||||||
break;
|
value = new ArrayList((ArrayList)option.value);
|
||||||
|
}
|
||||||
|
if (option.defaultValue != null) {
|
||||||
|
defaultValue = new ArrayList((ArrayList)option.defaultValue);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
} catch (BuildException be) {
|
||||||
|
// TODO: should we ignore this??
|
||||||
}
|
}
|
||||||
|
|
||||||
category = option.category;
|
category = option.category;
|
||||||
|
@ -1438,6 +1447,19 @@ public class Option extends BuildObject implements IOption {
|
||||||
}
|
}
|
||||||
return valueHandlerExtraArgument;
|
return valueHandlerExtraArgument;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.managedbuilder.core.IOption#setValueHandlerExtraArgument(String))
|
||||||
|
*/
|
||||||
|
public void setValueHandlerExtraArgument(String extraArgument) {
|
||||||
|
if (extraArgument == null)
|
||||||
|
extraArgument = ""; //$NON-NLS-1$
|
||||||
|
if (valueHandlerExtraArgument == null || !valueHandlerExtraArgument.equals(extraArgument)) {
|
||||||
|
valueHandlerExtraArgument = extraArgument;
|
||||||
|
setDirty(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* O B J E C T S T A T E M A I N T E N A N C E
|
* O B J E C T S T A T E M A I N T E N A N C E
|
||||||
|
|
|
@ -789,6 +789,12 @@ public class OptionReference implements IOption {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.managedbuilder.core.IOption#setValueHandlerExtraArgument(String))
|
||||||
|
*/
|
||||||
|
public void setValueHandlerExtraArgument(String extraArgument) {
|
||||||
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.managedbuilder.core.IOption#isValid()
|
* @see org.eclipse.cdt.managedbuilder.core.IOption#isValid()
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/**********************************************************************
|
/**********************************************************************
|
||||||
* Copyright (c) 2004 Intel Corporation and others.
|
* Copyright (c) 2004 2005 Intel Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Common Public License v1.0
|
* are made available under the terms of the Common Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
|
Loading…
Add table
Reference in a new issue