use of io.sloeber.core.api.SloeberProject in project arduino-eclipse-plugin by Sloeber.
the class Libraries method findAllHarwareLibraries.
/**
* Searches all the hardware dependent libraries of a project. If this is a
* board referencing a core then the libraries of the referenced core are added
* as well
*
* @param project
* the project to find all hardware libraries for
* @return all the library folder names. May contain empty values.
*/
private static Map<String, IPath> findAllHarwareLibraries(ICConfigurationDescription confDesc) {
Map<String, IPath> ret = new HashMap<>();
IProject project = confDesc.getProjectDescription().getProject();
SloeberProject sProject = SloeberProject.getSloeberProject(project);
BoardDescription boardDescriptor = sProject.getBoardDescription(confDesc.getName(), false);
// first add the referenced
IPath libPath = boardDescriptor.getReferencedCoreLibraryPath();
if (libPath != null) {
ret.putAll(findAllSubFolders(libPath));
}
// then add the referencing
libPath = boardDescriptor.getReferencingLibraryPath();
if (libPath != null) {
ret.putAll(findAllSubFolders(libPath));
}
return ret;
}
use of io.sloeber.core.api.SloeberProject 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");
}
}
use of io.sloeber.core.api.SloeberProject in project arduino-eclipse-plugin by Sloeber.
the class UploadProjectHandler method run.
@Override
protected IStatus run(IProgressMonitor monitor) {
boolean canUpload = true;
IStatus retStatus = Status.OK_STATUS;
if (MyPreferences.getBuildBeforeUploadOption()) {
try {
myBuildProject.build(IncrementalProjectBuilder.INCREMENTAL_BUILD, monitor);
canUpload = isBuildSuccessFull(myBuildProject);
} catch (Exception e) {
return new Status(IStatus.WARNING, PLUGIN_ID, Messages.Build_Error_Before_Upload, e);
}
if (!canUpload) {
Display.getDefault().syncExec(new Runnable() {
@Override
public void run() {
Shell theShell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
MessageBox dialog = new MessageBox(theShell, SWT.ICON_QUESTION | SWT.OK);
dialog.setText(Messages.arduino_upload_project_handler_build_failed);
dialog.setMessage(Messages.arduino_upload_project_handler_build_failed_so_no_upload);
dialog.open();
}
});
}
}
if (canUpload) {
SloeberProject sProject = SloeberProject.getSloeberProject(UploadJobHandler.this.myBuildProject);
if (sProject != null) {
if (myIsProgram) {
retStatus = sProject.upLoadUsingProgrammer();
} else {
retStatus = sProject.upload();
}
}
if (retStatus.isOK()) {
if (MyPreferences.getSwitchToSerialMonitorAfterUpload()) {
Display.getDefault().asyncExec(new Runnable() {
@Override
public void run() {
try {
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView(// $NON-NLS-1$
"io.sloeber.ui.monitor.views.SerialMonitor");
} catch (PartInitException e) {
e.printStackTrace();
}
}
});
}
}
}
return retStatus;
}
use of io.sloeber.core.api.SloeberProject in project arduino-eclipse-plugin by Sloeber.
the class OpenSerialMonitorHandler method execute.
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
try {
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView(// $NON-NLS-1$
"io.sloeber.ui.monitor.views.SerialMonitor");
// find all projects
IProject[] SelectedProjects = ProjectExplorerListener.getSelectedProjects();
// on
if ((SelectedProjects.length > 0) && (MyPreferences.getOpenSerialWithMonitor() == true)) {
for (IProject curproject : SelectedProjects) {
int baud = Sketch.getCodeBaudRate(curproject);
if (baud > 0) {
SloeberProject sProject = SloeberProject.getSloeberProject(curproject);
if (sProject != null) {
ICConfigurationDescription activeConf = CoreModel.getDefault().getProjectDescription(curproject).getActiveConfiguration();
BoardDescription boardDescription = sProject.getBoardDescription(activeConf.getName(), false);
String comPort = boardDescription.getUploadPort();
if (!comPort.isEmpty()) {
io.sloeber.ui.monitor.SerialConnection.add(comPort, baud);
}
}
}
}
}
} catch (PartInitException e) {
e.printStackTrace();
}
return null;
}
use of io.sloeber.core.api.SloeberProject in project arduino-eclipse-plugin by Sloeber.
the class IndexerController method postponeIndexerSetup.
@Override
public boolean postponeIndexerSetup(ICProject cProject) {
IProject project = cProject.getProject();
SloeberProject sloeberProject = SloeberProject.getSloeberProject(project);
if (sloeberProject != null) {
if (!sloeberProject.isInMemory()) {
doNotIndexProjects.add(project);
}
}
boolean ret = doNotIndexProjects.contains(project);
if (ret) {
// $NON-NLS-1$
Common.log(new Status(Const.SLOEBER_STATUS_DEBUG, Activator.getId(), "pospone index " + project.getName()));
indexingPosponedProjects.add(project);
} else {
Common.log(new Status(Const.SLOEBER_STATUS_DEBUG, Activator.getId(), // $NON-NLS-1$
"do not pospone index " + project.getName()));
}
return ret;
}
Aggregations