diff --git a/build.sh b/build.sh index c661e90..659940c 100755 --- a/build.sh +++ b/build.sh @@ -1,13 +1,35 @@ #!/bin/bash -if [ "$1" != "" ]; then +if [ "$1" == "" ]; then + echo "Give one of the targets: build, clean, upload" + echo "If you want to use a project directory different" + echo "than the current directory, give it as a second" + echo "argument." + exit 1 +fi + +if [ "$2" != "" ]; then PROJECT_DIR=$1 else PROJECT_DIR=$PWD fi -pushd $PROJECT_DIR/libraries/esp8266boilerplate/ConfigGenerator && ./configGen.sh && popd -env ARDUINO_SKETCHBOOK_DIR=$PROJECT_DIR arduino-cli compile --fqbn=esp8266:esp8266:nodemcu $PROJECT_DIR/sketch -cp sketch/sketch.esp8266.esp8266.nodemcu.* . + +if [ "$1" == "build" ]; then + pushd $PROJECT_DIR/libraries/esp8266boilerplate/ConfigGenerator && ./configGen.sh && popd + env ARDUINO_SKETCHBOOK_DIR=$PROJECT_DIR arduino-cli compile --fqbn=esp8266:esp8266:nodemcu $PROJECT_DIR/sketch + cp sketch/sketch.esp8266.esp8266.nodemcu.* . +elif [ "$1" == "clean" ]; then + for D in libraries/includes/configuration.h libraries/includes/configuration.cpp sketch/sketch.esp8266.esp8266.nodemcu.bin sketch/sketch.esp8266.esp8266.nodemcu.elf sketch.esp8266.esp8266.nodemcu.bin sketch.esp8266.esp8266.nodemcu.elf; do + echo -n "About to delete $D ... " + rm $PROJECT_DIR/$D && echo "done" + done +elif [ "$1" == "upload" ]; then + echo "About to upload to device" +else + echo "Unknown subcommand '$1'" + exit 1 +fi +