1
0
mirror of https://github.com/arduino/Arduino.git synced 2024-12-03 14:24:15 +01:00

Removed dependency from Base in the uploaders.

This commit is contained in:
Claudio Indellicati 2014-08-21 19:00:29 +02:00 committed by Cristian Maglie
parent 1bb2da83c1
commit a43d207e4f
4 changed files with 19 additions and 15 deletions

View File

@ -35,7 +35,7 @@ import cc.arduino.packages.ssh.*;
import com.jcraft.jsch.JSch; import com.jcraft.jsch.JSch;
import com.jcraft.jsch.JSchException; import com.jcraft.jsch.JSchException;
import com.jcraft.jsch.Session; import com.jcraft.jsch.Session;
import processing.app.Base; import processing.app.BaseNoGui;
import processing.app.I18n; import processing.app.I18n;
import processing.app.Preferences; import processing.app.Preferences;
import processing.app.debug.RunnerException; import processing.app.debug.RunnerException;
@ -117,9 +117,9 @@ public class SSHUploader extends Uploader {
} }
private boolean runAVRDude(SSH ssh) throws IOException, JSchException { private boolean runAVRDude(SSH ssh) throws IOException, JSchException {
TargetPlatform targetPlatform = Base.getTargetPlatform(); TargetPlatform targetPlatform = BaseNoGui.getTargetPlatform();
PreferencesMap prefs = Preferences.getMap(); PreferencesMap prefs = Preferences.getMap();
prefs.putAll(Base.getBoardPreferences()); prefs.putAll(BaseNoGui.getBoardPreferences());
prefs.putAll(targetPlatform.getTool(prefs.get("upload.tool"))); prefs.putAll(targetPlatform.getTool(prefs.get("upload.tool")));
String additionalParams = verbose ? prefs.get("upload.params.verbose") : prefs.get("upload.params.quiet"); String additionalParams = verbose ? prefs.get("upload.params.verbose") : prefs.get("upload.params.quiet");

View File

@ -32,7 +32,7 @@ import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import processing.app.Base; import processing.app.BaseNoGui;
import processing.app.I18n; import processing.app.I18n;
import processing.app.Preferences; import processing.app.Preferences;
import processing.app.Serial; import processing.app.Serial;
@ -48,13 +48,13 @@ public class SerialUploader extends Uploader {
public boolean uploadUsingPreferences(File sourcePath, String buildPath, String className, boolean usingProgrammer, List<String> warningsAccumulator) throws Exception { public boolean uploadUsingPreferences(File sourcePath, String buildPath, String className, boolean usingProgrammer, List<String> warningsAccumulator) throws Exception {
// FIXME: Preferences should be reorganized // FIXME: Preferences should be reorganized
TargetPlatform targetPlatform = Base.getTargetPlatform(); TargetPlatform targetPlatform = BaseNoGui.getTargetPlatform();
PreferencesMap prefs = Preferences.getMap(); PreferencesMap prefs = Preferences.getMap();
prefs.putAll(Base.getBoardPreferences()); prefs.putAll(BaseNoGui.getBoardPreferences());
String tool = prefs.getOrExcept("upload.tool"); String tool = prefs.getOrExcept("upload.tool");
if (tool.contains(":")) { if (tool.contains(":")) {
String[] split = tool.split(":", 2); String[] split = tool.split(":", 2);
targetPlatform = Base.getCurrentTargetPlatformFromPackage(split[0]); targetPlatform = BaseNoGui.getCurrentTargetPlatformFromPackage(split[0]);
tool = split[1]; tool = split[1];
} }
prefs.putAll(targetPlatform.getTool(tool)); prefs.putAll(targetPlatform.getTool(tool));
@ -202,16 +202,16 @@ public class SerialUploader extends Uploader {
public boolean uploadUsingProgrammer(String buildPath, String className) throws Exception { public boolean uploadUsingProgrammer(String buildPath, String className) throws Exception {
TargetPlatform targetPlatform = Base.getTargetPlatform(); TargetPlatform targetPlatform = BaseNoGui.getTargetPlatform();
String programmer = Preferences.get("programmer"); String programmer = Preferences.get("programmer");
if (programmer.contains(":")) { if (programmer.contains(":")) {
String[] split = programmer.split(":", 2); String[] split = programmer.split(":", 2);
targetPlatform = Base.getCurrentTargetPlatformFromPackage(split[0]); targetPlatform = BaseNoGui.getCurrentTargetPlatformFromPackage(split[0]);
programmer = split[1]; programmer = split[1];
} }
PreferencesMap prefs = Preferences.getMap(); PreferencesMap prefs = Preferences.getMap();
prefs.putAll(Base.getBoardPreferences()); prefs.putAll(BaseNoGui.getBoardPreferences());
PreferencesMap programmerPrefs = targetPlatform.getProgrammer(programmer); PreferencesMap programmerPrefs = targetPlatform.getProgrammer(programmer);
if (programmerPrefs == null) if (programmerPrefs == null)
throw new RunnerException( throw new RunnerException(
@ -245,14 +245,14 @@ public class SerialUploader extends Uploader {
} }
public boolean burnBootloader() throws Exception { public boolean burnBootloader() throws Exception {
TargetPlatform targetPlatform = Base.getTargetPlatform(); TargetPlatform targetPlatform = BaseNoGui.getTargetPlatform();
// Find preferences for the selected programmer // Find preferences for the selected programmer
PreferencesMap programmerPrefs; PreferencesMap programmerPrefs;
String programmer = Preferences.get("programmer"); String programmer = Preferences.get("programmer");
if (programmer.contains(":")) { if (programmer.contains(":")) {
String[] split = programmer.split(":", 2); String[] split = programmer.split(":", 2);
TargetPlatform platform = Base.getCurrentTargetPlatformFromPackage(split[0]); TargetPlatform platform = BaseNoGui.getCurrentTargetPlatformFromPackage(split[0]);
programmer = split[1]; programmer = split[1];
programmerPrefs = platform.getProgrammer(programmer); programmerPrefs = platform.getProgrammer(programmer);
} else { } else {
@ -264,7 +264,7 @@ public class SerialUploader extends Uploader {
// Build configuration for the current programmer // Build configuration for the current programmer
PreferencesMap prefs = Preferences.getMap(); PreferencesMap prefs = Preferences.getMap();
prefs.putAll(Base.getBoardPreferences()); prefs.putAll(BaseNoGui.getBoardPreferences());
prefs.putAll(programmerPrefs); prefs.putAll(programmerPrefs);
// Create configuration for bootloader tool // Create configuration for bootloader tool
@ -272,7 +272,7 @@ public class SerialUploader extends Uploader {
String tool = prefs.getOrExcept("bootloader.tool"); String tool = prefs.getOrExcept("bootloader.tool");
if (tool.contains(":")) { if (tool.contains(":")) {
String[] split = tool.split(":", 2); String[] split = tool.split(":", 2);
TargetPlatform platform = Base.getCurrentTargetPlatformFromPackage(split[0]); TargetPlatform platform = BaseNoGui.getCurrentTargetPlatformFromPackage(split[0]);
tool = split[1]; tool = split[1];
toolPrefs.putAll(platform.getTool(tool)); toolPrefs.putAll(platform.getTool(tool));
if (toolPrefs.size() == 0) if (toolPrefs.size() == 0)

View File

@ -2008,7 +2008,7 @@ public class Base {
} }
static public TargetPlatform getCurrentTargetPlatformFromPackage(String pack) { static public TargetPlatform getCurrentTargetPlatformFromPackage(String pack) {
return getTargetPlatform(pack, Preferences.get("target_platform")); return BaseNoGui.getCurrentTargetPlatformFromPackage(pack);
} }
static public PreferencesMap getBoardPreferences() { static public PreferencesMap getBoardPreferences() {

View File

@ -107,6 +107,10 @@ public class BaseNoGui {
return new File(working, name); return new File(working, name);
} }
static public TargetPlatform getCurrentTargetPlatformFromPackage(String pack) {
return getTargetPlatform(pack, Preferences.get("target_platform"));
}
static public File getHardwareFolder() { static public File getHardwareFolder() {
// calculate on the fly because it's needed by Preferences.init() to find // calculate on the fly because it's needed by Preferences.init() to find
// the boards.txt and programmers.txt preferences files (which happens // the boards.txt and programmers.txt preferences files (which happens