Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
22 changes: 14 additions & 8 deletions scripts/all-core.sh
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,8 @@ setup_quiet_wrappers()
# Note that the cmake wrapper breaks unless we use an absolute path here.
if [[ -e ${PWD}/framework/scripts/quiet ]]; then
export PATH=${PWD}/framework/scripts/quiet:$PATH
# pass on our own QUIET setting to the wrappers
export QUIET
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd prefer to avoid environment variable names that are too generic. Can we use MBEDTLS_QUIET here? (Just as the environment variable, not as the name inside the script.) Or would that be too confusing if we have two names and too much work if we rename it everywhere?

fi
}

Expand Down Expand Up @@ -661,10 +663,18 @@ pre_restore_files () {
# the ones checked into git, take care not to modify them. Whatever
# this function leaves behind is what the script will restore before
# each component.
case "$(head -n1 Makefile)" in
if ! in_mbedtls_repo; then
return
fi
local makefiles="library/Makefile programs/Makefile programs/fuzz/Makefile tests/Makefile"
Copy link
Contributor

Choose a reason for hiding this comment

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

Partly preexisting: how about $(git ls-files Makefile '**/Makefile')? That would be more future proof for when we finish removing the makefiles (although I suspect it'll take longer than what some people are hoping).

if in_3_6_branch; then
makefiles="Makefile $makefiles"
fi
# No root Makefile in development, use the one in library
case "$(head -n1 library/Makefile)" in
*[Gg]enerated*)
git update-index --no-skip-worktree Makefile library/Makefile programs/Makefile tests/Makefile programs/fuzz/Makefile
git checkout -- Makefile library/Makefile programs/Makefile tests/Makefile programs/fuzz/Makefile
git update-index --no-skip-worktree $makefiles
git checkout -- $makefiles
;;
esac
}
Expand Down Expand Up @@ -887,11 +897,7 @@ pre_generate_files() {
# since make doesn't have proper dependencies, remove any possibly outdate
# file that might be around before generating fresh ones
$MAKE_COMMAND neat
if [ $QUIET -eq 1 ]; then
$MAKE_COMMAND generated_files >/dev/null
else
$MAKE_COMMAND generated_files
fi
$MAKE_COMMAND generated_files
}

pre_load_helpers () {
Expand Down
39 changes: 33 additions & 6 deletions scripts/check_names.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,16 @@
from mbedtls_framework import build_tree


class MaxLevelFilter(logging.Filter):
"""Allow records with level <= max_level."""
def __init__(self, max_level):
super().__init__()
self.max_level = max_level

def filter(self, record):
return record.levelno <= self.max_level


# Naming patterns to check against. These are defined outside the NameCheck
# class for ease of modification.
PUBLIC_MACRO_PATTERN = r"^(MBEDTLS|PSA|TF_PSA_CRYPTO)_[0-9A-Z_]*[0-9A-Z]$"
Expand Down Expand Up @@ -791,11 +801,13 @@ def parse_symbols(self):
source_dir = os.getcwd()
build_dir = tempfile.mkdtemp()
os.chdir(build_dir)
subprocess.run(
result = subprocess.run(
Copy link
Contributor

Choose a reason for hiding this comment

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

Partly preexisting: it would be more robust to use subprocess.check_output (formerly check_call).

["cmake", "-DGEN_FILES=ON", source_dir],
universal_newlines=True,
stdout=subprocess.PIPE,
check=True
)
self.log.debug(result.stdout)
subprocess.run(
["cmake", "--build", "."],
env=my_environment,
Expand All @@ -813,7 +825,7 @@ def parse_symbols(self):
os.chdir(source_dir)
shutil.rmtree(build_dir)
except subprocess.CalledProcessError as error:
self.log.debug(error.output)
self.log.error(error.output)
raise error
finally:
# Put back the original config regardless of there being errors.
Expand Down Expand Up @@ -962,11 +974,13 @@ def parse_symbols(self):
source_dir = os.getcwd()
build_dir = tempfile.mkdtemp()
os.chdir(build_dir)
subprocess.run(
result = subprocess.run(
["cmake", "-DGEN_FILES=ON", source_dir],
universal_newlines=True,
stdout=subprocess.PIPE,
check=True
)
self.log.debug(result.stdout)
subprocess.run(
["cmake", "--build", "."],
env=my_environment,
Expand Down Expand Up @@ -1178,15 +1192,28 @@ def main():
parser.add_argument(
"-q", "--quiet",
action="store_true",
help="hide unnecessary text, explanations, and highlights"
help="only print warnings and errors"
)

args = parser.parse_args()

# Configure the global logger, which is then passed to the classes below
log = logging.getLogger()
log.setLevel(logging.DEBUG if args.verbose else logging.INFO)
log.addHandler(logging.StreamHandler())
log.setLevel(logging.DEBUG if args.verbose else
logging.INFO if not args.quiet else
logging.WARN)

# stdout handler: DEBUG/INFO only
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not send everything to stderr? That's the normal place for informational messages, as opposed to application data which goes to stdout. Separating two logging streams also creates the risk that they'll end up displayed out of order due to buffering (which I think doesn't happen on Jenkins, it did happen on Travis).

h_out = logging.StreamHandler(sys.stdout)
h_out.setLevel(logging.DEBUG)
h_out.addFilter(MaxLevelFilter(logging.INFO))

# stderr handler: WARNING and above
h_err = logging.StreamHandler(sys.stderr)
h_err.setLevel(logging.WARNING)

log.addHandler(h_out)
log.addHandler(h_err)

try:
if build_tree.looks_like_tf_psa_crypto_root(os.getcwd()):
Expand Down
7 changes: 6 additions & 1 deletion scripts/quiet/quiet.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@
# NO_SILENCE - a regex that describes the commandline arguments for which output will not
# be silenced, e.g. " --version | test ". In this example, "make lib test" will
# not be silent, but "make lib" will be.
#
# It optionally uses the following variable:
#
# QUIET - if set to a non-zero value, don't even print the command being invoked
: ${QUIET:=0}

# Identify path to original tool. There is an edge-case here where the quiet wrapper is on the path via
# a symlink or relative path, but "type -ap" yields the wrapper with it's normalised path. We use
Expand Down Expand Up @@ -48,7 +53,7 @@ print_quoted_args() {
done
}

if [[ ! " $* " =~ " --version " ]]; then
if [[ ! " $* " =~ " --version " ]] && [[ "$QUIET" -eq "0" ]]; 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.
Expand Down