From 6e4c8f68c5ab0a4381d7942c20e0e6241ddf1983 Mon Sep 17 00:00:00 2001 From: Iustin Pop <iustin@google.com> Date: Mon, 11 Jun 2012 11:15:59 +0200 Subject: [PATCH] Enable hlint in lint and reorganise this target MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Currently, the lint target does a sequential: pep8, pylint, pylint on the QA sources. hlint is run only when explicitly requested. This patch reorganises the lint target by: - splitting the current lint target into separate pylint (slow), pylint-qa (fast), pep8 (fast) targets - making lint itself depend on the above plus hlint - both pep8 and hlint are optional, based on whether the said binaries were detected at configure time make -j is slightly faster after this patch (1m18s β 1m7s). Signed-off-by: Iustin Pop <iustin@google.com> Reviewed-by: Guido Trotter <ultrotter@google.com> --- Makefile.am | 32 ++++++++++++++++++++++++-------- configure.ac | 10 ++++++++++ 2 files changed, 34 insertions(+), 8 deletions(-) diff --git a/Makefile.am b/Makefile.am index c8c36812b..321d166b0 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1314,24 +1314,40 @@ PEP8_IGNORE = E111,E261,E501 # For excluding pep8 expects filenames only, not whole paths PEP8_EXCLUDE = $(subst $(space),$(comma),$(strip $(notdir $(BUILT_PYTHON_SOURCES)))) +LINT_TARGETS = pylint pylint-qa +if HAS_PEP8 +LINT_TARGETS += pep8 +endif +if HAS_HLINT +LINT_TARGETS += hlint +endif + .PHONY: lint -lint: $(BUILT_SOURCES) +lint: $(LINT_TARGETS) + +.PHONY: pylint +pylint: $(BUILT_SOURCES) @test -n "$(PYLINT)" || { echo 'pylint' not found during configure; exit 1; } - if test -z "$(PEP8)"; then \ - echo '"pep8" not found during configure' >&2; \ - else \ - $(PEP8) --repeat --ignore='$(PEP8_IGNORE)' --exclude='$(PEP8_EXCLUDE)' \ - $(pep8_python_code); \ - fi $(PYLINT) $(LINT_OPTS) $(lint_python_code) + +.PHONY: pylint-qa +pylint-qa: $(BUILT_SOURCES) + @test -n "$(PYLINT)" || { echo 'pylint' not found during configure; exit 1; } cd $(top_srcdir)/qa && \ PYTHONPATH=$(abs_top_srcdir) $(PYLINT) $(LINT_OPTS) \ --rcfile ../pylintrc $(patsubst qa/%.py,%,$(qa_scripts)) +.PHONY: pep8 +pep8: $(BUILT_SOURCES) + @test -n "$(PEP8)" || { echo 'pep8' not found during configure; exit 1; } + $(PEP8) --ignore='$(PEP8_IGNORE)' --exclude='$(PEP8_EXCLUDE)' \ + --repeat $(pep8_python_code) + .PHONY: hlint hlint: $(HS_BUILT_SRCS) htools/lint-hints.hs + @test -n "$(HLINT)" || { echo 'hlint' not found during configure; exit 1; } if tty -s; then C="-c"; else C=""; fi; \ - hlint --report=doc/hs-lint.html --cross $$C \ + $(HLINT) --report=doc/hs-lint.html --cross $$C \ --ignore "Use first" \ --ignore "Use comparing" \ --ignore "Use on" \ diff --git a/configure.ac b/configure.ac index 7520c67d1..0a36b0b34 100644 --- a/configure.ac +++ b/configure.ac @@ -387,6 +387,7 @@ if test -z "$PEP8" then AC_MSG_WARN([pep8 not found, checking code will not be complete]) fi +AM_CONDITIONAL([HAS_PEP8], [test "$PEP8"]) # Check for socat AC_ARG_VAR(SOCAT, [socat path]) @@ -518,6 +519,14 @@ if test "$HADDOCK" && test "$HSCOLOUR"; then fi AC_SUBST(HTOOLS_APIDOC) +# Check for hlint +HLINT=no +AC_ARG_VAR(HLINT, [hlint path]) +AC_PATH_PROG(HLINT, [hlint], []) +if test -z "$HLINT"; then + AC_MSG_WARN([hlint not found, checking code will not be possible]) +fi + fi # end if enable_htools, define automake conditions if test "$HTOOLS" != "yes" && test "$HS_CONFD" = "True"; then @@ -528,6 +537,7 @@ fi AM_CONDITIONAL([WANT_HTOOLS], [test x$HTOOLS = xyes]) AM_CONDITIONAL([WANT_HTOOLSTESTS], [test "x$GHC_PKG_QUICKCHECK" != x]) AM_CONDITIONAL([WANT_HTOOLSAPIDOC], [test x$HTOOLS_APIDOC = xyes]) +AM_CONDITIONAL([HAS_HLINT], [test "$HLINT"]) # Check for fakeroot AC_ARG_VAR(FAKEROOT_PATH, [fakeroot path]) -- GitLab