mirror of
https://github.com/qmk/qmk_firmware.git
synced 2025-07-16 12:51:47 +00:00
Add rules.mk cleaning script
This commit is contained in:
parent
b7c22af1f6
commit
3372a9e806
34
util/rules_cleaner.sh
Normal file
34
util/rules_cleaner.sh
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# This script finds all rules.mk files in keyboards/ subdirectories,
|
||||||
|
# and deletes the build option filesize impacts from them.
|
||||||
|
|
||||||
|
# Print an error message with the word "ERROR" in red.
|
||||||
|
echo_error() {
|
||||||
|
echo -e "[\033[0;91mERROR\033[m]: $1"
|
||||||
|
}
|
||||||
|
|
||||||
|
# If we've been started from util/, we want to be in qmk_firmware/
|
||||||
|
[[ "$PWD" == *util ]] && cd ..
|
||||||
|
|
||||||
|
# The root qmk_firmware/ directory should have a subdirectory called quantum/
|
||||||
|
if [ ! -d "quantum" ]; then
|
||||||
|
echo_error "Could not detect the QMK firmware directory!"
|
||||||
|
echo_error "Are you sure you're in the right place?"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Set the inplace editing parameter for sed.
|
||||||
|
# macOS/BSD sed expects a file extension immediately following -i.
|
||||||
|
set_sed_i() {
|
||||||
|
sed_i=(-i)
|
||||||
|
|
||||||
|
case $(uname -a) in
|
||||||
|
*Darwin*) sed_i=(-i "")
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
set_sed_i
|
||||||
|
find keyboards -type f -name 'rules.mk' -exec sed "${sed_i[@]}" -e "s/(.*)$/""/g" {} +
|
||||||
|
|
||||||
|
echo "Cleaned up rules.mk files."
|
Loading…
Reference in New Issue
Block a user