1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-12-16 10:03:50 +01:00

dist/tools/insufficient_memory: Improve and clean up script

- drop all bash specifics and use generic sh
- fix all shellcheck warnings
- use nproc instead of hard-coded `-j4`
- print output on (real) compilation error
This commit is contained in:
Marian Buschsieweke 2023-02-21 12:07:02 +01:00
parent be29a00d74
commit f7b032e444
No known key found for this signature in database
GPG Key ID: CB8E3238CE715A94

View File

@ -1,4 +1,4 @@
#!/usr/bin/env bash #!/usr/bin/env sh
# #
# Copyright (C) 2019 Benjamin Valentin <benjamin.valentin@ml-pa.com> # Copyright (C) 2019 Benjamin Valentin <benjamin.valentin@ml-pa.com>
# #
@ -7,14 +7,16 @@
# directory for more details. # directory for more details.
# #
MAKE_ARGS="-j4" if nproc > /dev/null 2>&1; then
MAKE_ARGS="-j$(nproc)"
fi
if [ -z $1 ]; then if [ -z "$1" ]; then
echo "usage: $0 <board>" echo "usage: $0 <board>"
exit 1 exit 1
fi fi
if tput colors &> /dev/null && [ $(tput colors) -ge 8 ]; then if tput colors > /dev/null 2>&1 && [ "$(tput colors)" -ge 8 ]; then
COK="\e[1;32m" COK="\e[1;32m"
CBIG="\e[1;34m" CBIG="\e[1;34m"
CNORMAL="\e[1m" CNORMAL="\e[1m"
@ -32,38 +34,41 @@ else
CRESET= CRESET=
fi fi
if [ "$1" == "--no-docker" ]; then if [ "$1" = "--no-docker" ]; then
LOCAL_MAKE_ARGS=${MAKE_ARGS} LOCAL_MAKE_ARGS=${MAKE_ARGS}
shift 1 shift 1
else else
# Use a standardized build within Docker and with minimal output # Use a standardized build within Docker and with minimal output
export DOCKER_MAKE_ARGS=${MAKE_ARGS} export DOCKER_MAKE_ARGS="${MAKE_ARGS}"
export BUILD_IN_DOCKER=1 export BUILD_IN_DOCKER=1
fi fi
export RIOT_CI_BUILD=1 export RIOT_CI_BUILD=1
BOARD=$1 BOARD=$1
RIOTBASE=$(dirname $0)/../../.. RIOTBASE="$(dirname "$0")/../../.."
APPLICATIONS+=examples/*/Makefile APPLICATIONS="$APPLICATIONS examples/*/Makefile"
APPLICATIONS+=" " APPLICATIONS="$APPLICATIONS tests/*/Makefile"
APPLICATIONS+=tests/*/Makefile TMPFILE="$(mktemp)"
for app in ${APPLICATIONS}; do for app in ${APPLICATIONS}; do
application=$(dirname ${app}) application="$(dirname "${app}")"
printf "${CNORMAL}%-40s${CRESET}" ${application} printf "${CNORMAL}%-40s${CRESET}" "${application}"
output=$(make BOARD=${BOARD} ${LOCAL_MAKE_ARGS} -C ${RIOTBASE}/${application} 2>&1) # disable warning about globbing and word splitting for ${LOCAL_MAKE_ARGS}
if [ $? != 0 ]; then # as this is exactly what we want here
if echo ${output} | grep -e overflowed -e "not within region" > /dev/null; then # shellcheck disable=SC2086
if ! make BOARD="${BOARD}" ${LOCAL_MAKE_ARGS} -C "${RIOTBASE}/${application}" > "$TMPFILE" 2>&1; then
if grep -e overflowed -e "not within region" "$TMPFILE" > /dev/null; then
printf "${CBIG}%s${CRESET}\n" "too big" printf "${CBIG}%s${CRESET}\n" "too big"
make -f $(dirname $0)/Makefile.for_sh DIR=${RIOTBASE}/${application} BOARD=${BOARD} Makefile.ci > /dev/null make -f "$(dirname "$0")"/Makefile.for_sh DIR="${RIOTBASE}/${application}" BOARD="${BOARD}" Makefile.ci > /dev/null
elif echo ${output} | grep -e "not whitelisted" -e "unsatisfied feature requirements" > /dev/null; then elif grep -e "not whitelisted" -e "unsatisfied feature requirements" "$TMPFILE" > /dev/null; then
printf "${CWARN}%s${CRESET}\n" "not supported" printf "${CWARN}%s${CRESET}\n" "not supported"
else else
printf "${CERROR}%s${CRESET}\n" "build failed" printf "${CERROR}%s${CRESET}\n" "build failed"
cat "$TMPFILE"
fi fi
else else
if echo ${output} | grep -e "skipping link step" > /dev/null; then if grep -e "skipping link step" "$TMPFILE" > /dev/null; then
printf "${CSKIP}%s${CRESET}\n" "skipped" printf "${CSKIP}%s${CRESET}\n" "skipped"
else else
printf "${COK}%s${CRESET}\n" "OK" printf "${COK}%s${CRESET}\n" "OK"