1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-20 15:35:24 +02:00

bug 222817: [Contribution] <enablement and applicability calculator support with Option Category

Patch from Miwako Tokugawa
This commit is contained in:
Andrew Gvozdev 2011-04-25 04:38:22 +00:00
parent bd992e2e92
commit 0a90b65e97
26 changed files with 661 additions and 112 deletions

View file

@ -5114,7 +5114,20 @@
<tool <tool
id="enablement.this.child_1.2.3" id="enablement.this.child_1.2.3"
superClass="enablement.this"> superClass="enablement.this">
<optionCategory
id="enablement.category"
name="enablement category"
owner="enablement.this.child_1.2.3">
<enablement type="ALL">
<checkOption
optionId="enablement.trigger"
value="true">
</checkOption>
</enablement>
</optionCategory>
<option <option
owner="enablement.this.child_1.2.3"
category="enablement.category"
id="enablement.macro.test.string" id="enablement.macro.test.string"
defaultValue="000" defaultValue="000"
superClass="gnu.c.compiler.option30.optimization.flags" superClass="gnu.c.compiler.option30.optimization.flags"
@ -5130,6 +5143,12 @@
<listOptionValue value="y"/> <listOptionValue value="y"/>
<listOptionValue value="z"/> <listOptionValue value="z"/>
</option> </option>
<option
owner="enablement.this.child_1.2.3"
name="trigger"
valueType="boolean"
id="enablement.trigger">
</option>
<envVarBuildPath <envVarBuildPath
pathType="buildpathInclude" pathType="buildpathInclude"
variableList="CFGI,CFG0,PRJI"> variableList="CFGI,CFG0,PRJI">

View file

@ -34,6 +34,7 @@ import org.eclipse.cdt.managedbuilder.core.tests.ManagedProject21MakefileTests;
import org.eclipse.cdt.managedbuilder.core.tests.ManagedProject30MakefileTests; import org.eclipse.cdt.managedbuilder.core.tests.ManagedProject30MakefileTests;
import org.eclipse.cdt.managedbuilder.core.tests.ManagedProjectUpdateTests; import org.eclipse.cdt.managedbuilder.core.tests.ManagedProjectUpdateTests;
import org.eclipse.cdt.managedbuilder.core.tests.MultiVersionSupportTests; import org.eclipse.cdt.managedbuilder.core.tests.MultiVersionSupportTests;
import org.eclipse.cdt.managedbuilder.core.tests.OptionCategoryEnablementTests;
import org.eclipse.cdt.managedbuilder.core.tests.OptionEnablementTests; import org.eclipse.cdt.managedbuilder.core.tests.OptionEnablementTests;
import org.eclipse.cdt.managedbuilder.core.tests.PathConverterTest; import org.eclipse.cdt.managedbuilder.core.tests.PathConverterTest;
import org.eclipse.cdt.managedbuilder.core.tests.ResourceBuildCoreTests; import org.eclipse.cdt.managedbuilder.core.tests.ResourceBuildCoreTests;
@ -74,6 +75,7 @@ public class AllManagedBuildTests {
suite.addTest(ManagedBuildTCSupportedTest.suite()); suite.addTest(ManagedBuildTCSupportedTest.suite());
suite.addTest(MultiVersionSupportTests.suite()); suite.addTest(MultiVersionSupportTests.suite());
suite.addTest(OptionEnablementTests.suite()); suite.addTest(OptionEnablementTests.suite());
suite.addTest(OptionCategoryEnablementTests.suite());
suite.addTest(ManagedBuildDependencyCalculatorTests.suite()); suite.addTest(ManagedBuildDependencyCalculatorTests.suite());
suite.addTest(BuildDescriptionModelTests.suite()); suite.addTest(BuildDescriptionModelTests.suite());
suite.addTest(PathConverterTest.suite()); suite.addTest(PathConverterTest.suite());

View file

@ -0,0 +1,197 @@
/*******************************************************************************
* Copyright (c) 2011 Intel Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Intel Corporation - Initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.managedbuilder.core.tests;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
import org.eclipse.cdt.managedbuilder.core.BuildException;
import org.eclipse.cdt.managedbuilder.core.IBuildObject;
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
import org.eclipse.cdt.managedbuilder.core.IFileInfo;
import org.eclipse.cdt.managedbuilder.core.IFolderInfo;
import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
import org.eclipse.cdt.managedbuilder.core.IOption;
import org.eclipse.cdt.managedbuilder.core.IOptionCategory;
import org.eclipse.cdt.managedbuilder.core.IResourceConfiguration;
import org.eclipse.cdt.managedbuilder.core.IResourceInfo;
import org.eclipse.cdt.managedbuilder.core.ITool;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
import org.eclipse.cdt.managedbuilder.testplugin.ManagedBuildTestHelper;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
public class OptionCategoryEnablementTests extends TestCase {
private static final String testName = "optcaten"; //$NON-NLS-1$
private static boolean fHandleValueCalled;
public static Test suite() {
return new TestSuite(OptionCategoryEnablementTests.class);
}
private void resetValueHandler(){
fHandleValueCalled = false;
}
public void testEnablement(){
resetValueHandler();
IProject project = ManagedBuildTestHelper.createProject(testName,
"cdt.managedbuild.target.enablement.exe"); //$NON-NLS-1$
IFolder folder = ManagedBuildTestHelper.createFolder(project, "Folder");
IFile aFile = ManagedBuildTestHelper.createFile(project, "a.c"); //$NON-NLS-1$
IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(project);
IConfiguration cfg = info.getManagedProject().getConfigurations()[0];
assertFalse(fHandleValueCalled);
doTestEnablement(cfg, folder, aFile);
ManagedBuildTestHelper.removeProject(testName);
}
private void doTestEnablement(IBuildObject cfg, IFolder folder, IFile file){
final String TOOL_ID = "enablement.this"; //$NON-NLS-1$
final String OPTION_ID = "enablement.trigger"; //$NON-NLS-1$
final String CATEGORY_ID = "enablement.category"; //$NON-NLS-1$
IOption option;
IOptionCategory optionCategory;
try{
ITool tool = getTool(cfg, TOOL_ID);
option = tool.getOptionBySuperClassId(OPTION_ID);
assertEquals(option.getBooleanValue(),false);
// Config Level
// trigger option is false, so category should not be visible
optionCategory = tool.getOptionCategory(CATEGORY_ID);
assertFalse(optionCategory.getApplicabilityCalculator().isOptionCategoryVisible(cfg, tool, optionCategory));
// set the trigger option
((IConfiguration) cfg).setOption(tool, option, true);
// trigger option is true, so category should be visible
assertTrue(optionCategory.getApplicabilityCalculator().isOptionCategoryVisible(cfg, tool, optionCategory));
// Folder Level
IResourceInfo folderInfo = ((IConfiguration) cfg).getResourceInfo(folder.getFullPath(),false);
assertNotNull(folderInfo);
// unset the trigger option
option = getOptionForFolder((IFolderInfo)folderInfo, TOOL_ID, OPTION_ID);
assertNotNull(option);
folderInfo.setOption(tool, option, false);
// category should not be visible
optionCategory = getOptionCategoryForFolder((IFolderInfo)folderInfo, /*TOOL_ID,*/ CATEGORY_ID);
assertNotNull(optionCategory);
assertFalse(optionCategory.getApplicabilityCalculator().isOptionCategoryVisible(cfg, tool, optionCategory));
// set the trigger option
folderInfo.setOption(tool, option, true);
// category should be visible
assertTrue(optionCategory.getApplicabilityCalculator().isOptionCategoryVisible(cfg, tool, optionCategory));
// File Level
// set the trigger option
IResourceConfiguration fileInfo = ((IConfiguration) cfg).getResourceConfiguration(file.getFullPath().toString());
if (fileInfo==null)
fileInfo = ((IConfiguration) cfg).createResourceConfiguration(file);
option = getOptionForFile((IFileInfo)fileInfo, OPTION_ID);
assertNotNull(option);
fileInfo.setOption(tool, option, false);
optionCategory = getOptionCategoryForFile((IFileInfo)fileInfo, CATEGORY_ID);
assertNotNull(optionCategory);
// category should not be visible
assertFalse(optionCategory.getApplicabilityCalculator().isOptionCategoryVisible(cfg, tool, optionCategory));
// set the trigger option
fileInfo.setOption(tool, option, true);
// category should be visible
assertTrue(optionCategory.getApplicabilityCalculator().isOptionCategoryVisible(cfg, tool, optionCategory));
}catch (BuildException e){
fail(e.getLocalizedMessage());
}
}
private ITool getTool(IBuildObject cfgBo, String id){
IResourceConfiguration rcCfg = null;
IConfiguration cfg = null;
ITool tool = null;
if(cfgBo instanceof IResourceConfiguration){
rcCfg = (IResourceConfiguration)cfgBo;
cfg = rcCfg.getParent();
ITool tools[] = rcCfg.getTools();
for(int i = 0; i < tools.length; i++){
for(ITool tmp = tools[i]; tmp != null; tmp=tmp.getSuperClass()){
if(tmp.getId().equals(id)){
tool = tools[i];
break;
}
}
}
} else if(cfgBo instanceof IConfiguration){
cfg = (IConfiguration)cfgBo;
tool = cfg.getToolsBySuperClassId(id)[0];
} else
fail("wrong argument");
return tool;
}
private IOption getOptionForFolder(IFolderInfo rcInfo, String toolId, String optionId) {
ITool[] tools = null;
tools = rcInfo.getToolsBySuperClassId(toolId);
assertNotNull(tools);
ITool tool = tools[0];
assertNotNull(tool);
IOption option = tool.getOptionBySuperClassId(optionId);
return option;
}
private IOption getOptionForFile(IFileInfo rcInfo, String optionId) {
ITool[] tools = null;
tools = rcInfo.getTools();
assertNotNull(tools);
ITool tool = tools[0];
assertNotNull(tool);
IOption option = tool.getOptionBySuperClassId(optionId);
return option;
}
private IOptionCategory getOptionCategoryForFolder(IFolderInfo rcInfo, String categoryId) {
ITool[] tools = rcInfo.getTools();
tools = rcInfo.getTools();
assertNotNull(tools);
ITool tool = tools[0];
assertNotNull(tool);
IOptionCategory optionCategory = tool.getOptionCategory(categoryId);
return optionCategory;
}
private IOptionCategory getOptionCategoryForFile(IFileInfo rcInfo, String categoryId) {
ITool[] tools = rcInfo.getTools();
tools = rcInfo.getTools();
assertNotNull(tools);
ITool tool = tools[0];
assertNotNull(tool);
IOptionCategory optionCategory = tool.getOptionCategory(categoryId);
return optionCategory;
}
}

View file

@ -1144,6 +1144,9 @@ A custom field-editor needs to be registered, under the same ID, through the &lt
</documentation> </documentation>
</annotation> </annotation>
<complexType> <complexType>
<sequence>
<element ref="enablement" minOccurs="0" maxOccurs="unbounded"/>
</sequence>
<attribute name="id" type="string" use="required"> <attribute name="id" type="string" use="required">
<annotation> <annotation>
<documentation> <documentation>
@ -1448,6 +1451,9 @@ Additional special types exist to flag options of special relevance to the build
</documentation> </documentation>
</annotation> </annotation>
<complexType> <complexType>
<sequence>
<element ref="enablement" minOccurs="0" maxOccurs="unbounded"/>
</sequence>
<attribute name="id" type="string" use="required"> <attribute name="id" type="string" use="required">
<annotation> <annotation>
<documentation> <documentation>

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2003, 2010 IBM Corporation and others. * Copyright (c) 2003, 2011 IBM 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 Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -7,6 +7,7 @@
* *
* Contributors: * Contributors:
* IBM - Initial API and implementation * IBM - Initial API and implementation
* Miwako Tokugawa (Intel Corporation) - bug 222817 (OptionCategoryApplicability)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.managedbuilder.core; package org.eclipse.cdt.managedbuilder.core;
@ -119,4 +120,10 @@ public interface IOptionCategory extends IBuildObject {
* Sets the element's "dirty" (have I been modified?) flag. * Sets the element's "dirty" (have I been modified?) flag.
*/ */
public void setDirty(boolean isDirty); public void setDirty(boolean isDirty);
/**
* @return an instance of the class that calculates whether the option category is visible.
* @since 8.0
*/
public IOptionCategoryApplicability getApplicabilityCalculator();
} }

View file

@ -0,0 +1,36 @@
/*******************************************************************************
* Copyright (c) 2011 Intel Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Miwako Tokugawa (Intel Corporation) - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.managedbuilder.core;
/**
* This interface determines whether or not the option category is currently displayed.
*
* @noextend This class is not intended to be subclassed by clients.
* @noimplement This interface is not intended to be implemented by clients.
*
* @since 8.0
*/
public interface IOptionCategoryApplicability {
/**
* This method is queried whenever a new option category is displayed.
*
* @param configuration build configuration of option
* (may be IConfiguration or IResourceConfiguration)
* @param optHolder contains the holder of the option
* @param category the option category itself
*
* @return true if this option should be visible in the build options page,
* false otherwise
*/
public boolean isOptionCategoryVisible(
IBuildObject configuration,
IHoldsOptions optHolder, IOptionCategory category);
}

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2005, 2007 Intel Corporation and others. * Copyright (c) 2005, 2011 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 Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -7,6 +7,8 @@
* *
* Contributors: * Contributors:
* Intel Corporation - Initial API and implementation * Intel Corporation - Initial API and implementation
* Miwako Tokugawa (Intel Corporation) - bug 222817 (OptionCategoryApplicability)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.managedbuilder.internal.core; package org.eclipse.cdt.managedbuilder.internal.core;
@ -23,6 +25,8 @@ import org.eclipse.cdt.managedbuilder.core.IInputType;
import org.eclipse.cdt.managedbuilder.core.IManagedConfigElement; import org.eclipse.cdt.managedbuilder.core.IManagedConfigElement;
import org.eclipse.cdt.managedbuilder.core.IOption; import org.eclipse.cdt.managedbuilder.core.IOption;
import org.eclipse.cdt.managedbuilder.core.IOptionApplicability; import org.eclipse.cdt.managedbuilder.core.IOptionApplicability;
import org.eclipse.cdt.managedbuilder.core.IOptionCategory;
import org.eclipse.cdt.managedbuilder.core.IOptionCategoryApplicability;
import org.eclipse.cdt.managedbuilder.core.IOutputType; import org.eclipse.cdt.managedbuilder.core.IOutputType;
import org.eclipse.cdt.managedbuilder.core.IResourceInfo; import org.eclipse.cdt.managedbuilder.core.IResourceInfo;
import org.eclipse.cdt.managedbuilder.core.ITool; import org.eclipse.cdt.managedbuilder.core.ITool;
@ -30,7 +34,7 @@ import org.eclipse.cdt.managedbuilder.core.IToolChain;
import org.eclipse.cdt.managedbuilder.internal.enablement.AdjustmentContext; import org.eclipse.cdt.managedbuilder.internal.enablement.AdjustmentContext;
import org.eclipse.cdt.managedbuilder.internal.enablement.OptionEnablementExpression; import org.eclipse.cdt.managedbuilder.internal.enablement.OptionEnablementExpression;
public class BooleanExpressionApplicabilityCalculator implements IOptionApplicability { public class BooleanExpressionApplicabilityCalculator implements IOptionApplicability, IOptionCategoryApplicability {
private OptionEnablementExpression fExpressions[]; private OptionEnablementExpression fExpressions[];
private Map<String, Set<String>> fRefPropsMap; private Map<String, Set<String>> fRefPropsMap;
@ -231,4 +235,17 @@ public class BooleanExpressionApplicabilityCalculator implements IOptionApplicab
return set.toArray(new String[set.size()]); return set.toArray(new String[set.size()]);
} }
public boolean isOptionCategoryVisible(IBuildObject configuration, IHoldsOptions optHolder,
IOptionCategory category) {
return evaluateCategory(rcInfoFromConfiguration(configuration), optHolder, category);
}
private boolean evaluateCategory(IResourceInfo rcInfo, IHoldsOptions holder, IOptionCategory category) {
for(int i = 0; i < fExpressions.length; i++){
if(!fExpressions[i].evaluate(rcInfo, holder, category))
return false;
}
return true;
}
} }

View file

@ -7,6 +7,7 @@
* *
* Contributors: * Contributors:
* IBM - Initial API and implementation * IBM - Initial API and implementation
* Miwako Tokugawa (Intel Corporation) - bug 222817 (OptionCategoryApplicability)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.managedbuilder.internal.core; package org.eclipse.cdt.managedbuilder.internal.core;
@ -23,11 +24,16 @@ import org.eclipse.cdt.managedbuilder.core.IHoldsOptions;
import org.eclipse.cdt.managedbuilder.core.IManagedConfigElement; import org.eclipse.cdt.managedbuilder.core.IManagedConfigElement;
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.IOptionCategoryApplicability;
import org.eclipse.cdt.managedbuilder.core.IResourceConfiguration; import org.eclipse.cdt.managedbuilder.core.IResourceConfiguration;
import org.eclipse.cdt.managedbuilder.core.IResourceInfo; import org.eclipse.cdt.managedbuilder.core.IResourceInfo;
import org.eclipse.cdt.managedbuilder.core.ITool; import org.eclipse.cdt.managedbuilder.core.ITool;
import org.eclipse.cdt.managedbuilder.core.IToolChain; import org.eclipse.cdt.managedbuilder.core.IToolChain;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager; import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
import org.eclipse.cdt.managedbuilder.internal.enablement.OptionEnablementExpression;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.Path;
import org.osgi.framework.Version; import org.osgi.framework.Version;
@ -46,6 +52,13 @@ public class OptionCategory extends BuildObject implements IOptionCategory {
private IOptionCategory owner; // The logical Option Category parent private IOptionCategory owner; // The logical Option Category parent
private String ownerId; private String ownerId;
private URL iconPathURL; private URL iconPathURL;
private IConfigurationElement applicabilityCalculatorElement = null;
private IOptionCategoryApplicability applicabilityCalculator = null;
private BooleanExpressionApplicabilityCalculator booleanExpressionCalculator = null;
public static final String APPLICABILITY_CALCULATOR = "applicabilityCalculator"; //$NON-NLS-1$
// Miscellaneous // Miscellaneous
private boolean isExtensionOptionCategory = false; private boolean isExtensionOptionCategory = false;
private boolean isDirty = false; private boolean isDirty = false;
@ -63,7 +76,7 @@ public class OptionCategory extends BuildObject implements IOptionCategory {
* This constructor is called to create an option category defined by an extension point in * This constructor is called to create an option category defined by an extension point in
* a plugin manifest file, or returned by a dynamic element provider * a plugin manifest file, or returned by a dynamic element provider
* *
* @param parent The IHoldsOptions parent of this catgeory, or <code>null</code> if * @param parent The IHoldsOptions parent of this category, or <code>null</code> if
* defined at the top level * defined at the top level
* @param element The category definition from the manifest file or a dynamic element * @param element The category definition from the manifest file or a dynamic element
* provider * provider
@ -124,6 +137,19 @@ public class OptionCategory extends BuildObject implements IOptionCategory {
String icon = element.getAttribute(IOptionCategory.ICON); String icon = element.getAttribute(IOptionCategory.ICON);
iconPathURL = ManagedBuildManager.getURLInBuildDefinitions( (DefaultManagedConfigElement)element, new Path(icon) ); iconPathURL = ManagedBuildManager.getURLInBuildDefinitions( (DefaultManagedConfigElement)element, new Path(icon) );
} }
//get enablements
IManagedConfigElement enablements[] = element.getChildren(OptionEnablementExpression.NAME);
if(enablements.length > 0)
booleanExpressionCalculator = new BooleanExpressionApplicabilityCalculator(enablements);
// get the applicability calculator, if any
String applicabilityCalculatorStr = element.getAttribute(APPLICABILITY_CALCULATOR);
if (applicabilityCalculatorStr != null && element instanceof DefaultManagedConfigElement) {
applicabilityCalculatorElement = ((DefaultManagedConfigElement)element).getConfigurationElement();
} else {
applicabilityCalculator = booleanExpressionCalculator;
}
} }
/* (non-Javadoc) /* (non-Javadoc)
@ -536,4 +562,24 @@ public class OptionCategory extends BuildObject implements IOptionCategory {
} }
return primary; return primary;
} }
/*
* (non-Javadoc)
*
* @see org.eclipse.cdt.managedbuilder.core.IOptionCategory#getApplicabilityCalculator()
*/
public IOptionCategoryApplicability getApplicabilityCalculator() {
if (applicabilityCalculator == null) {
if (applicabilityCalculatorElement != null) {
try {
if (applicabilityCalculatorElement.getAttribute(APPLICABILITY_CALCULATOR) != null)
applicabilityCalculator = (IOptionCategoryApplicability) applicabilityCalculatorElement
.createExecutableExtension(APPLICABILITY_CALCULATOR);
} catch (CoreException e) {
ManagedBuilderCorePlugin.log(e);
}
}
}
return applicabilityCalculator;
}
} }

View file

@ -8,6 +8,7 @@
* Contributors: * Contributors:
* IBM - Initial API and implementation * IBM - Initial API and implementation
* Baltasar Belyavsky (Texas Instruments) - [279633] Custom option command-generator support * Baltasar Belyavsky (Texas Instruments) - [279633] Custom option command-generator support
* Miwako Tokugawa (Intel Corporation) - bug 222817 (OptionCategoryApplicability)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.managedbuilder.internal.core; package org.eclipse.cdt.managedbuilder.internal.core;
@ -49,6 +50,7 @@ import org.eclipse.cdt.managedbuilder.core.IManagedProject;
import org.eclipse.cdt.managedbuilder.core.IOption; import org.eclipse.cdt.managedbuilder.core.IOption;
import org.eclipse.cdt.managedbuilder.core.IOptionApplicability; import org.eclipse.cdt.managedbuilder.core.IOptionApplicability;
import org.eclipse.cdt.managedbuilder.core.IOptionCategory; import org.eclipse.cdt.managedbuilder.core.IOptionCategory;
import org.eclipse.cdt.managedbuilder.core.IOptionCategoryApplicability;
import org.eclipse.cdt.managedbuilder.core.IOptionCommandGenerator; import org.eclipse.cdt.managedbuilder.core.IOptionCommandGenerator;
import org.eclipse.cdt.managedbuilder.core.IOptionPathConverter; import org.eclipse.cdt.managedbuilder.core.IOptionPathConverter;
import org.eclipse.cdt.managedbuilder.core.IOutputType; import org.eclipse.cdt.managedbuilder.core.IOutputType;
@ -2499,6 +2501,9 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory, IMatch
// check to see if the option has an applicability calculator // check to see if the option has an applicability calculator
IOptionApplicability applicabilityCalculator = option.getApplicabilityCalculator(); IOptionApplicability applicabilityCalculator = option.getApplicabilityCalculator();
IOptionCategory cat = option.getCategory();
IOptionCategoryApplicability catApplicabilityCalculator = cat.getApplicabilityCalculator();
IBuildObject config = null; IBuildObject config = null;
IBuildObject parent = getParent(); IBuildObject parent = getParent();
if ( parent instanceof IResourceConfiguration ) { if ( parent instanceof IResourceConfiguration ) {
@ -2507,7 +2512,8 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory, IMatch
config = ((IToolChain)parent).getParent(); config = ((IToolChain)parent).getParent();
} }
if (applicabilityCalculator == null || applicabilityCalculator.isOptionUsedInCommandLine(config, this, option)) { if ((catApplicabilityCalculator==null || catApplicabilityCalculator.isOptionCategoryVisible(config, this, cat))
&& (applicabilityCalculator == null || applicabilityCalculator.isOptionUsedInCommandLine(config, this, option))) {
// update option in case when its value changed. // update option in case when its value changed.
// This code is added to fix bug #219684 and // This code is added to fix bug #219684 and
@ -4041,4 +4047,14 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory, IMatch
public boolean isExtensionBuildObject() { public boolean isExtensionBuildObject() {
return isExtensionElement(); return isExtensionElement();
} }
/*
* (non-Javadoc)
*
* @see org.eclipse.cdt.managedbuilder.core.IOptionCategory#getApplicabilityCalculator()
*/
public IOptionCategoryApplicability getApplicabilityCalculator() {
// Tool does not have any ApplicabilityCalculator.
return null;
}
} }

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2005, 2007 Intel Corporation and others. * Copyright (c) 2005, 2011 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 Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -7,12 +7,14 @@
* *
* Contributors: * Contributors:
* Intel Corporation - Initial API and implementation * Intel Corporation - Initial API and implementation
* Miwako Tokugawa (Intel Corporation) - bug 222817 (OptionCategoryApplicability)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.managedbuilder.internal.enablement; package org.eclipse.cdt.managedbuilder.internal.enablement;
import org.eclipse.cdt.managedbuilder.core.IHoldsOptions; import org.eclipse.cdt.managedbuilder.core.IHoldsOptions;
import org.eclipse.cdt.managedbuilder.core.IManagedConfigElement; import org.eclipse.cdt.managedbuilder.core.IManagedConfigElement;
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.IResourceInfo; import org.eclipse.cdt.managedbuilder.core.IResourceInfo;
public class AndExpression extends CompositeExpression { public class AndExpression extends CompositeExpression {
@ -32,4 +34,14 @@ public class AndExpression extends CompositeExpression {
} }
return true; return true;
} }
public boolean evaluate(IResourceInfo rcInfo,
IHoldsOptions holder,
IOptionCategory category) {
IBooleanExpression children[] = getChildren();
for(int i = 0; i < children.length; i++){
if(!children[i].evaluate(rcInfo, holder, category))
return false;
}
return true;
}
} }

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2007 Intel Corporation and others. * Copyright (c) 2007, 2011 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 Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -7,6 +7,7 @@
* *
* Contributors: * Contributors:
* Intel Corporation - Initial API and implementation * Intel Corporation - Initial API and implementation
* Miwako Tokugawa (Intel Corporation) - bug 222817 (OptionCategoryApplicability)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.managedbuilder.internal.enablement; package org.eclipse.cdt.managedbuilder.internal.enablement;
@ -15,6 +16,7 @@ import org.eclipse.cdt.managedbuilder.core.IConfiguration;
import org.eclipse.cdt.managedbuilder.core.IHoldsOptions; import org.eclipse.cdt.managedbuilder.core.IHoldsOptions;
import org.eclipse.cdt.managedbuilder.core.IManagedConfigElement; import org.eclipse.cdt.managedbuilder.core.IManagedConfigElement;
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.IResourceInfo; import org.eclipse.cdt.managedbuilder.core.IResourceInfo;
public class CheckBuildPropertyExpression implements IBooleanExpression { public class CheckBuildPropertyExpression implements IBooleanExpression {
@ -41,6 +43,15 @@ public class CheckBuildPropertyExpression implements IBooleanExpression {
public boolean evaluate(IResourceInfo rcInfo, IHoldsOptions holder, public boolean evaluate(IResourceInfo rcInfo, IHoldsOptions holder,
IOption option) { IOption option) {
return evaluate(rcInfo);
}
public boolean evaluate(IResourceInfo rcInfo, IHoldsOptions holder,
IOptionCategory category) {
return evaluate(rcInfo);
}
private boolean evaluate(IResourceInfo rcInfo) {
IConfiguration cfg = rcInfo.getParent(); IConfiguration cfg = rcInfo.getParent();
IBuildProperty prop = getBuildProperty(cfg, fPropertyId); IBuildProperty prop = getBuildProperty(cfg, fPropertyId);
if(prop != null){ if(prop != null){

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2005, 2007 Intel Corporation and others. * Copyright (c) 2005, 2011 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 Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -7,12 +7,14 @@
* *
* Contributors: * Contributors:
* Intel Corporation - Initial API and implementation * Intel Corporation - Initial API and implementation
* Miwako Tokugawa (Intel Corporation) - bug 222817 (OptionCategoryApplicability)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.managedbuilder.internal.enablement; package org.eclipse.cdt.managedbuilder.internal.enablement;
import org.eclipse.cdt.managedbuilder.core.IHoldsOptions; import org.eclipse.cdt.managedbuilder.core.IHoldsOptions;
import org.eclipse.cdt.managedbuilder.core.IManagedConfigElement; import org.eclipse.cdt.managedbuilder.core.IManagedConfigElement;
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.IResourceInfo; import org.eclipse.cdt.managedbuilder.core.IResourceInfo;
import org.eclipse.cdt.managedbuilder.core.ITool; import org.eclipse.cdt.managedbuilder.core.ITool;
import org.eclipse.cdt.managedbuilder.core.IToolChain; import org.eclipse.cdt.managedbuilder.core.IToolChain;
@ -28,9 +30,17 @@ public class CheckHolderExpression implements IBooleanExpression {
fHolderId = element.getAttribute(HOLDER_ID); fHolderId = element.getAttribute(HOLDER_ID);
} }
public boolean evaluate(IResourceInfo rcInfo, IHoldsOptions holder, public boolean evaluate(IResourceInfo rcInfo, IHoldsOptions holder,
IOption option) { IOption option) {
return evaluate(holder);
}
public boolean evaluate(IResourceInfo rcInfo, IHoldsOptions holder,
IOptionCategory category) {
return evaluate(holder);
}
private boolean evaluate(IHoldsOptions holder) {
if(fHolderId != null){ if(fHolderId != null){
for(; holder != null; holder = getHolderSuperClass(holder)){ for(; holder != null; holder = getHolderSuperClass(holder)){
if(fHolderId.equals(holder.getId())) if(fHolderId.equals(holder.getId()))

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2005, 2007 Intel Corporation and others. * Copyright (c) 2005, 2011 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 Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -7,6 +7,7 @@
* *
* Contributors: * Contributors:
* Intel Corporation - Initial API and implementation * Intel Corporation - Initial API and implementation
* Miwako Tokugawa (Intel Corporation) - bug 222817 (OptionCategoryApplicability)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.managedbuilder.internal.enablement; package org.eclipse.cdt.managedbuilder.internal.enablement;
@ -22,6 +23,7 @@ import org.eclipse.cdt.managedbuilder.core.IFolderInfo;
import org.eclipse.cdt.managedbuilder.core.IHoldsOptions; import org.eclipse.cdt.managedbuilder.core.IHoldsOptions;
import org.eclipse.cdt.managedbuilder.core.IManagedConfigElement; import org.eclipse.cdt.managedbuilder.core.IManagedConfigElement;
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.IResourceConfiguration; import org.eclipse.cdt.managedbuilder.core.IResourceConfiguration;
import org.eclipse.cdt.managedbuilder.core.IResourceInfo; import org.eclipse.cdt.managedbuilder.core.IResourceInfo;
import org.eclipse.cdt.managedbuilder.core.ITool; import org.eclipse.cdt.managedbuilder.core.ITool;
@ -79,7 +81,21 @@ public class CheckOptionExpression implements IBooleanExpression {
(IOption)otherHo[1],((IHoldsOptions)otherHo[0])); (IOption)otherHo[1],((IHoldsOptions)otherHo[0]));
} }
} }
return result;
}
public boolean evaluate(IResourceInfo rcInfo,
IHoldsOptions holder,
IOptionCategory category) {
boolean result = false;
IBuildObject ho[] = getHolderAndOption(fOptionId, fHolderId,
rcInfo, holder);
if(ho != null){
if(fValue != null)
result = evaluate((IOption)ho[1],((IHoldsOptions)ho[0]),fValue);
// otherOptionId shouldn't be set when enabling optionCategory
}
return result; return result;
} }
@ -253,6 +269,29 @@ public class CheckOptionExpression implements IBooleanExpression {
return result; return result;
} }
/* This is called for optionCategory */
protected IBuildObject[] getHolderAndOption(String optionId,
String holderId,
IResourceInfo rcInfo,
IHoldsOptions holder
){
IBuildObject result[] = null;
if(optionId != null) {
IHoldsOptions hld = null;
if(holderId == null)
hld = holder;
else
hld = getHolder(holderId,rcInfo);
if(hld != null) {
IOption opt = getOption(optionId,hld);
if(opt != null)
result = new IBuildObject[]{hld,opt};
}
}
return result;
}
protected IOption getOption(String optionId, protected IOption getOption(String optionId,
IHoldsOptions holder){ IHoldsOptions holder){
return holder.getOptionBySuperClassId(optionId); return holder.getOptionBySuperClassId(optionId);

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2005, 2008 Intel Corporation and others. * Copyright (c) 2005, 2011 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 Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -7,6 +7,7 @@
* *
* Contributors: * Contributors:
* Intel Corporation - Initial API and implementation * Intel Corporation - Initial API and implementation
* Miwako Tokugawa (Intel Corporation) - bug 222817 (OptionCategoryApplicability)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.managedbuilder.internal.enablement; package org.eclipse.cdt.managedbuilder.internal.enablement;
@ -16,6 +17,7 @@ import java.util.regex.Pattern;
import org.eclipse.cdt.managedbuilder.core.IHoldsOptions; import org.eclipse.cdt.managedbuilder.core.IHoldsOptions;
import org.eclipse.cdt.managedbuilder.core.IManagedConfigElement; import org.eclipse.cdt.managedbuilder.core.IManagedConfigElement;
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.IResourceInfo; import org.eclipse.cdt.managedbuilder.core.IResourceInfo;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager; import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
import org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableProvider; import org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableProvider;
@ -79,4 +81,37 @@ public class CheckStringExpression implements IBooleanExpression {
return false; return false;
} }
public boolean evaluate(IResourceInfo rcInfo,
IHoldsOptions holder,
IOptionCategory category) {
IBuildMacroProvider provider = ManagedBuildManager.getBuildMacroProvider();
IEnvironmentVariableProvider env = ManagedBuildManager.getEnvironmentVariableProvider();
String delimiter = env.getDefaultDelimiter();
try {
String resolvedString = provider.resolveValue(fString,
" ", //$NON-NLS-1$
delimiter,
IBuildMacroProvider.CONTEXT_OPTION,
new OptionContextData(category,holder)
);
String resolvedValue = provider.resolveValue(fValue,
" ", //$NON-NLS-1$
delimiter,
IBuildMacroProvider.CONTEXT_OPTION,
new OptionContextData(category,holder)
);
if(fIsRegex){
Pattern pattern = Pattern.compile(resolvedValue);
Matcher matcher = pattern.matcher(resolvedString);
return matcher.matches();
}
return resolvedString.equals(resolvedValue);
} catch (BuildMacroException e) {
}
return false;
}
} }

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2005, 2007 Intel Corporation and others. * Copyright (c) 2005, 2011 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 Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -7,12 +7,14 @@
* *
* Contributors: * Contributors:
* Intel Corporation - Initial API and implementation * Intel Corporation - Initial API and implementation
* Miwako Tokugawa (Intel Corporation) - bug 222817 (OptionCategoryApplicability)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.managedbuilder.internal.enablement; package org.eclipse.cdt.managedbuilder.internal.enablement;
import org.eclipse.cdt.managedbuilder.core.IHoldsOptions; import org.eclipse.cdt.managedbuilder.core.IHoldsOptions;
import org.eclipse.cdt.managedbuilder.core.IManagedConfigElement; import org.eclipse.cdt.managedbuilder.core.IManagedConfigElement;
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.IResourceInfo; import org.eclipse.cdt.managedbuilder.core.IResourceInfo;
public class FalseExpression implements IBooleanExpression { public class FalseExpression implements IBooleanExpression {
@ -25,5 +27,9 @@ public class FalseExpression implements IBooleanExpression {
IOption option) { IOption option) {
return false; return false;
} }
public boolean evaluate(IResourceInfo rcInfo, IHoldsOptions holder,
IOptionCategory category) {
return false;
}
} }

View file

@ -1,5 +1,5 @@
/********************************************************************** /**********************************************************************
* Copyright (c) 2007 QNX Software Systems and others. * Copyright (c) 2007, 2011 QNX Software Systems 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 Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -7,13 +7,15 @@
* *
* Contributors: * Contributors:
* QNX Software Systems - Initial API and implementation * QNX Software Systems - Initial API and implementation
**********************************************************************/ * Miwako Tokugawa (Intel Corporation) - bug 222817 (OptionCategoryApplicability)
**********************************************************************/
package org.eclipse.cdt.managedbuilder.internal.enablement; package org.eclipse.cdt.managedbuilder.internal.enablement;
import org.eclipse.cdt.managedbuilder.core.IConfiguration; import org.eclipse.cdt.managedbuilder.core.IConfiguration;
import org.eclipse.cdt.managedbuilder.core.IHoldsOptions; import org.eclipse.cdt.managedbuilder.core.IHoldsOptions;
import org.eclipse.cdt.managedbuilder.core.IManagedConfigElement; import org.eclipse.cdt.managedbuilder.core.IManagedConfigElement;
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.IResourceInfo; import org.eclipse.cdt.managedbuilder.core.IResourceInfo;
import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IResource;
@ -37,6 +39,15 @@ public class HasNatureExpression implements IBooleanExpression {
public boolean evaluate(IResourceInfo rcInfo, IHoldsOptions holder, public boolean evaluate(IResourceInfo rcInfo, IHoldsOptions holder,
IOption option) { IOption option) {
return evaluate(rcInfo);
}
public boolean evaluate(IResourceInfo rcInfo, IHoldsOptions holder,
IOptionCategory category) {
return evaluate(rcInfo);
}
private boolean evaluate(IResourceInfo rcInfo) {
// All null checks returns false to keep this expression // All null checks returns false to keep this expression
// from accidentally turning things on. Although // from accidentally turning things on. Although
// a 'z' value would be better to avoid having any affect. // a 'z' value would be better to avoid having any affect.
@ -60,5 +71,4 @@ public class HasNatureExpression implements IBooleanExpression {
} }
return false; return false;
} }
} }

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2005, 2007 Intel Corporation and others. * Copyright (c) 2005, 2011 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 Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -7,15 +7,20 @@
* *
* Contributors: * Contributors:
* Intel Corporation - Initial API and implementation * Intel Corporation - Initial API and implementation
* Miwako Tokugawa (Intel Corporation) - bug 222817 (OptionCategoryApplicability)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.managedbuilder.internal.enablement; package org.eclipse.cdt.managedbuilder.internal.enablement;
import org.eclipse.cdt.managedbuilder.core.IHoldsOptions; import org.eclipse.cdt.managedbuilder.core.IHoldsOptions;
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.IResourceInfo; import org.eclipse.cdt.managedbuilder.core.IResourceInfo;
public interface IBooleanExpression { public interface IBooleanExpression {
public boolean evaluate(IResourceInfo rcInfo, public boolean evaluate(IResourceInfo rcInfo,
IHoldsOptions holder, IHoldsOptions holder,
IOption option); IOption option);
public boolean evaluate(IResourceInfo rcInfo,
IHoldsOptions holder,
IOptionCategory category);
} }

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2005, 2008 Intel Corporation and others. * Copyright (c) 2005, 2011 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 Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -7,12 +7,14 @@
* *
* Contributors: * Contributors:
* Intel Corporation - Initial API and implementation * Intel Corporation - Initial API and implementation
* Miwako Tokugawa (Intel Corporation) - bug 222817 (OptionCategoryApplicability)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.managedbuilder.internal.enablement; package org.eclipse.cdt.managedbuilder.internal.enablement;
import org.eclipse.cdt.managedbuilder.core.IHoldsOptions; import org.eclipse.cdt.managedbuilder.core.IHoldsOptions;
import org.eclipse.cdt.managedbuilder.core.IManagedConfigElement; import org.eclipse.cdt.managedbuilder.core.IManagedConfigElement;
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.IResourceInfo; import org.eclipse.cdt.managedbuilder.core.IResourceInfo;
public class NotExpression extends AndExpression { public class NotExpression extends AndExpression {
@ -29,4 +31,11 @@ public class NotExpression extends AndExpression {
return !super.evaluate(rcInfo, holder, option); return !super.evaluate(rcInfo, holder, option);
} }
@Override
public boolean evaluate(IResourceInfo rcInfo,
IHoldsOptions holder,
IOptionCategory category) {
return !super.evaluate(rcInfo, holder, category);
}
} }

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2005, 2007 Intel Corporation and others. * Copyright (c) 2005, 2011 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 Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -7,12 +7,14 @@
* *
* Contributors: * Contributors:
* Intel Corporation - Initial API and implementation * Intel Corporation - Initial API and implementation
* Miwako Tokugawa (Intel Corporation) - bug 222817 (OptionCategoryApplicability)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.managedbuilder.internal.enablement; package org.eclipse.cdt.managedbuilder.internal.enablement;
import org.eclipse.cdt.managedbuilder.core.IHoldsOptions; import org.eclipse.cdt.managedbuilder.core.IHoldsOptions;
import org.eclipse.cdt.managedbuilder.core.IManagedConfigElement; import org.eclipse.cdt.managedbuilder.core.IManagedConfigElement;
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.IResourceInfo; import org.eclipse.cdt.managedbuilder.core.IResourceInfo;
public class OrExpression extends CompositeExpression { public class OrExpression extends CompositeExpression {
@ -32,4 +34,14 @@ public class OrExpression extends CompositeExpression {
} }
return false; return false;
} }
public boolean evaluate(IResourceInfo rcInfo,
IHoldsOptions holder,
IOptionCategory category) {
IBooleanExpression children[] = getChildren();
for(int i = 0; i < children.length; i++){
if(children[i].evaluate(rcInfo, holder, category))
return true;
}
return false;
}
} }

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2005, 2010 Intel Corporation and others. * Copyright (c) 2005, 2011 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 Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -7,6 +7,7 @@
* *
* Contributors: * Contributors:
* Intel Corporation - Initial API and implementation * Intel Corporation - Initial API and implementation
* Miwako Tokugawa (Intel Corporation) - bug 222817 (OptionCategoryApplicability)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.managedbuilder.internal.macros; package org.eclipse.cdt.managedbuilder.internal.macros;
@ -209,6 +210,7 @@ public class BuildMacroProvider implements IBuildMacroProvider, IMacroContextInf
String listDelimiter, int contextType, Object contextData) String listDelimiter, int contextType, Object contextData)
throws BuildMacroException { throws BuildMacroException {
IMacroContextInfo info = getMacroContextInfo(contextType,contextData); IMacroContextInfo info = getMacroContextInfo(contextType,contextData);
if(info != null){ if(info != null){
try { try {
return CdtVariableResolver.resolveToString(value, return CdtVariableResolver.resolveToString(value,

View file

@ -782,6 +782,9 @@ public class MbsMacroSupplier extends BuildCdtVariablesSupplierBase {
return EMPTY_STRING; return EMPTY_STRING;
IncludeDefaultsSubstitutor sub = new IncludeDefaultsSubstitutor(parent); IncludeDefaultsSubstitutor sub = new IncludeDefaultsSubstitutor(parent);
IOption option = parent.getOption(); IOption option = parent.getOption();
if (option==null)
return null;
String str = null; String str = null;
String strL[] = null; String strL[] = null;
try{ try{
@ -831,6 +834,9 @@ public class MbsMacroSupplier extends BuildCdtVariablesSupplierBase {
return new String[]{EMPTY_STRING}; return new String[]{EMPTY_STRING};
IncludeDefaultsSubstitutor sub = new IncludeDefaultsSubstitutor(parent); IncludeDefaultsSubstitutor sub = new IncludeDefaultsSubstitutor(parent);
IOption option = parent.getOption(); IOption option = parent.getOption();
if (option==null)
return null;
String str = null; String str = null;
String strL[] = null; String strL[] = null;
try{ try{
@ -894,6 +900,7 @@ public class MbsMacroSupplier extends BuildCdtVariablesSupplierBase {
fType = 0; fType = 0;
if(parentOptionContextData != null){ if(parentOptionContextData != null){
IOption option = parentOptionContextData.getOption(); IOption option = parentOptionContextData.getOption();
if (option!=null) {
try{ try{
switch (option.getValueType()) { switch (option.getValueType()) {
case IOption.BOOLEAN: case IOption.BOOLEAN:
@ -973,6 +980,7 @@ public class MbsMacroSupplier extends BuildCdtVariablesSupplierBase {
fType = 0; fType = 0;
} }
} }
}
boolean result = fType != 0; boolean result = fType != 0;
if(!result){ if(!result){

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2005, 2007 Intel Corporation and others. * Copyright (c) 2005, 2011 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 Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -7,6 +7,7 @@
* *
* Contributors: * Contributors:
* Intel Corporation - Initial API and implementation * Intel Corporation - Initial API and implementation
* Miwako Tokugawa (Intel Corporation) - bug 222817 (OptionCategoryApplicability)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.managedbuilder.internal.macros; package org.eclipse.cdt.managedbuilder.internal.macros;
@ -16,24 +17,34 @@ import org.eclipse.cdt.managedbuilder.core.IFileInfo;
import org.eclipse.cdt.managedbuilder.core.IFolderInfo; import org.eclipse.cdt.managedbuilder.core.IFolderInfo;
import org.eclipse.cdt.managedbuilder.core.IHoldsOptions; import org.eclipse.cdt.managedbuilder.core.IHoldsOptions;
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.IResourceInfo; import org.eclipse.cdt.managedbuilder.core.IResourceInfo;
import org.eclipse.cdt.managedbuilder.core.ITool; import org.eclipse.cdt.managedbuilder.core.ITool;
import org.eclipse.cdt.managedbuilder.core.IToolChain; import org.eclipse.cdt.managedbuilder.core.IToolChain;
import org.eclipse.cdt.managedbuilder.macros.IOptionContextData; import org.eclipse.cdt.managedbuilder.macros.IOptionContextData;
/** /**
* This is a trivial implementation of the IOptionContextData used internaly by the MBS * This is a trivial implementation of the IOptionContextData used internally by the MBS
* *
* @since 3.0 * @since 3.0
*/ */
public class OptionContextData implements IOptionContextData { public class OptionContextData implements IOptionContextData {
private IOption fOption; private IOption fOption;
private IOptionCategory fCategory;
private IBuildObject fParent; private IBuildObject fParent;
public OptionContextData(IOption option, IBuildObject parent){ public OptionContextData(IOption option, IBuildObject parent){
fOption = option; fOption = option;
fParent = parent; fParent = parent;
} }
/*
* @since 8.0
*/
public OptionContextData(IOptionCategory category, IBuildObject parent){
fCategory = category;
fParent = parent;
}
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.macros.IOptionContextData#getOption() * @see org.eclipse.cdt.managedbuilder.macros.IOptionContextData#getOption()
*/ */
@ -41,6 +52,13 @@ public class OptionContextData implements IOptionContextData {
return fOption; return fOption;
} }
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.macros.IOptionContextData#getOptionCategory()
*/
public IOptionCategory getOptionCategory() {
return fCategory;
}
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.macros.IOptionContextData#getParent() * @see org.eclipse.cdt.managedbuilder.macros.IOptionContextData#getParent()
*/ */

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2005, 2010 Intel Corporation and others. * Copyright (c) 2005, 2011 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 Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -7,11 +7,13 @@
* *
* Contributors: * Contributors:
* Intel Corporation - Initial API and implementation * Intel Corporation - Initial API and implementation
* Miwako Tokugawa (Intel Corporation) - bug 222817 (OptionCategoryApplicability)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.managedbuilder.macros; package org.eclipse.cdt.managedbuilder.macros;
import org.eclipse.cdt.managedbuilder.core.IBuildObject; import org.eclipse.cdt.managedbuilder.core.IBuildObject;
import org.eclipse.cdt.managedbuilder.core.IOption; import org.eclipse.cdt.managedbuilder.core.IOption;
import org.eclipse.cdt.managedbuilder.core.IOptionCategory;
/** /**
* This interface is used to represent an option context data * This interface is used to represent an option context data
@ -24,10 +26,19 @@ public interface IOptionContextData {
/** /**
* Returns an option * Returns an option
* *
* @return IOption * @return IOption, could be {@code null}
*/ */
public IOption getOption(); public IOption getOption();
/**
* Returns an option category
*
* @return IOptionCategory, could be {@code null}
*
* @since 8.0
*/
public IOptionCategory getOptionCategory();
/** /**
* Returns IBuildObject that represents the option holder. * Returns IBuildObject that represents the option holder.
* For the backward compatibility MBS will also support the cases * For the backward compatibility MBS will also support the cases

View file

@ -189,7 +189,7 @@ public class BuildOptionSettingsUI extends AbstractToolSettingUI {
*/ */
@Override @Override
protected void createFieldEditors() { protected void createFieldEditors() {
// true if he user selected "Display tool option tips at a fixed location" in Preferences AND // true if the user selected "Display tool option tips at a fixed location" in Preferences AND
// and we are displaying the tool tip box on this page because one or more option has non-empty tool tip. // and we are displaying the tool tip box on this page because one or more option has non-empty tool tip.
boolean pageHasToolTipBox = isToolTipBoxNeeded(); boolean pageHasToolTipBox = isToolTipBoxNeeded();

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2002, 2010 IBM Corporation and others. * Copyright (c) 2002, 2011 IBM 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 Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -8,6 +8,7 @@
* Contributors: * Contributors:
* Timesys - Initial API and implementation * Timesys - Initial API and implementation
* IBM Rational Software * IBM Rational Software
* Miwako Tokugawa (Intel Corporation) - bug 222817 (OptionCategoryApplicability)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.managedbuilder.ui.properties; package org.eclipse.cdt.managedbuilder.ui.properties;
@ -18,6 +19,7 @@ import org.eclipse.cdt.managedbuilder.core.IConfiguration;
import org.eclipse.cdt.managedbuilder.core.IFolderInfo; import org.eclipse.cdt.managedbuilder.core.IFolderInfo;
import org.eclipse.cdt.managedbuilder.core.IHoldsOptions; import org.eclipse.cdt.managedbuilder.core.IHoldsOptions;
import org.eclipse.cdt.managedbuilder.core.IOptionCategory; import org.eclipse.cdt.managedbuilder.core.IOptionCategory;
import org.eclipse.cdt.managedbuilder.core.IOptionCategoryApplicability;
import org.eclipse.cdt.managedbuilder.core.IResourceConfiguration; import org.eclipse.cdt.managedbuilder.core.IResourceConfiguration;
import org.eclipse.cdt.managedbuilder.core.IResourceInfo; import org.eclipse.cdt.managedbuilder.core.IResourceInfo;
import org.eclipse.cdt.managedbuilder.core.ITool; import org.eclipse.cdt.managedbuilder.core.ITool;
@ -66,7 +68,7 @@ public class ToolListContentProvider implements ITreeContentProvider{
for (int i=0; i<filteredTools.length; i++) { for (int i=0; i<filteredTools.length; i++) {
ToolListElement e = new ToolListElement(filteredTools[i]); ToolListElement e = new ToolListElement(filteredTools[i]);
elementList.add(e); elementList.add(e);
createChildElements(e); createChildElements(e,config);
} }
} }
return elementList.toArray(new ToolListElement[elementList.size()]); return elementList.toArray(new ToolListElement[elementList.size()]);
@ -93,11 +95,15 @@ public class ToolListContentProvider implements ITreeContentProvider{
} }
return elementList.toArray(new ToolListElement[elementList.size()]); return elementList.toArray(new ToolListElement[elementList.size()]);
} }
private void createChildElements(ToolListElement parentElement) { private void createChildElements(ToolListElement parentElement) {
createChildElements(parentElement,null);
}
private void createChildElements(ToolListElement parentElement, IConfiguration config) {
IOptionCategory parent = parentElement.getOptionCategory(); IOptionCategory parent = parentElement.getOptionCategory();
IHoldsOptions optHolder = parentElement.getHoldOptions(); IHoldsOptions optHolder = parentElement.getHoldOptions();
IOptionCategoryApplicability applicabilityCalculator = null;
if (parent == null) { if (parent == null) {
parent = parentElement.getTool().getTopOptionCategory(); // Must be an ITool parent = parentElement.getTool().getTopOptionCategory(); // Must be an ITool
optHolder = parentElement.getTool(); optHolder = parentElement.getTool();
@ -106,8 +112,11 @@ public class ToolListContentProvider implements ITreeContentProvider{
// Create an element for each one // Create an element for each one
for (int i=0; i<cats.length; i++) { for (int i=0; i<cats.length; i++) {
ToolListElement e = new ToolListElement(parentElement, optHolder, cats[i]); ToolListElement e = new ToolListElement(parentElement, optHolder, cats[i]);
applicabilityCalculator = e.getOptionCategory().getApplicabilityCalculator();
if (applicabilityCalculator == null || applicabilityCalculator.isOptionCategoryVisible(config, optHolder, parent)) {
parentElement.addChildElement(e); parentElement.addChildElement(e);
createChildElements(e); createChildElements(e,config);
}
} }
} }

View file

@ -133,6 +133,7 @@ public class ToolSettingsTab extends AbstractCBuildPropertyTab implements IPrefe
propertyObject = page.getElement(); propertyObject = page.getElement();
setValues(); setValues();
specificResize();
} }
private void specificResize() { private void specificResize() {
@ -433,7 +434,6 @@ public class ToolSettingsTab extends AbstractCBuildPropertyTab implements IPrefe
optionList.setSelection(new StructuredSelection(selectedElement), true); optionList.setSelection(new StructuredSelection(selectedElement), true);
} }
} }
specificResize();
} }
private ToolListElement matchSelectionElement(ToolListElement currentElement, ToolListElement[] elements) { private ToolListElement matchSelectionElement(ToolListElement currentElement, ToolListElement[] elements) {
@ -514,8 +514,11 @@ public class ToolSettingsTab extends AbstractCBuildPropertyTab implements IPrefe
} }
// Reset the category or tool selection and run selection event handler // Reset the category or tool selection and run selection event handler
selectedElement = null; selectedElement = null;
handleOptionSelection();
setDirty(true); setDirty(true);
fInfo = getResCfg(getResDesc());
setValues();
handleOptionSelection();
} }
/* /*
@ -714,6 +717,7 @@ public class ToolSettingsTab extends AbstractCBuildPropertyTab implements IPrefe
public void updateData(ICResourceDescription cfgd) { public void updateData(ICResourceDescription cfgd) {
fInfo = getResCfg(cfgd); fInfo = getResCfg(cfgd);
setValues(); setValues();
specificResize();
handleOptionSelection(); handleOptionSelection();
} }
@ -737,6 +741,8 @@ public class ToolSettingsTab extends AbstractCBuildPropertyTab implements IPrefe
copyHoldsOptions(pair.getKey(), pair.getValue(), ri2); copyHoldsOptions(pair.getKey(), pair.getValue(), ri2);
} }
setDirty(false); setDirty(false);
updateData(getResDesc());
} }
/** /**