From 373e7cae62e21b8626953efb36048555bc472a18 Mon Sep 17 00:00:00 2001 From: Alex Stewart Date: Tue, 5 Apr 2016 16:45:36 -0700 Subject: [PATCH 1/3] Add WARNINGS_AS_ERRORS make flag Previous behavior was all warnings were treated as errors. This is now controllable via a make variable and defaults to off (but can be turned on in local.mk for those who still want the old behavior) --- common.mk | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/common.mk b/common.mk index 4e8ee3a..8da70cd 100644 --- a/common.mk +++ b/common.mk @@ -106,8 +106,14 @@ ENTRY_SYMBOL ?= call_user_start # but compiled code size will come down a small amount.) SPLIT_SECTIONS ?= 1 +# Set this to 1 to have all compiler warnings treated as errors (and stop the +# build). This is recommended whenever you are working on code which will be +# submitted back to the main project, as all submitted code will be expected to +# compile without warnings to be accepted. +WARNINGS_AS_ERRORS ?= 0 + # Common flags for both C & C++_ -C_CXX_FLAGS ?= -Wall -Werror -Wl,-EL -nostdlib $(EXTRA_C_CXX_FLAGS) +C_CXX_FLAGS ?= -Wall -Wl,-EL -nostdlib $(EXTRA_C_CXX_FLAGS) # Flags for C only CFLAGS ?= $(C_CXX_FLAGS) -std=gnu99 $(EXTRA_CFLAGS) # Flags for C++ only @@ -118,6 +124,10 @@ CPPFLAGS += -mlongcalls -mtext-section-literals LDFLAGS = -nostdlib -Wl,--no-check-sections -L$(BUILD_DIR)sdklib -L$(ROOT)lib -u $(ENTRY_SYMBOL) -Wl,-static -Wl,-Map=$(BUILD_DIR)$(PROGRAM).map $(EXTRA_LDFLAGS) +ifeq ($(WARNINGS_AS_ERRORS),1) + C_CXX_FLAGS += -Werror +endif + ifeq ($(SPLIT_SECTIONS),1) C_CXX_FLAGS += -ffunction-sections -fdata-sections LDFLAGS += -Wl,-gc-sections From fa6dd229574af53b8bfe54a3ac748d52fb827661 Mon Sep 17 00:00:00 2001 From: Alex Stewart Date: Wed, 6 Apr 2016 11:06:11 -0700 Subject: [PATCH 2/3] Add WARNINGS_AS_ERRORS=1 to Travis build config --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index b22d9bb..629a359 100644 --- a/.travis.yml +++ b/.travis.yml @@ -58,4 +58,4 @@ script: - cd ${TRAVIS_BUILD_DIR} # Remove ssid_config requirement for examples - sed -i "s%#warning%//#warning%" include/ssid_config.h - - make -C examples/ build-examples CROSS="ccache xtensa-lx106-elf-" V=1 + - make WARNINGS_AS_ERRORS=1 -C examples/ build-examples CROSS="ccache xtensa-lx106-elf-" V=1 From 5b16aa5ba47efc9102718a8333b3f90a52e80707 Mon Sep 17 00:00:00 2001 From: Alex Stewart Date: Wed, 6 Apr 2016 11:42:58 -0700 Subject: [PATCH 3/3] Change #warning to #error in ssid_config.h --- .travis.yml | 2 +- include/ssid_config.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 629a359..bc4a117 100644 --- a/.travis.yml +++ b/.travis.yml @@ -57,5 +57,5 @@ before_install: script: - cd ${TRAVIS_BUILD_DIR} # Remove ssid_config requirement for examples - - sed -i "s%#warning%//#warning%" include/ssid_config.h + - sed -i "s%#error%//#error%" include/ssid_config.h - make WARNINGS_AS_ERRORS=1 -C examples/ build-examples CROSS="ccache xtensa-lx106-elf-" V=1 diff --git a/include/ssid_config.h b/include/ssid_config.h index edad5a9..a13e09a 100644 --- a/include/ssid_config.h +++ b/include/ssid_config.h @@ -20,7 +20,7 @@ // https://www.kernel.org/pub/software/scm/git/docs/git-update-index.html // -#warning "You need to enter your wifi credentials in this file and follow the instructions here to keep the password safe from Github commits." +#error "You need to enter your wifi credentials in this file and follow the instructions here to keep the password safe from Github commits." #ifndef __SSID_CONFIG_H__ #define __SSID_CONFIG_H__