From 118826e855fa101fb5d9d18b1d28a65782959ca7 Mon Sep 17 00:00:00 2001 From: Claudio Indellicati Date: Thu, 21 Aug 2014 12:35:01 +0200 Subject: [PATCH] Moved getAvrBasePath() and related methods from Base to BaseNoGui (work in progress). --- app/src/processing/app/Base.java | 28 +++------------ app/src/processing/app/BaseNoGui.java | 40 ++++++++++++++++++++++ app/src/processing/app/debug/Compiler.java | 2 +- 3 files changed, 45 insertions(+), 25 deletions(-) diff --git a/app/src/processing/app/Base.java b/app/src/processing/app/Base.java index 9c661973e..7fd113868 100644 --- a/app/src/processing/app/Base.java +++ b/app/src/processing/app/Base.java @@ -2096,10 +2096,7 @@ public class Base { static public File getHardwareFolder() { - // calculate on the fly because it's needed by Preferences.init() to find - // the boards.txt and programmers.txt preferences files (which happens - // before the other folders / paths get cached). - return getContentFile("hardware"); + return BaseNoGui.getHardwareFolder(); } //Get the core libraries @@ -2108,17 +2105,12 @@ public class Base { } static public String getHardwarePath() { - return getHardwareFolder().getAbsolutePath(); + return BaseNoGui.getHardwarePath(); } static public String getAvrBasePath() { - String path = getHardwarePath() + File.separator + "tools" + - File.separator + "avr" + File.separator + "bin" + File.separator; - if (OSUtils.isLinux() && !(new File(path)).exists()) { - return ""; // use distribution provided avr tools if bundled tools missing - } - return path; + return BaseNoGui.getAvrBasePath(); } /** @@ -2666,19 +2658,7 @@ public class Base { */ static public File getContentFile(String name) { - String path = System.getProperty("user.dir"); - - // Get a path to somewhere inside the .app folder - if (OSUtils.isMacOS()) { -// javaroot -// $JAVAROOT - String javaroot = System.getProperty("javaroot"); - if (javaroot != null) { - path = javaroot; - } - } - File working = new File(path); - return new File(working, name); + return BaseNoGui.getContentFile(name); } diff --git a/app/src/processing/app/BaseNoGui.java b/app/src/processing/app/BaseNoGui.java index 0574f6bfe..1713af6df 100644 --- a/app/src/processing/app/BaseNoGui.java +++ b/app/src/processing/app/BaseNoGui.java @@ -1,5 +1,9 @@ package processing.app; +import java.io.File; + +import processing.app.helpers.OSUtils; + public class BaseNoGui { public static final int REVISION = 158; @@ -8,4 +12,40 @@ public class BaseNoGui { /** Set true if this a proper release rather than a numbered revision. */ static public boolean RELEASE = false; + static public String getAvrBasePath() { + String path = getHardwarePath() + File.separator + "tools" + + File.separator + "avr" + File.separator + "bin" + File.separator; + if (OSUtils.isLinux() && !(new File(path)).exists()) { + return ""; // use distribution provided avr tools if bundled tools missing + } + return path; + } + + static public File getContentFile(String name) { + String path = System.getProperty("user.dir"); + + // Get a path to somewhere inside the .app folder + if (OSUtils.isMacOS()) { +// javaroot +// $JAVAROOT + String javaroot = System.getProperty("javaroot"); + if (javaroot != null) { + path = javaroot; + } + } + File working = new File(path); + return new File(working, name); + } + + static public File getHardwareFolder() { + // calculate on the fly because it's needed by Preferences.init() to find + // the boards.txt and programmers.txt preferences files (which happens + // before the other folders / paths get cached). + return getContentFile("hardware"); + } + + static public String getHardwarePath() { + return getHardwareFolder().getAbsolutePath(); + } + } diff --git a/app/src/processing/app/debug/Compiler.java b/app/src/processing/app/debug/Compiler.java index 79e4958b4..5667d617c 100644 --- a/app/src/processing/app/debug/Compiler.java +++ b/app/src/processing/app/debug/Compiler.java @@ -225,7 +225,7 @@ public class Compiler implements MessageConsumer { // point. if (!p.containsKey("compiler.path")) { System.err.println(_("Third-party platform.txt does not define compiler.path. Please report this to the third-party hardware maintainer.")); - p.put("compiler.path", Base.getAvrBasePath()); + p.put("compiler.path", BaseNoGui.getAvrBasePath()); } // Core folder