Skip to content

Commit 365a855

Browse files
author
jantje
committed
#1283 first successfull test
I had to do lots of changes to get this to work but now there is a "convert to sloeber project" which works with a new general project (when adding a sloeber.cfg and .ino before conversion no additional actions are needed) I guess there are plenty of problems but I wanted to check in this code One of the reasons this was complicated is because config info was stored based on the ID and not on the name. I neded to switch because tI do not want the id in the sloeber.cfg and I can not create ID's so I needed to switch to using names That also means that there was work on making config name renames work.
1 parent 2ac83b4 commit 365a855

File tree

14 files changed

+392
-114
lines changed

14 files changed

+392
-114
lines changed

io.sloeber.core/src/io/sloeber/core/api/BoardDescription.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1127,4 +1127,9 @@ public static BoardDescription getFromCDT(ICConfigurationDescription confDesc) {
11271127
return ret;
11281128
}
11291129

1130+
public boolean isValid() {
1131+
// TODO Auto-generated method stub
1132+
return false;
1133+
}
1134+
11301135
}

io.sloeber.core/src/io/sloeber/core/api/SloeberProject.java

Lines changed: 269 additions & 90 deletions
Large diffs are not rendered by default.

io.sloeber.core/src/io/sloeber/core/toolchain/SloeberConfigurationVariableSupplier.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ private void initializeIfNotYetDone(IConfiguration configuration) {
7777
ICConfigurationDescription confDesc = ManagedBuildManager.getDescriptionForConfiguration(configuration);
7878
ICProjectDescription projDesc = confDesc.getProjectDescription();
7979
IProject project = projDesc.getProject();
80-
SloeberProject.getSloeberProject(project, false);
80+
SloeberProject sloeberProject = SloeberProject.getSloeberProject(project, false);
81+
sloeberProject.configure();
8182
}
8283
}

io.sloeber.core/src/io/sloeber/core/tools/Libraries.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ private static Map<String, IPath> findAllHarwareLibraries(ICConfigurationDescrip
116116
Map<String, IPath> ret = new HashMap<>();
117117
IProject project = confDesc.getProjectDescription().getProject();
118118
SloeberProject sProject = SloeberProject.getSloeberProject(project, false);
119-
BoardDescription boardDescriptor = sProject.getBoardDescription(confDesc, false);
119+
BoardDescription boardDescriptor = sProject.getBoardDescription(confDesc.getName(), false);
120120
// first add the referenced
121121
IPath libPath = boardDescriptor.getReferencedLibraryPath();
122122
if (libPath != null) {

io.sloeber.core/src/io/sloeber/core/tools/uploaders/UploadSketchWrapper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ private Job internalUpload(IProject project,
5757
ICConfigurationDescription confDesc) {
5858

5959
SloeberProject sProject = SloeberProject.getSloeberProject(project, false);
60-
BoardDescription boardDescriptor = sProject.getBoardDescription(confDesc, false);
60+
BoardDescription boardDescriptor = sProject.getBoardDescription(confDesc.getName(), false);
6161

6262
String UpLoadTool = boardDescriptor.getActualUploadTool();
6363
// String uploadClass = Common.getBuildEnvironmentVariable(confDesc,

io.sloeber.tests/src/io/sloeber/core/RegressionTest.java

Lines changed: 50 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ public void issue555() {
106106
}
107107
SloeberProject arduinoProject = SloeberProject.getSloeberProject(theTestProject, false);
108108
ICProjectDescription cProjectDescription = CCorePlugin.getDefault().getProjectDescription(theTestProject);
109-
arduinoProject.setBoardDescription(cProjectDescription.getActiveConfiguration(), teensyBoardid, true);
109+
arduinoProject.setBoardDescription(cProjectDescription.getActiveConfiguration().getName(), teensyBoardid, true);
110110

111111
Shared.waitForAllJobsToFinish();
112112
try {
@@ -328,6 +328,42 @@ public void are_defines_before_includes_taken_into_account() throws Exception {
328328

329329
}
330330

331+
/**
332+
* Does Sloeber still compile after a configuration renamen
333+
*
334+
* @throws Exception
335+
*/
336+
@Test
337+
public void rename_Configuration() throws Exception {
338+
BoardDescription unoBoardid = Arduino.uno().getBoardDescriptor();
339+
340+
IProject theTestProject = null;
341+
String projectName = "rename_Configuration";
342+
343+
CodeDescription codeDescriptor = CodeDescription.createDefaultIno();
344+
345+
NullProgressMonitor monitor = new NullProgressMonitor();
346+
theTestProject = SloeberProject.createArduinoProject(projectName, null, unoBoardid, codeDescriptor,
347+
new CompileDescription(), new NullProgressMonitor());
348+
349+
Shared.waitForAllJobsToFinish(); // for the indexer
350+
theTestProject.build(IncrementalProjectBuilder.FULL_BUILD, monitor);
351+
if (Shared.hasBuildErrors(theTestProject)) {
352+
fail("Failed to compile the project before config rename");
353+
}
354+
355+
CCorePlugin cCorePlugin = CCorePlugin.getDefault();
356+
ICProjectDescription prjCDesc = cCorePlugin.getProjectDescription(theTestProject);
357+
ICConfigurationDescription activeConfig = prjCDesc.getActiveConfiguration();
358+
activeConfig.setName("renamedConfig");
359+
cCorePlugin.setProjectDescription(theTestProject, prjCDesc);
360+
361+
Shared.waitForAllJobsToFinish(); // for the indexer
362+
theTestProject.build(IncrementalProjectBuilder.FULL_BUILD, monitor);
363+
if (Shared.hasBuildErrors(theTestProject)) {
364+
fail("Failed to compile the project after config rename");
365+
}
366+
}
331367
/**
332368
* open and close a project should keep the compileDescription and
333369
* BoardDescriotion
@@ -351,8 +387,8 @@ public void openAndClosePreservesSettings() throws Exception {
351387
SloeberProject sloeberDesc = SloeberProject.getSloeberProject(theTestProject, false);
352388
ICProjectDescription projDesc = CoreModel.getDefault().getProjectDescription(theTestProject);
353389
ICConfigurationDescription confDesc = projDesc.getActiveConfiguration();
354-
BoardDescription createdBoardDesc = sloeberDesc.getBoardDescription(confDesc, false);
355-
CompileDescription createdCompileDesc = sloeberDesc.getCompileDescription(confDesc, false);
390+
BoardDescription createdBoardDesc = sloeberDesc.getBoardDescription(confDesc.getName(), false);
391+
CompileDescription createdCompileDesc = sloeberDesc.getCompileDescription(confDesc.getName(), false);
356392

357393
// close and reopen the project
358394
theTestProject.close(null);
@@ -366,8 +402,8 @@ public void openAndClosePreservesSettings() throws Exception {
366402
sloeberDesc = SloeberProject.getSloeberProject(theTestProject, false);
367403
projDesc = CoreModel.getDefault().getProjectDescription(theTestProject);
368404
confDesc = projDesc.getActiveConfiguration();
369-
BoardDescription reopenedBoardDesc = sloeberDesc.getBoardDescription(confDesc, false);
370-
CompileDescription reopenedCompileDesc = sloeberDesc.getCompileDescription(confDesc, false);
405+
BoardDescription reopenedBoardDesc = sloeberDesc.getBoardDescription(confDesc.getName(), false);
406+
CompileDescription reopenedCompileDesc = sloeberDesc.getCompileDescription(confDesc.getName(), false);
371407

372408
// check the data is equal
373409
boolean createBoardsDiff = !unoBoardid.equals(createdBoardDesc);
@@ -451,14 +487,16 @@ public void openAndCloseUsesSavedSettings() throws Exception {
451487
SloeberProject proj1SloeberDesc = SloeberProject.getSloeberProject(proj1, false);
452488
ICProjectDescription proj1Desc = CoreModel.getDefault().getProjectDescription(proj1);
453489
ICConfigurationDescription proj1ConfDesc = proj1Desc.getActiveConfiguration();
454-
BoardDescription proj1CreatedBoardDesc = proj1SloeberDesc.getBoardDescription(proj1ConfDesc, false);
455-
CompileDescription proj1CreatedCompileDesc = proj1SloeberDesc.getCompileDescription(proj1ConfDesc, false);
490+
BoardDescription proj1CreatedBoardDesc = proj1SloeberDesc.getBoardDescription(proj1ConfDesc.getName(), false);
491+
CompileDescription proj1CreatedCompileDesc = proj1SloeberDesc.getCompileDescription(proj1ConfDesc.getName(),
492+
false);
456493

457494
SloeberProject proj2SloeberDesc = SloeberProject.getSloeberProject(proj2, false);
458495
ICProjectDescription proj2Desc = CoreModel.getDefault().getProjectDescription(proj2);
459496
ICConfigurationDescription proj2ConfDesc = proj2Desc.getActiveConfiguration();
460-
BoardDescription proj2CreatedBoardDesc = proj2SloeberDesc.getBoardDescription(proj2ConfDesc, false);
461-
CompileDescription proj2CreatedCompileDesc = proj2SloeberDesc.getCompileDescription(proj2ConfDesc, false);
497+
BoardDescription proj2CreatedBoardDesc = proj2SloeberDesc.getBoardDescription(proj2ConfDesc.getName(), false);
498+
CompileDescription proj2CreatedCompileDesc = proj2SloeberDesc.getCompileDescription(proj2ConfDesc.getName(),
499+
false);
462500

463501
// get the filenames to copy
464502
IFile file = proj1.getFile("sloeber.cfg"); //$NON-NLS-1$
@@ -485,8 +523,9 @@ public void openAndCloseUsesSavedSettings() throws Exception {
485523
proj2SloeberDesc = SloeberProject.getSloeberProject(proj2, false);
486524
proj2Desc = CoreModel.getDefault().getProjectDescription(proj2);
487525
proj2ConfDesc = proj2Desc.getActiveConfiguration();
488-
BoardDescription proj2OpenedBoardDesc = proj2SloeberDesc.getBoardDescription(proj2ConfDesc, false);
489-
CompileDescription proj2OpenedCompileDesc = proj2SloeberDesc.getCompileDescription(proj2ConfDesc, false);
526+
BoardDescription proj2OpenedBoardDesc = proj2SloeberDesc.getBoardDescription(proj2ConfDesc.getName(), false);
527+
CompileDescription proj2OpenedCompileDesc = proj2SloeberDesc.getCompileDescription(proj2ConfDesc.getName(),
528+
false);
490529

491530
// check the setup was done correctly
492531
if (!proj1BoardDesc.equals(proj1CreatedBoardDesc)) {

io.sloeber.tests/src/io/sloeber/core/Shared.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@
1414
import java.util.zip.ZipInputStream;
1515

1616
import org.apache.commons.lang.SystemUtils;
17+
import org.eclipse.cdt.core.CCorePlugin;
1718
import org.eclipse.cdt.core.model.ICModelMarker;
19+
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
20+
import org.eclipse.cdt.core.settings.model.ICProjectDescription;
1821
import org.eclipse.core.resources.IMarker;
1922
import org.eclipse.core.resources.IProject;
2023
import org.eclipse.core.resources.IResource;
@@ -65,7 +68,11 @@ public static boolean hasBuildErrors(IProject project) throws CoreException {
6568
return true;
6669
}
6770
}
68-
IPath resultPath = project.getLocation().append("Release");
71+
CCorePlugin cCorePlugin = CCorePlugin.getDefault();
72+
ICProjectDescription prjCDesc = cCorePlugin.getProjectDescription(project);
73+
ICConfigurationDescription activeConfig = prjCDesc.getActiveConfiguration();
74+
75+
IPath resultPath = project.getLocation().append(activeConfig.getName());
6976
String projName=project.getName() ;
7077
String[] validOutputss= {projName+".elf",projName+".bin",projName+".hex",projName+".exe","application.axf"};
7178
for(String validOutput:validOutputss) {
663 Bytes
Loading

io.sloeber.ui/plugin.xml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,20 @@
210210
<primaryWizard
211211
id="io.sloeber.eclipse.NewArduinoSketchWizard">
212212
</primaryWizard>
213+
<wizard
214+
canFinishEarly="true"
215+
category="io.sloeber.eclipse.newWizards"
216+
class="io.sloeber.ui.wizard.ConvertToSloeber"
217+
finalPerspective="io.sloeber.application.perspective"
218+
hasPages="true"
219+
icon="icons/convertToSloeber.png"
220+
id="io.sloeber.convert.wizard"
221+
name="convert to Sloeber propject"
222+
project="false">
223+
<selection
224+
class="org.eclipse.core.resources.IProject">
225+
</selection>
226+
</wizard>
213227
</extension>
214228
<extension
215229
point="org.eclipse.ui.propertyPages">

io.sloeber.ui/src/io/sloeber/ui/actions/OpenSerialMonitorHandler.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ public Object execute(ExecutionEvent event) throws ExecutionException {
4747
if (sProject != null) {
4848
ICConfigurationDescription activeConf = CoreModel.getDefault()
4949
.getProjectDescription(curproject).getActiveConfiguration();
50-
BoardDescription boardDescription = sProject.getBoardDescription(activeConf, false);
50+
BoardDescription boardDescription = sProject.getBoardDescription(activeConf.getName(),
51+
false);
5152
String comPort = boardDescription.getUploadPort();
5253
if (!comPort.isEmpty()) {
5354
io.sloeber.ui.monitor.SerialConnection.add(comPort, baud);

0 commit comments

Comments
 (0)