Search in sources :

Example 6 with CompileDescription

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

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

the class RegressionTest method are_defines_before_includes_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
 */
@Test
public void are_defines_before_includes_taken_into_account() throws Exception {
    BoardDescription unoBoardid = Arduino.uno().getBoardDescriptor();
    IProject theTestProject = null;
    String projectName = "defines_and_includes";
    IPath templateFolder = Shared.getTemplateFolder(projectName);
    CodeDescription codeDescriptor = CodeDescription.createCustomTemplate(templateFolder);
    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:" + projectName + " defines have not been taken into account properly.");
    }
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) BoardDescription(io.sloeber.core.api.BoardDescription) IPath(org.eclipse.core.runtime.IPath) CodeDescription(io.sloeber.core.api.CodeDescription) CompileDescription(io.sloeber.core.api.CompileDescription) IProject(org.eclipse.core.resources.IProject) Test(org.junit.Test)

Example 8 with CompileDescription

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

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

the class Shared method BuildAndVerify.

/**
 * Convenience method to call BuildAndVerify with default project name and null
 * as compile options
 *
 * @param boardDescriptor
 * @param codeDescriptor
 * @param compileOptions
 *            can be null
 * @return true if build is successful otherwise false
 */
public static boolean BuildAndVerify(BoardDescription boardDescriptor, CodeDescription codeDescriptor, CompileDescription compileOptions, int globalBuildCounter) {
    int projectCounter = myLocalBuildCounter;
    if (globalBuildCounter >= 0) {
        projectCounter = globalBuildCounter;
    }
    String projectName = String.format("%05d_%s", Integer.valueOf(projectCounter), boardDescriptor.getBoardID());
    if (codeDescriptor.getExampleName() != null) {
        if (codeDescriptor.getExamples().get(0).toString().toLowerCase().contains("libraries")) {
            projectName = String.format("%05d_Library_%s_%s", Integer.valueOf(projectCounter), codeDescriptor.getLibraryName(), codeDescriptor.getExampleName());
        } else {
            projectName = String.format("%05d_%s", Integer.valueOf(projectCounter), codeDescriptor.getExampleName());
        }
    }
    CompileDescription localCompileOptions = compileOptions;
    if (compileOptions == null) {
        localCompileOptions = new CompileDescription();
    }
    return BuildAndVerify(projectName, boardDescriptor, codeDescriptor, localCompileOptions);
}
Also used : CompileDescription(io.sloeber.core.api.CompileDescription)

Example 10 with CompileDescription

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

the class RegressionTestFailingOnTravis method redirectedJson.

/**
 * Test wether a platform json redirect is handled properly
 * https://github.com/jantje/arduino-eclipse-plugin/issues/393
 */
@SuppressWarnings("static-method")
@Test
public void redirectedJson() {
    // this board references to arduino avr so install that one to
    Arduino.installLatestAVRBoards();
    BoardsManager.installLatestPlatform("package_talk2.wisen.com_index.json", "Talk2", "avr");
    Map<String, String> options = new HashMap<>();
    options.put("mhz", "16MHz");
    BoardDescription boardid = BoardsManager.getBoardDescription("package_talk2.wisen.com_index.json", "Talk2", "avr", "whispernode", options);
    if (boardid == null) {
        fail("redirect Json ");
        return;
    }
    if (!Shared.BuildAndVerify("redirect_json", boardid, CodeDescription.createDefaultIno(), new CompileDescription())) {
        fail(Shared.getLastFailMessage());
    }
}
Also used : BoardDescription(io.sloeber.core.api.BoardDescription) HashMap(java.util.HashMap) CompileDescription(io.sloeber.core.api.CompileDescription) Test(org.junit.Test)

Aggregations

CompileDescription (io.sloeber.core.api.CompileDescription)21 CodeDescription (io.sloeber.core.api.CodeDescription)14 Test (org.junit.Test)14 BoardDescription (io.sloeber.core.api.BoardDescription)13 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)13 IProject (org.eclipse.core.resources.IProject)12 CoreException (org.eclipse.core.runtime.CoreException)7 IPath (org.eclipse.core.runtime.IPath)7 ICProjectDescription (org.eclipse.cdt.core.settings.model.ICProjectDescription)4 SloeberProject (io.sloeber.core.api.SloeberProject)3 ICConfigurationDescription (org.eclipse.cdt.core.settings.model.ICConfigurationDescription)3 MCUBoard (io.sloeber.providers.MCUBoard)2 TreeMap (java.util.TreeMap)2 SizeCommands (io.sloeber.core.api.CompileDescription.SizeCommands)1 WarningLevels (io.sloeber.core.api.CompileDescription.WarningLevels)1 OtherDescription (io.sloeber.core.api.OtherDescription)1 File (java.io.File)1 URI (java.net.URI)1 DateTimeFormatter (java.time.format.DateTimeFormatter)1 HashMap (java.util.HashMap)1