Search in sources :

Example 6 with CodeDescriptor

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

the class RegressionTest method are_defines_before_includes_taken_into_account.

/**
 * If a .ino file is including a include using extern C is this handled
 * properly by the ino to cpp parser
 * @throws Exception
 */
@SuppressWarnings("static-method")
@Test
public void are_defines_before_includes_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 = "externc";
    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 + " extern \"C\" has 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 7 with CodeDescriptor

use of io.sloeber.core.api.CodeDescriptor 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 8 with CodeDescriptor

use of io.sloeber.core.api.CodeDescriptor 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 9 with CodeDescriptor

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

the class CreateAndCompileJantjesBoardsTest method examples.

@SuppressWarnings("rawtypes")
@Parameters(name = "{index}: {0}")
public static Collection examples() {
    String[] packageUrlsToAdd = { "https://raw.githubusercontent.com/jantje/hardware/master/package_jantje_index.json" };
    PackageManager.addPackageURLs(new HashSet<>(Arrays.asList(packageUrlsToAdd)), true);
    PackageManager.installLatestPlatform(Jantje.getJsonFileName(), Jantje.getPackageName(), Jantje.getPlatformName());
    Shared.waitForAllJobsToFinish();
    LinkedList<Object[]> examples = new LinkedList<>();
    TreeMap<String, IPath> exampleFolders = LibraryManager.getAllArduinoIDEExamples();
    for (Map.Entry<String, IPath> curexample : exampleFolders.entrySet()) {
        String fqn = curexample.getKey().trim();
        IPath examplePath = curexample.getValue();
        Examples example = new Examples(fqn, null, examplePath);
        if (!skipExample(example)) {
            ArrayList<IPath> paths = new ArrayList<>();
            paths.add(examplePath);
            CodeDescriptor codeDescriptor = CodeDescriptor.createExample(false, paths);
            Object[] theData = new Object[] { "Example:" + fqn, codeDescriptor, example };
            examples.add(theData);
        }
    }
    return examples;
}
Also used : IPath(org.eclipse.core.runtime.IPath) ArrayList(java.util.ArrayList) CodeDescriptor(io.sloeber.core.api.CodeDescriptor) LinkedList(java.util.LinkedList) Map(java.util.Map) TreeMap(java.util.TreeMap) Parameters(org.junit.runners.Parameterized.Parameters)

Example 10 with CodeDescriptor

use of io.sloeber.core.api.CodeDescriptor 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)

Aggregations

CodeDescriptor (io.sloeber.core.api.CodeDescriptor)11 IPath (org.eclipse.core.runtime.IPath)9 BoardDescriptor (io.sloeber.core.api.BoardDescriptor)8 CoreException (org.eclipse.core.runtime.CoreException)7 CompileOptions (io.sloeber.core.api.CompileOptions)6 Test (org.junit.Test)6 ArrayList (java.util.ArrayList)5 HashMap (java.util.HashMap)5 IProject (org.eclipse.core.resources.IProject)5 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)5 LinkedList (java.util.LinkedList)4 Map (java.util.Map)4 TreeMap (java.util.TreeMap)4 Parameters (org.junit.runners.Parameterized.Parameters)4 MCUBoard (io.sloeber.providers.MCUBoard)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 ICProjectDescription (org.eclipse.cdt.core.settings.model.ICProjectDescription)1 IStatus (org.eclipse.core.runtime.IStatus)1 Path (org.eclipse.core.runtime.Path)1 Status (org.eclipse.core.runtime.Status)1