improve build script

This commit is contained in:
Wolfgang Hottgenroth 2019-11-19 11:34:30 +01:00
parent 49afd6d818
commit 7887f67442
Signed by: wn
GPG Key ID: 6C1E5E531E0D5D7F

View File

@ -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