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.

72 lines
2.3 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. echo "--------------------------------------------------------------"
  39. echo "Get revision..."
  40. revision=$(git rev-parse HEAD)
  41. revision=${revision:0:7}
  42. cp espurna/config/version.h espurna/config/version.h.original
  43. sed -i -e "s/APP_REVISION \".*\"/APP_REVISION \"$revision\"/g" espurna/config/version.h
  44. # Recreate web interface
  45. echo "--------------------------------------------------------------"
  46. echo "Building web interface..."
  47. node node_modules/gulp/bin/gulp.js || exit
  48. # Build all the required firmware images
  49. echo "--------------------------------------------------------------"
  50. echo "Building firmware images..."
  51. mkdir -p ../firmware/espurna-$version
  52. for environment in $environments; do
  53. echo "* espurna-$version-$environment.bin"
  54. platformio run --silent --environment $environment || break
  55. mv .pioenvs/$environment/firmware.bin ../firmware/espurna-$version/espurna-$version-$environment.bin
  56. done
  57. echo "--------------------------------------------------------------"
  58. mv espurna/config/version.h.original espurna/config/version.h