Search in sources :

Example 6 with CompileOptions

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

the class CreateAndCompileArduinoIDEExamplesOnTeensyTest method BuildAndVerify.

public void BuildAndVerify(BoardDescriptor boardDescriptor) {
    IProject theTestProject = null;
    NullProgressMonitor monitor = new NullProgressMonitor();
    String projectName = String.format("%05d_:%s_%s", new Integer(mCounter++), this.myName, boardDescriptor.getBoardID());
    try {
        theTestProject = boardDescriptor.createProject(projectName, null, ConfigurationDescriptor.getDefaultDescriptors(), this.myCodeDescriptor, new CompileOptions(null), monitor);
        // for the indexer
        Shared.waitForAllJobsToFinish();
    } catch (Exception e) {
        e.printStackTrace();
        totalFails++;
        fail("Failed to create the project:" + projectName);
        return;
    }
    try {
        theTestProject.build(IncrementalProjectBuilder.FULL_BUILD, monitor);
        if (Shared.hasBuildErrors(theTestProject)) {
            // try again because the libraries may not yet been added
            // for the indexer
            Shared.waitForAllJobsToFinish();
            try {
                // seen sometimes the libs were still not
                Thread.sleep(3000);
            // added
            } catch (InterruptedException e) {
            // ignore
            }
            theTestProject.build(IncrementalProjectBuilder.FULL_BUILD, monitor);
            if (Shared.hasBuildErrors(theTestProject)) {
                // give up
                totalFails++;
                fail("Failed to compile the project:" + projectName + " build errors");
            } else {
                theTestProject.delete(true, null);
            }
        } else {
            theTestProject.delete(true, null);
        }
    } catch (CoreException e) {
        e.printStackTrace();
        totalFails++;
        fail("Failed to compile the project:" + projectName + " exception");
    }
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) CoreException(org.eclipse.core.runtime.CoreException) CompileOptions(io.sloeber.core.api.CompileOptions) IProject(org.eclipse.core.resources.IProject) CoreException(org.eclipse.core.runtime.CoreException)

Example 7 with CompileOptions

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

the class CreateAndCompileExamplesTest method BuildAndVerify.

public void BuildAndVerify(BoardDescriptor boardid, CodeDescriptor codeDescriptor) {
    IProject theTestProject = null;
    NullProgressMonitor monitor = new NullProgressMonitor();
    String projectName = String.format("%05d_%s", new Integer(mCounter++), this.myName);
    try {
        theTestProject = boardid.createProject(projectName, null, ConfigurationDescriptor.getDefaultDescriptors(), codeDescriptor, new CompileOptions(null), monitor);
        // for the indexer
        Shared.waitForAllJobsToFinish();
    } catch (Exception e) {
        e.printStackTrace();
        totalFails++;
        fail("Failed to create the project:" + projectName);
        return;
    }
    try {
        theTestProject.build(IncrementalProjectBuilder.FULL_BUILD, monitor);
        if (Shared.hasBuildErrors(theTestProject)) {
            // try again because the libraries may not yet been added
            // for the indexer
            Shared.waitForAllJobsToFinish();
            try {
                // seen sometimes the libs were still not
                Thread.sleep(3000);
            // added
            } catch (InterruptedException e) {
            // ignore
            }
            theTestProject.build(IncrementalProjectBuilder.FULL_BUILD, monitor);
            if (Shared.hasBuildErrors(theTestProject)) {
                // give up
                totalFails++;
                fail("Failed to compile the project:" + projectName + " build errors");
            } else {
                theTestProject.delete(true, null);
            }
        } else {
            theTestProject.delete(true, null);
        }
    } catch (CoreException e) {
        e.printStackTrace();
        totalFails++;
        try {
            theTestProject.close(null);
        } catch (@SuppressWarnings("unused") CoreException e1) {
        // fully ignore
        }
        fail("Failed to compile the project:" + projectName + " exception");
    }
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) CoreException(org.eclipse.core.runtime.CoreException) CompileOptions(io.sloeber.core.api.CompileOptions) IProject(org.eclipse.core.resources.IProject) CoreException(org.eclipse.core.runtime.CoreException)

Example 8 with CompileOptions

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

the class CreateAndCompileJantjesBoardsTest method BuildAndVerify.

public void BuildAndVerify(BoardDescriptor boardDescriptor) {
    IProject theTestProject = null;
    NullProgressMonitor monitor = new NullProgressMonitor();
    String projectName = String.format("%05d_:%s_%s", new Integer(mCounter++), this.myName, boardDescriptor.getBoardID());
    try {
        theTestProject = boardDescriptor.createProject(projectName, null, ConfigurationDescriptor.getDefaultDescriptors(), this.myCodeDescriptor, new CompileOptions(null), monitor);
        // for the indexer
        Shared.waitForAllJobsToFinish();
    } catch (Exception e) {
        e.printStackTrace();
        totalFails++;
        fail("Failed to create the project:" + projectName);
        return;
    }
    try {
        theTestProject.build(IncrementalProjectBuilder.FULL_BUILD, monitor);
        if (Shared.hasBuildErrors(theTestProject)) {
            // try again because the libraries may not yet been added
            // for the indexer
            Shared.waitForAllJobsToFinish();
            try {
                // seen sometimes the libs were still not
                Thread.sleep(3000);
            // added
            } catch (InterruptedException e) {
            // ignore
            }
            theTestProject.build(IncrementalProjectBuilder.FULL_BUILD, monitor);
            if (Shared.hasBuildErrors(theTestProject)) {
                // give up
                totalFails++;
                fail("Failed to compile the project:" + projectName + " build errors");
            } else {
                theTestProject.delete(true, null);
            }
        } else {
            theTestProject.delete(true, null);
        }
    } catch (CoreException e) {
        e.printStackTrace();
        totalFails++;
        fail("Failed to compile the project:" + projectName + " exception");
    }
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) CoreException(org.eclipse.core.runtime.CoreException) CompileOptions(io.sloeber.core.api.CompileOptions) IProject(org.eclipse.core.resources.IProject) CoreException(org.eclipse.core.runtime.CoreException)

Example 9 with CompileOptions

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

the class CreateAndCompileLibraryExamplesTest method BuildAndVerify.

public void BuildAndVerify(BoardDescriptor boardid, CodeDescriptor codeDescriptor) {
    IProject theTestProject = null;
    NullProgressMonitor monitor = new NullProgressMonitor();
    String projectName = String.format("%05d_%1.100s", new Integer(myCounter), myExample.getFQN());
    try {
        theTestProject = boardid.createProject(projectName, null, ConfigurationDescriptor.getDefaultDescriptors(), codeDescriptor, new CompileOptions(null), monitor);
        // for the indexer
        Shared.waitForAllJobsToFinish();
    } catch (Exception e) {
        e.printStackTrace();
        myTotalFails++;
        fail("Failed to create the project:" + projectName);
        return;
    }
    try {
        theTestProject.build(IncrementalProjectBuilder.FULL_BUILD, monitor);
        if (Shared.hasBuildErrors(theTestProject)) {
            // try again because the libraries may not yet been added
            // for the indexer
            Shared.waitForAllJobsToFinish();
            try {
                // seen sometimes the libs were still not
                Thread.sleep(3000);
            // added
            } catch (InterruptedException e) {
            // ignore
            }
            theTestProject.build(IncrementalProjectBuilder.FULL_BUILD, monitor);
            if (Shared.hasBuildErrors(theTestProject)) {
                // give up
                myTotalFails++;
                theTestProject.close(null);
                fail("Failed to compile the project:" + projectName + " build errors");
            } else {
                theTestProject.delete(true, null);
            }
        } else {
            theTestProject.delete(true, null);
        }
    } catch (CoreException e) {
        e.printStackTrace();
        myTotalFails++;
        fail("Failed to compile the project:" + projectName + " exception");
    }
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) CoreException(org.eclipse.core.runtime.CoreException) CompileOptions(io.sloeber.core.api.CompileOptions) IProject(org.eclipse.core.resources.IProject) CoreException(org.eclipse.core.runtime.CoreException)

Example 10 with CompileOptions

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

CompileOptions (io.sloeber.core.api.CompileOptions)18 CoreException (org.eclipse.core.runtime.CoreException)14 IProject (org.eclipse.core.resources.IProject)11 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)11 BoardDescriptor (io.sloeber.core.api.BoardDescriptor)6 CodeDescriptor (io.sloeber.core.api.CodeDescriptor)6 Test (org.junit.Test)6 HashMap (java.util.HashMap)5 IPath (org.eclipse.core.runtime.IPath)5 IOException (java.io.IOException)2 ICProjectDescription (org.eclipse.cdt.core.settings.model.ICProjectDescription)2 IStatus (org.eclipse.core.runtime.IStatus)2 Status (org.eclipse.core.runtime.Status)2 FileNotFoundException (java.io.FileNotFoundException)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 URISyntaxException (java.net.URISyntaxException)1 ArrayList (java.util.ArrayList)1 IEnvironmentVariable (org.eclipse.cdt.core.envvar.IEnvironmentVariable)1 IEnvironmentVariableManager (org.eclipse.cdt.core.envvar.IEnvironmentVariableManager)1 ICConfigurationDescription (org.eclipse.cdt.core.settings.model.ICConfigurationDescription)1