Improve output from make/cmake wrapper

Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
This commit is contained in:
Dave Rodgman 2024-02-15 14:39:48 +00:00
parent 0fa6b36257
commit 90dbba5385
2 changed files with 44 additions and 6 deletions

View File

@ -18,13 +18,32 @@ TOOL=$(basename "$0")
# Locate original tool
ORIGINAL_TOOL=$(type -ap ${TOOL} | grep -v "$0" | head -n1 )
quote_args() {
# similar to printf '%q' "$@"
# but produce more human-readable results for common/simple cases like "a b"
local args=("$@")
s=""
for a in "${args[@]}"; do
simple_pattern='^[[:alnum:] _=+-]*$'
if [[ $a =~ ' ' && $a =~ $simple_pattern ]]; then
# a has spaces, but no other special characters that need escaping
# (quoting after removing spaces yields no backslashes)
# simplify quoted form to "$a" - e.g. yield "a b c" instead of a\ b\ c
q="\"$a\""
else
# get bash to do the quoting
q=$(printf '%q' "$a")
fi
s="$s $q"
done
echo $s
}
if [[ ! " $@ " =~ " --version " ]]; then
# Display the command being invoked - if it succeeds, this is all that will
# be displayed. Don't do this for invocations with --version, because
# this output is often parsed by scripts, so we don't want to modify it.
echo -n "${TOOL} "
printf '%q ' "$@"
echo
echo "${TOOL} $(quote_args "$@")"
fi
if [[ " $@ " =~ $NO_SILENCE || -n "${VERBOSE_LOGS}" ]]; then

View File

@ -18,13 +18,32 @@ TOOL=$(basename "$0")
# Locate original tool
ORIGINAL_TOOL=$(type -ap ${TOOL} | grep -v "$0" | head -n1 )
quote_args() {
# similar to printf '%q' "$@"
# but produce more human-readable results for common/simple cases like "a b"
local args=("$@")
s=""
for a in "${args[@]}"; do
simple_pattern='^[[:alnum:] _=+-]*$'
if [[ $a =~ ' ' && $a =~ $simple_pattern ]]; then
# a has spaces, but no other special characters that need escaping
# (quoting after removing spaces yields no backslashes)
# simplify quoted form to "$a" - e.g. yield "a b c" instead of a\ b\ c
q="\"$a\""
else
# get bash to do the quoting
q=$(printf '%q' "$a")
fi
s="$s $q"
done
echo $s
}
if [[ ! " $@ " =~ " --version " ]]; then
# Display the command being invoked - if it succeeds, this is all that will
# be displayed. Don't do this for invocations with --version, because
# this output is often parsed by scripts, so we don't want to modify it.
echo -n "${TOOL} "
printf '%q ' "$@"
echo
echo "${TOOL} $(quote_args "$@")"
fi
if [[ " $@ " =~ $NO_SILENCE || -n "${VERBOSE_LOGS}" ]]; then