Search in sources :

Example 11 with ITool

use of org.eclipse.cdt.managedbuilder.core.ITool in project usbdm-eclipse-plugins by podonoghue.

the class ToolchainValueHandler method isEnumValueAppropriate.

@Override
public boolean isEnumValueAppropriate(IBuildObject configuration, IHoldsOptions holder, IOption option, String extraArgument, String enumValue) {
    String configTypeID = "net.sourceforge.usbdm.cdt.toolchain.processor.mcpu";
    System.err.println("ToolchainValueHandler.isEnumValueAppropriate()");
    // 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("ToolchainValueHandler.isEnumValueAppropriate() config not found");
        return true;
    }
    IToolChain toolChain = config.getToolChain();
    ITool[] tools = toolChain.getTools();
    IOption CPUListOption = null;
    for (int i = 0; i < tools.length; i++) {
        System.err.println("ToolchainValueHandler.isEnumValueAppropriate() Checking tool: " + tools[i].getId());
        if (tools[i].getOptionBySuperClassId(configTypeID) != null) {
            CPUListOption = tools[i].getOptionBySuperClassId(configTypeID);
        }
    }
    if (CPUListOption == null) {
        System.err.println("ToolchainValueHandler.isEnumValueAppropriate() CPUListOption not found");
    }
    return true;
}
Also used : IToolChain(org.eclipse.cdt.managedbuilder.core.IToolChain) IOption(org.eclipse.cdt.managedbuilder.core.IOption) IConfiguration(org.eclipse.cdt.managedbuilder.core.IConfiguration) IFolderInfo(org.eclipse.cdt.managedbuilder.core.IFolderInfo) ITool(org.eclipse.cdt.managedbuilder.core.ITool)

Example 12 with ITool

use of org.eclipse.cdt.managedbuilder.core.ITool 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;
}
Also used : IOption(org.eclipse.cdt.managedbuilder.core.IOption) IToolChain(org.eclipse.cdt.managedbuilder.core.IToolChain) IConfiguration(org.eclipse.cdt.managedbuilder.core.IConfiguration) IFolderInfo(org.eclipse.cdt.managedbuilder.core.IFolderInfo) ITool(org.eclipse.cdt.managedbuilder.core.ITool)

Example 13 with ITool

use of org.eclipse.cdt.managedbuilder.core.ITool in project usbdm-eclipse-plugins by podonoghue.

the class ApplyOptions method setOptionValue.

// public void updateConfigurations(IProgressMonitor monitor) {
// ManagedBuildManager.saveBuildInfo(projectHandle, true);
// IConfiguration[] projectConfigs = ManagedBuildManager.getBuildInfo(projectHandle).getManagedProject().getConfigurations();
// for (IConfiguration config : projectConfigs) {
// ScannerConfigBuilder.build(config, ScannerConfigBuilder.PERFORM_CORE_UPDATE, monitor);
// }
// }
private boolean setOptionValue(String id, String[] value, String path, boolean replace, String targetConfig, IProgressMonitor monitor) throws Exception {
    IConfiguration[] projectConfigs = ManagedBuildManager.getBuildInfo(projectHandle).getManagedProject().getConfigurations();
    // $NON-NLS-1$ //$NON-NLS-2$
    boolean resource = !(path == null || path.equals("") || path.equals("/"));
    boolean modified = false;
    for (IConfiguration config : projectConfigs) {
        if ((targetConfig != null) && !config.getId().contains(targetConfig)) {
            // System.err.println("ApplyOptions() - Skipping config " + config.getId()); //$NON-NLS-1$
            continue;
        }
        IResourceConfiguration resourceConfig = null;
        if (resource) {
            resourceConfig = config.getResourceConfiguration(path);
            if (resourceConfig == null) {
                IFile file = projectHandle.getFile(path);
                if (file == null) {
                    // $NON-NLS-1$
                    throw new Exception("ApplyOptions() file is null for path = " + path);
                }
                resourceConfig = config.createResourceConfiguration(file);
            }
            ITool[] tools = resourceConfig.getTools();
            for (ITool tool : tools) {
                modified |= addToOptionForResourceConfig(id, value, replace, resourceConfig, tool.getOptions(), tool);
            }
        } else {
            IToolChain toolChain = config.getToolChain();
            modified |= addToOptionForConfig(id, value, replace, config, toolChain.getOptions(), toolChain);
            ITool[] tools = config.getTools();
            for (ITool tool : tools) {
                modified |= addToOptionForConfig(id, value, replace, config, tool.getOptions(), tool);
            }
        }
    }
    return modified;
}
Also used : IFile(org.eclipse.core.resources.IFile) IResourceConfiguration(org.eclipse.cdt.managedbuilder.core.IResourceConfiguration) IToolChain(org.eclipse.cdt.managedbuilder.core.IToolChain) IConfiguration(org.eclipse.cdt.managedbuilder.core.IConfiguration) ITool(org.eclipse.cdt.managedbuilder.core.ITool) BuildException(org.eclipse.cdt.managedbuilder.core.BuildException) ProcessFailureException(org.eclipse.cdt.core.templateengine.process.ProcessFailureException)

Example 14 with ITool

use of org.eclipse.cdt.managedbuilder.core.ITool 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));
    }
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) CoreException(org.eclipse.core.runtime.CoreException) IOption(org.eclipse.cdt.managedbuilder.core.IOption) BuildException(org.eclipse.cdt.managedbuilder.core.BuildException) ITool(org.eclipse.cdt.managedbuilder.core.ITool)

Example 15 with ITool

use of org.eclipse.cdt.managedbuilder.core.ITool in project linuxtools by eclipse.

the class CProjectBuildHelpers method helperGetGccCompilerToolBySuperClass.

/**
 * <h1>Get the tool that has the given id at the top of its superclass chain.</h1>
 *
 * @param superClassId a string representing the expected top-most superclass id of the compiler tool.
 * @param activeConf The current active configuration of the project, from which we should be able to find the ITool.
 * @return the 'ITool' instance.
 */
private static ITool helperGetGccCompilerToolBySuperClass(String superClassId, IConfiguration activeConf) {
    ITool[] tools = activeConf.getTools();
    ITool gccCompileriTool = null;
    for (ITool iTool : tools) {
        ITool tool = iTool;
        while (tool.getSuperClass() != null) {
            tool = tool.getSuperClass();
        }
        if (tool.getId().equals(superClassId)) {
            gccCompileriTool = iTool;
            break;
        }
    }
    return gccCompileriTool;
}
Also used : ITool(org.eclipse.cdt.managedbuilder.core.ITool)

Aggregations

ITool (org.eclipse.cdt.managedbuilder.core.ITool)24 IConfiguration (org.eclipse.cdt.managedbuilder.core.IConfiguration)11 BuildException (org.eclipse.cdt.managedbuilder.core.BuildException)8 IOption (org.eclipse.cdt.managedbuilder.core.IOption)8 ArrayList (java.util.ArrayList)7 IOutputType (org.eclipse.cdt.managedbuilder.core.IOutputType)5 IToolChain (org.eclipse.cdt.managedbuilder.core.IToolChain)5 CoreException (org.eclipse.core.runtime.CoreException)5 IPath (org.eclipse.core.runtime.IPath)5 IFolderInfo (org.eclipse.cdt.managedbuilder.core.IFolderInfo)4 IManagedDependencyGeneratorType (org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyGeneratorType)4 IInputType (org.eclipse.cdt.managedbuilder.core.IInputType)3 IManagedDependencyGenerator2 (org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyGenerator2)3 IResource (org.eclipse.core.resources.IResource)3 Path (org.eclipse.core.runtime.Path)3 List (java.util.List)2 IFileInfo (org.eclipse.cdt.managedbuilder.core.IFileInfo)2 IManagedCommandLineGenerator (org.eclipse.cdt.managedbuilder.core.IManagedCommandLineGenerator)2 IManagedCommandLineInfo (org.eclipse.cdt.managedbuilder.core.IManagedCommandLineInfo)2 BuildConfigurationData (org.eclipse.cdt.managedbuilder.internal.dataprovider.BuildConfigurationData)2