Skip to content

Commit 118826e

Browse files
bitroncmaglie
authored andcommitted
Moved getAvrBasePath() and related methods from Base to BaseNoGui (work in progress).
1 parent 057106f commit 118826e

File tree

3 files changed

+45
-25
lines changed

3 files changed

+45
-25
lines changed

app/src/processing/app/Base.java

Lines changed: 4 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2096,10 +2096,7 @@ static public String getToolsPath() {
20962096

20972097

20982098
static public File getHardwareFolder() {
2099-
// calculate on the fly because it's needed by Preferences.init() to find
2100-
// the boards.txt and programmers.txt preferences files (which happens
2101-
// before the other folders / paths get cached).
2102-
return getContentFile("hardware");
2099+
return BaseNoGui.getHardwareFolder();
21032100
}
21042101

21052102
//Get the core libraries
@@ -2108,17 +2105,12 @@ static public File getCoreLibraries(String path) {
21082105
}
21092106

21102107
static public String getHardwarePath() {
2111-
return getHardwareFolder().getAbsolutePath();
2108+
return BaseNoGui.getHardwarePath();
21122109
}
21132110

21142111

21152112
static public String getAvrBasePath() {
2116-
String path = getHardwarePath() + File.separator + "tools" +
2117-
File.separator + "avr" + File.separator + "bin" + File.separator;
2118-
if (OSUtils.isLinux() && !(new File(path)).exists()) {
2119-
return ""; // use distribution provided avr tools if bundled tools missing
2120-
}
2121-
return path;
2113+
return BaseNoGui.getAvrBasePath();
21222114
}
21232115

21242116
/**
@@ -2666,19 +2658,7 @@ static public String getLibContentsPath(String filename) {
26662658
*/
26672659

26682660
static public File getContentFile(String name) {
2669-
String path = System.getProperty("user.dir");
2670-
2671-
// Get a path to somewhere inside the .app folder
2672-
if (OSUtils.isMacOS()) {
2673-
// <key>javaroot</key>
2674-
// <string>$JAVAROOT</string>
2675-
String javaroot = System.getProperty("javaroot");
2676-
if (javaroot != null) {
2677-
path = javaroot;
2678-
}
2679-
}
2680-
File working = new File(path);
2681-
return new File(working, name);
2661+
return BaseNoGui.getContentFile(name);
26822662
}
26832663

26842664

app/src/processing/app/BaseNoGui.java

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
package processing.app;
22

3+
import java.io.File;
4+
5+
import processing.app.helpers.OSUtils;
6+
37
public class BaseNoGui {
48

59
public static final int REVISION = 158;
@@ -8,4 +12,40 @@ public class BaseNoGui {
812
/** Set true if this a proper release rather than a numbered revision. */
913
static public boolean RELEASE = false;
1014

15+
static public String getAvrBasePath() {
16+
String path = getHardwarePath() + File.separator + "tools" +
17+
File.separator + "avr" + File.separator + "bin" + File.separator;
18+
if (OSUtils.isLinux() && !(new File(path)).exists()) {
19+
return ""; // use distribution provided avr tools if bundled tools missing
20+
}
21+
return path;
22+
}
23+
24+
static public File getContentFile(String name) {
25+
String path = System.getProperty("user.dir");
26+
27+
// Get a path to somewhere inside the .app folder
28+
if (OSUtils.isMacOS()) {
29+
// <key>javaroot</key>
30+
// <string>$JAVAROOT</string>
31+
String javaroot = System.getProperty("javaroot");
32+
if (javaroot != null) {
33+
path = javaroot;
34+
}
35+
}
36+
File working = new File(path);
37+
return new File(working, name);
38+
}
39+
40+
static public File getHardwareFolder() {
41+
// calculate on the fly because it's needed by Preferences.init() to find
42+
// the boards.txt and programmers.txt preferences files (which happens
43+
// before the other folders / paths get cached).
44+
return getContentFile("hardware");
45+
}
46+
47+
static public String getHardwarePath() {
48+
return getHardwareFolder().getAbsolutePath();
49+
}
50+
1151
}

app/src/processing/app/debug/Compiler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ private PreferencesMap createBuildPreferences(String _buildPath,
225225
// point.
226226
if (!p.containsKey("compiler.path")) {
227227
System.err.println(_("Third-party platform.txt does not define compiler.path. Please report this to the third-party hardware maintainer."));
228-
p.put("compiler.path", Base.getAvrBasePath());
228+
p.put("compiler.path", BaseNoGui.getAvrBasePath());
229229
}
230230

231231
// Core folder

0 commit comments

Comments
 (0)