Search in sources :

Example 1 with SloeberProject

use of io.sloeber.core.api.SloeberProject in project arduino-eclipse-plugin by Sloeber.

the class Libraries method findAllHarwareLibraries.

/**
 * Searches all the hardware dependent libraries of a project. If this is a
 * board referencing a core then the libraries of the referenced core are added
 * as well
 *
 * @param project
 *            the project to find all hardware libraries for
 * @return all the library folder names. May contain empty values.
 */
private static Map<String, IPath> findAllHarwareLibraries(ICConfigurationDescription confDesc) {
    Map<String, IPath> ret = new HashMap<>();
    IProject project = confDesc.getProjectDescription().getProject();
    SloeberProject sProject = SloeberProject.getSloeberProject(project);
    BoardDescription boardDescriptor = sProject.getBoardDescription(confDesc.getName(), false);
    // first add the referenced
    IPath libPath = boardDescriptor.getReferencedCoreLibraryPath();
    if (libPath != null) {
        ret.putAll(findAllSubFolders(libPath));
    }
    // then add the referencing
    libPath = boardDescriptor.getReferencingLibraryPath();
    if (libPath != null) {
        ret.putAll(findAllSubFolders(libPath));
    }
    return ret;
}
Also used : BoardDescription(io.sloeber.core.api.BoardDescription) IPath(org.eclipse.core.runtime.IPath) HashMap(java.util.HashMap) SloeberProject(io.sloeber.core.api.SloeberProject) IProject(org.eclipse.core.resources.IProject)

Example 2 with SloeberProject

use of io.sloeber.core.api.SloeberProject in project arduino-eclipse-plugin by Sloeber.

the class RegressionTest method issue555.

/**
 * make sure when switching between a board with variant file and without the
 * build still succeeds
 */
@Test
public void issue555() {
    if (MySystem.getTeensyPlatform().isEmpty()) {
        // skip test due to no teensy install folder provided
        // do not fail as this will always fail on travis
        System.out.println("skipping the test because teensy is not installed.");
        return;
    }
    System.out.println("Teensy is installed at " + MySystem.getTeensyPlatform());
    BoardDescription unoBoardid = Arduino.uno().getBoardDescriptor();
    BoardDescription teensyBoardid = Teensy.Teensy3_1().getBoardDescriptor();
    IProject theTestProject = null;
    CodeDescription codeDescriptor = CodeDescription.createDefaultIno();
    String projectName = "issue555";
    NullProgressMonitor monitor = new NullProgressMonitor();
    try {
        theTestProject = SloeberProject.createArduinoProject(projectName, null, unoBoardid, codeDescriptor, new CompileDescription(), monitor);
        // for the indexer
        Shared.waitForAllJobsToFinish();
    } catch (Exception e) {
        e.printStackTrace();
        fail("Failed to create the project:" + projectName);
        return;
    }
    try {
        theTestProject.build(IncrementalProjectBuilder.FULL_BUILD, monitor);
        if (Shared.hasBuildErrors(theTestProject)) {
            fail("Failed to compile the project:" + projectName + " as uno  build errors");
        }
    } catch (CoreException e) {
        e.printStackTrace();
        fail("Failed to compile the project:" + unoBoardid.getBoardName() + " as uno exception");
    }
    SloeberProject arduinoProject = SloeberProject.getSloeberProject(theTestProject);
    ICProjectDescription cProjectDescription = CCorePlugin.getDefault().getProjectDescription(theTestProject);
    arduinoProject.setBoardDescription(cProjectDescription.getActiveConfiguration().getName(), teensyBoardid, true);
    Shared.waitForAllJobsToFinish();
    try {
        theTestProject.build(IncrementalProjectBuilder.FULL_BUILD, monitor);
        if (Shared.hasBuildErrors(theTestProject)) {
            Shared.waitForAllJobsToFinish();
            theTestProject.build(IncrementalProjectBuilder.FULL_BUILD, monitor);
            if (Shared.hasBuildErrors(theTestProject)) {
                fail("Failed to compile the project:" + projectName + " as teensy");
            }
        }
    } catch (CoreException e) {
        e.printStackTrace();
        fail("Failed to compile the project:" + unoBoardid.getBoardName() + " as teensy exception");
    }
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) ICProjectDescription(org.eclipse.cdt.core.settings.model.ICProjectDescription) BoardDescription(io.sloeber.core.api.BoardDescription) CodeDescription(io.sloeber.core.api.CodeDescription) CoreException(org.eclipse.core.runtime.CoreException) SloeberProject(io.sloeber.core.api.SloeberProject) CompileDescription(io.sloeber.core.api.CompileDescription) IProject(org.eclipse.core.resources.IProject) CoreException(org.eclipse.core.runtime.CoreException) Test(org.junit.Test)

Example 3 with SloeberProject

use of io.sloeber.core.api.SloeberProject in project arduino-eclipse-plugin by Sloeber.

the class UploadProjectHandler method run.

@Override
protected IStatus run(IProgressMonitor monitor) {
    boolean canUpload = true;
    IStatus retStatus = Status.OK_STATUS;
    if (MyPreferences.getBuildBeforeUploadOption()) {
        try {
            myBuildProject.build(IncrementalProjectBuilder.INCREMENTAL_BUILD, monitor);
            canUpload = isBuildSuccessFull(myBuildProject);
        } catch (Exception e) {
            return new Status(IStatus.WARNING, PLUGIN_ID, Messages.Build_Error_Before_Upload, e);
        }
        if (!canUpload) {
            Display.getDefault().syncExec(new Runnable() {

                @Override
                public void run() {
                    Shell theShell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
                    MessageBox dialog = new MessageBox(theShell, SWT.ICON_QUESTION | SWT.OK);
                    dialog.setText(Messages.arduino_upload_project_handler_build_failed);
                    dialog.setMessage(Messages.arduino_upload_project_handler_build_failed_so_no_upload);
                    dialog.open();
                }
            });
        }
    }
    if (canUpload) {
        SloeberProject sProject = SloeberProject.getSloeberProject(UploadJobHandler.this.myBuildProject);
        if (sProject != null) {
            if (myIsProgram) {
                retStatus = sProject.upLoadUsingProgrammer();
            } else {
                retStatus = sProject.upload();
            }
        }
        if (retStatus.isOK()) {
            if (MyPreferences.getSwitchToSerialMonitorAfterUpload()) {
                Display.getDefault().asyncExec(new Runnable() {

                    @Override
                    public void run() {
                        try {
                            PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView(// $NON-NLS-1$
                            "io.sloeber.ui.monitor.views.SerialMonitor");
                        } catch (PartInitException e) {
                            e.printStackTrace();
                        }
                    }
                });
            }
        }
    }
    return retStatus;
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) IStatus(org.eclipse.core.runtime.IStatus) Shell(org.eclipse.swt.widgets.Shell) SloeberProject(io.sloeber.core.api.SloeberProject) PartInitException(org.eclipse.ui.PartInitException) CoreException(org.eclipse.core.runtime.CoreException) PartInitException(org.eclipse.ui.PartInitException) ExecutionException(org.eclipse.core.commands.ExecutionException) MessageBox(org.eclipse.swt.widgets.MessageBox)

Example 4 with SloeberProject

use of io.sloeber.core.api.SloeberProject in project arduino-eclipse-plugin by Sloeber.

the class OpenSerialMonitorHandler method execute.

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    try {
        PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView(// $NON-NLS-1$
        "io.sloeber.ui.monitor.views.SerialMonitor");
        // find all projects
        IProject[] SelectedProjects = ProjectExplorerListener.getSelectedProjects();
        // on
        if ((SelectedProjects.length > 0) && (MyPreferences.getOpenSerialWithMonitor() == true)) {
            for (IProject curproject : SelectedProjects) {
                int baud = Sketch.getCodeBaudRate(curproject);
                if (baud > 0) {
                    SloeberProject sProject = SloeberProject.getSloeberProject(curproject);
                    if (sProject != null) {
                        ICConfigurationDescription activeConf = CoreModel.getDefault().getProjectDescription(curproject).getActiveConfiguration();
                        BoardDescription boardDescription = sProject.getBoardDescription(activeConf.getName(), false);
                        String comPort = boardDescription.getUploadPort();
                        if (!comPort.isEmpty()) {
                            io.sloeber.ui.monitor.SerialConnection.add(comPort, baud);
                        }
                    }
                }
            }
        }
    } catch (PartInitException e) {
        e.printStackTrace();
    }
    return null;
}
Also used : BoardDescription(io.sloeber.core.api.BoardDescription) SloeberProject(io.sloeber.core.api.SloeberProject) ICConfigurationDescription(org.eclipse.cdt.core.settings.model.ICConfigurationDescription) PartInitException(org.eclipse.ui.PartInitException) IProject(org.eclipse.core.resources.IProject)

Example 5 with SloeberProject

use of io.sloeber.core.api.SloeberProject in project arduino-eclipse-plugin by Sloeber.

the class IndexerController method postponeIndexerSetup.

@Override
public boolean postponeIndexerSetup(ICProject cProject) {
    IProject project = cProject.getProject();
    SloeberProject sloeberProject = SloeberProject.getSloeberProject(project);
    if (sloeberProject != null) {
        if (!sloeberProject.isInMemory()) {
            doNotIndexProjects.add(project);
        }
    }
    boolean ret = doNotIndexProjects.contains(project);
    if (ret) {
        // $NON-NLS-1$
        Common.log(new Status(Const.SLOEBER_STATUS_DEBUG, Activator.getId(), "pospone index " + project.getName()));
        indexingPosponedProjects.add(project);
    } else {
        Common.log(new Status(Const.SLOEBER_STATUS_DEBUG, Activator.getId(), // $NON-NLS-1$
        "do not pospone index " + project.getName()));
    }
    return ret;
}
Also used : Status(org.eclipse.core.runtime.Status) SloeberProject(io.sloeber.core.api.SloeberProject) IProject(org.eclipse.core.resources.IProject)

Aggregations

SloeberProject (io.sloeber.core.api.SloeberProject)12 IProject (org.eclipse.core.resources.IProject)8 BoardDescription (io.sloeber.core.api.BoardDescription)6 Status (org.eclipse.core.runtime.Status)5 ICProjectDescription (org.eclipse.cdt.core.settings.model.ICProjectDescription)4 CoreException (org.eclipse.core.runtime.CoreException)4 CodeDescription (io.sloeber.core.api.CodeDescription)3 CompileDescription (io.sloeber.core.api.CompileDescription)3 ICConfigurationDescription (org.eclipse.cdt.core.settings.model.ICConfigurationDescription)3 IStatus (org.eclipse.core.runtime.IStatus)3 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)3 Test (org.junit.Test)3 HashMap (java.util.HashMap)2 IBuildEnvironmentVariable (org.eclipse.cdt.managedbuilder.envvar.IBuildEnvironmentVariable)2 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)2 Job (org.eclipse.core.runtime.jobs.Job)2 PartInitException (org.eclipse.ui.PartInitException)2 OtherDescription (io.sloeber.core.api.OtherDescription)1 File (java.io.File)1 URL (java.net.URL)1