config/functions: add build message printf helpers

Signed-off-by: Ian Leonard <antonlacon@gmail.com>
This commit is contained in:
Ian Leonard 2018-11-17 05:44:38 +00:00
parent 4ad81f9999
commit b8e57d9dfe

View File

@ -85,6 +85,23 @@ print_color() {
fi
}
# print build progress messages
# param1: message color, p2: label, p3: text, p4: indent (optional)
build_msg() {
if [ -n "${3}" ]; then
printf "%${BUILD_INDENT}c$(print_color "${1}" "${2}") ${3}\n" ' '>&${SILENT_OUT}
else
printf "%${BUILD_INDENT}c$(print_color "${1}" "${2}")\n" ' '>&${SILENT_OUT}
fi
# pad left space to create "indent" effect
if [ "${4}" = "indent" ]; then
export BUILD_INDENT=$((${BUILD_INDENT:-0}+${BUILD_INDENT_SIZE}))
elif [ -n "${4}" ]; then
die "ERROR: ${0} unexpected parameter: ${4}"
fi
}
### BUILDSYSTEM HELPERS ###
# check if a flag is enabled