2021-05-20 02:14:20 +00:00
|
|
|
#!/bin/bash
|
|
|
|
set -e
|
|
|
|
|
|
|
|
# This script can be used when you want to test locally the amount of warnings produced by your changes before doing a PR.
|
|
|
|
|
2021-09-29 22:42:24 +00:00
|
|
|
# Terminal colour codes
|
|
|
|
# when $TERM is empty (non-interactive shell), then expand tput with '-T xterm-256color'
|
|
|
|
[[ ${TERM}=="" ]] && TPUTTERM='-T dumb' \
|
|
|
|
|| TPUTTERM=''
|
|
|
|
|
|
|
|
declare -r BOLD=`tput ${TPUTTERM} bold`
|
|
|
|
declare -r RED=`tput ${TPUTTERM} setaf 1`
|
|
|
|
declare -r PURPLE=`tput ${TPUTTERM} setaf 5`
|
|
|
|
declare -r WHITE=`tput ${TPUTTERM} setaf 7`
|
|
|
|
declare -r BLINK=`tput ${TPUTTERM} blink`
|
|
|
|
declare -r RST=`tput ${TPUTTERM} sgr0`
|
|
|
|
|
|
|
|
|
2021-05-20 02:14:20 +00:00
|
|
|
DIR="$(dirname "$(readlink -f "$0")")"
|
|
|
|
cd "$DIR/../.."
|
|
|
|
|
2021-09-29 22:42:24 +00:00
|
|
|
COMPARE_WARNINGS="$DIR/compare_warnings.sh"
|
|
|
|
|
|
|
|
usage () {
|
|
|
|
echo "Usage: $0 [-h] [-j jobs]"
|
|
|
|
}
|
|
|
|
|
|
|
|
show_help () {
|
|
|
|
usage
|
|
|
|
echo "
|
|
|
|
Check for new warnings created.
|
|
|
|
|
|
|
|
Optional arguments:
|
|
|
|
-h Display this message and exit.
|
2021-11-19 15:52:32 +00:00
|
|
|
-f Run full build process
|
2021-09-29 22:42:24 +00:00
|
|
|
-j N use N jobs (does not support plain -j because you shouldn't use it anyway)
|
|
|
|
"
|
|
|
|
}
|
|
|
|
|
|
|
|
jobs=1
|
2021-11-19 15:52:32 +00:00
|
|
|
full=
|
|
|
|
run="make clean
|
|
|
|
make uncompressed"
|
2021-09-29 22:42:24 +00:00
|
|
|
|
2021-11-19 15:52:32 +00:00
|
|
|
|
|
|
|
|
|
|
|
while getopts "hfj:" opt
|
2021-09-29 22:42:24 +00:00
|
|
|
do
|
|
|
|
case $opt in
|
|
|
|
h) show_help
|
|
|
|
exit 0
|
|
|
|
;;
|
2021-11-19 15:52:32 +00:00
|
|
|
f) full="true"
|
|
|
|
run="make distclean
|
|
|
|
make setup
|
|
|
|
make disasm
|
|
|
|
make all"
|
|
|
|
;;
|
2021-09-29 22:42:24 +00:00
|
|
|
j) j_option_arg="$OPTARG"
|
|
|
|
if [[ ! "${j_option_arg}" =~ ^[0-9]*$ ]]
|
|
|
|
then
|
|
|
|
echo "Error: Option '-j' expects numeric argument, you gave: ${j_option_arg}"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
jobs="$j_option_arg"
|
|
|
|
;;
|
|
|
|
?) usage
|
|
|
|
exit 2
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
shift $(($OPTIND - 1))
|
|
|
|
|
|
|
|
# Confirm run with -j jobs
|
|
|
|
echo "This will run
|
2021-11-19 15:52:32 +00:00
|
|
|
$run
|
2021-09-29 22:42:24 +00:00
|
|
|
using $jobs threads. This may take some time."
|
|
|
|
read -r -p "Is this okay? [Y/n]" response
|
|
|
|
response=${response,,} # tolower
|
|
|
|
if !([[ $response =~ ^(yes|y| ) ]] || [[ -z $response ]]); then
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
remove_ansi_codes () {
|
|
|
|
perl -pe '
|
|
|
|
s/\e\[[\x30-\x3f]*[\x20-\x2f]*[\x40-\x7e]//g;
|
|
|
|
s/\e[PX^_].*?\e\\//g;
|
|
|
|
s/\e\][^\a]*(?:\a|\e\\)//g;
|
|
|
|
s/\e[\[\]A-Z\\^_@]//g;' $1
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
make_warnings () {
|
|
|
|
make $1 -j$jobs 2> >(tee tools/warnings_count/warnings_temp.txt) \
|
|
|
|
&& remove_ansi_codes tools/warnings_count/warnings_temp.txt > tools/warnings_count/warnings_$2_new.txt \
|
|
|
|
&& rm tools/warnings_count/warnings_temp.txt
|
|
|
|
}
|
|
|
|
|
2021-11-19 15:52:32 +00:00
|
|
|
if [[ $full ]]; then
|
|
|
|
make distclean
|
|
|
|
make_warnings setup setup
|
|
|
|
make_warnings disasm disasm
|
|
|
|
make_warnings all build
|
|
|
|
else
|
|
|
|
make clean
|
|
|
|
make_warnings uncompressed build
|
|
|
|
fi
|
2021-09-29 22:42:24 +00:00
|
|
|
|
|
|
|
|
2021-11-19 15:52:32 +00:00
|
|
|
if [[ $full ]]; then
|
|
|
|
$COMPARE_WARNINGS setup
|
|
|
|
$COMPARE_WARNINGS disasm
|
|
|
|
fi
|
2021-09-29 22:42:24 +00:00
|
|
|
$COMPARE_WARNINGS build
|
2021-05-20 02:14:20 +00:00
|
|
|
|