mirror of
https://github.com/esp8266/Arduino.git
synced 2025-06-16 11:21:18 +03:00
Fixed issues about invalid targets. Menu selection of boards and libraries are now functional.
This commit is contained in:
@ -959,7 +959,7 @@ public class Base {
|
|||||||
//Choose which library to add by chip platform
|
//Choose which library to add by chip platform
|
||||||
|
|
||||||
try {
|
try {
|
||||||
//Find the current target. Get the platform, and then select the correct name and core path.
|
//Find the current target. Get the platform, and then select the correct name and core path.
|
||||||
String platformname = this.getBoardPreferences().get("platform");
|
String platformname = this.getBoardPreferences().get("platform");
|
||||||
String targetname = this.getPlatformPreferences(platformname).get("name");
|
String targetname = this.getPlatformPreferences(platformname).get("name");
|
||||||
String libraryPath = this.getPlatformPreferences(platformname).get("library.core.path");
|
String libraryPath = this.getPlatformPreferences(platformname).get("library.core.path");
|
||||||
@ -1553,11 +1553,20 @@ public class Base {
|
|||||||
|
|
||||||
|
|
||||||
static public Target getTarget() {
|
static public Target getTarget() {
|
||||||
return Base.targetsTable.get(Preferences.get("target"));
|
System.out.println("Base.targetsTable.get(Preferences.get(\"target\"))" + Base.targetsTable.get(Preferences.get("target")));
|
||||||
|
System.out.println("Preferences.get(\"target\")" + Preferences.get("target"));
|
||||||
|
Target target = Base.targetsTable.get(Preferences.get("target"));
|
||||||
|
if (target == null) {
|
||||||
|
System.out.println("default target is not in list. Replace with default.");
|
||||||
|
Preferences.set("target", "arduino");
|
||||||
|
target = Base.targetsTable.get(Preferences.get("target"));
|
||||||
|
}
|
||||||
|
return target;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static public Map<String, String> getPlatformPreferences() {
|
static public Map<String, String> getPlatformPreferences() {
|
||||||
|
System.out.println("getPlatformPreferences() no arguments: start");
|
||||||
Target target = getTarget();
|
Target target = getTarget();
|
||||||
//if (target == null) return new LinkedHashMap();
|
//if (target == null) return new LinkedHashMap();
|
||||||
Map map = target.getPlatforms();
|
Map map = target.getPlatforms();
|
||||||
@ -1576,22 +1585,73 @@ static public Map<String, String> getPlatformPreferences() {
|
|||||||
|
|
||||||
//Get a specific platform
|
//Get a specific platform
|
||||||
static public Map<String, String> getPlatformPreferences(String platformname) {
|
static public Map<String, String> getPlatformPreferences(String platformname) {
|
||||||
|
if (platformname == null) {
|
||||||
|
platformname = Preferences.get("platform");
|
||||||
|
|
||||||
|
}
|
||||||
|
System.out.println("getlatformPreferences(String platformname)): start: platformname = " + platformname );
|
||||||
Target target = getTarget();
|
Target target = getTarget();
|
||||||
Map map = target.getPlatforms();
|
if (target == null ) {
|
||||||
map = (Map) map.get(platformname);
|
System.out.println("get target is null. trouble! ");
|
||||||
|
}
|
||||||
|
Map map = target.getPlatforms();
|
||||||
|
map = (Map) map.get(platformname);
|
||||||
|
|
||||||
|
//What if null or defaults to nonexisent platform
|
||||||
|
System.out.println("PlatformName: " + platformname);
|
||||||
|
if (map == null)
|
||||||
|
{
|
||||||
|
System.err.println("Error loading platforms preference from Target");
|
||||||
|
System.exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
|
static public Map<String, String> bogusgetBoardPreferences() {
|
||||||
|
System.out.println("getBoardPrefences method: start");
|
||||||
|
Target target = getTarget();
|
||||||
|
if (target == null) {
|
||||||
|
System.out.println("getBoardPrefereces method: target == null");
|
||||||
|
return new LinkedHashMap();
|
||||||
|
}
|
||||||
|
Map map = target.getBoards();
|
||||||
|
if (map == null) {
|
||||||
|
System.out.println("getBoardPrefereces method: target.getBoards() == null");
|
||||||
|
return new LinkedHashMap();
|
||||||
|
}
|
||||||
|
map = (Map) map.get(Preferences.get("board"));
|
||||||
|
if (map == null) {
|
||||||
|
System.out.println("getBoardPrefereces method: Preferences.get(board) == null");
|
||||||
|
return new LinkedHashMap();
|
||||||
|
}
|
||||||
|
//Debug iterate the map
|
||||||
|
Iterator iterator = map.entrySet().iterator();
|
||||||
|
while(iterator.hasNext())
|
||||||
|
{
|
||||||
|
Map.Entry pair = (Map.Entry)iterator.next();
|
||||||
|
if (pair.getValue() == null)
|
||||||
|
{
|
||||||
|
System.out.println("KeyName: " + pair.getKey() + " val: null");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
System.out.println("KeyName: " + pair.getKey() + " val" + pair.getValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
static public Map<String, String> getBoardPreferences() {
|
static public Map<String, String> getBoardPreferences() {
|
||||||
Target target = getTarget();
|
Target target = getTarget();
|
||||||
if (target == null) return new LinkedHashMap();
|
Map map = new LinkedHashMap();
|
||||||
Map map = target.getBoards();
|
if (target != null) {
|
||||||
if (map == null) return new LinkedHashMap();
|
map = target.getBoards();
|
||||||
map = (Map) map.get(Preferences.get("board"));
|
map = (Map) map.get(Preferences.get("board"));
|
||||||
if (map == null) return new LinkedHashMap();
|
}
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static public File getSketchbookFolder() {
|
static public File getSketchbookFolder() {
|
||||||
return new File(Preferences.get("sketchbook.path"));
|
return new File(Preferences.get("sketchbook.path"));
|
||||||
|
@ -1331,10 +1331,9 @@ public class Sketch {
|
|||||||
//Remember to clear library path before building it.
|
//Remember to clear library path before building it.
|
||||||
libraryPath = "";
|
libraryPath = "";
|
||||||
for (String item : preprocessor.getExtraImports()) {
|
for (String item : preprocessor.getExtraImports()) {
|
||||||
File libFolder = (File) Base.importToLibraryTable.get(item);
|
|
||||||
|
|
||||||
File libFolder = (File) Base.importToLibraryTable.get(item);
|
File libFolder = (File) Base.importToLibraryTable.get(item);
|
||||||
//Debug libraryPath
|
//If needed can Debug libraryPath here
|
||||||
|
|
||||||
if (libFolder != null && !importedLibraries.contains(libFolder)) {
|
if (libFolder != null && !importedLibraries.contains(libFolder)) {
|
||||||
importedLibraries.add(libFolder);
|
importedLibraries.add(libFolder);
|
||||||
|
@ -39,6 +39,7 @@ public class Target {
|
|||||||
private Map platforms;
|
private Map platforms;
|
||||||
|
|
||||||
public Target(String name, File folder) {
|
public Target(String name, File folder) {
|
||||||
|
System.out.println("Target: constructor start, name: " + name);
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.folder = folder;
|
this.folder = folder;
|
||||||
this.boards = new LinkedHashMap();
|
this.boards = new LinkedHashMap();
|
||||||
@ -61,6 +62,7 @@ public class Target {
|
|||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
System.err.println("Error loading boards from " + boardsFile + ": " + e);
|
System.err.println("Error loading boards from " + boardsFile + ": " + e);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
File platformsFile = new File(folder,"platforms.txt");
|
File platformsFile = new File(folder,"platforms.txt");
|
||||||
@ -80,7 +82,7 @@ public class Target {
|
|||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
System.err.println("Error loading platforms from " +
|
System.err.println("Error loading platforms from " +
|
||||||
platformsFile + ": " + e);
|
platformsFile + ": " + e);
|
||||||
// System.exit(0);
|
System.exit(0);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user