Search in sources :

Example 11 with BoardDescriptor

use of io.sloeber.core.api.BoardDescriptor 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
 */
@SuppressWarnings("static-method")
@Test
public void issue555() {
    if (MySystem.getTeensyPlatform().isEmpty()) {
        // do not fail as this will always fail on travis
        return;
    }
    Map<String, String> unoOptions = new HashMap<>();
    BoardDescriptor unoBoardid = PackageManager.getBoardDescriptor("package_index.json", "arduino", "Arduino AVR Boards", "uno", unoOptions);
    Map<String, String> teensyOptions = new HashMap<>();
    teensyOptions.put("usb", "serial");
    teensyOptions.put("speed", "96");
    teensyOptions.put("keys", "en-us");
    BoardDescriptor teensyBoardid = PackageManager.getBoardDescriptor("local", MySystem.getTeensyBoard_txt(), "", "teensy31", teensyOptions);
    IProject theTestProject = null;
    CodeDescriptor codeDescriptor = CodeDescriptor.createDefaultIno();
    String projectName = "issue555";
    NullProgressMonitor monitor = new NullProgressMonitor();
    try {
        theTestProject = unoBoardid.createProject(projectName, null, ConfigurationDescriptor.getDefaultDescriptors(), codeDescriptor, new CompileOptions(null), 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 teensy build errors");
        }
    } catch (CoreException e) {
        e.printStackTrace();
        fail("Failed to compile the project:" + unoBoardid.getBoardName() + " as uno exception");
    }
    teensyBoardid.configureProject(theTestProject, monitor);
    Shared.waitForAllJobsToFinish();
    try {
        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) CoreException(org.eclipse.core.runtime.CoreException) HashMap(java.util.HashMap) CompileOptions(io.sloeber.core.api.CompileOptions) BoardDescriptor(io.sloeber.core.api.BoardDescriptor) CodeDescriptor(io.sloeber.core.api.CodeDescriptor) IProject(org.eclipse.core.resources.IProject) CoreException(org.eclipse.core.runtime.CoreException) Test(org.junit.Test)

Example 12 with BoardDescriptor

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

the class CreateAndCompileExamplesTest method examples.

@SuppressWarnings("rawtypes")
@Parameters(name = "{index}: {0}")
public static Collection examples() {
    WaitForInstallerToFinish();
    MCUBoard[] myBoards = { Arduino.leonardo(), Arduino.uno(), Arduino.esplora(), Adafruit.feather(), Arduino.adafruitnCirquitPlayground(), ESP8266.nodeMCU(), Arduino.primo(), Arduino.getMega2560Board(), Arduino.gemma(), Arduino.zero(), Arduino.mkrfox1200(), Arduino.due() };
    LinkedList<Object[]> examples = new LinkedList<>();
    TreeMap<String, IPath> exampleFolders = LibraryManager.getAllLibraryExamples();
    for (Map.Entry<String, IPath> curexample : exampleFolders.entrySet()) {
        ArrayList<IPath> paths = new ArrayList<>();
        paths.add(new Path(curexample.getValue().toString()));
        CodeDescriptor codeDescriptor = CodeDescriptor.createExample(false, paths);
        String fqn = curexample.getKey();
        String libName = "";
        if (examples.size() == 82) {
            // use this for debugging based on the
            // project number
            // use this to put breakpoint
            int a = 0;
            a = a + 1;
        }
        try {
            libName = fqn.split(" ")[0].trim();
        } catch (Exception e) {
        // ignore error
        }
        Examples example = new Examples(fqn, libName, curexample.getValue());
        // with the current amount of examples only do one
        BoardDescriptor curBoard = Examples.pickBestBoard(example, myBoards).getBoardDescriptor();
        if (curBoard != null) {
            Object[] theData = new Object[] { fqn.trim(), curBoard, codeDescriptor };
            examples.add(theData);
        }
    }
    return examples;
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) IPath(org.eclipse.core.runtime.IPath) ArrayList(java.util.ArrayList) CodeDescriptor(io.sloeber.core.api.CodeDescriptor) LinkedList(java.util.LinkedList) CoreException(org.eclipse.core.runtime.CoreException) MCUBoard(io.sloeber.providers.MCUBoard) BoardDescriptor(io.sloeber.core.api.BoardDescriptor) Map(java.util.Map) TreeMap(java.util.TreeMap) Parameters(org.junit.runners.Parameterized.Parameters)

Example 13 with BoardDescriptor

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

the class RegressionTest method issue687.

/**
 * support void loop{};
 * @throws Exception
 */
@SuppressWarnings("static-method")
@Test
public void issue687() throws Exception {
    PackageManager.installLatestPlatform("package_index.json", "arduino", "Arduino AVR Boards");
    Map<String, String> unoOptions = new HashMap<>();
    BoardDescriptor unoBoardid = PackageManager.getBoardDescriptor("package_index.json", "arduino", "Arduino AVR Boards", "uno", unoOptions);
    IProject theTestProject = null;
    String projectName = "issue687";
    IPath templateFolder = Shared.getTemplateFolder(projectName);
    CodeDescriptor codeDescriptor = CodeDescriptor.createCustomTemplate(templateFolder);
    try {
        theTestProject = unoBoardid.createProject(projectName, null, ConfigurationDescriptor.getDefaultDescriptors(), codeDescriptor, new CompileOptions(null), new NullProgressMonitor());
        // for the indexer
        Shared.waitForAllJobsToFinish();
        theTestProject.build(IncrementalProjectBuilder.FULL_BUILD, new NullProgressMonitor());
        if (Shared.hasBuildErrors(theTestProject)) {
            fail("Failed to compile the project:" + projectName + " issue687 is not fixed");
        }
    } catch (Exception e) {
        e.printStackTrace();
        fail("Failed to create the project:" + projectName);
        return;
    }
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IPath(org.eclipse.core.runtime.IPath) HashMap(java.util.HashMap) CompileOptions(io.sloeber.core.api.CompileOptions) BoardDescriptor(io.sloeber.core.api.BoardDescriptor) CodeDescriptor(io.sloeber.core.api.CodeDescriptor) IProject(org.eclipse.core.resources.IProject) CoreException(org.eclipse.core.runtime.CoreException) Test(org.junit.Test)

Example 14 with BoardDescriptor

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

the class RegressionTest method is_extern_C_taken_into_account.

/**
 * If a .ino file is defining defines before including a include this should
 * be handled properly by the ino to cpp parser
 * @throws Exception
 */
@SuppressWarnings("static-method")
@Test
public void is_extern_C_taken_into_account() throws Exception {
    PackageManager.installLatestPlatform("package_index.json", "arduino", "Arduino AVR Boards");
    Map<String, String> unoOptions = new HashMap<>();
    BoardDescriptor unoBoardid = PackageManager.getBoardDescriptor("package_index.json", "arduino", "Arduino AVR Boards", "uno", unoOptions);
    IProject theTestProject = null;
    String projectName = "defines_and_includes";
    IPath templateFolder = Shared.getTemplateFolder(projectName);
    CodeDescriptor codeDescriptor = CodeDescriptor.createCustomTemplate(templateFolder);
    NullProgressMonitor monitor = new NullProgressMonitor();
    try {
        theTestProject = unoBoardid.createProject(projectName, null, ConfigurationDescriptor.getDefaultDescriptors(), codeDescriptor, new CompileOptions(null), monitor);
        // for the indexer
        Shared.waitForAllJobsToFinish();
        theTestProject.build(IncrementalProjectBuilder.FULL_BUILD, monitor);
        if (Shared.hasBuildErrors(theTestProject)) {
            fail("Failed to compile the project:" + projectName + " defines have not been taken into account properly.");
        }
    } catch (Exception e) {
        e.printStackTrace();
        fail("Failed to create the project:" + projectName);
        return;
    }
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IPath(org.eclipse.core.runtime.IPath) HashMap(java.util.HashMap) CompileOptions(io.sloeber.core.api.CompileOptions) BoardDescriptor(io.sloeber.core.api.BoardDescriptor) CodeDescriptor(io.sloeber.core.api.CodeDescriptor) IProject(org.eclipse.core.resources.IProject) CoreException(org.eclipse.core.runtime.CoreException) Test(org.junit.Test)

Example 15 with BoardDescriptor

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

the class ExplorerLabelDecorator method decorateText.

@Override
public String decorateText(String text, Object element) {
    IProject proj = (IProject) element;
    if (proj.isOpen()) {
        if (Sketch.isSketch(proj)) {
            ICProjectDescription prjDesc = CoreModel.getDefault().getProjectDescription(proj);
            if (prjDesc == null) {
                return new String();
            }
            ICConfigurationDescription configurationDescription = prjDesc.getActiveConfiguration();
            BoardDescriptor boardDescriptor = BoardDescriptor.makeBoardDescriptor(configurationDescription);
            String boardName = boardDescriptor.getBoardName();
            String portName = boardDescriptor.getUploadPort();
            if (portName.isEmpty()) {
                // $NON-NLS-1$
                portName = "no port";
            }
            if (boardName.isEmpty()) {
                // $NON-NLS-1$
                boardName = "no Board";
            }
            return text + ' ' + boardName + ' ' + ':' + portName;
        }
    }
    return null;
}
Also used : ICProjectDescription(org.eclipse.cdt.core.settings.model.ICProjectDescription) ICConfigurationDescription(org.eclipse.cdt.core.settings.model.ICConfigurationDescription) BoardDescriptor(io.sloeber.core.api.BoardDescriptor) IProject(org.eclipse.core.resources.IProject)

Aggregations

BoardDescriptor (io.sloeber.core.api.BoardDescriptor)16 CodeDescriptor (io.sloeber.core.api.CodeDescriptor)8 HashMap (java.util.HashMap)7 CoreException (org.eclipse.core.runtime.CoreException)7 IPath (org.eclipse.core.runtime.IPath)7 Test (org.junit.Test)7 CompileOptions (io.sloeber.core.api.CompileOptions)6 IProject (org.eclipse.core.resources.IProject)6 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)5 ICProjectDescription (org.eclipse.cdt.core.settings.model.ICProjectDescription)4 ArrayList (java.util.ArrayList)3 ICConfigurationDescription (org.eclipse.cdt.core.settings.model.ICConfigurationDescription)3 TreeMap (java.util.TreeMap)2 IStatus (org.eclipse.core.runtime.IStatus)2 Status (org.eclipse.core.runtime.Status)2 Parameters (org.junit.runners.Parameterized.Parameters)2 InternalBoardDescriptor (io.sloeber.core.InternalBoardDescriptor)1 MCUBoard (io.sloeber.providers.MCUBoard)1 File (java.io.File)1 IOException (java.io.IOException)1