MAKEALL: Fix return value
PATCH v2 1/1 MAKEALL: Fix return value
Previously MAKEALL would always return a value of 0, even if 1 or more boards did not compile. This change causes MAKEALL to return 0 if all boards were able to build, otherwise 1.
This change also requires changing the script interpreter from sh to bash to support bash's PIPESTATUS variable.
---
Changes since v1:
- Return only 0 or 1
Mike pointed out that if we want to maintain POSIX compliance we could replace the PIPESTATUS usage with:
# need to maintain exit value ourselves as pipes eat it
fail=${LOG_DIR}/$target.failed
rm -f ${fail}
(${MAKE} ${JOBS} all 2>&1 >${LOG_DIR}/$target.MAKELOG \
|| touch ${fail}) | tee ${LOG_DIR}/$target.ERR
[ -e ${fail} ] && RC=1
rm -f ${fail}Let me know if others prefer POSIX compliance over the more straight- forward PIPESATUS usage.
MAKEALL | 11 ++++++++++- 1 files changed, 10 insertions(+), 1 deletions(-)
MAKEALL +10 -1
@@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # Print statistics when we exit trap exit 1 2 3 15
@@ -39,6 +39,7 @@ LIST="" ERR_CNT=0 ERR_LIST="" TOTAL_CNT=0 +RC=0 ######################################################################### ## MPC5xx Systems
@@ -936,6 +937,12 @@ build_target() { ${MAKE} ${JOBS} all 2>&1 >${LOG_DIR}/$target.MAKELOG \ | tee ${LOG_DIR}/$target.ERR + + # Check for 'make' errors + if [ ${PIPESTATUS[0]} -ne 0 ] ; then + RC=1 + fi + if [ -s ${LOG_DIR}/$target.ERR ] ; then ERR_CNT=$((ERR_CNT + 1)) ERR_LIST="${ERR_LIST} $target"
@@ -959,6 +966,8 @@ print_stats() { echo "Boards with warnings or errors: ${ERR_CNT} (${ERR_LIST} )" fi echo "----------------------------------------------------------" + + exit $RC } #-----------------------------------------------------------------------
Signature · 1 line
1.6.2.1
Wolfgang Denk
AppliedPATCH v2 1/1 MAKEALL: Fix return value
Dear Peter Tyser,
Quoted 22 lines · In message <[email protected]> you wrote:
Previously MAKEALL would always return a value of 0, even if 1 or more boards did not compile. This change causes MAKEALL to return 0 if all boards were able to build, otherwise 1.
This change also requires changing the script interpreter from sh to bash to support bash's PIPESTATUS variable.
Signed-off-by Peter Tyser <[email protected]>---
Changes since v1:
- Return only 0 or 1Mike pointed out that if we want to maintain POSIX compliance we could replace the PIPESTATUS usage with:
# need to maintain exit value ourselves as pipes eat it fail=${LOG_DIR}/$target.failed rm -f ${fail} (${MAKE} ${JOBS} all 2>&1 >${LOG_DIR}/$target.MAKELOG \ || touch ${fail}) | tee ${LOG_DIR}/$target.ERR [ -e ${fail} ] && RC=1 rm -f ${fail}
Quoted 2 lines
Let me know if others prefer POSIX compliance over the more straight- forward PIPESATUS usage.
For me, bash is just fine here. Looks more readable and does without additional temp files.
Quoted 2 lines
MAKEALL | 11 ++++++++++- 1 files changed, 10 insertions(+), 1 deletions(-)
Applied, thanks.
Best regards,
Wolfgang Denk
Signature · 6 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de I will also, for an appropriate fee, certify that your keyboard is object-oriented, and that the bits on your hard disk are template- compatible. - Jeffrey S. Haemer in <[email protected]>