Search in sources :

Example 6 with IToolChain

use of org.eclipse.cdt.managedbuilder.core.IToolChain 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;
}
Also used : ToolInformationData(net.sourceforge.usbdm.constants.ToolInformationData) ICProject(org.eclipse.cdt.core.model.ICProject) IToolChain(org.eclipse.cdt.managedbuilder.core.IToolChain) IOption(org.eclipse.cdt.managedbuilder.core.IOption) IConfiguration(org.eclipse.cdt.managedbuilder.core.IConfiguration) CoreException(org.eclipse.core.runtime.CoreException)

Example 7 with IToolChain

use of org.eclipse.cdt.managedbuilder.core.IToolChain in project m2e-nar by maven-nar.

the class CProjectConfigurator method getToolChain.

/**
 * Reorders selected configurations in "physical" order. Although toolchains
 * are displayed in alphabetical order in Wizard, it's required to create
 * corresponding configurations in the same order as they are listed in xml
 * file, inside of single project type.
 *
 * @param its
 *            - items in initial order.
 * @return
 * @return - items in "physical" order.
 */
/*
	 * public static List<IConfiguration> reorder(List<IConfiguration> cfgs) {
	 * List<IConfiguration> ls = new ArrayList<IConfiguration>(cfgs.size());
	 * IConfiguration[] its = cfgs.toArray(new IConfiguration[cfgs.size()]);
	 * boolean found = true; while (found) { found = false; for (int i=0;
	 * i<its.length; i++) { if (its[i] == null) continue; found = true;
	 * IProjectType pt = its[i].getProjectType(); if (pt == null) {
	 * ls.add(its[i]); its[i] = null; continue; } IConfiguration[] cfs =
	 * pt.getConfigurations(); for (int j=0; j<cfs.length; j++) { for (int k=0;
	 * k<its.length; k++) { if (its[k] == null) continue; if
	 * (cfs[j].equals(its[k].getTcCfg())) { ls.add(its[k]); its[k] = null; } } }
	 * } } return ls.toArray(new CfgHolder[ls.size()]); }
	 */
private IToolChain getToolChain(final String toolChain, final String artefactType) throws CoreException {
    // Find the tool chains supported on our system for the selected
    // artefact type
    IToolChain[] tcs = ManagedBuildManager.getExtensionsToolChains(ManagedBuildManager.BUILD_ARTEFACT_TYPE_PROPERTY_ID, artefactType, true);
    // Find the tool chain
    IToolChain tc = null;
    for (IToolChain tc2 : tcs) {
        if (isValid(tc2) && toolChain.equals(tc2.getUniqueRealName())) {
            tc = tc2;
            break;
        }
    }
    if (tc == null) {
        throw new CoreException(new Status(IStatus.ERROR, MavenNarPlugin.PLUGIN_ID, "Could not find valid tool chain \"" + toolChain + "\""));
    }
    return tc;
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) CoreException(org.eclipse.core.runtime.CoreException) IToolChain(org.eclipse.cdt.managedbuilder.core.IToolChain)

Example 8 with IToolChain

use of org.eclipse.cdt.managedbuilder.core.IToolChain in project m2e-nar by maven-nar.

the class CProjectConfigurator method configure.

@Override
public void configure(ProjectConfigurationRequest request, IProgressMonitor monitor) throws CoreException {
    final ConfiguratorContext context = new ConfiguratorContext(maven, projectManager);
    IProject project = request.getProject();
    monitor.setTaskName(Messages.CProjectConfigurator_task_name + project.getName());
    logger.info("configure");
    ICProjectDescriptionManager mngr = CoreModel.getDefault().getProjectDescriptionManager();
    // Set the first created configuration as active.
    boolean setActive = true;
    final IMavenProjectFacade facade = request.getMavenProjectFacade();
    List<NarExecution> narExecutions = MavenUtils.buildCompileNarExecutions(context, facade, monitor);
    narExecutions.addAll(MavenUtils.buildTestCompileNarExecutions(context, facade, monitor));
    for (NarExecution narSettings : narExecutions) {
        if (!narSettings.isSkip()) {
            final String os = narSettings.getOS();
            final String linkerName = narSettings.getLinkerName();
            final AbstractSettingsSynchroniser synchro = SynchroniserFactory.getSettingsSynchroniser(os, linkerName);
            final String toolchain = synchro.getToolchain();
            for (NarBuildArtifact artifactSettings : narSettings.getArtifactSettings()) {
                final String configName = artifactSettings.getConfigName();
                final String cdtArtefactType = CdtUtils.convertArtefactType(artifactSettings.getType());
                IToolChain tc = getToolChain(toolchain, cdtArtefactType);
                ICProjectDescription desc = getCdtProject(project, tc, cdtArtefactType, monitor);
                ICConfigurationDescription cfg = getCdtMavenConfig(project, desc, tc, cdtArtefactType, configName, setActive, monitor);
                setActive = false;
                synchro.fullSync(cfg, artifactSettings);
                mngr.setProjectDescription(project, desc);
            }
        }
    }
    AbstractProjectConfigurator jConfig = LifecycleMappingFactory.createProjectConfigurator(JAVA_CONFIGURATOR_ID);
    jConfig.configure(request, monitor);
    // ensure CDT builder is after the Maven one
    boolean changed = false;
    IProjectDescription description = project.getDescription();
    ICommand cdtBuilder = null;
    ICommand mavenBuilder = null;
    ArrayList<ICommand> newSpec = new ArrayList<ICommand>();
    for (ICommand command : description.getBuildSpec()) {
        if (ManagedCProjectNature.getBuilderID().equals(command.getBuilderName()) && mavenBuilder == null) {
            cdtBuilder = command;
        } else {
            newSpec.add(command);
        }
        if (IMavenConstants.BUILDER_ID.equals(command.getBuilderName())) {
            mavenBuilder = command;
            if (cdtBuilder != null) {
                newSpec.add(cdtBuilder);
                changed = true;
            }
        }
    }
    if (changed) {
        description.setBuildSpec(newSpec.toArray(new ICommand[newSpec.size()]));
        project.setDescription(description, monitor);
    }
}
Also used : ICProjectDescription(org.eclipse.cdt.core.settings.model.ICProjectDescription) IToolChain(org.eclipse.cdt.managedbuilder.core.IToolChain) ArrayList(java.util.ArrayList) ICProjectDescriptionManager(org.eclipse.cdt.core.settings.model.ICProjectDescriptionManager) IProject(org.eclipse.core.resources.IProject) NarBuildArtifact(com.github.sdedwards.m2e_nar.internal.model.NarBuildArtifact) ICommand(org.eclipse.core.resources.ICommand) IProjectDescription(org.eclipse.core.resources.IProjectDescription) AbstractSettingsSynchroniser(com.github.sdedwards.m2e_nar.internal.cdt.AbstractSettingsSynchroniser) AbstractProjectConfigurator(org.eclipse.m2e.core.project.configurator.AbstractProjectConfigurator) ICConfigurationDescription(org.eclipse.cdt.core.settings.model.ICConfigurationDescription) IMavenProjectFacade(org.eclipse.m2e.core.project.IMavenProjectFacade) NarExecution(com.github.sdedwards.m2e_nar.internal.model.NarExecution)

Example 9 with IToolChain

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

the class UsbdmGCCSpecsRunSIProvider method getToolPrefix.

/**
 * @param project       The project to look in for options
 * @return              The prefix for the build tools
 */
private String getToolPrefix(IProject project) {
    IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(project);
    if (info == null) {
        return "";
    }
    IConfiguration cfg = info.getDefaultConfiguration();
    // System.err.println("UsbdmGCCSpecsRunSIProvider.initialize() Found IConfiguration = " + cfg.getName());
    IToolChain toolChain = cfg.getToolChain();
    // System.err.println("UsbdmGCCSpecsRunSIProvider.initialize() Found toolChain = " + toolChain.getName());
    // Find selected build tool (either ARM or Coldfire)
    IOption buildToolOption = toolChain.getOptionBySuperClassId(UsbdmConstants.ARM_BUILDTOOLS_OPTIONS);
    if (buildToolOption == null) {
        buildToolOption = toolChain.getOptionBySuperClassId(UsbdmConstants.COLDFIRE_BUILDTOOLS_OPTIONS);
    }
    if (buildToolOption == null) {
        return "";
    }
    // Get build path variable
    ToolInformationData toolData = ToolInformationData.getToolInformationTable().get(buildToolOption.getValue().toString());
    if (toolData == null) {
        return "";
    }
    String toolPrefixVariableId = toolData.getPrefixVariableName();
    if (toolPrefixVariableId == null) {
        return "";
    }
    UsbdmSharedSettings settings = UsbdmSharedSettings.getSharedSettings();
    String toolPrefix = null;
    if (settings != null) {
        toolPrefix = settings.get(toolPrefixVariableId);
    }
    if (toolPrefix == null) {
        toolPrefix = "Tool Prefix not set";
        return "";
    }
    // System.err.println("UsbdmGCCSpecsRunSIProvider.initialize() Found tool prefix = " + toolPrefix);
    return toolPrefix;
}
Also used : UsbdmSharedSettings(net.sourceforge.usbdm.constants.UsbdmSharedSettings) IManagedBuildInfo(org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo) ToolInformationData(net.sourceforge.usbdm.constants.ToolInformationData) IToolChain(org.eclipse.cdt.managedbuilder.core.IToolChain) IOption(org.eclipse.cdt.managedbuilder.core.IOption) IConfiguration(org.eclipse.cdt.managedbuilder.core.IConfiguration)

Example 10 with IToolChain

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

the class ProjectUtilities method createIncludeFolder.

public static void createIncludeFolder(IProject project, String targetPath, IProgressMonitor progressMonitor) throws CoreException, BuildException {
    // createSourceFolder(project, targetPath, progressMonitor);
    createFolder(project, targetPath, progressMonitor);
    IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(project);
    // Add to Include search paths
    IConfiguration[] configs = info.getManagedProject().getConfigurations();
    for (IConfiguration config : configs) {
        // Creates include folder path that is portable (e.g. rename project doesn't break paths)
        String path = "\"${ProjDirPath}/" + project.getFolder(targetPath).getProjectRelativePath().toOSString() + "\"";
        IToolChain toolChain = config.getToolChain();
        setIncludePathOptionForConfig(path, config, toolChain.getOptions(), toolChain);
        ITool[] tools = config.getTools();
        for (ITool tool : tools) {
            setIncludePathOptionForConfig(path, config, tool.getOptions(), tool);
        }
    }
    ManagedBuildManager.saveBuildInfo(project, true);
}
Also used : IManagedBuildInfo(org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo) IToolChain(org.eclipse.cdt.managedbuilder.core.IToolChain) IConfiguration(org.eclipse.cdt.managedbuilder.core.IConfiguration) ITool(org.eclipse.cdt.managedbuilder.core.ITool)

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