mirror of
https://github.com/esp8266/Arduino.git
synced 2025-06-16 11:21:18 +03:00
Majority of non Compiler.java changes made.
This commit is contained in:
@ -956,8 +956,20 @@ public class Base {
|
|||||||
importToLibraryTable = new HashMap<String, File>();
|
importToLibraryTable = new HashMap<String, File>();
|
||||||
|
|
||||||
// Add from the "libraries" subfolder in the Processing directory
|
// Add from the "libraries" subfolder in the Processing directory
|
||||||
|
//Choose which library to add by chip platform
|
||||||
|
|
||||||
try {
|
try {
|
||||||
addLibraries(importMenu, librariesFolder);
|
//Find the current target. Get the platform, and then select the correct name and core path.
|
||||||
|
String platformname = this.getBoardPreferences().get("platform");
|
||||||
|
String targetname = this.getPlatformPreferences(platformname).get("name");
|
||||||
|
String libraryPath = this.getPlatformPreferences(platformname).get("library.core.path");
|
||||||
|
|
||||||
|
JMenuItem platformItem = new JMenuItem(targetname);
|
||||||
|
platformItem.setEnabled(false);
|
||||||
|
importMenu.add(platformItem);
|
||||||
|
importMenu.addSeparator();
|
||||||
|
addLibraries(importMenu, getCoreLibraries(libraryPath));
|
||||||
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
@ -1005,6 +1017,8 @@ public class Base {
|
|||||||
//System.out.println("Switching to " + target + ":" + board);
|
//System.out.println("Switching to " + target + ":" + board);
|
||||||
Preferences.set("target", (String) getValue("target"));
|
Preferences.set("target", (String) getValue("target"));
|
||||||
Preferences.set("board", (String) getValue("board"));
|
Preferences.set("board", (String) getValue("board"));
|
||||||
|
//Debug: created new imports menu based on board
|
||||||
|
rebuildImportMenu(activeEditor.importMenu);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
action.putValue("target", target.getName());
|
action.putValue("target", target.getName());
|
||||||
@ -1518,6 +1532,10 @@ public class Base {
|
|||||||
return getContentFile("hardware");
|
return getContentFile("hardware");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Get the core libraries
|
||||||
|
static public File getCoreLibraries(String path) {
|
||||||
|
return getContentFile(path);
|
||||||
|
}
|
||||||
|
|
||||||
static public String getHardwarePath() {
|
static public String getHardwarePath() {
|
||||||
return getHardwareFolder().getAbsolutePath();
|
return getHardwareFolder().getAbsolutePath();
|
||||||
@ -1539,6 +1557,31 @@ public class Base {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static public Map<String, String> getPlatformPreferences() {
|
||||||
|
Target target = getTarget();
|
||||||
|
//if (target == null) return new LinkedHashMap();
|
||||||
|
Map map = target.getPlatforms();
|
||||||
|
/*
|
||||||
|
if (map == null)
|
||||||
|
{
|
||||||
|
System.err.println("Error loading platforms preference from Target");
|
||||||
|
System.exit(0);
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
//if (map == null) return new LinkedHashMap();
|
||||||
|
map = (Map) map.get(Preferences.get("platform"));
|
||||||
|
//if (map == null) return new LinkedHashMap();
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Get a specific platform
|
||||||
|
static public Map<String, String> getPlatformPreferences(String platformname) {
|
||||||
|
Target target = getTarget();
|
||||||
|
Map map = target.getPlatforms();
|
||||||
|
map = (Map) map.get(platformname);
|
||||||
|
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();
|
if (target == null) return new LinkedHashMap();
|
||||||
|
@ -684,6 +684,9 @@ public class Editor extends JFrame implements RunnerListener {
|
|||||||
if (boardsMenu == null) {
|
if (boardsMenu == null) {
|
||||||
boardsMenu = new JMenu("Board");
|
boardsMenu = new JMenu("Board");
|
||||||
base.rebuildBoardsMenu(boardsMenu);
|
base.rebuildBoardsMenu(boardsMenu);
|
||||||
|
//Debug: rebuild imports
|
||||||
|
importMenu.removeAll();
|
||||||
|
base.rebuildImportMenu(importMenu);
|
||||||
}
|
}
|
||||||
menu.add(boardsMenu);
|
menu.add(boardsMenu);
|
||||||
|
|
||||||
|
@ -776,4 +776,22 @@ public class Preferences {
|
|||||||
|
|
||||||
return new SyntaxStyle(color, italic, bold);
|
return new SyntaxStyle(color, italic, bold);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//get a Map of the Preferences
|
||||||
|
static public Map<String, String> getMap()
|
||||||
|
{
|
||||||
|
Map globalpreferences = new LinkedHashMap();
|
||||||
|
Enumeration e = table.keys();
|
||||||
|
|
||||||
|
while (e.hasMoreElements())
|
||||||
|
{
|
||||||
|
String key = (String) e.nextElement();
|
||||||
|
//System.out.println("Key: " + key + "Val: " + table.get(key));
|
||||||
|
String value = (String) table.get(key);
|
||||||
|
globalpreferences.put(key, value );
|
||||||
|
}
|
||||||
|
|
||||||
|
return globalpreferences;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1328,10 +1328,14 @@ public class Sketch {
|
|||||||
// grab the imports from the code just preproc'd
|
// grab the imports from the code just preproc'd
|
||||||
|
|
||||||
importedLibraries = new ArrayList<File>();
|
importedLibraries = new ArrayList<File>();
|
||||||
|
//Remember to clear library path before building it.
|
||||||
|
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 (libFolder != null && !importedLibraries.contains(libFolder)) {
|
if (libFolder != null && !importedLibraries.contains(libFolder)) {
|
||||||
importedLibraries.add(libFolder);
|
importedLibraries.add(libFolder);
|
||||||
//classPath += Compiler.contentsToClassPath(libFolder);
|
//classPath += Compiler.contentsToClassPath(libFolder);
|
||||||
|
@ -29,18 +29,21 @@ import java.io.*;
|
|||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
import processing.app.Preferences;
|
import processing.app.Preferences;
|
||||||
|
//import processing.app.Base;
|
||||||
|
|
||||||
public class Target {
|
public class Target {
|
||||||
private String name;
|
private String name;
|
||||||
private File folder;
|
private File folder;
|
||||||
private Map boards;
|
private Map boards;
|
||||||
private Map programmers;
|
private Map programmers;
|
||||||
|
private Map platforms;
|
||||||
|
|
||||||
public Target(String name, File folder) {
|
public Target(String name, File folder) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.folder = folder;
|
this.folder = folder;
|
||||||
this.boards = new LinkedHashMap();
|
this.boards = new LinkedHashMap();
|
||||||
this.programmers = new LinkedHashMap();
|
this.programmers = new LinkedHashMap();
|
||||||
|
this.platforms = new LinkedHashMap();
|
||||||
|
|
||||||
File boardsFile = new File(folder, "boards.txt");
|
File boardsFile = new File(folder, "boards.txt");
|
||||||
try {
|
try {
|
||||||
@ -60,6 +63,28 @@ public class Target {
|
|||||||
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");
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if(platformsFile.exists()){
|
||||||
|
Map platformPreferences = new LinkedHashMap();
|
||||||
|
Preferences.load(new FileInputStream(platformsFile), platformPreferences);
|
||||||
|
for(Object k : platformPreferences.keySet())
|
||||||
|
{
|
||||||
|
String key=(String) k;
|
||||||
|
String platform=key.substring(0,key.indexOf('.'));
|
||||||
|
if (!platforms.containsKey(platform)) platforms.put(platform, new HashMap());
|
||||||
|
((Map) platforms.get(platform)).put(key.substring(key.indexOf('.') + 1),platformPreferences.get(key));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
System.err.println("Error loading platforms from " +
|
||||||
|
platformsFile + ": " + e);
|
||||||
|
// System.exit(0);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
File programmersFile = new File(folder, "programmers.txt");
|
File programmersFile = new File(folder, "programmers.txt");
|
||||||
try {
|
try {
|
||||||
if (programmersFile.exists()) {
|
if (programmersFile.exists()) {
|
||||||
@ -88,4 +113,8 @@ public class Target {
|
|||||||
public Map<String, Map<String, String>> getProgrammers() {
|
public Map<String, Map<String, String>> getProgrammers() {
|
||||||
return programmers;
|
return programmers;
|
||||||
}
|
}
|
||||||
|
public Map<String, Map<String, String>> getPlatforms() {
|
||||||
|
return platforms;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
Reference in New Issue
Block a user