Skip to content

Commit 38c5309

Browse files
author
jantje
committed
#826 if no programmers.txt is found use the arduino
1 parent 28a8e50 commit 38c5309

File tree

2 files changed

+23
-5
lines changed

2 files changed

+23
-5
lines changed

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,8 +297,13 @@ private void ParseSection(Map<String, String> boardInfo) {
297297
String refVersion = valueSplit[2];
298298
String actualValue = valueSplit[3];
299299
this.myBoardsVariant = actualValue;
300+
if("*".equals(refVersion)) {
301+
this.myReferencedBoardVariantPlatformPath = Manager.getPlatformInstallPath(refVendor, refArchitecture);
302+
}
303+
else {
300304
this.myReferencedBoardVariantPlatformPath = Manager.getPlatformInstallPath(refVendor, refArchitecture,
301305
refVersion);
306+
}
302307
if (this.myReferencedBoardVariantPlatformPath == null) {
303308
Common.log(new Status(IStatus.ERROR, Const.CORE_PLUGIN_ID,
304309
Messages.Helpers_tool_reference_missing.replaceAll(TOOL_KEY, variant)
@@ -928,4 +933,13 @@ public IPath getreferencedHardwarePath() {
928933
return platformPath.removeLastSegments(1);
929934
}
930935

936+
/*
937+
* get the latest installed arduino platform with the same architecture.
938+
* This is the platform to use the programmers.txt if no other programmers.txt
939+
* are found.
940+
*/
941+
public IPath getArduinoPlatformPath() {
942+
return Manager.getPlatformInstallPath("arduino", getArchitecture());
943+
}
944+
931945
}

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

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ public class Programmers extends TxtFile {
2121
super(programmersFile);
2222
}
2323

24-
private static Programmers[] fromBoards(IPath referencingPlatformPath, IPath referencedPlatformPath) {
24+
private static Programmers[] fromBoards(IPath referencingPlatformPath, IPath referencedPlatformPath,
25+
IPath arduinoPlatformPath) {
2526
HashSet<File> BoardsFiles = new HashSet<>();
2627
BoardsFiles.add(referencingPlatformPath.append(programmersFileName1).toFile());
2728
BoardsFiles.add(referencingPlatformPath.append(programmersFileName2).toFile());
@@ -35,7 +36,11 @@ private static Programmers[] fromBoards(IPath referencingPlatformPath, IPath ref
3536
i.remove();
3637
}
3738
}
38-
39+
if ((BoardsFiles.size() == 0) && (referencedPlatformPath == null) && (arduinoPlatformPath != null)) {
40+
if (arduinoPlatformPath.append(programmersFileName1).toFile().exists()) {
41+
BoardsFiles.add(arduinoPlatformPath.append(programmersFileName1).toFile());
42+
}
43+
}
3944
Programmers ret[] = new Programmers[BoardsFiles.size()];
4045
int i = 0;
4146
for (File file : BoardsFiles) {
@@ -49,8 +54,7 @@ private static Programmers[] fromBoards(IPath referencingPlatformPath, IPath ref
4954
public static String[] getUploadProtocols(BoardDescriptor boardsDescriptor) {
5055
String[] ret = new String[1];
5156
ret[0] = Defaults.getDefaultUploadProtocol();
52-
Programmers allProgrammers[] = fromBoards(boardsDescriptor.getreferencingPlatformPath(),
53-
boardsDescriptor.getReferencedUploadPlatformPath());
57+
Programmers allProgrammers[] = fromBoards(boardsDescriptor);
5458
for (Programmers curprogrammer : allProgrammers) {
5559
ret = curprogrammer.getAllNames(ret);
5660
}
@@ -60,7 +64,7 @@ public static String[] getUploadProtocols(BoardDescriptor boardsDescriptor) {
6064

6165
public static Programmers[] fromBoards(BoardDescriptor boardsDescriptor) {
6266
return fromBoards(boardsDescriptor.getreferencingPlatformPath(),
63-
boardsDescriptor.getReferencedUploadPlatformPath());
67+
boardsDescriptor.getReferencedUploadPlatformPath(), boardsDescriptor.getArduinoPlatformPath());
6468
}
6569

6670
}

0 commit comments

Comments
 (0)