Fork of the espurna firmware for `mhsw` switches
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

63 lines
1.9 KiB

6 years ago
6 years ago
  1. #!/bin/bash
  2. # Welcome
  3. echo "--------------------------------------------------------------"
  4. echo "ESPURNA FIRMWARE BUILDER"
  5. # Available environments
  6. travis=$(grep env: platformio.ini | grep travis | sed 's/\[env://' | sed 's/\]/ /' | sort)
  7. available=$(grep env: platformio.ini | grep -v ota | grep -v ssl | grep -v travis | sed 's/\[env://' | sed 's/\]/ /' | sort)
  8. # Parameters
  9. environments=$@
  10. if [ "$environments" == "list" ]; then
  11. echo "--------------------------------------------------------------"
  12. echo "Available environments:"
  13. for environment in $available; do
  14. echo "* $environment"
  15. done
  16. exit
  17. fi
  18. # Environments to build
  19. if [ $# -eq 0 ]; then
  20. environments=$available
  21. # Hook to build travis test envs
  22. if [[ "${TRAVIS_BRANCH}" != "" ]]; then
  23. if [[ ${TRAVIS_BRANCH} != "master" ]]; then
  24. environments=$travis
  25. fi
  26. fi
  27. fi
  28. # Get current version
  29. version=$(grep APP_VERSION espurna/config/version.h | awk '{print $3}' | sed 's/"//g')
  30. echo "Building for version $version"
  31. # Create output folder
  32. mkdir -p firmware
  33. if [ ! -e node_modules/gulp/bin/gulp.js ]; then
  34. echo "--------------------------------------------------------------"
  35. echo "Installing dependencies..."
  36. npm install --only=dev
  37. fi
  38. # Recreate web interface
  39. echo "--------------------------------------------------------------"
  40. echo "Building web interface..."
  41. node node_modules/gulp/bin/gulp.js || exit
  42. # Build all the required firmware images
  43. echo "--------------------------------------------------------------"
  44. echo "Building firmware images..."
  45. mkdir -p ../firmware/espurna-$version
  46. for environment in $environments; do
  47. echo "* espurna-$version-$environment.bin"
  48. platformio run --silent --environment $environment || exit
  49. mv .pioenvs/$environment/firmware.bin ../firmware/espurna-$version/espurna-$version-$environment.bin
  50. done
  51. echo "--------------------------------------------------------------"