Search in sources :

Example 1 with IBuilder

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

the class CProjectBuildHelpers method getProjectType.

/**
 * <h1>Finds out the type of the project as defined by {@link ProjectBuildType ProjectBuildType}.</h1>
 *
 * <p> A project can be of different types.<br>
 * Common types are:
 *  - Autotools<br>
 *  - Managed Make project<br>
 *  - Manual Makefiles<br></p>
 *
 * <p>
 * Some dialogues (initially in gCov and gProf) distinguish between these when displaying dialogues. This code is used
 * by these dialogues.
 * </p>
 *
 * <p>
 * The method was written with extensibility in mind. <br>
 * Other routines check for autotools/Managed make, and if those are not present, then it shows generic advice about
 * adding flags. MAKEFILE per-se isn't really checked. I.e this means that it should be safe to add additional
 * project types.
 * </p>
 *
 * @param project  project for which you want to get the type.
 * @return (enum)  projectType : <br>
 *         AUTO_TOOLS, <br>
 *         MANAGED_MAKEFILE, <br>
 *         OTHER <br>
 */
public static ProjectBuildType getProjectType(IProject project) {
    // Autotools has an 'Autotools' nature by which we can identify it.
    if (isAutoTools(project)) {
        return ProjectBuildType.AUTO_TOOLS;
    }
    IConfiguration defaultConfiguration = helperGetActiveConfiguration(project);
    IBuilder builder = defaultConfiguration.getBuilder();
    Boolean projIsManaged = builder.isManagedBuildOn();
    // MANAGED PROJECT
    if (projIsManaged) {
        return ProjectBuildType.MANAGED_MAKEFILE;
    } else {
        // E.g a manual makefile.
        return ProjectBuildType.OTHER;
    }
}
Also used : IBuilder(org.eclipse.cdt.managedbuilder.core.IBuilder) IConfiguration(org.eclipse.cdt.managedbuilder.core.IConfiguration)

Example 2 with IBuilder

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

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

the class ArduinoGnuMakefileGenerator method initialize.

@Override
public void initialize(int buildKind, IConfiguration cfg, IBuilder _builder, IProgressMonitor monitor1) {
    IBuilder builder1 = _builder;
    // Save the project so we can get path and member information
    this.project = cfg.getOwner().getProject();
    if (builder1 == null) {
        builder1 = cfg.getEditableBuilder();
    }
    try {
        this.projectResources = this.project.members();
    } catch (CoreException e) {
        this.projectResources = null;
    }
    // Save the monitor reference for reporting back to the user
    this.monitor = monitor1;
    // Get the build info for the project
    // this.info = info;
    // Get the name of the build target
    this.buildTargetName = cfg.getArtifactName();
    // Get its extension
    this.buildTargetExt = cfg.getArtifactExtension();
    try {
        // try to resolve the build macros in the target extension
        this.buildTargetExt = ManagedBuildManager.getBuildMacroProvider().resolveValueToMakefileFormat(this.buildTargetExt, "", " ", IBuildMacroProvider.CONTEXT_CONFIGURATION, builder1);
    } catch (BuildMacroException e) {
    /* JABA is not going to write this code */
    }
    try {
        // try to resolve the build macros in the target name
        String resolved = ManagedBuildManager.getBuildMacroProvider().resolveValueToMakefileFormat(this.buildTargetName, "", " ", IBuildMacroProvider.CONTEXT_CONFIGURATION, builder1);
        if (resolved != null) {
            resolved = resolved.trim();
            if (resolved.length() > 0)
                this.buildTargetName = resolved;
        }
    } catch (BuildMacroException e) {
    /* JABA is not going to write this code */
    }
    if (this.buildTargetExt == null) {
        this.buildTargetExt = new String();
    }
    // Cache the build tools
    this.config = cfg;
    this.builder = builder1;
    initToolInfos();
    // set the top build dir path
    this.topBuildDir = this.project.getFolder(cfg.getName()).getFullPath();
    this.srcEntries = this.config.getSourceEntries();
    if (this.srcEntries.length == 0) {
        this.srcEntries = new ICSourceEntry[] { new CSourceEntry(Path.EMPTY, null, ICSettingEntry.RESOLVED | ICSettingEntry.VALUE_WORKSPACE_PATH) };
    } else {
        ICConfigurationDescription cfgDes = ManagedBuildManager.getDescriptionForConfiguration(this.config);
        this.srcEntries = CDataUtil.resolveEntries(this.srcEntries, cfgDes);
    }
}
Also used : IBuilder(org.eclipse.cdt.managedbuilder.core.IBuilder) CoreException(org.eclipse.core.runtime.CoreException) BuildMacroException(org.eclipse.cdt.managedbuilder.macros.BuildMacroException) ICConfigurationDescription(org.eclipse.cdt.core.settings.model.ICConfigurationDescription) ICSourceEntry(org.eclipse.cdt.core.settings.model.ICSourceEntry) CSourceEntry(org.eclipse.cdt.core.settings.model.CSourceEntry)

Example 4 with IBuilder

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

the class CProjectConfigurator method createConfiguration.

private IConfiguration createConfiguration(IConfiguration cfg, IManagedProject proj, ICProjectDescription des) throws WriteAccessException, CoreException {
    String id = ManagedBuildManager.calculateChildId(cfg.getId(), null);
    // CProjectDescriptionManager.getInstance();
    Configuration config = new Configuration((ManagedProject) proj, (Configuration) cfg, id, false, true);
    CConfigurationData data = config.getConfigurationData();
    ICConfigurationDescription cfgDes = des.createConfiguration(ManagedBuildManager.CFG_DATA_PROVIDER_ID, data);
    config.setConfigurationDescription(cfgDes);
    config.exportArtifactInfo();
    // Force internal builder
    IBuilder internalBuilder = ManagedBuildManager.getInternalBuilder();
    config.changeBuilder(internalBuilder, internalBuilder.getId(), internalBuilder.getName());
    // IBuilder bld = config.getEditableBuilder();
    // if (bld != null) { bld.setManagedBuildOn(true); }
    config.setName(cfg.getName());
    config.setArtifactName(proj.getDefaultArtifactName());
    return config;
}
Also used : IBuilder(org.eclipse.cdt.managedbuilder.core.IBuilder) IConfiguration(org.eclipse.cdt.managedbuilder.core.IConfiguration) Configuration(org.eclipse.cdt.managedbuilder.internal.core.Configuration) CConfigurationData(org.eclipse.cdt.core.settings.model.extension.CConfigurationData) ICConfigurationDescription(org.eclipse.cdt.core.settings.model.ICConfigurationDescription)

Aggregations

IBuilder (org.eclipse.cdt.managedbuilder.core.IBuilder)4 ICConfigurationDescription (org.eclipse.cdt.core.settings.model.ICConfigurationDescription)3 IConfiguration (org.eclipse.cdt.managedbuilder.core.IConfiguration)3 CConfigurationData (org.eclipse.cdt.core.settings.model.extension.CConfigurationData)2 Configuration (org.eclipse.cdt.managedbuilder.internal.core.Configuration)2 ConfigurationDescriptor (io.sloeber.core.api.ConfigurationDescriptor)1 CSourceEntry (org.eclipse.cdt.core.settings.model.CSourceEntry)1 ICProjectDescription (org.eclipse.cdt.core.settings.model.ICProjectDescription)1 ICProjectDescriptionManager (org.eclipse.cdt.core.settings.model.ICProjectDescriptionManager)1 ICSourceEntry (org.eclipse.cdt.core.settings.model.ICSourceEntry)1 IToolChain (org.eclipse.cdt.managedbuilder.core.IToolChain)1 ManagedBuildInfo (org.eclipse.cdt.managedbuilder.internal.core.ManagedBuildInfo)1 ManagedProject (org.eclipse.cdt.managedbuilder.internal.core.ManagedProject)1 BuildMacroException (org.eclipse.cdt.managedbuilder.macros.BuildMacroException)1 CoreException (org.eclipse.core.runtime.CoreException)1