dragondaud / myClock

Pixel Display NTP/Weather Clock for ESP8266/ESP32
MIT License
27 stars 13 forks source link

update.sh script uses incorrect path for ARDUINO #12

Closed jcwren closed 5 years ago

jcwren commented 5 years ago

Running the update.sh script does update the myClock app correctly, but is using the incorrect directory to update the libraries (at least on Mac OS).

mbpro:myClock jcw$ ./update.sh 
++ realpath ./update.sh
+ SCRIPT=/Users/jcw/Projects/myClock/update.sh
++ dirname /Users/jcw/Projects/myClock/update.sh
+ SCRIPTPATH=/Users/jcw/Projects/myClock
++ realpath /Users/jcw/Projects/myClock/..
+ ARDUINO=/Users/jcw/Projects
+ BOLD='\033[1;34m'
+ NC='\033[0m'
+ getopts cth opt
+ cd /Users/jcw/Projects/myClock
++ basename /Users/jcw/Projects/myClock
+ echo -en '\033[1;34mmyClock: \033[0m'
myClock: + git pull --no-edit
Already up to date.
+ cd /Users/jcw/Projects/libraries/ArduinoJson
./update.sh: line 71: cd: /Users/jcw/Projects/libraries/ArduinoJson: No such file or directory
+ cd /Users/jcw/Projects/libraries/Syslog
./update.sh: line 72: cd: /Users/jcw/Projects/libraries/Syslog: No such file or directory
+ cd /Users/jcw/Projects/libraries/Adafruit-GFX-Library
./update.sh: line 73: cd: /Users/jcw/Projects/libraries/Adafruit-GFX-Library: No such file or directory
+ cd /Users/jcw/Projects/libraries/PxMatrix
./update.sh: line 74: cd: /Users/jcw/Projects/libraries/PxMatrix: No such file or directory
+ cd /Users/jcw/Projects/libraries/WiFiManager
./update.sh: line 75: cd: /Users/jcw/Projects/libraries/WiFiManager: No such file or directory
+ cd /Users/jcw/Projects/libraries/DallasTemperature
./update.sh: line 76: cd: /Users/jcw/Projects/libraries/DallasTemperature: No such file or directory
+ cd /Users/jcw/Projects/libraries/OneWire
./update.sh: line 77: cd: /Users/jcw/Projects/libraries/OneWire: No such file or directory
mbpro:myClock jcw$ 
dragondaud commented 5 years ago

The standard layout on any platform is to have an Arduino directory somewhere that contains 'hardware' and 'libraries' local to current user and to store projects in the same directory. You can change the script to work for your choice, or make a symlink.

jcwren commented 5 years ago

Yeah, but the build.sh script figures it out correctly. Seems like the update.sh script just needs the same logic.

dragondaud commented 5 years ago

The build script doesn't need to find the libraries, but obviously the Arduino UI is able to find them. I started using the Arduino command line to locate certain directories in an attempt to work more easily across platforms, so that technique can be used here, as well.

Your Projects directory is not configured as your Sketchbook directory, and therefore the libraries and hardware are not found using relative access. Instead of assuming the parent of the current directory is the sketchbook directory, I will ask arduino, like I switched to using for locating tools.

dragondaud commented 5 years ago

Updated build.sh to provide update.sh functionality, removed update.sh. When switching platforms with -o (update core) your preferences.txt will be deleted. Found no other way to reliably get Arduino to pick correct platform.