Search in sources :

Example 1 with ManagedBuildInfo

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

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

the class CDTProjectManager method createUSBDMProject.

/**
 * Create USBDM CDT project
 *
 * @param paramMap      Parameters for project (from Wizard dialogue)
 * @param monitor       Progress monitor
 *
 * @return  Created project
 *
 * @throws Exception
 */
public IProject createUSBDMProject(Map<String, String> paramMap, IProgressMonitor progressMonitor) throws Exception {
    SubMonitor monitor = SubMonitor.convert(progressMonitor);
    // Create model project and accompanied descriptions
    IProject project;
    try {
        monitor.beginTask("Create configuration", 100);
        String projectName = MacroSubstitute.substitute(paramMap.get(UsbdmConstants.PROJECT_NAME_KEY), paramMap);
        String directoryPath = MacroSubstitute.substitute(paramMap.get(UsbdmConstants.PROJECT_HOME_PATH_KEY), paramMap);
        String projectType = MacroSubstitute.substitute(paramMap.get(UsbdmConstants.PROJECT_OUTPUT_TYPE_KEY), paramMap);
        InterfaceType interfaceType = InterfaceType.valueOf(paramMap.get(UsbdmConstants.INTERFACE_TYPE_KEY));
        boolean hasCCNature = Boolean.valueOf(paramMap.get(UsbdmConstants.HAS_CC_NATURE_KEY));
        String artifactName = MacroSubstitute.substitute(paramMap.get(UsbdmConstants.PROJECT_ARTIFACT_KEY), paramMap);
        if ((artifactName == null) || (artifactName.length() == 0)) {
            artifactName = "${ProjName}";
        }
        project = createProject(projectName, directoryPath, hasCCNature, monitor.newChild(70));
        CoreModel coreModel = CoreModel.getDefault();
        // Create project description
        ICProjectDescription projectDescription = coreModel.createProjectDescription(project, false);
        Assert.isNotNull(projectDescription, "createProjectDescription returned null");
        // Create one configuration description
        ManagedBuildInfo info = ManagedBuildManager.createBuildInfo(project);
        IProjectType type = ManagedBuildManager.getProjectType(projectType);
        Assert.isNotNull(type, "project type not found");
        ManagedProject mProj = new ManagedProject(project, type);
        info.setManagedProject(mProj);
        IConfiguration[] cfgs = type.getConfigurations();
        Assert.isNotNull(cfgs, "configurations not found");
        Assert.isTrue(cfgs.length > 0, "no configurations found in the project type");
        String configurationName = null;
        String os = System.getProperty("os.name");
        switch(interfaceType) {
            case T_ARM:
                configurationName = ARM_CONFIGURATION_ID;
                break;
            case T_CFV1:
            case T_CFVX:
                configurationName = COLDFIRE_CONFIGURATION_ID;
                break;
        }
        for (IConfiguration configuration : cfgs) {
            String configId = configuration.getId();
            if (!configId.startsWith(configurationName)) {
                continue;
            }
            String id = ManagedBuildManager.calculateChildId(configuration.getId(), null);
            Configuration config = new Configuration(mProj, (Configuration) configuration, id, false, true, false);
            config.setArtifactName(artifactName);
            CConfigurationData data = config.getConfigurationData();
            Assert.isNotNull(data, "data is null for created configuration");
            projectDescription.createConfiguration(ManagedBuildManager.CFG_DATA_PROVIDER_ID, data);
        }
        Assert.isTrue(projectDescription.getConfigurations().length > 0, "No Configurations!");
        coreModel.setProjectDescription(project, projectDescription);
        // }
        if (!(hasCCNature && !project.hasNature(CCProjectNature.CC_NATURE_ID))) {
            CCProjectNature.addCCNature(project, monitor.newChild(5));
        }
        CoreModel.getDefault().updateProjectDescriptions(new IProject[] { project }, monitor);
        if (!(hasCCNature && !project.hasNature(CCProjectNature.CC_NATURE_ID))) {
            CCProjectNature.addCCNature(project, monitor.newChild(5));
        }
    } finally {
        monitor.done();
    }
    return project;
}
Also used : ICProjectDescription(org.eclipse.cdt.core.settings.model.ICProjectDescription) IConfiguration(org.eclipse.cdt.managedbuilder.core.IConfiguration) Configuration(org.eclipse.cdt.managedbuilder.internal.core.Configuration) IProjectType(org.eclipse.cdt.managedbuilder.core.IProjectType) SubMonitor(org.eclipse.core.runtime.SubMonitor) CConfigurationData(org.eclipse.cdt.core.settings.model.extension.CConfigurationData) IProject(org.eclipse.core.resources.IProject) InterfaceType(net.sourceforge.usbdm.constants.UsbdmSharedConstants.InterfaceType) CoreModel(org.eclipse.cdt.core.model.CoreModel) ManagedBuildInfo(org.eclipse.cdt.managedbuilder.internal.core.ManagedBuildInfo) ManagedProject(org.eclipse.cdt.managedbuilder.internal.core.ManagedProject) IConfiguration(org.eclipse.cdt.managedbuilder.core.IConfiguration)

Aggregations

ICProjectDescription (org.eclipse.cdt.core.settings.model.ICProjectDescription)2 CConfigurationData (org.eclipse.cdt.core.settings.model.extension.CConfigurationData)2 IConfiguration (org.eclipse.cdt.managedbuilder.core.IConfiguration)2 Configuration (org.eclipse.cdt.managedbuilder.internal.core.Configuration)2 ManagedBuildInfo (org.eclipse.cdt.managedbuilder.internal.core.ManagedBuildInfo)2 ManagedProject (org.eclipse.cdt.managedbuilder.internal.core.ManagedProject)2 ConfigurationDescriptor (io.sloeber.core.api.ConfigurationDescriptor)1 InterfaceType (net.sourceforge.usbdm.constants.UsbdmSharedConstants.InterfaceType)1 CoreModel (org.eclipse.cdt.core.model.CoreModel)1 ICConfigurationDescription (org.eclipse.cdt.core.settings.model.ICConfigurationDescription)1 ICProjectDescriptionManager (org.eclipse.cdt.core.settings.model.ICProjectDescriptionManager)1 IBuilder (org.eclipse.cdt.managedbuilder.core.IBuilder)1 IProjectType (org.eclipse.cdt.managedbuilder.core.IProjectType)1 IToolChain (org.eclipse.cdt.managedbuilder.core.IToolChain)1 IProject (org.eclipse.core.resources.IProject)1 SubMonitor (org.eclipse.core.runtime.SubMonitor)1