Skip to content

Commit 407b88f

Browse files
committed
static-test: Check for Makefile.dep touching CFLAGS
The `Makefile.dep` are intended for dependency tracking only. Modifying CFLAGS as part of the dependency resolution process is just wrong. This extends the build system sanity check to prevent this kind of bug from sneaking in again.
1 parent 3327e2a commit 407b88f

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

  • dist/tools/buildsystem_sanity_check

dist/tools/buildsystem_sanity_check/check.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,18 @@ check_pinned_docker_version_is_up_to_date() {
402402
fi
403403
}
404404

405+
check_if_cflags_are_touched_at_right_place() {
406+
for file in $(git -C "${RIOTBASE}" grep -lE 'CFLAGS[\t ]*\+='); do
407+
case $file in
408+
*/Makefile.dep)
409+
# CFLAGS may not be touched in `Makefile.dep`
410+
git -C "${RIOTBASE}" grep -nE 'CFLAGS[\t ]*\+=' "$file" \
411+
| error_with_message "A Makefile.dep is for dependency modelling only. Modify CFLAGS in a Makefile.include, in an app's Makefile, or (if only relevant to a single module/package) in the module's/package's Makefile"
412+
;;
413+
esac
414+
done
415+
}
416+
405417
error_on_input() {
406418
! grep ''
407419
}
@@ -425,6 +437,7 @@ all_checks() {
425437
check_stderr_null
426438
check_tests_application_path
427439
check_pinned_docker_version_is_up_to_date
440+
check_if_cflags_are_touched_at_right_place
428441
}
429442

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

0 commit comments

Comments
 (0)