diff options
author | Michał Barnaś <mb@semihalf.com> | 2021-11-05 18:59:19 +0100 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-11-12 12:09:01 +0000 |
commit | 132f6bbe6c93374efe408f64d09132d51d3dc69d (patch) | |
tree | a98e1db4db88749a1828d0ae4fdbf6a71a103170 | |
parent | c31b47cde029a18873b5147be1a4bbfb837bfbc1 (diff) | |
download | chrome-ec-132f6bbe6c93374efe408f64d09132d51d3dc69d.tar.gz |
build: add option to disable -Werror flag
This commit adds possibility to disable treating warnings as errors.
In CrOS EC, define NO_ERRORS=1 as make parameter.
In Zephyr, use --no-errors flag when configuring using zmake.
BRANCH=main
BUG=b:197888003
TEST=Add unused static function.
Build without flags, compilation should fail.
Build with no-errors flags, only warning should be visible.
Change-Id: I7f873b7530317b74ff2865f420c4c248b4a95360
Signed-off-by: Michał Barnaś <mb@semihalf.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3264191
Reviewed-by: Keith Short <keithshort@chromium.org>
Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
-rw-r--r-- | Makefile.toolchain | 6 | ||||
-rw-r--r-- | zephyr/CMakeLists.txt | 5 | ||||
-rw-r--r-- | zephyr/zmake/zmake/__main__.py | 6 | ||||
-rw-r--r-- | zephyr/zmake/zmake/zmake.py | 7 |
4 files changed, 22 insertions, 2 deletions
diff --git a/Makefile.toolchain b/Makefile.toolchain index a79f248ea2..a56193201a 100644 --- a/Makefile.toolchain +++ b/Makefile.toolchain @@ -59,15 +59,19 @@ GCOV=$(CROSS_COMPILE)gcov HOSTGCOV=$(CURDIR)/util/llvm-gcov.sh C_WARN = -Wstrict-prototypes -Wdeclaration-after-statement -Wno-pointer-sign -COMMON_WARN = -Wall -Wundef -Werror -Werror-implicit-function-declaration \ +COMMON_WARN = -Wall -Wundef -Werror-implicit-function-declaration \ -Wno-trigraphs -Wno-format-security -Wno-address-of-packed-member \ -fno-common -fno-strict-aliasing -fno-strict-overflow + +ifndef ALLOW_WARNINGS +COMMON_WARN+=-Werror ifeq ($(cc-name),clang) COMMON_WARN+=-Werror=uninitialized endif ifeq ($(cc-name),gcc) COMMON_WARN+=-Werror=maybe-uninitialized endif +endif ifeq ($(cc-name),clang) # TODO(b/172020503): Re-enabling this warning requires a large CL. diff --git a/zephyr/CMakeLists.txt b/zephyr/CMakeLists.txt index 0ff7f890be..a8b2168c79 100644 --- a/zephyr/CMakeLists.txt +++ b/zephyr/CMakeLists.txt @@ -40,7 +40,10 @@ if(DEFINED CONFIG_PLATFORM_EC) zephyr_compile_definitions("CONFIG_ZEPHYR") # Force compiler warnings to generate errors - zephyr_compile_options(-Werror) + option(ALLOW_WARNINGS "Do not treat warnings as errors") + if (NOT ALLOW_WARNINGS) + zephyr_compile_options(-Werror) + endif() include(fpu.cmake) diff --git a/zephyr/zmake/zmake/__main__.py b/zephyr/zmake/zmake/__main__.py index ad4a7d96f0..f776c1dbaa 100644 --- a/zephyr/zmake/zmake/__main__.py +++ b/zephyr/zmake/zmake/__main__.py @@ -184,6 +184,12 @@ def main(argv=None): help="Enable bringup debugging features", ) configure.add_argument( + "--allow-warnings", + action="store_true", + default=False, + help="Do not treat warnings as errors", + ) + configure.add_argument( "-B", "--build-dir", type=pathlib.Path, help="Build directory" ) configure.add_argument( diff --git a/zephyr/zmake/zmake/zmake.py b/zephyr/zmake/zmake/zmake.py index c924196caa..a5c3cb62a5 100644 --- a/zephyr/zmake/zmake/zmake.py +++ b/zephyr/zmake/zmake/zmake.py @@ -214,6 +214,7 @@ class Zmake: test_after_configure=False, bringup=False, coverage=False, + allow_warnings=False, ): """Locate a project by name or directory and then call _configure.""" root_dir = pathlib.Path(project_name_or_dir) @@ -238,6 +239,7 @@ class Zmake: test_after_configure=test_after_configure, bringup=bringup, coverage=coverage, + allow_warnings=allow_warnings, ) def _configure( @@ -250,6 +252,7 @@ class Zmake: test_after_configure=False, bringup=False, coverage=False, + allow_warnings=False, ): """Set up a build directory to later be built by "zmake build".""" supported_version = util.parse_zephyr_version(project.config.zephyr_version) @@ -319,6 +322,10 @@ class Zmake: base_config |= zmake.build_config.BuildConfig( kconfig_defs={"CONFIG_COVERAGE": "y"} ) + if allow_warnings: + base_config |= zmake.build_config.BuildConfig( + cmake_defs={"ALLOW_WARNINGS": "ON"} + ) if not build_dir.exists(): build_dir = build_dir.mkdir() |