Skip to content

Log build steps in the outcome file #129

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions scripts/all-core.sh
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,9 @@ pre_initialize_variables () {
# Specify character collation for regular expressions and sorting with C locale
export LC_COLLATE=C

# Make the location of the root directory available to reporting scripts
export MBEDTLS_TEST_ROOT="$PWD"

: ${MBEDTLS_TEST_OUTCOME_FILE=}
: ${MBEDTLS_TEST_PLATFORM="$(uname -s | tr -c \\n0-9A-Za-z _)-$(uname -m | tr -c \\n0-9A-Za-z _)"}
export MBEDTLS_TEST_OUTCOME_FILE
Expand Down
37 changes: 33 additions & 4 deletions scripts/quiet/make
Original file line number Diff line number Diff line change
Expand Up @@ -20,31 +20,60 @@ TOOL="make"
EXIT_STATUS=$?

log_outcome () {
# Options passed to make indicating that a different makefile is used
modifier=
# Space-separated list of targets
targets=
# Temporary variable used in the loop after an option that takes an argument
skip=

for arg in "$@"; do
if [ -n "$skip" ]; then
if [ "$skip" = "modifier" ]; then
modifier="$modifier$arg "
fi
skip=
continue
fi

case $arg in
--question|-q) # do-nothing option
--dry-run|--help|--just-print|--question|--recon|--version|-n|-q|-v)
# do-nothing option
return;;
--assume-new|--assume-old|--directory|--file| \
--directory=*|--file=*|-C?*|-f?*) # Modifier option with its argument
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are both "--directory=somedir" and "--directory somedir" required?

For example would passing "--directory" and nothing else assert skip=1?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With --directory=..., we want to remember the option and move on to the next argument which is another option or a non-option argument. With --directory, we want to skip the next argument, which is the argument of the --directory option.

make --directory is invalid. I don't know what the code here does in this case, but I don't think this wrapper needs to care about invalid usage of make.

modifier="$modifier$arg ";;
--directory|--file|-C|-f) # Modifier option with separate argument
skip=modifier
modifier="$modifier$arg ";;
--assume-new|--assume-old| \
--include-dir|--makefile|--new-file|--old-file|--what-if| \
-C|-I|-W|-f|-k|-o) # Option with separate argument
-I|-W|-k|-o) # Boring option with separate argument
skip=1; continue;;
-*) continue;; # Option
-*) continue;; # Other option (assumed boring)
*=*) continue;; # Variable assignment
*[!-+./0-9@A-Z_a-z]*) # Target with problematic character
targets="$targets ${arg%%[!-+./0-9@A-Z_a-z]*}...";;
*) # Normal target
targets="$targets $arg";;
esac
done

if [ -n "$MBEDTLS_TEST_ROOT" ] && [ "$MBEDTLS_TEST_ROOT" != "$PWD" ]; then
# Record that `make` was run in a different directory.
# This is only accurate when run by all.sh (or more generally
# if $MBEDTLS_TEST_ROOT is set in the environment).
case "$PWD" in
"$MBEDTLS_TEST_ROOT/"*) modifier="-C ${PWD#"${MBEDTLS_TEST_ROOT}/"} $modifier";;
*) modifier="-C $PWD $modifier";;
esac
fi

if [ -n "$targets" ]; then
targets=${targets# }
else
# Assume that the default target is "all". This is true for
# the toplevel Makefile and when using CMake, but might not be
# true when using a different makefile.
targets=all
fi

Expand Down