Skip to content
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

dist/tools: add build system sanity check script #10179

Merged
Merged
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
62 changes: 62 additions & 0 deletions dist/tools/buildsystem_sanity_check/check.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#!/usr/bin/env bash
#
# Copyright (C) 2018 Gaëtan Harter <[email protected]>
#
# This file is subject to the terms and conditions of the GNU Lesser
# General Public License v2.1. See the file LICENSE in the top level
# directory for more details.
#

#
# Central test script to have sanity checks for the build system
# It is run unconditionally on all files.
#
#

: "${RIOTBASE:="$(cd "$(dirname "$0")/../../../" || exit; pwd)"}"
jcarrano marked this conversation as resolved.
Show resolved Hide resolved

SCRIPT_PATH=dist/tools/buildsystem_sanity_check/check.sh
jcarrano marked this conversation as resolved.
Show resolved Hide resolved

# Modules should not check the content of FEATURES_PROVIDED/_REQUIRED/OPTIONAL
# Handling specific behaviors/dependencies should by checking the content of:
# * `USEMODULE`
# * maybe `FEATURES_USED` if it is not a module (== not a periph_)
check_not_parsing_features() {
local patterns=()
local pathspec=()

patterns+=(-e 'if.*filter.*FEATURES_PROVIDED')
jcarrano marked this conversation as resolved.
Show resolved Hide resolved
patterns+=(-e 'if.*filter.*FEATURES_REQUIRED')
patterns+=(-e 'if.*filter.*FEATURES_OPTIONAL')

# Pathspec with exclude should start by an inclusive pathspec in git 2.7.4
pathspec+=('*')

# Ignore this file when matching as it self matches
pathspec+=(":!${SCRIPT_PATH}")

# These two files contain sanity checks using FEATURES_ so are allowed
pathspec+=(':!Makefile.include' ':!makefiles/info-global.inc.mk')

git -C "${RIOTBASE}" grep "${patterns[@]}" -- "${pathspec[@]}"
}


main() {
local errors=''

errors+="$(check_not_parsing_features)"

if [ -n "${errors}" ]
then
printf 'Invalid build system patterns found by %s:\n' "${0}"
printf '%s\n' "${errors}"
exit 1
fi
exit 0
}


if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
main
fi