Search in sources :

Example 1 with IToolChain

use of org.eclipse.cdt.managedbuilder.core.IToolChain in project arduino-eclipse-plugin by Sloeber.

the class ShouldHaveBeenInCDT method setCProjectDescription.

/*
	 * Copied from wizard STDWizardHandler package package
	 * org.eclipse.cdt.managedbuilder.ui.wizards;; This method creates the
	 * .cProject file in your project.
	 *
	 * BK: modified this and made it work for multiple configs.
	 */
/**
 * This method creates the .cProject file in your project. it is intended to
 * be used with newly created projects. Using this method with project that
 * have existed for some time is unknown
 *
 * @param project
 *            The newly created project that needs a .cproject file.
 * @param alCfgs
 *            An array-list of configuration descriptors (names, toolchain
 *            IDs) to be used with this project
 * @param isManagedBuild
 *            When true the project is managed build. Else the project is
 *            not (read you have to maintain the makefiles yourself)
 * @param monitor
 *            The monitor to follow the process
 * @throws CoreException
 */
public static ICProjectDescription setCProjectDescription(IProject project, ArrayList<ConfigurationDescriptor> alCfgs, boolean isManagedBuild, IProgressMonitor monitor) throws CoreException {
    ICProjectDescriptionManager mngr = CoreModel.getDefault().getProjectDescriptionManager();
    ICProjectDescription des = mngr.createProjectDescription(project, false, true);
    ManagedBuildInfo info = ManagedBuildManager.createBuildInfo(project);
    ManagedProject mProj = new ManagedProject(des);
    info.setManagedProject(mProj);
    monitor.worked(20);
    // Iterate across the configurations
    for (ConfigurationDescriptor curConfDesc : alCfgs) {
        IToolChain tcs = ManagedBuildManager.getExtensionToolChain(curConfDesc.ToolchainID);
        Configuration cfg = new Configuration(mProj, (ToolChain) tcs, ManagedBuildManager.calculateChildId(curConfDesc.ToolchainID, null), curConfDesc.configName);
        IBuilder bld = cfg.getEditableBuilder();
        if (bld != null) {
            bld.setManagedBuildOn(isManagedBuild);
            // $NON-NLS-1$
            cfg.setArtifactName("${ProjName}");
        } else {
            // $NON-NLS-1$
            System.out.println("Messages.StdProjectTypeHandler_3");
        }
        CConfigurationData data = cfg.getConfigurationData();
        ICConfigurationDescription cfgDes = des.createConfiguration(ManagedBuildManager.CFG_DATA_PROVIDER_ID, data);
        setDefaultLanguageSettingsProviders(project, curConfDesc, cfg, cfgDes);
    }
    monitor.worked(50);
    return des;
}
Also used : IBuilder(org.eclipse.cdt.managedbuilder.core.IBuilder) ICProjectDescription(org.eclipse.cdt.core.settings.model.ICProjectDescription) IConfiguration(org.eclipse.cdt.managedbuilder.core.IConfiguration) Configuration(org.eclipse.cdt.managedbuilder.internal.core.Configuration) ManagedBuildInfo(org.eclipse.cdt.managedbuilder.internal.core.ManagedBuildInfo) ManagedProject(org.eclipse.cdt.managedbuilder.internal.core.ManagedProject) IToolChain(org.eclipse.cdt.managedbuilder.core.IToolChain) ICProjectDescriptionManager(org.eclipse.cdt.core.settings.model.ICProjectDescriptionManager) CConfigurationData(org.eclipse.cdt.core.settings.model.extension.CConfigurationData) ICConfigurationDescription(org.eclipse.cdt.core.settings.model.ICConfigurationDescription) ConfigurationDescriptor(io.sloeber.core.api.ConfigurationDescriptor)

Example 2 with IToolChain

use of org.eclipse.cdt.managedbuilder.core.IToolChain 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 3 with IToolChain

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

Example 4 with IToolChain

use of org.eclipse.cdt.managedbuilder.core.IToolChain 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 5 with IToolChain

use of org.eclipse.cdt.managedbuilder.core.IToolChain 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)

Aggregations

IToolChain (org.eclipse.cdt.managedbuilder.core.IToolChain)15 IConfiguration (org.eclipse.cdt.managedbuilder.core.IConfiguration)10 IOption (org.eclipse.cdt.managedbuilder.core.IOption)10 ToolInformationData (net.sourceforge.usbdm.constants.ToolInformationData)5 ITool (org.eclipse.cdt.managedbuilder.core.ITool)5 UsbdmSharedSettings (net.sourceforge.usbdm.constants.UsbdmSharedSettings)4 IFolderInfo (org.eclipse.cdt.managedbuilder.core.IFolderInfo)3 IManagedBuildInfo (org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo)3 ArrayList (java.util.ArrayList)2 ICConfigurationDescription (org.eclipse.cdt.core.settings.model.ICConfigurationDescription)2 ICProjectDescription (org.eclipse.cdt.core.settings.model.ICProjectDescription)2 ICProjectDescriptionManager (org.eclipse.cdt.core.settings.model.ICProjectDescriptionManager)2 BuildException (org.eclipse.cdt.managedbuilder.core.BuildException)2 CoreException (org.eclipse.core.runtime.CoreException)2 AbstractSettingsSynchroniser (com.github.sdedwards.m2e_nar.internal.cdt.AbstractSettingsSynchroniser)1 NarBuildArtifact (com.github.sdedwards.m2e_nar.internal.model.NarBuildArtifact)1 NarExecution (com.github.sdedwards.m2e_nar.internal.model.NarExecution)1 ConfigurationDescriptor (io.sloeber.core.api.ConfigurationDescriptor)1 ICProject (org.eclipse.cdt.core.model.ICProject)1 CConfigurationData (org.eclipse.cdt.core.settings.model.extension.CConfigurationData)1