Search in sources :

Example 26 with ICProjectDescription

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

the class RegressionTest method rename_Configuration.

/**
 * Does Sloeber still compile after a configuration renamen
 *
 * @throws Exception
 */
@Test
public void rename_Configuration() throws Exception {
    BoardDescription unoBoardid = Arduino.uno().getBoardDescriptor();
    IProject theTestProject = null;
    String projectName = "rename_Configuration";
    CodeDescription codeDescriptor = CodeDescription.createDefaultIno();
    NullProgressMonitor monitor = new NullProgressMonitor();
    theTestProject = SloeberProject.createArduinoProject(projectName, null, unoBoardid, codeDescriptor, new CompileDescription(), new NullProgressMonitor());
    // for the indexer
    Shared.waitForAllJobsToFinish();
    theTestProject.build(IncrementalProjectBuilder.FULL_BUILD, monitor);
    if (Shared.hasBuildErrors(theTestProject)) {
        fail("Failed to compile the project before config rename");
    }
    CCorePlugin cCorePlugin = CCorePlugin.getDefault();
    ICProjectDescription prjCDesc = cCorePlugin.getProjectDescription(theTestProject);
    ICConfigurationDescription activeConfig = prjCDesc.getActiveConfiguration();
    activeConfig.setName("renamedConfig");
    cCorePlugin.setProjectDescription(theTestProject, prjCDesc);
    // for the indexer
    Shared.waitForAllJobsToFinish();
    theTestProject.build(IncrementalProjectBuilder.FULL_BUILD, monitor);
    if (Shared.hasBuildErrors(theTestProject)) {
        fail("Failed to compile the project after config rename");
    }
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) ICProjectDescription(org.eclipse.cdt.core.settings.model.ICProjectDescription) BoardDescription(io.sloeber.core.api.BoardDescription) CCorePlugin(org.eclipse.cdt.core.CCorePlugin) CodeDescription(io.sloeber.core.api.CodeDescription) CompileDescription(io.sloeber.core.api.CompileDescription) ICConfigurationDescription(org.eclipse.cdt.core.settings.model.ICConfigurationDescription) IProject(org.eclipse.core.resources.IProject) Test(org.junit.Test)

Example 27 with ICProjectDescription

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

the class Shared method hasBuildErrors.

public static boolean hasBuildErrors(IProject project) throws CoreException {
    IMarker[] markers = project.findMarkers(ICModelMarker.C_MODEL_PROBLEM_MARKER, true, IResource.DEPTH_INFINITE);
    for (IMarker marker : markers) {
        if (marker.getAttribute(IMarker.SEVERITY, IMarker.SEVERITY_INFO) == IMarker.SEVERITY_ERROR) {
            return true;
        }
    }
    CCorePlugin cCorePlugin = CCorePlugin.getDefault();
    ICProjectDescription prjCDesc = cCorePlugin.getProjectDescription(project);
    ICConfigurationDescription activeConfig = prjCDesc.getActiveConfiguration();
    IPath resultPath = project.getLocation().append(activeConfig.getName());
    String projName = project.getName();
    String[] validOutputss = { projName + ".elf", projName + ".bin", projName + ".hex", projName + ".exe", "application.axf" };
    for (String validOutput : validOutputss) {
        File validFile = resultPath.append(validOutput).toFile();
        if (validFile.exists()) {
            return false;
        }
    }
    return true;
}
Also used : ICProjectDescription(org.eclipse.cdt.core.settings.model.ICProjectDescription) CCorePlugin(org.eclipse.cdt.core.CCorePlugin) IPath(org.eclipse.core.runtime.IPath) IMarker(org.eclipse.core.resources.IMarker) ICConfigurationDescription(org.eclipse.cdt.core.settings.model.ICConfigurationDescription) File(java.io.File)

Example 28 with ICProjectDescription

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

the class Import_Libraries_Page method createSourceGroup.

@Override
protected void createSourceGroup(Composite parent) {
    if (this.myProject == null)
        return;
    Composite composite = new Composite(parent, SWT.NONE);
    GridLayout theGridLayout = new GridLayout();
    theGridLayout.numColumns = 1;
    composite.setLayout(theGridLayout);
    composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    composite.setFont(parent.getFont());
    GridData theGriddata;
    this.myLibrarySelector = new Tree(composite, SWT.CHECK | SWT.BORDER);
    theGriddata = new GridData(SWT.FILL, SWT.FILL, true, true);
    theGriddata.horizontalSpan = 1;
    this.myLibrarySelector.setLayoutData(theGriddata);
    // find the items to add to the list
    Map<String, IPath> allLibraries = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
    ICProjectDescription prjDesc = CoreModel.getDefault().getProjectDescription(myProject);
    if (prjDesc != null) {
        ICConfigurationDescription confDesc = prjDesc.getActiveConfiguration();
        allLibraries = Sketch.getAllAvailableLibraries(confDesc);
    }
    // Get the data in the tree
    Set<String> allLibrariesAlreadyUsed = Sketch.getAllImportedLibraries(this.myProject);
    this.myLibrarySelector.setRedraw(false);
    for (Entry<String, IPath> curlib : allLibraries.entrySet()) {
        TreeItem child = new TreeItem(this.myLibrarySelector, SWT.NONE);
        child.setText(curlib.getKey());
        if (allLibrariesAlreadyUsed.contains(curlib.getKey()))
            child.setChecked(true);
    }
    this.myLibrarySelector.setRedraw(true);
}
Also used : ICProjectDescription(org.eclipse.cdt.core.settings.model.ICProjectDescription) Composite(org.eclipse.swt.widgets.Composite) IPath(org.eclipse.core.runtime.IPath) TreeItem(org.eclipse.swt.widgets.TreeItem) TreeMap(java.util.TreeMap) GridLayout(org.eclipse.swt.layout.GridLayout) GridData(org.eclipse.swt.layout.GridData) Tree(org.eclipse.swt.widgets.Tree) ICConfigurationDescription(org.eclipse.cdt.core.settings.model.ICConfigurationDescription)

Example 29 with ICProjectDescription

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

the class SloeberCpropertyTab method performOK.

@Override
protected void performOK() {
    // Get the project description
    ICConfigurationDescription confDesc = getConfdesc();
    ICProjectDescription projDesc = confDesc.getProjectDescription();
    // Copy local info to sloeber project and clean local info up
    for (ICConfigurationDescription curConfDesc : projDesc.getConfigurations()) {
        updateSloeber(curConfDesc);
        clearSessionProperties(curConfDesc);
    }
    super.performOK();
}
Also used : ICProjectDescription(org.eclipse.cdt.core.settings.model.ICProjectDescription) ICConfigurationDescription(org.eclipse.cdt.core.settings.model.ICConfigurationDescription)

Example 30 with ICProjectDescription

use of org.eclipse.cdt.core.settings.model.ICProjectDescription in project linuxtools by eclipse.

the class CProjectHelper method addDefaultBinaryParser.

/**
 * Add the default binary parser if no binary parser configured.
 *
 * @param project
 * @throws CoreException
 */
private static boolean addDefaultBinaryParser(IProject project) throws CoreException {
    ICConfigExtensionReference[] binaryParsers = CCorePlugin.getDefault().getDefaultBinaryParserExtensions(project);
    if (binaryParsers == null || binaryParsers.length == 0) {
        ICProjectDescription desc = CCorePlugin.getDefault().getProjectDescription(project);
        if (desc == null) {
            return false;
        }
        desc.getDefaultSettingConfiguration().create(CCorePlugin.BINARY_PARSER_UNIQ_ID, CCorePlugin.DEFAULT_BINARY_PARSER_UNIQ_ID);
        CCorePlugin.getDefault().setProjectDescription(project, desc);
    }
    return true;
}
Also used : ICProjectDescription(org.eclipse.cdt.core.settings.model.ICProjectDescription) ICConfigExtensionReference(org.eclipse.cdt.core.settings.model.ICConfigExtensionReference)

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