per1234 / arduino-ci-script

Bash script for continuous integration of Arduino projects
MIT License
24 stars 7 forks source link

Add a set_fail_on_compiler_warning function #12

Open per1234 opened 7 years ago

per1234 commented 7 years ago

Setting this to true will cause the build to fail if any sketch build causes a compiler warning.

Due to warnings caused by external dependencies such as libraries or hardware core files, it is not always possible for a project to be completely free from warnings but when this is possible it's useful to be able to enforce a zero warnings policy.

The cleanest way to achieve this is to simply set -Werror=all via compiler.cpp.extra_flags and compiler.c.extra_flags properties. This is dependent on the hardware package correctly implementing the extra_flags properties. This will NOT catch warnings generated by the preprocessor such as via the #warning directive or:

#define FOO-BAR
warning: ISO C++11 requires whitespace after the macro name

The other option is to simply use the script's warning count. This a bit more fragile since it relies on parsing the compiler output and thus does have the potential for false positives or false negatives.

The benefit of this option is I could set a maximum warning count so that you can still use the function when there are some warnings that can't be fixed (e.g., they're caused by external code).