Skip to content

Commit 627ed69

Browse files
committed
Support for 1.6.6
1 parent 545c8c2 commit 627ed69

File tree

2 files changed

+46
-6
lines changed

2 files changed

+46
-6
lines changed

Diff for: make.sh

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ echo "INSTALLDIR: $INSTALLDIR"
77

88
pde_path=`find ../../.. -name pde.jar`
99
core_path=`find ../../.. -name arduino-core.jar`
10+
lib_path=`find ../../.. -name commons-codec-1.7.jar`
1011
if [[ -z "$core_path" || -z "$pde_path" ]]; then
1112
echo "Some java libraries have not been built yet (did you run ant build?)"
1213
return 1
@@ -15,7 +16,7 @@ fi
1516
set -e
1617

1718
mkdir -p bin
18-
javac -target 1.8 -cp "$pde_path:$core_path" \
19+
javac -target 1.8 -cp "$pde_path:$core_path:$lib_path" \
1920
-d bin src/ESP8266FS.java
2021

2122
pushd bin

Diff for: src/ESP8266FS.java

+44-5
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,12 @@
2626
import java.io.File;
2727
import java.io.BufferedReader;
2828
import java.io.InputStreamReader;
29+
import java.io.IOException;
2930

3031
import java.text.SimpleDateFormat;
3132
import java.util.Date;
32-
33+
import java.lang.reflect.Field;
34+
import java.lang.reflect.InvocationTargetException;
3335
import javax.swing.JOptionPane;
3436

3537
import processing.app.PreferencesData;
@@ -38,10 +40,15 @@
3840
import processing.app.BaseNoGui;
3941
import processing.app.Platform;
4042
import processing.app.Sketch;
43+
import processing.app.SketchData;
4144
import processing.app.tools.Tool;
4245
import processing.app.helpers.ProcessUtils;
4346
import processing.app.debug.TargetPlatform;
4447

48+
import org.apache.commons.codec.digest.DigestUtils;
49+
import processing.app.helpers.FileUtils;
50+
51+
import cc.arduino.files.DeleteFilesOnShutdown;
4552

4653
/**
4754
* Example Tools menu entry.
@@ -99,6 +106,36 @@ public void run() {
99106
thread.start();
100107
}
101108

109+
private String getBuildFolderPath(Sketch s) {
110+
try {
111+
File buildFolder = FileUtils.createTempFolder("build", DigestUtils.md5Hex(s.getMainFilePath()) + ".spiffs");
112+
DeleteFilesOnShutdown.add(buildFolder);
113+
return buildFolder.getAbsolutePath();
114+
}
115+
catch (IOException e) {
116+
editor.statusError(e);
117+
}
118+
catch (NoSuchMethodError e) {
119+
// Arduino 1.6.5 doesn't have FileUtils.createTempFolder
120+
// String buildPath = BaseNoGui.getBuildFolder().getAbsolutePath();
121+
java.lang.reflect.Method method;
122+
try {
123+
method = BaseNoGui.class.getMethod("getBuildFolder");
124+
File f = (File) method.invoke(null);
125+
return f.getAbsolutePath();
126+
} catch (SecurityException ex) {
127+
editor.statusError(ex);
128+
} catch (IllegalAccessException ex) {
129+
editor.statusError(ex);
130+
} catch (InvocationTargetException ex) {
131+
editor.statusError(ex);
132+
} catch (NoSuchMethodException ex) {
133+
editor.statusError(ex);
134+
}
135+
}
136+
return "";
137+
}
138+
102139

103140
private long getIntPref(String name){
104141
String data = BaseNoGui.getBoardPreferences().get(name);
@@ -150,7 +187,7 @@ private void createAndUpload(){
150187
mkspiffsCmd = "mkspiffs.exe";
151188
else
152189
mkspiffsCmd = "mkspiffs";
153-
190+
154191
File tool = new File(platform.getFolder() + "/tools", mkspiffsCmd);
155192
if (!tool.exists()) {
156193
tool = new File(PreferencesData.get("runtime.tools.mkspiffs.path"), mkspiffsCmd);
@@ -162,7 +199,10 @@ private void createAndUpload(){
162199
}
163200

164201
int fileCount = 0;
165-
File dataFolder = editor.getSketch().prepareDataFolder();
202+
File dataFolder = new File(editor.getSketch().getFolder(), "data");
203+
if (!dataFolder.exists()) {
204+
dataFolder.mkdirs();
205+
}
166206
if(dataFolder.exists() && dataFolder.isDirectory()){
167207
File[] files = dataFolder.listFiles();
168208
if(files.length > 0){
@@ -176,8 +216,7 @@ private void createAndUpload(){
176216
String toolPath = tool.getAbsolutePath();
177217
String esptoolPath = esptool.getAbsolutePath();
178218
String sketchName = editor.getSketch().getName();
179-
String buildPath = BaseNoGui.getBuildFolder().getAbsolutePath();
180-
String imagePath = buildPath+"/"+sketchName+".spiffs.bin";
219+
String imagePath = getBuildFolderPath(editor.getSketch()) + "/" + sketchName + ".spiffs.bin";
181220
String serialPort = PreferencesData.get("serial.port");
182221
String resetMethod = BaseNoGui.getBoardPreferences().get("upload.resetmethod");
183222
String uploadSpeed = BaseNoGui.getBoardPreferences().get("upload.speed");

0 commit comments

Comments
 (0)