Search in sources :

Example 11 with CodeDescription

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

the class NewSketchWizard method performFinish.

@Override
public boolean performFinish() {
    if (this.mProject != null) {
        return true;
    }
    BoardDescription boardDescription = this.mArduinoPage.getBoardDescriptor();
    CodeDescription codeDescription = this.mNewArduinoSketchWizardCodeSelectionPage.getCodeDescription();
    CompileDescription compileDescription = new CompileDescription();
    URI locationURI = (!this.mWizardPage.useDefaults()) ? this.mWizardPage.getLocationURI() : null;
    compileDescription.setEnableParallelBuild(MyPreferences.getEnableParallelBuildForNewProjects());
    boardDescription.saveUserSelection();
    this.mProject = SloeberProject.createArduinoProject(this.mWizardPage.getProjectName(), locationURI, boardDescription, codeDescription, compileDescription, new NullProgressMonitor());
    if (this.mProject == null) {
        log(new Status(IStatus.ERROR, PLUGIN_ID, Messages.ui_new_sketch_error_failed_to_create_project));
        return false;
    }
    // so now we set Eclipse to the right perspective and switch to our just
    // created project
    BasicNewProjectResourceWizard.updatePerspective(this.mConfig);
    IWorkbenchWindow TheWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    BasicNewResourceWizard.selectAndReveal(this.mProject, TheWindow);
    return true;
}
Also used : Status(org.eclipse.core.runtime.Status) IStatus(org.eclipse.core.runtime.IStatus) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) BoardDescription(io.sloeber.core.api.BoardDescription) CodeDescription(io.sloeber.core.api.CodeDescription) CompileDescription(io.sloeber.core.api.CompileDescription) URI(java.net.URI)

Example 12 with CodeDescription

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

the class NightlyBoardPatronTest method testExamples.

@Test
public void testExamples() {
    myBuildCounter++;
    Assume.assumeTrue("Skipping first " + mySkipAtStart + " tests", myBuildCounter >= mySkipAtStart);
    Assume.assumeTrue("To many fails. Stopping test", myTotalFails < maxFails);
    ArrayList<IPath> paths = new ArrayList<>();
    paths.add(myExample.getPath());
    CodeDescription codeDescriptor = CodeDescription.createExample(false, paths);
    Map<String, String> boardOptions = myBoardID.getBoardOptions(myExample);
    BoardDescription boardDescriptor = myBoardID.getBoardDescriptor();
    boardDescriptor.setOptions(boardOptions);
    if (!Shared.BuildAndVerify(myBoardID.getBoardDescriptor(), codeDescriptor, myCompileOptions, myBuildCounter)) {
        myTotalFails++;
        fail(Shared.getLastFailMessage());
    }
}
Also used : BoardDescription(io.sloeber.core.api.BoardDescription) IPath(org.eclipse.core.runtime.IPath) CodeDescription(io.sloeber.core.api.CodeDescription) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 13 with CodeDescription

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

the class RegressionTest method issue687.

/**
 * support void loop{};
 *
 * @throws Exception
 */
@Test
public void issue687() throws Exception {
    BoardDescription unoBoardid = Arduino.uno().getBoardDescriptor();
    IProject theTestProject = null;
    String projectName = "issue687";
    IPath templateFolder = Shared.getTemplateFolder(projectName);
    CodeDescription codeDescriptor = CodeDescription.createCustomTemplate(templateFolder);
    try {
        theTestProject = SloeberProject.createArduinoProject(projectName, null, unoBoardid, codeDescriptor, new CompileDescription(), 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) 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) CoreException(org.eclipse.core.runtime.CoreException) Test(org.junit.Test)

Example 14 with CodeDescription

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

the class RegressionTest method openAndCloseUsesSavedSettings.

/**
 * open and close a project should keep the compileDescription and
 * BoardDescriotion
 *
 * @throws Exception
 */
@Test
public void openAndCloseUsesSavedSettings() throws Exception {
    CodeDescription codeDesc = new CodeDescription(CodeDescription.CodeTypes.defaultCPP);
    String proj1Name = "openModAndClose1";
    BoardDescription proj1BoardDesc = Arduino.uno().getBoardDescriptor();
    OtherDescription otherDesc = new OtherDescription();
    otherDesc.setVersionControlled(true);
    CompileDescription proj1CompileDesc = getBunkersCompileDescription();
    IProject proj1 = SloeberProject.createArduinoProject(proj1Name, null, proj1BoardDesc, codeDesc, proj1CompileDesc, otherDesc, new NullProgressMonitor());
    String proj2Name = "openModAndClose2";
    BoardDescription proj2BoardDesc = Arduino.mega2560Board().getBoardDescriptor();
    CompileDescription proj2CompileDesc = new CompileDescription();
    IProject proj2 = SloeberProject.createArduinoProject(proj2Name, null, proj2BoardDesc, codeDesc, proj2CompileDesc, new NullProgressMonitor());
    // Read the data we want to test
    // for the indexer
    Shared.waitForAllJobsToFinish();
    SloeberProject proj1SloeberDesc = SloeberProject.getSloeberProject(proj1);
    ICProjectDescription proj1Desc = CoreModel.getDefault().getProjectDescription(proj1);
    ICConfigurationDescription proj1ConfDesc = proj1Desc.getActiveConfiguration();
    BoardDescription proj1CreatedBoardDesc = proj1SloeberDesc.getBoardDescription(proj1ConfDesc.getName(), false);
    CompileDescription proj1CreatedCompileDesc = proj1SloeberDesc.getCompileDescription(proj1ConfDesc.getName(), false);
    SloeberProject proj2SloeberDesc = SloeberProject.getSloeberProject(proj2);
    ICProjectDescription proj2Desc = CoreModel.getDefault().getProjectDescription(proj2);
    ICConfigurationDescription proj2ConfDesc = proj2Desc.getActiveConfiguration();
    BoardDescription proj2CreatedBoardDesc = proj2SloeberDesc.getBoardDescription(proj2ConfDesc.getName(), false);
    CompileDescription proj2CreatedCompileDesc = proj2SloeberDesc.getCompileDescription(proj2ConfDesc.getName(), false);
    // get the filenames to copy
    IFile file = proj1.getFile(SLOEBER_CFG);
    File proj1SloeberFile = file.getLocation().toFile();
    file = proj2.getFile(SLOEBER_CFG);
    File proj2SloeberFile = file.getLocation().toFile();
    // close and reopen the project
    proj2.close(null);
    // just wait a while
    Thread.sleep(1000);
    Shared.waitForAllJobsToFinish();
    // copy from proj1 to proj2
    FileUtils.copyFile(proj1SloeberFile, proj2SloeberFile);
    // reopen the project
    proj2.open(null);
    Thread.sleep(1000);
    Shared.waitForAllJobsToFinish();
    // reread project 2
    proj2SloeberDesc = SloeberProject.getSloeberProject(proj2);
    proj2Desc = CoreModel.getDefault().getProjectDescription(proj2);
    proj2ConfDesc = proj2Desc.getActiveConfiguration();
    BoardDescription proj2OpenedBoardDesc = proj2SloeberDesc.getBoardDescription(proj2ConfDesc.getName(), false);
    CompileDescription proj2OpenedCompileDesc = proj2SloeberDesc.getCompileDescription(proj2ConfDesc.getName(), false);
    // check the setup was done correctly
    if (!proj1BoardDesc.equals(proj1CreatedBoardDesc)) {
        fail("Project 1 not created properly.");
    }
    if (!proj2BoardDesc.equals(proj2CreatedBoardDesc)) {
        fail("Project 2 not created properly.");
    }
    if (!proj1CompileDesc.equals(proj1CreatedCompileDesc)) {
        fail("Project 1 not created properly.");
    }
    if (!proj2CompileDesc.equals(proj2CreatedCompileDesc)) {
        fail("Project 2 not created properly.");
    }
    // check wether the file modification was taken into account
    if (!proj1BoardDesc.equals(proj2OpenedBoardDesc)) {
        fail("Project 2 not created properly.");
    }
    if (!proj1CompileDesc.equals(proj2OpenedCompileDesc)) {
        fail("Project 2 not created properly.");
    }
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) ICProjectDescription(org.eclipse.cdt.core.settings.model.ICProjectDescription) BoardDescription(io.sloeber.core.api.BoardDescription) IFile(org.eclipse.core.resources.IFile) CodeDescription(io.sloeber.core.api.CodeDescription) SloeberProject(io.sloeber.core.api.SloeberProject) OtherDescription(io.sloeber.core.api.OtherDescription) CompileDescription(io.sloeber.core.api.CompileDescription) ICConfigurationDescription(org.eclipse.cdt.core.settings.model.ICConfigurationDescription) IFile(org.eclipse.core.resources.IFile) File(java.io.File) IProject(org.eclipse.core.resources.IProject) Test(org.junit.Test)

Example 15 with CodeDescription

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

the class RegressionTest method is_extern_C_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
 */
@Test
public void is_extern_C_taken_into_account() throws Exception {
    BoardDescription unoBoardid = Arduino.uno().getBoardDescriptor();
    IProject theTestProject = null;
    String projectName = "externc";
    IPath templateFolder = Shared.getTemplateFolder(projectName);
    CodeDescription codeDescriptor = CodeDescription.createCustomTemplate(templateFolder);
    NullProgressMonitor monitor = new NullProgressMonitor();
    try {
        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 + " 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) 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) CoreException(org.eclipse.core.runtime.CoreException) Test(org.junit.Test)

Aggregations

CodeDescription (io.sloeber.core.api.CodeDescription)20 BoardDescription (io.sloeber.core.api.BoardDescription)16 Test (org.junit.Test)15 CompileDescription (io.sloeber.core.api.CompileDescription)14 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)13 IProject (org.eclipse.core.resources.IProject)12 IPath (org.eclipse.core.runtime.IPath)12 CoreException (org.eclipse.core.runtime.CoreException)7 ArrayList (java.util.ArrayList)6 MCUBoard (io.sloeber.providers.MCUBoard)5 TreeMap (java.util.TreeMap)5 LinkedList (java.util.LinkedList)4 Map (java.util.Map)4 ICProjectDescription (org.eclipse.cdt.core.settings.model.ICProjectDescription)4 Parameters (org.junit.runners.Parameterized.Parameters)4 SloeberProject (io.sloeber.core.api.SloeberProject)3 ICConfigurationDescription (org.eclipse.cdt.core.settings.model.ICConfigurationDescription)3 OtherDescription (io.sloeber.core.api.OtherDescription)1 File (java.io.File)1 URI (java.net.URI)1