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.

73 lines
2.3 KiB

7 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. re='^[0-9]+\.[0-9]+\.[0-9]+$'
  24. if ! [[ ${TRAVIS_BRANCH} =~ $re ]]; then
  25. environments=$travis
  26. fi
  27. fi
  28. fi
  29. # Get current version
  30. version=$(grep APP_VERSION espurna/config/version.h | awk '{print $3}' | sed 's/"//g')
  31. echo "Building for version $version"
  32. # Create output folder
  33. mkdir -p firmware
  34. if [ ! -e node_modules/gulp/bin/gulp.js ]; then
  35. echo "--------------------------------------------------------------"
  36. echo "Installing dependencies..."
  37. npm install --only=dev
  38. fi
  39. echo "--------------------------------------------------------------"
  40. echo "Get revision..."
  41. revision=$(git rev-parse HEAD)
  42. revision=${revision:0:7}
  43. cp espurna/config/version.h espurna/config/version.h.original
  44. sed -i -e "s/APP_REVISION \".*\"/APP_REVISION \"$revision\"/g" espurna/config/version.h
  45. # Recreate web interface
  46. echo "--------------------------------------------------------------"
  47. echo "Building web interface..."
  48. node node_modules/gulp/bin/gulp.js || exit
  49. # Build all the required firmware images
  50. echo "--------------------------------------------------------------"
  51. echo "Building firmware images..."
  52. mkdir -p ../firmware/espurna-$version
  53. for environment in $environments; do
  54. echo "* espurna-$version-$environment.bin"
  55. platformio run --silent --environment $environment || exit 1
  56. mv .pioenvs/$environment/firmware.bin ../firmware/espurna-$version/espurna-$version-$environment.bin
  57. done
  58. echo "--------------------------------------------------------------"
  59. mv espurna/config/version.h.original espurna/config/version.h