Search in sources :

Example 6 with IManagedBuildInfo

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

Example 7 with IManagedBuildInfo

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

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

the class CProjectConfigurator method getCdtProject.

private ICProjectDescription getCdtProject(IProject project, IToolChain tc, String artefactType, IProgressMonitor monitor) throws CoreException {
    try {
        ICProjectDescriptionManager mngr = CoreModel.getDefault().getProjectDescriptionManager();
        if (!project.hasNature(CCProjectNature.CC_NATURE_ID)) {
            MavenNarPlugin.getDefault().log("Configuring project with " + tc.getUniqueRealName() + " tool chain");
            // Add the C++ Nature
            CCorePlugin.getDefault().convertProjectToNewCC(project, ManagedBuildManager.CFG_DATA_PROVIDER_ID, monitor);
            ICProjectDescription des = mngr.createProjectDescription(project, false, false);
            IManagedBuildInfo info = ManagedBuildManager.createBuildInfo(project);
            List<IConfiguration> cfgs = getCfgs(tc, artefactType);
            if (cfgs.isEmpty()) {
                throw new CoreException(new Status(IStatus.ERROR, MavenNarPlugin.PLUGIN_ID, "Cannot find any configurations"));
            }
            IConfiguration cf = cfgs.get(0);
            IManagedProject mProj = ManagedBuildManager.createManagedProject(project, cf.getProjectType());
            info.setManagedProject(mProj);
            return des;
        } else {
            ICProjectDescription des = mngr.getProjectDescription(project, true);
            return des;
        }
    } catch (BuildException e) {
        throw new CoreException(new Status(IStatus.ERROR, MavenNarPlugin.PLUGIN_ID, "Cannot create CDT managed project", e));
    }
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) IManagedProject(org.eclipse.cdt.managedbuilder.core.IManagedProject) ICProjectDescription(org.eclipse.cdt.core.settings.model.ICProjectDescription) IManagedBuildInfo(org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo) CoreException(org.eclipse.core.runtime.CoreException) ICProjectDescriptionManager(org.eclipse.cdt.core.settings.model.ICProjectDescriptionManager) BuildException(org.eclipse.cdt.managedbuilder.core.BuildException) IConfiguration(org.eclipse.cdt.managedbuilder.core.IConfiguration)

Aggregations

IManagedBuildInfo (org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo)8 IConfiguration (org.eclipse.cdt.managedbuilder.core.IConfiguration)6 IToolChain (org.eclipse.cdt.managedbuilder.core.IToolChain)3 CoreException (org.eclipse.core.runtime.CoreException)3 ToolInformationData (net.sourceforge.usbdm.constants.ToolInformationData)2 UsbdmSharedSettings (net.sourceforge.usbdm.constants.UsbdmSharedSettings)2 ICProjectDescription (org.eclipse.cdt.core.settings.model.ICProjectDescription)2 BuildException (org.eclipse.cdt.managedbuilder.core.BuildException)2 IOption (org.eclipse.cdt.managedbuilder.core.IOption)2 ITool (org.eclipse.cdt.managedbuilder.core.ITool)2 IPath (org.eclipse.core.runtime.IPath)2 IStatus (org.eclipse.core.runtime.IStatus)2 Status (org.eclipse.core.runtime.Status)2 File (java.io.File)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Pattern (java.util.regex.Pattern)1 IContributedEnvironment (org.eclipse.cdt.core.envvar.IContributedEnvironment)1 IEnvironmentVariable (org.eclipse.cdt.core.envvar.IEnvironmentVariable)1