Search in sources :

Example 1 with CodeDescriptor

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

the class NewSketchWizard method createProjectWrapper.

protected void createProjectWrapper(IProgressMonitor monitor) {
    BoardDescriptor boardID = this.mArduinoPage.getBoardID();
    CodeDescriptor codeDescription = this.mNewArduinoSketchWizardCodeSelectionPage.getCodeDescription();
    try {
        this.mProject = boardID.createProject(this.mWizardPage.getProjectName(), (!this.mWizardPage.useDefaults()) ? this.mWizardPage.getLocationURI() : null, ConfigurationDescriptor.getDefaultDescriptors(), codeDescription, new CompileOptions(null), monitor);
    } catch (Exception e) {
        this.mProject = null;
        Activator.log(new Status(IStatus.ERROR, Activator.getId(), Messages.ui_new_sketch_error_failed_to_create_project, e));
    }
}
Also used : Status(org.eclipse.core.runtime.Status) IStatus(org.eclipse.core.runtime.IStatus) CompileOptions(io.sloeber.core.api.CompileOptions) BoardDescriptor(io.sloeber.core.api.BoardDescriptor) CodeDescriptor(io.sloeber.core.api.CodeDescriptor) CoreException(org.eclipse.core.runtime.CoreException) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Example 2 with CodeDescriptor

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

the class CreateAndCompileArduinoIDEExamplesOnAVRHardwareTest method examples.

@SuppressWarnings("rawtypes")
@Parameters(name = "{index}: {0}")
public static Collection examples() {
    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) TreeMap(java.util.TreeMap) Map(java.util.Map) Parameters(org.junit.runners.Parameterized.Parameters)

Example 3 with CodeDescriptor

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

the class CreateAndCompileArduinoIDEExamplesOnTeensyTest method examples.

@SuppressWarnings("rawtypes")
@Parameters(name = "{index}: {0}")
public static Collection examples() {
    installAdditionalBoards();
    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) TreeMap(java.util.TreeMap) Map(java.util.Map) Parameters(org.junit.runners.Parameterized.Parameters)

Example 4 with CodeDescriptor

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

the class CreateAndCompileLibraryExamplesTest method testExamples.

@Test
public void testExamples() {
    if (myTotalFails > maxFails) {
        // failing is annoying when doing fixing
        return;
    }
    if (skipAtStart >= myCounter++) {
        // skip these
        return;
    }
    if (!myBoardID.isExampleSupported(myExample)) {
        fail("Trying to run a test on unsoprted board");
        return;
    }
    ArrayList<IPath> paths = new ArrayList<>();
    paths.add(myExample.getPath());
    CodeDescriptor codeDescriptor = CodeDescriptor.createExample(false, paths);
    Map<String, String> boardOptions = myBoardID.getBoardOptions(myExample);
    BoardDescriptor boardDescriptor = myBoardID.getBoardDescriptor();
    boardDescriptor.setOptions(boardOptions);
    BuildAndVerify(myBoardID.getBoardDescriptor(), codeDescriptor);
}
Also used : IPath(org.eclipse.core.runtime.IPath) ArrayList(java.util.ArrayList) BoardDescriptor(io.sloeber.core.api.BoardDescriptor) CodeDescriptor(io.sloeber.core.api.CodeDescriptor) Test(org.junit.Test)

Example 5 with CodeDescriptor

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

the class RegressionTest method are_jantjes_options_taken_into_account.

/**
 * This test will fail if the arduino compile option are not taken into
 * account To do sa a bunch of defines are added to the command line and the
 * code checks whether these defines are set properly
 * @throws Exception
 */
@SuppressWarnings("static-method")
@Test
public void are_jantjes_options_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 = "are_defines_found";
    IPath templateFolder = Shared.getTemplateFolder(projectName);
    CodeDescriptor codeDescriptor = CodeDescriptor.createCustomTemplate(templateFolder);
    NullProgressMonitor monitor = new NullProgressMonitor();
    try {
        CompileOptions compileOptions = new CompileOptions(null);
        compileOptions.set_C_andCPP_CompileOptions("-DTEST_C_CPP");
        compileOptions.set_C_CompileOptions("-DTEST_C");
        compileOptions.set_CPP_CompileOptions("-DTEST_CPP");
        theTestProject = unoBoardid.createProject(projectName, null, ConfigurationDescriptor.getDefaultDescriptors(), codeDescriptor, compileOptions, monitor);
        ICProjectDescription prjCDesc = CoreModel.getDefault().getProjectDescription(theTestProject);
        CoreModel.getDefault().getProjectDescriptionManager().setProjectDescription(theTestProject, prjCDesc, true, null);
        // for the indexer
        Shared.waitForAllJobsToFinish();
        theTestProject.build(IncrementalProjectBuilder.FULL_BUILD, monitor);
        if (Shared.hasBuildErrors(theTestProject)) {
            fail("Failed to compile the project:" + projectName + " The 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) ICProjectDescription(org.eclipse.cdt.core.settings.model.ICProjectDescription) 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