Search in sources :

Example 16 with ICProjectDescription

use of org.eclipse.cdt.core.settings.model.ICProjectDescription in project arduino-eclipse-plugin by Sloeber.

the class SloeberProject method getTargetFile.

public IFile getTargetFile() {
    // I assume the extension is .hex as the Arduino Framework does not provide the
    // extension nor a key for the uploadable sketch (=build target)
    // as currently this method is only used for network upload via yun this is ok
    // nor now
    CCorePlugin cCorePlugin = CCorePlugin.getDefault();
    ICProjectDescription prjCDesc = cCorePlugin.getProjectDescription(myProject);
    String activeConfig = prjCDesc.getActiveConfiguration().getName();
    return myProject.getFolder(activeConfig).getFile(myProject.getName() + ".hex");
}
Also used : ICProjectDescription(org.eclipse.cdt.core.settings.model.ICProjectDescription) CCorePlugin(org.eclipse.cdt.core.CCorePlugin)

Example 17 with ICProjectDescription

use of org.eclipse.cdt.core.settings.model.ICProjectDescription in project arduino-eclipse-plugin by Sloeber.

the class SloeberProject method configure.

public void configure() {
    CCorePlugin cCorePlugin = CCorePlugin.getDefault();
    ICProjectDescription prjCDesc = cCorePlugin.getProjectDescription(myProject);
    configure(prjCDesc, false);
}
Also used : ICProjectDescription(org.eclipse.cdt.core.settings.model.ICProjectDescription) CCorePlugin(org.eclipse.cdt.core.CCorePlugin)

Example 18 with ICProjectDescription

use of org.eclipse.cdt.core.settings.model.ICProjectDescription in project arduino-eclipse-plugin by Sloeber.

the class SloeberProject method sloeberCfgChanged.

/**
 * Call this method when the sloeber.cfg file changed
 */
public void sloeberCfgChanged() {
    CCorePlugin cCorePlugin = CCorePlugin.getDefault();
    ICProjectDescription projDesc = cCorePlugin.getProjectDescription(myProject);
    ICConfigurationDescription activeConfig = projDesc.getActiveConfiguration();
    myIsInMemory = false;
    boolean projDescNeedsSaving = configure(projDesc, true);
    Helpers.deleteBuildFolder(myProject, activeConfig.getName());
    projDescNeedsSaving = projDescNeedsSaving || setActiveConfig(activeConfig);
    if (projDescNeedsSaving) {
        try {
            cCorePlugin.setProjectDescription(myProject, projDesc);
        } catch (CoreException e) {
            e.printStackTrace();
        }
    }
}
Also used : ICProjectDescription(org.eclipse.cdt.core.settings.model.ICProjectDescription) CCorePlugin(org.eclipse.cdt.core.CCorePlugin) CoreException(org.eclipse.core.runtime.CoreException) ICConfigurationDescription(org.eclipse.cdt.core.settings.model.ICConfigurationDescription)

Example 19 with ICProjectDescription

use of org.eclipse.cdt.core.settings.model.ICProjectDescription in project arduino-eclipse-plugin by Sloeber.

the class SloeberProject method setActiveConfigInRunnable.

/**
 * This method set the active configuration This means the core and library
 * folders of the project are updated. To avoid many update notifications this
 * is done in a runnable with AVOID_UPDATE
 *
 * @param confDesc
 *            a writable configuration setting to be made active
 *
 * @return true if the configuration setting has been changed and needs tioo be
 *         saved
 */
private boolean setActiveConfigInRunnable(ICConfigurationDescription confDesc) {
    class MyRunnable implements ICoreRunnable {

        public boolean projConfMustBeSaved = false;

        @Override
        public void run(IProgressMonitor internalMonitor) throws CoreException {
            projConfMustBeSaved = setActiveConfig(confDesc);
        }
    }
    final IWorkspace workspace = ResourcesPlugin.getWorkspace();
    IWorkspaceRoot root = workspace.getRoot();
    MyRunnable runnable = new MyRunnable();
    try {
        workspace.run(runnable, root, IWorkspace.AVOID_UPDATE, null);
    } catch (Exception e) {
        ICProjectDescription projDesc = confDesc.getProjectDescription();
        String confDescName = confDesc.getName();
        String projName = projDesc.getProject().getName();
        Common.log(new Status(IStatus.INFO, io.sloeber.core.Activator.getId(), "Setting config " + confDescName + " for project " + projName + " failed", // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
        e));
    }
    return runnable.projConfMustBeSaved;
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) ICProjectDescription(org.eclipse.cdt.core.settings.model.ICProjectDescription) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) IWorkspaceRoot(org.eclipse.core.resources.IWorkspaceRoot) ICoreRunnable(org.eclipse.core.runtime.ICoreRunnable) IWorkspace(org.eclipse.core.resources.IWorkspace) CoreException(org.eclipse.core.runtime.CoreException) IOException(java.io.IOException)

Example 20 with ICProjectDescription

use of org.eclipse.cdt.core.settings.model.ICProjectDescription in project arduino-eclipse-plugin by Sloeber.

the class CDT_EnvironmentVariableResolver method getConfigurationDescription.

/**
 * Find the active configuration of the project selected in the project manager
 *
 * @return The configuration description or null if not found
 */
private static ICConfigurationDescription getConfigurationDescription() {
    IProject project = getGUISelectedProject();
    if (project != null && project.exists() && project.isOpen()) {
        CCorePlugin cCorePlugin = CCorePlugin.getDefault();
        ICProjectDescription prjCDesc = cCorePlugin.getProjectDescription(project);
        return prjCDesc.getActiveConfiguration();
    }
    return null;
}
Also used : ICProjectDescription(org.eclipse.cdt.core.settings.model.ICProjectDescription) CCorePlugin(org.eclipse.cdt.core.CCorePlugin) IProject(org.eclipse.core.resources.IProject)

Aggregations

ICProjectDescription (org.eclipse.cdt.core.settings.model.ICProjectDescription)45 ICConfigurationDescription (org.eclipse.cdt.core.settings.model.ICConfigurationDescription)31 CoreException (org.eclipse.core.runtime.CoreException)17 IProject (org.eclipse.core.resources.IProject)13 Status (org.eclipse.core.runtime.Status)10 ICProjectDescriptionManager (org.eclipse.cdt.core.settings.model.ICProjectDescriptionManager)9 IPath (org.eclipse.core.runtime.IPath)9 IStatus (org.eclipse.core.runtime.IStatus)9 CCorePlugin (org.eclipse.cdt.core.CCorePlugin)8 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)8 IConfiguration (org.eclipse.cdt.managedbuilder.core.IConfiguration)7 IOException (java.io.IOException)5 BoardDescription (io.sloeber.core.api.BoardDescription)4 CodeDescription (io.sloeber.core.api.CodeDescription)4 CompileDescription (io.sloeber.core.api.CompileDescription)4 HashMap (java.util.HashMap)4 LinkedList (java.util.LinkedList)4 IWorkspace (org.eclipse.core.resources.IWorkspace)4 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)4 BoardDescriptor (io.sloeber.core.api.BoardDescriptor)3