If flake8 is installed, run it at build time.  Similar to most Makefile
targets, run it once and then only run again if the files change.

flake8 is set to ignore all error and warning types that currently occur.
Future patches will remove items from the ignore list as they are
resolved.

Signed-off-by: Russell Bryant <russ...@ovn.org>
Acked-by: Ben Pfaff <b...@ovn.org>
---
 INSTALL.md            |  2 ++
 Makefile.am           |  7 +++++++
 configure.ac          |  1 +
 debian/automake.mk    |  3 +++
 m4/openvswitch.m4     | 12 ++++++++++++
 ofproto/automake.mk   |  2 ++
 python/automake.mk    |  7 +++++++
 tests/automake.mk     |  2 ++
 utilities/automake.mk |  2 ++
 vtep/automake.mk      |  2 ++
 xenserver/automake.mk |  3 +++
 11 files changed, 43 insertions(+)

diff --git a/INSTALL.md b/INSTALL.md
index 906825a..bf756f2 100644
--- a/INSTALL.md
+++ b/INSTALL.md
@@ -129,6 +129,8 @@ installing the following to obtain better warnings:
 
   - clang, version 3.4 or later
 
+  - flake8 (for Python code)
+
 Also, you may find the ovs-dev script found in utilities/ovs-dev.py useful.
 
 Installation Requirements
diff --git a/Makefile.am b/Makefile.am
index 946e1c2..52db244 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -141,6 +141,7 @@ SUFFIXES =
 check_DATA =
 check_SCRIPTS =
 pkgconfig_DATA =
+FLAKE8_PYFILES =
 
 scriptsdir = $(pkgdatadir)/scripts
 completiondir = $(sysconfdir)/bash_completion.d
@@ -339,6 +340,12 @@ manpage-check: $(man_MANS) $(dist_man_MANS) 
$(noinst_man_MANS)
 CLEANFILES += manpage-check
 endif
 
+if HAVE_FLAKE8
+ALL_LOCAL += flake8-check
+flake8-check: $(FLAKE8_PYFILES)
+       $(AM_V_GEN) if flake8 $^ 
--ignore=E111,E112,E113,E123,E126,E127,E128,E129,E131,E201,E203,E222,E225,E226,E231,E241,E251,E261,E262,E265,E271,E302,E303,E501,E502,E703,E711,E713,E721,F401,F811,F821,F841,W601
 ${FLAKE8_FLAGS}; then touch $@; else exit 1; fi
+endif
+
 include $(srcdir)/manpages.mk
 $(srcdir)/manpages.mk: $(MAN_ROOTS) build-aux/sodepends.pl
        @$(PERL) $(srcdir)/build-aux/sodepends.pl -I. -I$(srcdir) $(MAN_ROOTS) 
>$(@F).tmp
diff --git a/configure.ac b/configure.ac
index 8418aea..49aa182 100644
--- a/configure.ac
+++ b/configure.ac
@@ -95,6 +95,7 @@ OVS_CHECK_OPENSSL
 OVS_CHECK_LIBCAPNG
 OVS_CHECK_LOGDIR
 OVS_CHECK_PYTHON
+OVS_CHECK_FLAKE8
 OVS_CHECK_DOT
 OVS_CHECK_IF_PACKET
 OVS_CHECK_IF_DL
diff --git a/debian/automake.mk b/debian/automake.mk
index c29a560..0e30971 100644
--- a/debian/automake.mk
+++ b/debian/automake.mk
@@ -58,6 +58,9 @@ EXTRA_DIST += \
        debian/ifupdown.sh \
        debian/source/format
 
+FLAKE8_PYFILES += \
+       debian/ovs-monitor-ipsec
+
 check-debian-changelog-version:
        @DEB_VERSION=`echo '$(VERSION)' | sed 's/pre/~pre/'`;                \
        if $(FGREP) '($(DEB_VERSION)' $(srcdir)/debian/changelog >/dev/null; \
diff --git a/m4/openvswitch.m4 b/m4/openvswitch.m4
index 0cfaae6..6d4e5da 100644
--- a/m4/openvswitch.m4
+++ b/m4/openvswitch.m4
@@ -353,6 +353,18 @@ else:
    AM_CONDITIONAL([HAVE_PYTHON], [test "$HAVE_PYTHON" = yes])])
 
 dnl Checks for dot.
+AC_DEFUN([OVS_CHECK_FLAKE8],
+  [AC_CACHE_CHECK(
+    [for flake8],
+    [ovs_cv_flake8],
+    [if flake8 --version >/dev/null 2>&1; then
+       ovs_cv_flake8=yes
+     else
+       ovs_cv_flake8=no
+     fi])
+   AM_CONDITIONAL([HAVE_FLAKE8], [test "$ovs_cv_flake8" = yes])])
+
+dnl Checks for dot.
 AC_DEFUN([OVS_CHECK_DOT],
   [AC_CACHE_CHECK(
     [for dot],
diff --git a/ofproto/automake.mk b/ofproto/automake.mk
index 0058ff3..50e7507 100644
--- a/ofproto/automake.mk
+++ b/ofproto/automake.mk
@@ -82,3 +82,5 @@ ofproto/ipfix-entities.def: ofproto/ipfix.xml 
ofproto/ipfix-gen-entities
 
 # IPFIX enterprise entity definition macros.
 EXTRA_DIST += ofproto/ipfix-enterprise-entities.def
+
+FLAKE8_PYFILES += ofproto/ipfix-gen-entities
diff --git a/python/automake.mk b/python/automake.mk
index 42b428a..dc62422 100644
--- a/python/automake.mk
+++ b/python/automake.mk
@@ -50,6 +50,13 @@ PYFILES = $(ovs_pyfiles) python/ovs/dirs.py 
$(ovstest_pyfiles)
 EXTRA_DIST += $(PYFILES)
 PYCOV_CLEAN_FILES += $(PYFILES:.py=.py,cover)
 
+FLAKE8_PYFILES += \
+       $(filter-out python/ovs/dirs.py,$(PYFILES)) \
+       python/setup.py \
+       python/build/__init__.py \
+       python/build/nroff.py \
+       python/ovs/dirs.py.template
+
 if HAVE_PYTHON
 nobase_pkgdata_DATA = $(ovs_pyfiles) $(ovstest_pyfiles)
 ovs-install-data-local:
diff --git a/tests/automake.mk b/tests/automake.mk
index 6ce503f..28078c0 100644
--- a/tests/automake.mk
+++ b/tests/automake.mk
@@ -354,6 +354,8 @@ CHECK_PYFILES = \
 EXTRA_DIST += $(CHECK_PYFILES)
 PYCOV_CLEAN_FILES += $(CHECK_PYFILES:.py=.py,cover) .coverage
 
+FLAKE8_PYFILES += $(CHECK_PYFILES)
+
 if HAVE_OPENSSL
 TESTPKI_FILES = \
        tests/testpki-cacert.pem \
diff --git a/utilities/automake.mk b/utilities/automake.mk
index d5d1c33..d08347e 100644
--- a/utilities/automake.mk
+++ b/utilities/automake.mk
@@ -153,4 +153,6 @@ bin_PROGRAMS += utilities/ovs-benchmark
 utilities_ovs_benchmark_SOURCES = utilities/ovs-benchmark.c
 utilities_ovs_benchmark_LDADD = lib/libopenvswitch.la
 
+FLAKE8_PYFILES += utilities/ovs-pcap.in
+
 include utilities/bugtool/automake.mk
diff --git a/vtep/automake.mk b/vtep/automake.mk
index de028b6..2645f30 100644
--- a/vtep/automake.mk
+++ b/vtep/automake.mk
@@ -43,6 +43,8 @@ scripts_SCRIPTS += \
 docs += vtep/README.ovs-vtep.md
 EXTRA_DIST += vtep/ovs-vtep
 
+FLAKE8_PYFILES += vtep/ovs-vtep
+
 # VTEP schema and IDL
 EXTRA_DIST += vtep/vtep.ovsschema
 pkgdata_DATA += vtep/vtep.ovsschema
diff --git a/xenserver/automake.mk b/xenserver/automake.mk
index 816b1b5..1f75e3a 100644
--- a/xenserver/automake.mk
+++ b/xenserver/automake.mk
@@ -26,6 +26,9 @@ EXTRA_DIST += \
        xenserver/usr_share_openvswitch_scripts_ovs-xapi-sync \
        xenserver/usr_share_openvswitch_scripts_sysconfig.template
 
+FLAKE8_PYFILES += \
+       xenserver/usr_share_openvswitch_scripts_ovs-xapi-sync
+
 $(srcdir)/xenserver/openvswitch-xen.spec: xenserver/openvswitch-xen.spec.in 
$(top_builddir)/config.status
        $(AM_V_GEN)($(ro_shell) && sed -e 's,[@]VERSION[@],$(VERSION),g') \
                < $(srcdir)/xenserver/$(@F).in > $(@F).tmp || exit 1; \
-- 
2.5.0

_______________________________________________
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev

Reply via email to