Skip to content

Commit e62a7cb

Browse files
author
jantje
committed
#1339 fix lots of todo's
1 parent 01d8555 commit e62a7cb

20 files changed

+867
-869
lines changed

io.sloeber.core/src/io/sloeber/core/Activator.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -207,8 +207,7 @@ private static void initializeImportantVariables() {
207207
try {
208208
workspace.setDescription(workspaceDesc);
209209
} catch (CoreException e) {
210-
// TODO Auto-generated catch block
211-
e.printStackTrace();
210+
Common.log(new Status(IStatus.ERROR, CORE_PLUGIN_ID, e.getMessage(), e));
212211
}
213212
// Make sure some important variables are being initialized
214213
InstancePreferences.setPrivateLibraryPaths(InstancePreferences.getPrivateLibraryPaths());

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

+9-12
Original file line numberDiff line numberDiff line change
@@ -279,12 +279,12 @@ private void ParseSection() {
279279
public static List<BoardDescription> makeBoardDescriptors(File boardFile, Map<String, String> options) {
280280
BoardTxtFile txtFile = new BoardTxtFile(resolvePathEnvironmentString(boardFile));
281281
List<BoardDescription> boards = new ArrayList<>();
282-
String[] allSectionNames = txtFile.getAllSectionNames();
283-
for (String curboardName : allSectionNames) {
284-
Map<String, String> boardSection = txtFile.getSection(txtFile.getIDFromNiceName(curboardName));
282+
List<String> boardIDs = txtFile.getAllBoardIDs();
283+
for (String curboardID : boardIDs) {
284+
Map<String, String> boardSection = txtFile.getSection(curboardID);
285285
if (boardSection != null) {
286286
if (!"true".equalsIgnoreCase(boardSection.get("hide"))) { //$NON-NLS-1$ //$NON-NLS-2$
287-
boards.add(new BoardDescription(boardFile, txtFile.getIDFromNiceName(curboardName), options));
287+
boards.add(new BoardDescription(boardFile, curboardID, options));
288288
}
289289
}
290290
}
@@ -571,8 +571,7 @@ public Path getreferencingPlatformPath() {
571571
}
572572
}
573573

574-
//TODO rename add core
575-
public PlatformTxtFile getreferencedPlatformFile() {
574+
public PlatformTxtFile getreferencedCorePlatformFile() {
576575
updateWhenDirty();
577576
if (myReferencedPlatformCore == null) {
578577
return null;
@@ -584,8 +583,7 @@ public PlatformTxtFile getreferencedPlatformFile() {
584583
return null;
585584
}
586585

587-
//TODO rename add core
588-
public IPath getReferencedLibraryPath() {
586+
public IPath getReferencedCoreLibraryPath() {
589587
updateWhenDirty();
590588
if (myReferencedPlatformCore == null) {
591589
return null;
@@ -608,8 +606,7 @@ public String getUploadPatternKey() {
608606
return TOOLS + DOT + upLoadTool + DOT + UPLOAD + DOT + networkPrefix + PATTERN;
609607
}
610608

611-
//TODO rename add core
612-
public IPath getreferencedHardwarePath() {
609+
public IPath getreferencedCoreHardwarePath() {
613610
updateWhenDirty();
614611
if (myReferencedPlatformCore == null) {
615612
return new Path(myBoardTxtFile.getLoadedFile().toString()).removeLastSegments(1);
@@ -773,7 +770,7 @@ public Map<String, String> getEnvVars() {
773770
allVars.putAll(pluginPreProcessingBoardsTxt.getBoardEnvironVars(getBoardID()));
774771

775772
String architecture = getArchitecture();
776-
IPath coreHardwarePath = getreferencedHardwarePath();
773+
IPath coreHardwarePath = getreferencedCoreHardwarePath();
777774
allVars.put(ENV_KEY_BUILD_ARCH, architecture.toUpperCase());
778775
allVars.put(ENV_KEY_HARDWARE_PATH, coreHardwarePath.removeLastSegments(1).toOSString());
779776
allVars.put(ENV_KEY_BUILD_SYSTEM_PATH, coreHardwarePath.append(SYSTEM).toOSString());
@@ -793,7 +790,7 @@ public Map<String, String> getEnvVars() {
793790
allVars.put(ENV_KEY_BUILD_VARIANT_PATH, EMPTY);
794791
}
795792

796-
PlatformTxtFile referencedPlatfromFile = getreferencedPlatformFile();
793+
PlatformTxtFile referencedPlatfromFile = getreferencedCorePlatformFile();
797794
// process the platform file referenced by the boards.txt
798795
if (referencedPlatfromFile != null) {
799796
allVars.putAll(referencedPlatfromFile.getAllEnvironVars());

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

-5
Original file line numberDiff line numberDiff line change
@@ -289,11 +289,6 @@ public static void addPrivateHardwarePath(String newHardwarePath) {
289289
InstancePreferences.setPrivateHardwarePaths(newPaths);
290290
}
291291

292-
public static String[] getBoardNames(String boardFile) {
293-
BoardTxtFile theBoardsFile = new BoardTxtFile(new File(boardFile));
294-
return theBoardsFile.getAllSectionNames();
295-
}
296-
297292
/**
298293
* Searches for all boards.txt files from the hardware folders and the boards
299294
* manager

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

+3-4
Original file line numberDiff line numberDiff line change
@@ -1101,19 +1101,18 @@ private IStatus BuildTarget(String targetName) {
11011101

11021102
try {
11031103
IMakeTargetManager targetManager = MakeCorePlugin.getDefault().getTargetManager();
1104-
IContainer targetResource = myProject.getFolder("Release");
1104+
IContainer targetResource = myProject.getFolder("Release"); //$NON-NLS-1$
11051105
IMakeTarget target = targetManager.findTarget(targetResource, targetName);
11061106
if (target == null) {
1107-
target = targetManager.createTarget(myProject, targetName, "org.eclipse.cdt.build.MakeTargetBuilder");
1107+
target = targetManager.createTarget(myProject, targetName, "org.eclipse.cdt.build.MakeTargetBuilder"); //$NON-NLS-1$
11081108
target.setBuildTarget(targetName);
11091109
targetManager.addTarget(targetResource, target);
11101110
}
11111111
if (target != null) {
11121112
target.build(new NullProgressMonitor());
11131113
}
11141114
} catch (CoreException e) {
1115-
// TODO Auto-generated catch block
1116-
e.printStackTrace();
1115+
return new Status(IStatus.ERROR, CORE_PLUGIN_ID, e.getMessage(), e);
11171116
}
11181117
return Status.OK_STATUS;
11191118
}

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

+2-5
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ private static Map<String, IPath> findAllHarwareLibraries(ICConfigurationDescrip
117117
SloeberProject sProject = SloeberProject.getSloeberProject(project, false);
118118
BoardDescription boardDescriptor = sProject.getBoardDescription(confDesc.getName(), false);
119119
// first add the referenced
120-
IPath libPath = boardDescriptor.getReferencedLibraryPath();
120+
IPath libPath = boardDescriptor.getReferencedCoreLibraryPath();
121121
if (libPath != null) {
122122
ret.putAll(findAllSubFolders(libPath));
123123
}
@@ -426,10 +426,7 @@ public static void checkLibraries(IProject affectedProject) {
426426
.getLatestInstallableLibraries(uninstalledIncludedHeaders);
427427

428428
if (!availableLibs.isEmpty()) {
429-
// We now know which libraries to install
430-
// TODO for now I just install but there should
431-
// be some user
432-
// interaction
429+
// Ask the user which libs need installing
433430
availableLibs = installHandler.selectLibrariesToInstall(availableLibs);
434431
for (Entry<String, ArduinoLibraryVersion> curLib : availableLibs.entrySet()) {
435432
LibraryManager.install(curLib.getValue(), new NullProgressMonitor());

io.sloeber.core/src/io/sloeber/core/txt/BoardTxtFile.java

+16-4
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,12 @@
77
import java.util.ArrayList;
88
import java.util.Arrays;
99
import java.util.HashSet;
10+
import java.util.LinkedList;
11+
import java.util.List;
1012
import java.util.Map;
1113
import java.util.Map.Entry;
1214
import java.util.Set;
1315

14-
1516
public class BoardTxtFile extends TxtFile {
1617

1718
public BoardTxtFile(File boardsFile) {
@@ -28,7 +29,6 @@ private static File getActualTxtFile(File boardsFile) {
2829
return boardsFile;
2930
}
3031

31-
3232
public String getMenuItemIDFromMenuItemName(String boardID, String menuID, String menuItemName) {
3333

3434
// boardid."menu".menuid.menuitemid=name
@@ -149,7 +149,6 @@ public Map<String, String> getMenus() {
149149
return getSection(MENU);
150150
}
151151

152-
153152
/**
154153
* this is public String[] getAllSectionNames (String[] toaddNames) with a empty
155154
* toaddnames
@@ -173,7 +172,7 @@ public String[] getAllSectionNames() {
173172
* @author Trump
174173
*
175174
*/
176-
String[] getAllSectionNames(String[] toaddNames) {
175+
public String[] getAllSectionNames(String[] toaddNames) {
177176

178177
HashSet<String> allNames = new HashSet<>();
179178
for (String curName : toaddNames) {
@@ -193,6 +192,19 @@ String[] getAllSectionNames(String[] toaddNames) {
193192
return sBoards;
194193
}
195194

195+
public List<String> getAllBoardIDs() {
196+
List<String> allBoardIDs = new LinkedList<>();
197+
for (String curKey : myData.getChildren().keySet()) {
198+
if ((curKey != null) && (!curKey.isEmpty())) {
199+
String theName = myData.getValue(curKey + DOT + NAME);
200+
if ((theName != null) && (!theName.isEmpty())) {
201+
allBoardIDs.add(curKey);
202+
}
203+
}
204+
}
205+
return allBoardIDs;
206+
}
207+
196208
/**
197209
* Get all the key value pairs that need to be added to the environment
198210
* variables for the given boardID

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

+68-67
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,12 @@
99
* At the time of writing 560 examples are compiled
1010
*
1111
*/
12-
import static org.junit.Assert.fail;
12+
import static org.junit.Assert.*;
1313

1414
import java.util.ArrayList;
1515
import java.util.Collection;
1616
import java.util.LinkedList;
17+
import java.util.List;
1718
import java.util.Map;
1819
import java.util.TreeMap;
1920

@@ -34,72 +35,72 @@
3435
@SuppressWarnings({ "nls" })
3536
@RunWith(Parameterized.class)
3637
public class CreateAndCompileArduinoIDEExamplesOnAVRHardwareTest {
37-
private CodeDescription myCodeDescriptor;
38-
private MCUBoard myBoard;
39-
private String myProjectName;
40-
private static int myBuildCounter = 0;
41-
private static int myTotalFails = 0;
42-
private static int maxFails = 50;
43-
private static int mySkipAtStart = 0;
44-
45-
public CreateAndCompileArduinoIDEExamplesOnAVRHardwareTest(String projectName, CodeDescription codeDescriptor,
46-
MCUBoard board) {
47-
48-
myCodeDescriptor = codeDescriptor;
49-
myBoard = board;
50-
myProjectName = projectName;
51-
}
52-
53-
@SuppressWarnings("rawtypes")
54-
@Parameters(name = " {0}")
55-
public static Collection examples() {
56-
Shared.waitForAllJobsToFinish();
57-
Preferences.setUseBonjour(false);
58-
LinkedList<Object[]> examples = new LinkedList<>();
59-
MCUBoard[] allBoards = Arduino.getAllBoards();
60-
61-
TreeMap<String, IPath> exampleFolders = LibraryManager.getAllArduinoIDEExamples();
62-
for (Map.Entry<String, IPath> curexample : exampleFolders.entrySet()) {
63-
String fqn = curexample.getKey().trim();
64-
IPath examplePath = curexample.getValue();
65-
Examples example = new Examples(fqn, examplePath);
66-
if (!skipExample(example)) {
67-
ArrayList<IPath> paths = new ArrayList<>();
68-
69-
paths.add(examplePath);
70-
CodeDescription codeDescriptor = CodeDescription.createExample(false, paths);
71-
for (MCUBoard curboard : allBoards) {
72-
if (curboard.isExampleSupported(example)) {
73-
String projectName = Shared.getProjectName(codeDescriptor, example, curboard);
74-
Object[] theData = new Object[] { projectName, codeDescriptor, curboard };
75-
examples.add(theData);
76-
}
77-
}
78-
}
79-
}
80-
81-
return examples;
82-
83-
}
84-
85-
private static boolean skipExample(Examples example) {
86-
// skip Teensy stuff on Arduino hardware
87-
// Teensy is so mutch more advanced that most arduino avr hardware can not
88-
// handle it
89-
return example.getPath().toString().contains("Teensy");
90-
}
91-
92-
@Test
93-
public void testExample() {
94-
95-
Assume.assumeTrue("Skipping first " + mySkipAtStart + " tests", myBuildCounter++ >= mySkipAtStart);
96-
Assume.assumeTrue("To many fails. Stopping test", myTotalFails < maxFails);
97-
98-
if (!Shared.BuildAndVerify(myProjectName, myBoard.getBoardDescriptor(), myCodeDescriptor,
38+
private CodeDescription myCodeDescriptor;
39+
private MCUBoard myBoard;
40+
private String myProjectName;
41+
private static int myBuildCounter = 0;
42+
private static int myTotalFails = 0;
43+
private static int maxFails = 50;
44+
private static int mySkipAtStart = 0;
45+
46+
public CreateAndCompileArduinoIDEExamplesOnAVRHardwareTest(String projectName, CodeDescription codeDescriptor,
47+
MCUBoard board) {
48+
49+
myCodeDescriptor = codeDescriptor;
50+
myBoard = board;
51+
myProjectName = projectName;
52+
}
53+
54+
@SuppressWarnings("rawtypes")
55+
@Parameters(name = " {0}")
56+
public static Collection examples() {
57+
Shared.waitForAllJobsToFinish();
58+
Preferences.setUseBonjour(false);
59+
LinkedList<Object[]> examples = new LinkedList<>();
60+
List<MCUBoard> allBoards = Arduino.getAllBoards();
61+
62+
TreeMap<String, IPath> exampleFolders = LibraryManager.getAllArduinoIDEExamples();
63+
for (Map.Entry<String, IPath> curexample : exampleFolders.entrySet()) {
64+
String fqn = curexample.getKey().trim();
65+
IPath examplePath = curexample.getValue();
66+
Example example = new Example(fqn, examplePath);
67+
if (!skipExample(example)) {
68+
ArrayList<IPath> paths = new ArrayList<>();
69+
70+
paths.add(examplePath);
71+
CodeDescription codeDescriptor = CodeDescription.createExample(false, paths);
72+
for (MCUBoard curboard : allBoards) {
73+
if (curboard.isExampleSupported(example)) {
74+
String projectName = Shared.getProjectName(codeDescriptor, example, curboard);
75+
Object[] theData = new Object[] { projectName, codeDescriptor, curboard };
76+
examples.add(theData);
77+
}
78+
}
79+
}
80+
}
81+
82+
return examples;
83+
84+
}
85+
86+
private static boolean skipExample(Example example) {
87+
// skip Teensy stuff on Arduino hardware
88+
// Teensy is so mutch more advanced that most arduino avr hardware can not
89+
// handle it
90+
return example.getPath().toString().contains("Teensy");
91+
}
92+
93+
@Test
94+
public void testExample() {
95+
96+
Assume.assumeTrue("Skipping first " + mySkipAtStart + " tests", myBuildCounter++ >= mySkipAtStart);
97+
Assume.assumeTrue("To many fails. Stopping test", myTotalFails < maxFails);
98+
99+
if (!Shared.BuildAndVerify(myProjectName, myBoard.getBoardDescriptor(), myCodeDescriptor,
99100
new CompileDescription())) {
100-
myTotalFails++;
101-
fail(Shared.getLastFailMessage());
102-
}
103-
}
101+
myTotalFails++;
102+
fail(Shared.getLastFailMessage());
103+
}
104+
}
104105

105106
}

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public static Collection examples() {
7070
for (Map.Entry<String, IPath> curexample : exampleFolders.entrySet()) {
7171
String fqn = curexample.getKey().trim();
7272
IPath examplePath = curexample.getValue();
73-
Examples example = new Examples(fqn, examplePath);
73+
Example example = new Example(fqn, examplePath);
7474
if (!skipExample(example)) {
7575
ArrayList<IPath> paths = new ArrayList<>();
7676
paths.add(examplePath);
@@ -94,7 +94,7 @@ public static Collection examples() {
9494
}
9595

9696
@SuppressWarnings("unused")
97-
private static boolean skipExample(Examples example) {
97+
private static boolean skipExample(Example example) {
9898
// no need to skip examples in this test
9999
return false;
100100
}

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public static Collection examples() {
5959
for (Map.Entry<String, IPath> curexample : exampleFolders.entrySet()) {
6060
String fqn = curexample.getKey().trim();
6161
IPath examplePath = curexample.getValue();
62-
Examples example = new Examples(fqn, examplePath);
62+
Example example = new Example(fqn, examplePath);
6363
if (!skipExample(example)) {
6464
ArrayList<IPath> paths = new ArrayList<>();
6565

@@ -78,7 +78,7 @@ public static Collection examples() {
7878

7979
}
8080

81-
private static boolean skipExample(Examples example) {
81+
private static boolean skipExample(Example example) {
8282
switch (example.getFQN()) {
8383
case "example/10.StarterKit/BasicKit/p13_TouchSensorLamp":
8484
return true;

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

-1
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,6 @@ public static Collection boards() {
269269

270270
List<BoardDescription> boards = new ArrayList<>();
271271
for (File curBoardFile : BoardsManager.getAllBoardsFiles()) {
272-
// TOFIX these options should not be set here but in IBoard.getOptions
273272
Map<String, String> options = null;
274273
System.out.println("Adding boards of " + curBoardFile.toString());
275274
boards.addAll(BoardDescription.makeBoardDescriptors(curBoardFile, options));

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,9 @@ public static Collection examples() {
7575
CodeDescription codeDescriptor = CodeDescription.createExample(false, paths);
7676

7777
String fqn=curexample.getKey();
78-
Examples example=new Examples(fqn,curexample.getValue());
78+
Example example=new Example(fqn,curexample.getValue());
7979
// with the current amount of examples only do one
80-
MCUBoard board = Examples.pickBestBoard(example, myBoards);
80+
MCUBoard board = Example.pickBestBoard(example, myBoards);
8181
if (board != null) {
8282
BoardDescription curBoard = board.getBoardDescriptor();
8383
if (curBoard != null) {

0 commit comments

Comments
 (0)