Search in sources :

Example 1 with CompileOptions

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

the class ArduinoLanguageProvider method getCompilerCommand.

@Override
protected String getCompilerCommand(String languageId) {
    String compilerCommand = new String();
    ICProjectDescription prjDesc = CoreModel.getDefault().getProjectDescription(this.currentProject);
    if (prjDesc == null)
        return compilerCommand;
    IEnvironmentVariableManager envManager = CCorePlugin.getDefault().getBuildEnvironmentManager();
    ICConfigurationDescription confDesc = prjDesc.getActiveConfiguration();
    String recipeKey = new String();
    String extraOptions = new String();
    CompileOptions compileOptions = new CompileOptions(confDesc);
    if (languageId.equals("org.eclipse.cdt.core.gcc")) {
        recipeKey = Common.get_ENV_KEY_RECIPE(Const.ACTION_C_to_O);
        extraOptions = compileOptions.get_C_CompileOptions();
    } else if (languageId.equals("org.eclipse.cdt.core.g++")) {
        recipeKey = Common.get_ENV_KEY_RECIPE(Const.ACTION_CPP_to_O);
        extraOptions = compileOptions.get_CPP_CompileOptions();
    } else {
        ManagedBuilderCorePlugin.error("Unable to find compiler command for language " + languageId + " in toolchain=" + getToolchainId());
    }
    extraOptions = extraOptions + " " + compileOptions.get_C_andCPP_CompileOptions() + " " + compileOptions.get_All_CompileOptions();
    try {
        compilerCommand = envManager.getVariable(recipeKey + Const.DOT + "1", confDesc, false).getValue();
        compilerCommand = compilerCommand + envManager.getVariable(recipeKey + Const.DOT + "2", confDesc, false).getValue();
        compilerCommand = compilerCommand + envManager.getVariable(recipeKey + Const.DOT + "3", confDesc, false).getValue();
    } catch (Exception e) {
        compilerCommand = new String();
    }
    compilerCommand = compilerCommand + ' ' + extraOptions;
    return compilerCommand.replaceAll(" -o ", " ");
}
Also used : ICProjectDescription(org.eclipse.cdt.core.settings.model.ICProjectDescription) CompileOptions(io.sloeber.core.api.CompileOptions) IEnvironmentVariableManager(org.eclipse.cdt.core.envvar.IEnvironmentVariableManager) ICConfigurationDescription(org.eclipse.cdt.core.settings.model.ICConfigurationDescription) CoreException(org.eclipse.core.runtime.CoreException)

Example 2 with CompileOptions

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

the class CompileProperties method updateData.

@Override
protected void updateData(ICResourceDescription cfg) {
    this.myCompileOptions = new CompileOptions(getConfdesc());
    updateScreenData();
}
Also used : CompileOptions(io.sloeber.core.api.CompileOptions)

Example 3 with CompileOptions

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

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

the class CompileAndUpload method testExamples.

@Test
public void testExamples() {
    IPath templateFolder = Shared.getTemplateFolder("fastBlink");
    CompileOptions compileOptions = new CompileOptions(null);
    compileOptions.set_C_andCPP_CompileOptions("-DINTERVAL=" + interval);
    Build_Verify_upload(CodeDescriptor.createCustomTemplate(templateFolder), compileOptions);
}
Also used : IPath(org.eclipse.core.runtime.IPath) CompileOptions(io.sloeber.core.api.CompileOptions) Test(org.junit.Test)

Example 5 with CompileOptions

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

the class CreateAndCompileArduinoIDEExamplesOnAVRHardwareTest 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)

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