1
0
Fork 0
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:
Leo Treggiari 2005-06-10 20:07:28 +00:00
parent 38e72c571b
commit 3c624f71bf
6 changed files with 123 additions and 40 deletions

View file

@ -375,6 +375,13 @@ public interface IOption extends IBuildObject {
*/
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,
* and <code>false</code> if it was loaded from a project (.cdtbuild) file.

View file

@ -2479,7 +2479,7 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
}
// Get options associated with tools under toolChain
ITool[] tools = toolChain.getTools();
ITool[] tools = config.getFilteredTools();
for (int i = 0; i < tools.length; ++i) {
IOption[] toolOptions = tools[i].getOptions();
for (int j = 0; j < toolOptions.length; ++j) {

View file

@ -11,6 +11,8 @@
package org.eclipse.cdt.managedbuilder.core;
import java.util.Arrays;
/**
* This class implements the default managed option value handler for MBS.
@ -49,7 +51,7 @@ public class ManagedOptionValueHandler implements
IOption option,
String extraArgument, int event)
{
/*
/*
// The following is for debug purposes and thus normally commented out
String configLabel = "???"; //$NON-NLS-1$
String holderLabel = "???"; //$NON-NLS-1$
@ -84,7 +86,7 @@ public class ManagedOptionValueHandler implements
option.getId() + ", " + //$NON-NLS-1$
"String = " + //$NON-NLS-1$
extraArgument + ")"); //$NON-NLS-1$
*/
*/
// The event was not handled, thus return false
return false;
}
@ -95,12 +97,58 @@ public class ManagedOptionValueHandler implements
public boolean isDefaultValue(IBuildObject configuration,
IHoldsOptions holder,
IOption option, String extraArgument) {
// Implement default behavior
if (option.getDefaultValue() == option.getValue()) {
return true;
} else {
return false;
}
// Get the default Value
Object defaultValue = option.getDefaultValue();
try {
// 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)

View file

@ -195,39 +195,48 @@ public class Option extends BuildObject implements IOption {
enumCommands = new HashMap(option.enumCommands);
enumNames = new HashMap(option.enumNames);
}
if (option.valueType != null) {
valueType = new Integer(option.valueType.intValue());
switch (valueType.intValue()) {
case BOOLEAN:
if (option.value != null) {
value = new Boolean(((Boolean)option.value).booleanValue());
}
if (option.defaultValue != null) {
defaultValue = new Boolean(((Boolean)option.defaultValue).booleanValue());
}
break;
case STRING:
case ENUMERATED:
if (option.value != null) {
value = new String((String)option.value);
}
if (option.defaultValue != null) {
defaultValue = new String((String)option.defaultValue);
}
break;
case STRING_LIST:
case INCLUDE_PATH:
case PREPROCESSOR_SYMBOLS:
case LIBRARIES:
case OBJECTS:
if (option.value != null) {
value = new ArrayList((ArrayList)option.value);
}
if (option.defaultValue != null) {
defaultValue = new ArrayList((ArrayList)option.defaultValue);
}
break;
}
Integer vType = null;
try {
vType = new Integer(option.getValueType());
if (vType != null) {
switch (vType.intValue()) {
case BOOLEAN:
if (option.value != null) {
value = new Boolean(((Boolean)option.value).booleanValue());
}
if (option.defaultValue != null) {
defaultValue = new Boolean(((Boolean)option.defaultValue).booleanValue());
}
break;
case STRING:
case ENUMERATED:
if (option.value != null) {
value = new String((String)option.value);
}
if (option.defaultValue != null) {
defaultValue = new String((String)option.defaultValue);
}
break;
case STRING_LIST:
case INCLUDE_PATH:
case PREPROCESSOR_SYMBOLS:
case LIBRARIES:
case OBJECTS:
if (option.value != null) {
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;
@ -1438,6 +1447,19 @@ public class Option extends BuildObject implements IOption {
}
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

View file

@ -789,6 +789,12 @@ public class OptionReference implements IOption {
return null;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IOption#setValueHandlerExtraArgument(String))
*/
public void setValueHandlerExtraArgument(String extraArgument) {
}
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IOption#isValid()
*/

View file

@ -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
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at