use of org.eclipse.cdt.managedbuilder.core.IOption in project usbdm-eclipse-plugins by podonoghue.
the class ValueHandlerTest method handleValue.
@Override
public boolean handleValue(IBuildObject configuration, IHoldsOptions holder, IOption option, String extraArgument, int event) {
System.err.println("====================================================================================================");
System.err.println("net.sourceforge.usbdm.cdt.wizard.ValueHandler() - extraArgument = \'" + extraArgument + "\'");
switch(event) {
case EVENT_OPEN:
System.err.println("net.sourceforge.usbdm.cdt.wizard.ValueHandler() - EVENT_OPEN");
break;
case EVENT_CLOSE:
System.err.println("net.sourceforge.usbdm.cdt.wizard.ValueHandler() - EVENT_CLOSE");
break;
case EVENT_SETDEFAULT:
System.err.println("net.sourceforge.usbdm.cdt.wizard.ValueHandler() - EVENT_SETDEFAULT");
break;
case EVENT_APPLY:
System.err.println("net.sourceforge.usbdm.cdt.wizard.ValueHandler() - EVENT_APPLY");
break;
case EVENT_LOAD:
System.err.println("net.sourceforge.usbdm.cdt.wizard.ValueHandler() - EVENT_APPLY");
break;
default:
System.err.println("net.sourceforge.usbdm.cdt.wizard.ValueHandler() - Unexpected event " + event);
break;
}
listConfigs(configuration, extraArgument);
IOption option1 = holder.getOptionBySuperClassId(extraArgument);
if (option1 != null) {
System.err.println("net.sourceforge.usbdm.cdt.wizard.ValueHandler() - holder.getOptionBySuperClassId(extraArgument) => " + option1.getName());
} else {
System.err.println("net.sourceforge.usbdm.cdt.wizard.ValueHandler() - holder.getOptionBySuperClassId(extraArgument) = null");
}
IOption option2 = holder.getOptionById(extraArgument);
if (option2 != null) {
System.err.println("net.sourceforge.usbdm.cdt.wizard.ValueHandler() - holder.getOptionById(extraArgument) = " + option2.getName());
} else {
System.err.println("net.sourceforge.usbdm.cdt.wizard.ValueHandler() - holder.getOptionById(extraArgument) = null");
}
if (configuration instanceof IConfiguration) {
IConfiguration theConfiguration = (IConfiguration) configuration;
System.err.println("theConfiguration = " + theConfiguration.getName());
IToolChain toolchain = theConfiguration.getToolChain();
System.err.println("toolchain = " + toolchain.getName());
// $NON-NLS-1$
IOption mcpuOption = toolchain.getOptionBySuperClassId(extraArgument);
if (mcpuOption != null) {
System.err.println("cdt.managedbuild.option.gnu.cross.prefix mcpuOption.getName() => " + mcpuOption.getId());
System.err.println("cdt.managedbuild.option.gnu.cross.prefix mcpuOption.getValue().toString() => " + mcpuOption.getValue().toString());
// String mcpuOptionValue = (String)mcpuOption.getValue();
// try {
// option.setValue(mcpuOptionValue);
// } catch (BuildException e) {
// e.printStackTrace();
// }
}
}
return false;
}
use of org.eclipse.cdt.managedbuilder.core.IOption in project usbdm-eclipse-plugins by podonoghue.
the class ValueHandlerTest method listConfigs.
IOption listConfigs(IBuildObject configuration, String configTypeID) {
System.err.println("ValueHandlerTest.listConfigs(configTypeID=" + configTypeID + ")");
// first we check the preference for this project, if it exists
IConfiguration config = null;
if (configuration instanceof IConfiguration) {
config = (IConfiguration) configuration;
} else if (configuration instanceof IFolderInfo) {
IFolderInfo folderInfo = (IFolderInfo) configuration;
config = folderInfo.getParent();
}
if (config == null) {
System.err.println("ValueHandlerTest.listConfigs() config not found");
}
IOption targetOption = null;
IToolChain toolChain = config.getToolChain();
System.err.println("ValueHandlerTest.listConfigs() Checking toolchain: " + toolChain.getId());
if (toolChain.getOptionBySuperClassId(configTypeID) != null) {
targetOption = toolChain.getOptionBySuperClassId(configTypeID);
System.err.println("ValueHandlerTest.listConfigs() Checking toolchain: Found => " + targetOption.getValue().toString());
// return targetOption;
}
ITool[] tools = toolChain.getTools();
for (int i = 0; i < tools.length; i++) {
System.err.println("ValueHandlerTest.listConfigs() Checking tool: " + tools[i].getId());
if (tools[i].getOptionBySuperClassId(configTypeID) != null) {
targetOption = tools[i].getOptionBySuperClassId(configTypeID);
System.err.println("ValueHandlerTest.listConfigs() Checking tool: Found => " + targetOption.getValue().toString());
// return targetOption;
}
}
if (targetOption == null) {
System.err.println("ValueHandlerTest.listConfigs() targetOption not found");
}
return targetOption;
}
use of org.eclipse.cdt.managedbuilder.core.IOption in project usbdm-eclipse-plugins by podonoghue.
the class UsbdmDebuggerPanel method getToolInformationDataFromConfig.
/**
* Try to get interface type from project via ILaunchConfiguration
*
* @param configuration
* @return
*/
private ToolInformationData getToolInformationDataFromConfig(ILaunchConfiguration configuration) {
String buildToolsId = null;
try {
// ToDo Consider using - ICProject projectHandle =
// CDebugUtils.verifyCProject(configuration);
String projectName = configuration.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, (String) null);
String projectBuildId = configuration.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_BUILD_CONFIG_ID, (String) null);
if ((projectName != null) && (projectBuildId != null)) {
ICProject projectHandle = CoreModel.getDefault().getCModel().getCProject(projectName);
IConfiguration buildConfig = ManagedBuildManager.getBuildInfo(projectHandle.getProject()).getManagedProject().getConfiguration(projectBuildId);
if (buildConfig != null) {
IToolChain toolChain = buildConfig.getToolChain();
if (toolChain != null) {
IOption option = toolChain.getOptionBySuperClassId("net.sourceforge.usbdm.cdt.arm.toolchain.buildtools");
if (option == null) {
option = toolChain.getOptionBySuperClassId("net.sourceforge.usbdm.cdt.coldfire.toolchain.buildtools");
}
if (option != null) {
// System.err.println("option(net.sourceforge.usbdm.cdt.arm.toolchain.buildtools).getId()
// = "+option.getId());
// System.err.println("option(net.sourceforge.usbdm.cdt.arm.toolchain.buildtools).getName()
// = "+option.getName());
buildToolsId = option.getStringValue();
}
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
// System.err.println("Selected Build Tools ID = " + buildToolsId);
ToolInformationData toolInformationData = null;
if (buildToolsId != null) {
toolInformationData = ToolInformationData.get(buildToolsId);
}
// System.err.println("Selected Build Tools = " + toolInformationData);
return toolInformationData;
}
use of org.eclipse.cdt.managedbuilder.core.IOption in project m2e-nar by maven-nar.
the class OptionSetter method setOption.
public void setOption(final String optionId, final boolean value) throws CoreException {
try {
for (final ITool tool : config.getToolsBySuperClassId(toolId)) {
final IOption option = tool.getOptionBySuperClassId(optionId);
config.setOption(tool, option, value);
}
} catch (BuildException e) {
throw new CoreException(new Status(IStatus.ERROR, MavenNarPlugin.PLUGIN_ID, "Couldn't set " + optionId + " option", e));
}
}
use of org.eclipse.cdt.managedbuilder.core.IOption in project linuxtools by eclipse.
the class CProjectBuildHelpers method setOptionInCDTTool.
/**
* <h1>Set Option in CDT</h1>
* Same as {@link #setOptionInCDT(IProject project, String optionIDString, boolean value) setOption_in } <br>
* except you can specify the parent tool manually (in case current implementation does not support what yon need.
*
* @param project an IProject
* @param optionIDString ID of option as defined in plugin.xml. e.g gnu.cpp.compiler.option.debugging.gprof
* @param value true/false
* @param toolSuperClassId
* Name of the tool where the option resides. E.g 'GCC C Compiler' or 'GCC C++ Compiler'. <br>
* To find out, check/uncheck an option, inspect the .cproject file, look for the option,<br>
* then see what tool it's under. See the name property
* @return true if all went well, false otherwise
*/
private static boolean setOptionInCDTTool(IProject project, String optionIDString, boolean value, String toolSuperClassId) {
// Get configuration
IConfiguration activeConf = helperGetActiveConfiguration(project);
// Get the ITool the option.
ITool gccCompileriTool = helperGetGccCompilerToolBySuperClass(toolSuperClassId, activeConf);
// Get Template Opiton.
// Get Option ~Immutable. This is like a 'templete' that we will base the actual option on.
IOption optionTemplate = gccCompileriTool.getOptionById(optionIDString);
// Check that we got a good option template.
if (optionTemplate == null) {
// This could fail if the specified option doesn't exist or is miss-spelled.
MessageDialogSyncedRunnable.openErrorSyncedRunnable(ProfilingMessages.errorTitle, ProfilingMessages.errorGetOptionTemplate);
return false;
}
// Get Actual Option
//
// Now we acquire an option that can be 'set' to something.
// In contrast to the immutable option above, if the user never checked/unchecked the option by hand,
// then the first time 'set' of this option will work correctly. Whereas
// the immutable option would only work if the user checked/unchecked the option by hand before.
IOption mutableOptionToSet = null;
try {
mutableOptionToSet = gccCompileriTool.getOptionToSet(optionTemplate, false);
mutableOptionToSet.setValue(value);
} catch (BuildException e) {
// This is reached if the template that was provided was bad.
MessageDialogSyncedRunnable.openErrorSyncedRunnable(ProfilingMessages.errorTitle, ProfilingMessages.errorGetOptionForWriting);
}
// get resource info. (where things are saved to).
IResourceInfo resourceInfo = activeConf.getResourceInfos()[0];
// Mark the option as enabled in the build manager.
ManagedBuildManager.setOption(resourceInfo, gccCompileriTool, mutableOptionToSet, true);
// Save this business to disk.
ManagedBuildManager.saveBuildInfo(project, true);
return true;
}
Aggregations