From 37b1b1130a54f5c36ab97930962c3ae291d30c84 Mon Sep 17 00:00:00 2001 From: Rainer Poisel Date: Mon, 17 Jul 2017 00:11:19 +0200 Subject: [PATCH] Dumping executed commands; build-script improvmenets --- .gitignore | 1 + make.sh | 16 +++++++++++----- src/ESP8266FS.java | 26 +++++++++++++++++++++++--- 3 files changed, 35 insertions(+), 8 deletions(-) diff --git a/.gitignore b/.gitignore index a5d8f72..8c1d2f8 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ bin/ dist/ +*.swp diff --git a/make.sh b/make.sh index 9a7702e..4e43bd2 100755 --- a/make.sh +++ b/make.sh @@ -1,16 +1,22 @@ #!/usr/bin/env bash if [[ -z "$INSTALLDIR" ]]; then - INSTALLDIR="$HOME/Documents/Arduino" + if [[ -z "$TAG" ]]; then + TAG=1.6.12 + fi + INSTALLDIR="$HOME/Arduino-$TAG/build/linux/work" +fi +if [[ -L "$INSTALLDIR" ]]; then + INSTALLDIR=$INSTALLDIR/ fi echo "INSTALLDIR: $INSTALLDIR" -pde_path=`find ../../../ -name pde.jar` -core_path=`find ../../../ -name arduino-core.jar` -lib_path=`find ../../../ -name commons-codec-1.7.jar` +pde_path=`find ${INSTALLDIR} -name pde.jar` +core_path=`find ${INSTALLDIR} -name arduino-core.jar` +lib_path=`find ${INSTALLDIR} -name commons-codec-1.7.jar` if [[ -z "$core_path" || -z "$pde_path" ]]; then echo "Some java libraries have not been built yet (did you run ant build?)" - return 1 + exit 1 fi echo "pde_path: $pde_path" echo "core_path: $core_path" diff --git a/src/ESP8266FS.java b/src/ESP8266FS.java index fd210f2..e8118a2 100644 --- a/src/ESP8266FS.java +++ b/src/ESP8266FS.java @@ -284,7 +284,9 @@ private void createAndUpload(){ System.out.println("[SPIFFS] block : "+spiBlock); try { - if(listenOnProcess(new String[]{toolPath, "-c", dataPath, "-p", spiPage+"", "-b", spiBlock+"", "-s", (spiEnd - spiStart)+"", imagePath}) != 0){ + String[] buildCmd = new String[]{toolPath, "-c", dataPath, "-p", spiPage+"", "-b", spiBlock+"", "-s", (spiEnd - spiStart)+"", imagePath}; + dumpCommand(buildCmd, "build.verbose"); + if(listenOnProcess(buildCmd) != 0){ System.err.println(); editor.statusError("SPIFFS Create Failed!"); return; @@ -298,6 +300,7 @@ private void createAndUpload(){ editor.statusNotice("SPIFFS Uploading Image..."); System.out.println("[SPIFFS] upload : "+imagePath); + String[] uploadCmd; if(isNetwork){ String pythonCmd; if(PreferencesData.get("runtime.os").contentEquals("windows")) @@ -307,18 +310,35 @@ private void createAndUpload(){ System.out.println("[SPIFFS] IP : "+serialPort); System.out.println(); - sysExec(new String[]{pythonCmd, espota.getAbsolutePath(), "-i", serialPort, "-s", "-f", imagePath}); + uploadCmd = new String[]{pythonCmd, espota.getAbsolutePath(), "-i", serialPort, "-s", "-f", imagePath}; } else { System.out.println("[SPIFFS] address: "+uploadAddress); System.out.println("[SPIFFS] reset : "+resetMethod); System.out.println("[SPIFFS] port : "+serialPort); System.out.println("[SPIFFS] speed : "+uploadSpeed); System.out.println(); - sysExec(new String[]{esptool.getAbsolutePath(), "-cd", resetMethod, "-cb", uploadSpeed, "-cp", serialPort, "-ca", uploadAddress, "-cf", imagePath}); + uploadCmd = new String[]{esptool.getAbsolutePath(), "-cd", resetMethod, "-cb", uploadSpeed, "-cp", serialPort, "-ca", uploadAddress, "-cf", imagePath}; } + dumpCommand(uploadCmd, "upload.verbose"); + sysExec(uploadCmd); } public void run() { createAndUpload(); } + + private void dumpCommand(String[] fragments, String preference) { + if (!PreferencesData.getBoolean(preference)) { + return; + } + + StringBuffer commandBuf = new StringBuffer(128); + for (int cnt = 0; cnt < fragments.length; cnt++) { + commandBuf.append(fragments[cnt]); + if (cnt < fragments.length - 1) { + commandBuf.append(" " ); + } + } + System.out.println(commandBuf.toString()); + } }