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.

40 lines
1.1 KiB

  1. #!/usr/bin/env bash
  2. # This script finds all rules.mk files in keyboards/ subdirectories,
  3. # and deletes the build option filesize impacts from them.
  4. # Print an error message with the word "ERROR" in red.
  5. echo_error() {
  6. echo -e "[\033[0;91mERROR\033[m]: $1"
  7. }
  8. # If we've been started from util/, we want to be in qmk_firmware/
  9. [[ "$PWD" == *util ]] && cd ..
  10. # The root qmk_firmware/ directory should have a subdirectory called quantum/
  11. if [ ! -d "quantum" ]; then
  12. echo_error "Could not detect the QMK firmware directory!"
  13. echo_error "Are you sure you're in the right place?"
  14. exit 1
  15. fi
  16. # Set the inplace editing parameter for sed.
  17. # macOS/BSD sed expects a file extension immediately following -i.
  18. set_sed_i() {
  19. sed_i=(-i)
  20. case $(uname -a) in
  21. *Darwin*) sed_i=(-i "")
  22. esac
  23. }
  24. set_sed_i
  25. # Exclude keyamps/ directories
  26. files=$(find keyboards -type f -name 'rules.mk' -not \( -path '*/keymaps*' -prune \))
  27. # Edit rules.mk files
  28. for file in $files; do
  29. sed "${sed_i[@]}" -e "s/(+[0-9].*)$//g" "$file"
  30. done
  31. echo "Cleaned up rules.mk files."