[ovs-dev] [PATCH] Makefiles: Fail build for flake8 only when configured with --enable-Werror.

Ben Pfaff blp at ovn.org
Thu Jul 6 22:12:00 UTC 2017


flake8 checking is useful.  Until now, it always failed the build for any
flake8 errors.  This is too aggressive, for the same reason that always
failing the build for any compiler warnings is too aggressive: compilers
change over time and asynchronously from OVS itself.  Thus, if we release
some version of OVS today, even if it's flake8-clean today, it might not
be flake8-clean tomorrow, even with the same settings.  We don't want to
have to track flake8 warnings on every release branch.

Thus, this adopts the same policy for compiler warnings: always report
them, but only fail the build if --enable-Werror was configured.  Usually
just developers use that configure option, and they're prepared to deal
with the fallout.

Signed-off-by: Ben Pfaff <blp at ovn.org>
---
 Makefile.am  |  2 +-
 acinclude.m4 | 11 ++++++++++-
 2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index d810a5e72c72..7e11e04ac748 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -365,7 +365,7 @@ ALL_LOCAL += flake8-check
 FLAKE8_SELECT = H231,H232,H233,H238
 FLAKE8_IGNORE = E121,E123,E125,E126,E127,E128,E129,E131,W503,F811,D,H,I
 flake8-check: $(FLAKE8_PYFILES)
-	$(AM_V_GEN) \
+	$(FLAKE8_WERROR)$(AM_V_GEN) \
 	  src='$^' && \
 	  flake8 $$src --select=$(FLAKE8_SELECT) $(FLAKE8_FLAGS) && \
 	  flake8 $$src --ignore=$(FLAKE8_IGNORE) $(FLAKE8_FLAGS) && \
diff --git a/acinclude.m4 b/acinclude.m4
index 7d7b6832bc2e..b8b43d9c377a 100644
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -23,7 +23,16 @@ AC_DEFUN([OVS_ENABLE_WERROR],
    AC_CONFIG_COMMANDS_PRE(
      [if test "X$enable_Werror" = Xyes; then
         OVS_CFLAGS="$OVS_CFLAGS -Werror"
-      fi])])
+      fi])
+
+   # Unless --enable-Werror is specified, report but do not fail the build
+   # for errors reported by flake8.
+   if test "X$enable_Werror" = Xyes; then
+     FLAKE8_WERROR=
+   else
+     FLAKE8_WERROR=-
+   fi
+   AC_SUBST([FLAKE8_WERROR])])
 
 dnl OVS_CHECK_LINUX
 dnl
-- 
2.10.2



More information about the dev mailing list