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.

60 lines
1.5 KiB

  1. #!/bin/sh
  2. # NOTE: This script uses tabs for indentation
  3. errcho() {
  4. echo "$@" >&2
  5. }
  6. USAGE="Usage: $0 [keyboard[:keymap[:target]]]"
  7. # Check preconditions
  8. for arg; do
  9. if [ "$arg" = "--help" ]; then
  10. echo "$USAGE"
  11. exit 0
  12. fi
  13. done
  14. if [ $# -gt 1 ]; then
  15. errcho "$USAGE"
  16. exit 1
  17. elif ! command -v docker >/dev/null 2>&1; then
  18. errcho "Error: docker not found"
  19. errcho "See https://docs.docker.com/install/#supported-platforms for installation instructions"
  20. exit 2
  21. fi
  22. # Determine arguments
  23. if [ $# -eq 0 ]; then
  24. printf "keyboard=" && read -r keyboard
  25. [ -n "$keyboard" ] && printf "keymap=" && read -r keymap
  26. [ -n "$keymap" ] && printf "target=" && read -r target
  27. else
  28. IFS=':' read -r keyboard keymap target x <<-EOF
  29. $1
  30. EOF
  31. if [ -n "$x" ]; then
  32. errcho "$USAGE"
  33. exit 1
  34. fi
  35. fi
  36. if [ -n "$target" ]; then
  37. if [ "$(uname)" = "Linux" ] || docker-machine active >/dev/null 2>&1; then
  38. usb_args="--privileged -v /dev:/dev"
  39. else
  40. errcho "Error: target requires docker-machine to work on your platform"
  41. errcho "See http://gw.tnode.com/docker/docker-machine-with-usb-support-on-windows-macos"
  42. errcho "Consider flashing with QMK Toolbox (https://github.com/qmk/qmk_toolbox) instead"
  43. exit 3
  44. fi
  45. fi
  46. dir=$(pwd -W 2>/dev/null) || dir=$PWD # Use Windows path if on Windows
  47. # Run container and build firmware
  48. docker run --rm -it $usb_args \
  49. -w /qmk_firmware \
  50. -v "$dir":/qmk_firmware \
  51. -e ALT_GET_KEYBOARDS=true \
  52. -e SKIP_GIT="$SKIP_GIT" \
  53. -e MAKEFLAGS="$MAKEFLAGS" \
  54. qmkfm/base_container \
  55. make "$keyboard${keymap:+:$keymap}${target:+:$target}"