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