mirror of
https://github.com/esp8266/Arduino.git
synced 2025-06-16 11:21:18 +03:00
Removed useless defaults in platform. Remove useless boards.txt/*.platform keys. Renamed some method to a more meaningful name
This commit is contained in:
@ -93,7 +93,7 @@ public class Base {
|
|||||||
// found in the sketchbook)
|
// found in the sketchbook)
|
||||||
static public String librariesClassPath;
|
static public String librariesClassPath;
|
||||||
|
|
||||||
static public Map<String, TargetPackage> targetsTable;
|
static public Map<String, TargetPackage> packages;
|
||||||
|
|
||||||
// Location for untitled items
|
// Location for untitled items
|
||||||
static File untitledFolder;
|
static File untitledFolder;
|
||||||
@ -270,7 +270,7 @@ public class Base {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
targetsTable = new HashMap<String, TargetPackage>();
|
packages = new HashMap<String, TargetPackage>();
|
||||||
loadHardware(getHardwareFolder());
|
loadHardware(getHardwareFolder());
|
||||||
loadHardware(getSketchbookHardwareFolder());
|
loadHardware(getSketchbookHardwareFolder());
|
||||||
|
|
||||||
@ -941,7 +941,6 @@ public class Base {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void rebuildImportMenu(JMenu importMenu) {
|
public void rebuildImportMenu(JMenu importMenu) {
|
||||||
// System.out.println("rebuilding import menu");
|
// System.out.println("rebuilding import menu");
|
||||||
importMenu.removeAll();
|
importMenu.removeAll();
|
||||||
@ -958,10 +957,9 @@ public class Base {
|
|||||||
try {
|
try {
|
||||||
// Find the current target. Get the platform, and then select the
|
// Find the current target. Get the platform, and then select the
|
||||||
// correct name and core path.
|
// correct name and core path.
|
||||||
String platformname = getBoardPreferences().get("platform");
|
PreferencesMap prefs = getTargetPlatform().getPreferences();
|
||||||
String targetname = getPlatformPreferences(platformname).get("name");
|
String targetname = prefs.get("name");
|
||||||
String libraryPath = getPlatformPreferences(platformname).get(
|
String libraryPath = prefs.get("library.core.path");
|
||||||
"library.core.path");
|
|
||||||
|
|
||||||
JMenuItem platformItem = new JMenuItem(targetname);
|
JMenuItem platformItem = new JMenuItem(targetname);
|
||||||
platformItem.setEnabled(false);
|
platformItem.setEnabled(false);
|
||||||
@ -1015,7 +1013,7 @@ public class Base {
|
|||||||
//System.out.println("rebuilding boards menu");
|
//System.out.println("rebuilding boards menu");
|
||||||
menu.removeAll();
|
menu.removeAll();
|
||||||
ButtonGroup group = new ButtonGroup();
|
ButtonGroup group = new ButtonGroup();
|
||||||
for (TargetPackage targetPackage : targetsTable.values()) {
|
for (TargetPackage targetPackage : packages.values()) {
|
||||||
for (TargetPlatform targetPlatform : targetPackage.platforms()) {
|
for (TargetPlatform targetPlatform : targetPackage.platforms()) {
|
||||||
for (String board : targetPlatform.getBoards().keySet()) {
|
for (String board : targetPlatform.getBoards().keySet()) {
|
||||||
AbstractAction action = new AbstractAction(targetPlatform.getBoards().get(
|
AbstractAction action = new AbstractAction(targetPlatform.getBoards().get(
|
||||||
@ -1053,7 +1051,7 @@ public class Base {
|
|||||||
//System.out.println("rebuilding programmer menu");
|
//System.out.println("rebuilding programmer menu");
|
||||||
menu.removeAll();
|
menu.removeAll();
|
||||||
ButtonGroup group = new ButtonGroup();
|
ButtonGroup group = new ButtonGroup();
|
||||||
for (TargetPackage targetPackage : targetsTable.values()) {
|
for (TargetPackage targetPackage : packages.values()) {
|
||||||
for (TargetPlatform targetPlatform : targetPackage.platforms()) {
|
for (TargetPlatform targetPlatform : targetPackage.platforms()) {
|
||||||
for (String programmer : targetPlatform.getProgrammers().keySet()) {
|
for (String programmer : targetPlatform.getProgrammers().keySet()) {
|
||||||
String id = targetPackage.getName() + ":" + targetPlatform.getName() + ":"
|
String id = targetPackage.getName() + ":" + targetPlatform.getName() + ":"
|
||||||
@ -1282,7 +1280,7 @@ public class Base {
|
|||||||
|
|
||||||
for (String target : list) {
|
for (String target : list) {
|
||||||
File subfolder = new File(folder, target);
|
File subfolder = new File(folder, target);
|
||||||
targetsTable.put(target, new TargetPackage(target, subfolder));
|
packages.put(target, new TargetPackage(target, subfolder));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1565,38 +1563,31 @@ public class Base {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static public TargetPlatform getTarget() {
|
/**
|
||||||
TargetPackage pack = targetsTable.get(Preferences.get("target_package"));
|
* Returns the currently selected TargetPlatform.
|
||||||
TargetPlatform platform = pack.get(Preferences.get("target_platform"));
|
*
|
||||||
if (platform == null) {
|
* @return
|
||||||
System.out.println("Selected platform is not in list. Replace with default.");
|
*/
|
||||||
Preferences.set("target_platform", "arduino");
|
static public TargetPlatform getTargetPlatform() {
|
||||||
platform = pack.get(Preferences.get("target_platform"));
|
String packageName = Preferences.get("target_package");
|
||||||
}
|
String platformName = Preferences.get("target_platform");
|
||||||
return platform;
|
return getTargetPlatform(packageName, platformName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
static public PreferencesMap getPlatformPreferences() {
|
* Returns a specific TargetPlatform searching Package/Platform
|
||||||
return getTarget().getPlatform();
|
*
|
||||||
}
|
* @param packageName
|
||||||
|
* @param platformName
|
||||||
// Search for a specific platform
|
* @return
|
||||||
static public TargetPlatform getTargetPlatform(String pack, String platform) {
|
*/
|
||||||
return targetsTable.get(pack).get(platform);
|
static public TargetPlatform getTargetPlatform(String packageName,
|
||||||
}
|
String platformName) {
|
||||||
|
return packages.get(packageName).get(platformName);
|
||||||
// Get a specific platform preferences inside actual package
|
|
||||||
static public PreferencesMap getPlatformPreferences(String platformName) {
|
|
||||||
if (platformName == null)
|
|
||||||
platformName = Preferences.get("platform");
|
|
||||||
TargetPackage pack = targetsTable.get(Preferences.get("target_package"));
|
|
||||||
TargetPlatform target = pack.get(platformName);
|
|
||||||
return target.getPlatform();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static public PreferencesMap getBoardPreferences() {
|
static public PreferencesMap getBoardPreferences() {
|
||||||
TargetPlatform target = getTarget();
|
TargetPlatform target = getTargetPlatform();
|
||||||
if (target != null) {
|
if (target != null) {
|
||||||
String board = Preferences.get("board");
|
String board = Preferences.get("board");
|
||||||
return target.getBoards().get(board);
|
return target.getBoards().get(board);
|
||||||
|
@ -46,7 +46,7 @@ public class AvrdudeUploader extends Uploader {
|
|||||||
// bootloader and upload using the selected programmer.
|
// bootloader and upload using the selected programmer.
|
||||||
if (usingProgrammer || boardPreferences.get("upload.protocol") == null) {
|
if (usingProgrammer || boardPreferences.get("upload.protocol") == null) {
|
||||||
String programmer = Preferences.get("programmer");
|
String programmer = Preferences.get("programmer");
|
||||||
TargetPlatform targetPlatform = Base.getTarget();
|
TargetPlatform targetPlatform = Base.getTargetPlatform();
|
||||||
|
|
||||||
if (programmer.contains(":")) {
|
if (programmer.contains(":")) {
|
||||||
String[] split = programmer.split(":", 2);
|
String[] split = programmer.split(":", 2);
|
||||||
@ -90,7 +90,7 @@ public class AvrdudeUploader extends Uploader {
|
|||||||
|
|
||||||
public boolean burnBootloader() throws RunnerException {
|
public boolean burnBootloader() throws RunnerException {
|
||||||
String programmer = Preferences.get("programmer");
|
String programmer = Preferences.get("programmer");
|
||||||
TargetPlatform targetPlatform = Base.getTarget();
|
TargetPlatform targetPlatform = Base.getTargetPlatform();
|
||||||
if (programmer.contains(":")) {
|
if (programmer.contains(":")) {
|
||||||
String[] split = programmer.split(":", 2);
|
String[] split = programmer.split(":", 2);
|
||||||
targetPlatform = Base.getTargetPlatform(split[0], Preferences
|
targetPlatform = Base.getTargetPlatform(split[0], Preferences
|
||||||
@ -152,7 +152,7 @@ public class AvrdudeUploader extends Uploader {
|
|||||||
TargetPlatform targetPlatform;
|
TargetPlatform targetPlatform;
|
||||||
if (bootloaderPath.contains(":")) {
|
if (bootloaderPath.contains(":")) {
|
||||||
// the current target (associated with the board)
|
// the current target (associated with the board)
|
||||||
targetPlatform = Base.getTarget();
|
targetPlatform = Base.getTargetPlatform();
|
||||||
} else {
|
} else {
|
||||||
String[] split = bootloaderPath.split(":", 2);
|
String[] split = bootloaderPath.split(":", 2);
|
||||||
targetPlatform = Base.getTargetPlatform(split[0], Preferences
|
targetPlatform = Base.getTargetPlatform(split[0], Preferences
|
||||||
|
@ -83,13 +83,8 @@ public class Compiler implements MessageConsumer {
|
|||||||
|
|
||||||
PreferencesMap boardPreferences = Base.getBoardPreferences();
|
PreferencesMap boardPreferences = Base.getBoardPreferences();
|
||||||
|
|
||||||
// Check for null platform, and use system default if not found
|
TargetPlatform targetPlatform = Base.getTargetPlatform();
|
||||||
String platform = boardPreferences.get("platform");
|
PreferencesMap platformPreferences = targetPlatform.getPreferences();
|
||||||
PreferencesMap platformPreferences;
|
|
||||||
if (platform == null)
|
|
||||||
platformPreferences = Base.getPlatformPreferences();
|
|
||||||
else
|
|
||||||
platformPreferences = Base.getPlatformPreferences(platform);
|
|
||||||
|
|
||||||
// Merge all the global preference configuration in order of priority
|
// Merge all the global preference configuration in order of priority
|
||||||
prefs = new PreferencesMap();
|
prefs = new PreferencesMap();
|
||||||
@ -104,10 +99,7 @@ public class Compiler implements MessageConsumer {
|
|||||||
toolsPath = prefs.get("compiler.path");
|
toolsPath = prefs.get("compiler.path");
|
||||||
if (toolsPath == null) {
|
if (toolsPath == null) {
|
||||||
toolsPath = Base.getAvrBasePath();
|
toolsPath = Base.getAvrBasePath();
|
||||||
System.out.println("avrBasePath: " + toolsPath);
|
|
||||||
} else {
|
} else {
|
||||||
System.out.println("avrBasePath:exists: " + toolsPath);
|
|
||||||
|
|
||||||
// Put in the system path in the compiler path if available
|
// Put in the system path in the compiler path if available
|
||||||
MessageFormat compileFormat = new MessageFormat(toolsPath);
|
MessageFormat compileFormat = new MessageFormat(toolsPath);
|
||||||
String basePath = System.getProperty("user.dir");
|
String basePath = System.getProperty("user.dir");
|
||||||
@ -131,7 +123,7 @@ public class Compiler implements MessageConsumer {
|
|||||||
|
|
||||||
File coreFolder;
|
File coreFolder;
|
||||||
if (!core.contains(":")) {
|
if (!core.contains(":")) {
|
||||||
TargetPlatform t = Base.getTarget();
|
TargetPlatform t = Base.getTargetPlatform();
|
||||||
coreFolder = new File(t.getFolder(), "cores");
|
coreFolder = new File(t.getFolder(), "cores");
|
||||||
coreFolder = new File(coreFolder, core);
|
coreFolder = new File(coreFolder, core);
|
||||||
} else {
|
} else {
|
||||||
@ -148,7 +140,7 @@ public class Compiler implements MessageConsumer {
|
|||||||
if (variant != null) {
|
if (variant != null) {
|
||||||
File variantFolder;
|
File variantFolder;
|
||||||
if (!variant.contains(":")) {
|
if (!variant.contains(":")) {
|
||||||
TargetPlatform t = Base.getTarget();
|
TargetPlatform t = Base.getTargetPlatform();
|
||||||
variantFolder = new File(t.getFolder(), "variants");
|
variantFolder = new File(t.getFolder(), "variants");
|
||||||
variantFolder = new File(variantFolder, variant);
|
variantFolder = new File(variantFolder, variant);
|
||||||
} else {
|
} else {
|
||||||
|
@ -34,7 +34,7 @@ public class TargetPlatform {
|
|||||||
private File folder;
|
private File folder;
|
||||||
private Map<String, PreferencesMap> boards;
|
private Map<String, PreferencesMap> boards;
|
||||||
private Map<String, PreferencesMap> programmers;
|
private Map<String, PreferencesMap> programmers;
|
||||||
private PreferencesMap platform;
|
private PreferencesMap preferences;
|
||||||
|
|
||||||
public TargetPlatform(String _name, File _folder) {
|
public TargetPlatform(String _name, File _folder) {
|
||||||
System.out.println("TargetPlatform: constructor start, name: " + _name);
|
System.out.println("TargetPlatform: constructor start, name: " + _name);
|
||||||
@ -42,7 +42,7 @@ public class TargetPlatform {
|
|||||||
folder = _folder;
|
folder = _folder;
|
||||||
boards = new HashMap<String, PreferencesMap>();
|
boards = new HashMap<String, PreferencesMap>();
|
||||||
programmers = new HashMap<String, PreferencesMap>();
|
programmers = new HashMap<String, PreferencesMap>();
|
||||||
platform = new PreferencesMap();
|
preferences = new PreferencesMap();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
File boardsFile = new File(_folder, "boards.txt");
|
File boardsFile = new File(_folder, "boards.txt");
|
||||||
@ -58,7 +58,7 @@ public class TargetPlatform {
|
|||||||
try {
|
try {
|
||||||
File platformsFile = new File(_folder, "platforms.txt");
|
File platformsFile = new File(_folder, "platforms.txt");
|
||||||
if (platformsFile.exists())
|
if (platformsFile.exists())
|
||||||
platform.load(platformsFile);
|
preferences.load(platformsFile);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
System.err.println("Error loading platforms from platform.txt: " + e);
|
System.err.println("Error loading platforms from platform.txt: " + e);
|
||||||
}
|
}
|
||||||
@ -92,7 +92,7 @@ public class TargetPlatform {
|
|||||||
return programmers;
|
return programmers;
|
||||||
}
|
}
|
||||||
|
|
||||||
public PreferencesMap getPlatform() {
|
public PreferencesMap getPreferences() {
|
||||||
return platform;
|
return preferences;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user