Fork from bluejay at github and modified for my custom ESC. I need to modify it because some mistake design on my ESC hardware.
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.

51 lines
1.2 KiB

  1. #!/bin/bash
  2. source_path=$(dirname $(pwd))
  3. usage() {
  4. echo "Usage: $0 [-l <A-W>] [-m <H|L>] [-d <integer>] [-p <24|48|96>]" 1>&2
  5. exit 1
  6. }
  7. while getopts ":l:m:d:p:" o; do
  8. case "${o}" in
  9. l)
  10. layout=${OPTARG}
  11. ;;
  12. m)
  13. mcu=${OPTARG}
  14. ((mcu == 'H' || mcu == 'L')) || usage
  15. ;;
  16. d)
  17. deadtime=${OPTARG}
  18. ;;
  19. p)
  20. pwm=${OPTARG}
  21. ((pwm == 24 || pwm == 48 || pwm == 96)) || usage
  22. ;;
  23. *)
  24. usage
  25. ;;
  26. esac
  27. done
  28. shift $((OPTIND-1))
  29. if [ -z "${layout}" ] && [ -z "${mcu}" ] && [ -z "${deadtime}" ] && [ -z "${pwm}" ]; then
  30. # All optional parameters are missing
  31. target="all"
  32. params="all"
  33. else
  34. if [ -z "${layout}" ] || [ -z "${mcu}" ] || [ -z "${deadtime}" ] || [ -z "${pwm}" ]; then
  35. # If one optional parameter is given, all are needed
  36. usage
  37. fi
  38. target="${layout}_${mcu}_${deadtime}_${pwm}"
  39. params="LAYOUT=${layout} MCU=${mcu} DEADTIME=${deadtime} PWM=${pwm}"
  40. fi
  41. echo "Building ${target}"
  42. docker run -t -d --name bluejay-$target --mount type=bind,source="$source_path",target=/root/source bluejay-build:latest
  43. docker exec bluejay-$target sh -c "cd /root/source && make $params"
  44. docker stop bluejay-$target > /dev/null
  45. docker rm bluejay-$target > /dev/null