Skip to content

Commit

Permalink
Add a help for the build subcommand with advanced options; add option…
Browse files Browse the repository at this point in the history
…al argument to show summary of successful builds
  • Loading branch information
SiteRelEnby committed Apr 29, 2024
1 parent 37953d2 commit 67ec848
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 4 deletions.
49 changes: 45 additions & 4 deletions bin/build-all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,36 @@ if [ "${DEBUG}" == "1" ]; then
export DEBUG
fi

# trap ^C to show the build summary on aborted builds, if we got that far
function ctrlc(){
# output the build summary if the build was cancelled but a build was attempted beforehand
if [ "$PASS" -gt 0 ] || [ "$FAIL" -gt 0 ]
then
echo #push a new line below the ^C char for neatness
build_summary
exit 1
else
exit 1
fi
}

trap ctrlc INT

function build_help(){
cat << ENDOFHELP
Advanced build options:
--build-help Show this help text
--user USER Load user's custom configuration from users/USER
--no-user Do not load any custom user configuration; build default targets only
--debug Enable script debug output
--save-cpp Save the intermediate .cpp source file (usually for debugging preprocessor macros)
--show-passed Output a list of successful builds, in addition to any failed
ENDOFHELP
exit 2
}

USER_CONFIGS=()
POSITIONAL=()
while [ "${#}" -gt "0" ]
Expand Down Expand Up @@ -62,6 +92,13 @@ do
then
# save the rendered .cpp, e.g. for preprocessor debugging
export SAVE_CPP=1
elif [[ "${1}" == "--show-passed" ]]
then
#enable output of list of passed builds
export SHOW_PASSED=1
elif [[ "${1}" == "--build-help" ]]
then
build_help
else
# Store var in a temporary array to restore after we've finished parsing for builder-specific args
POSITIONAL+=("$1")
Expand Down Expand Up @@ -115,13 +152,13 @@ function search_build_targets {
for TARGET in hw/*/*/**/"$UI".h ; do

# friendly name for this build
NAME=$(echo "$TARGET" | perl -ne 's|/|-|g; /hw-(.*)-'"$UI"'.h/ && print "$1\n";')
NAME=$(perl -ne 's|/|-|g; /hw-(.*)-'"$UI"'.h/ && print "$1\n";' <<< "$TARGET")

# limit builds to searched patterns, if given
SKIP=0
if [ ${#SEARCH[@]} -gt 0 ]; then
for text in "${SEARCH[@]}" ; do
if ! echo "$NAME $TARGET" | grep -i -- "$text" > /dev/null ; then
if ! grep -i -- "$text" <<< "$NAME $TARGET" > /dev/null ; then
SKIP=1
fi
done
Expand Down Expand Up @@ -198,11 +235,15 @@ function main {

search_build_targets

build_summary
}

function build_summary(){
# summary
echo "===== $PASS builds succeeded, $FAIL failed ====="
#echo "PASS: $PASSED"
[ -n "${SHOW_PASSED}" ] && echo "PASS: $PASSED"
if [ 0 != $FAIL ]; then
echo "FAIL:$FAILED"
echo "FAIL: $FAILED"
exit 1
fi
}
Expand Down
5 changes: 5 additions & 0 deletions make
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ Usage: ./make TASK
... where TASK is:
help Show this help text
build-help Show help for advanced build options
(nothing) Compile all build targets
flash FILE Flash firmare FILE to a hardware device
clean Delete generated files
Expand Down Expand Up @@ -59,6 +60,10 @@ function main() {
-h|--help|help|/\?|/h|/help)
help
;;
build-help|--build-help)
set -- "--build-help"
shift # past arg
;;
clean)
echo 'rm -vf -- **/*~ hex/*.hex ui/**/*.elf ui/**/*.o ui/**/*.cpp'
rm -vf -- **/*~ hex/*.hex ui/**/*.elf ui/**/*.o ui/**/*.cpp
Expand Down

0 comments on commit 67ec848

Please sign in to comment.