From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by arlo.cworth.org (Postfix) with ESMTP id 84E746DE0927 for ; Tue, 29 Aug 2017 11:48:05 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at cworth.org X-Spam-Flag: NO X-Spam-Score: 0.033 X-Spam-Level: X-Spam-Status: No, score=0.033 tagged_above=-999 required=5 tests=[AWL=0.053, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01] autolearn=disabled Received: from arlo.cworth.org ([127.0.0.1]) by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id XDRi3hsnbUe0 for ; Tue, 29 Aug 2017 11:48:04 -0700 (PDT) Received: from mail-lf0-f67.google.com (mail-lf0-f67.google.com [209.85.215.67]) by arlo.cworth.org (Postfix) with ESMTPS id 067626DE00DB for ; Tue, 29 Aug 2017 11:48:04 -0700 (PDT) Received: by mail-lf0-f67.google.com with SMTP id z12so1170856lfd.5 for ; Tue, 29 Aug 2017 11:48:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nikula-org.20150623.gappssmtp.com; s=20150623; h=from:to:subject:in-reply-to:references:date:message-id:mime-version; bh=LR79qt4zimw/OEe5/+kW/M5Uz2CUF++Hb+1WX89Emtg=; b=Kya8ZVnBibPAC3viDfreXW/u62joVffmk3Xdfhy6y8wAmGtcVbgoH2hF9mjJz5bNqL BdTw8/Crr+k6h3X9qOBfOEjpMYmcU8a2RzScbYkY0/cjt7QaBd5NqEAl/IaDo6em5FD1 PRGvL3q6Tzivro3e59gjxsUWiCcHYCBVYWvvgCGURPbem+5PwdkfUux2UkvCu0YvsSoJ KU3k4533eK/jGBlU9HDKmQ00M5oWKFTFc7Nv+Q9lDj8ODigCBMtw9ps/TTTT/772Vqe+ w25izirVSQupVIFO1EPwtzIK+QTo0yaHwySaL4bsHAMROPucyVcRnVa05hYVAU6Q7Okn N/hA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:in-reply-to:references:date :message-id:mime-version; bh=LR79qt4zimw/OEe5/+kW/M5Uz2CUF++Hb+1WX89Emtg=; b=R91dh8HL4BxbHzAeoTAfMMWLpI4MGh8ObLwGHbYpbvYJY/SAtVjxVyzK+NzjzRxf+z 7EtkItbvRBDyLsKXm4PjXX32B3QVukRYehjwV9kwpESrZ5P4k156H4fwZu+65gUpa+Rc fp1ThP02EmNFxkGBCF9tptSplCV3CH6vj4FX5Jmme/JvFokuUZiWy7JDPaXrfo198aeb WEYYqonT285eSvhi3nW35lEYPpIcAJ2d7E2FUiBb2BaME0O9nWMNvPynQ53UZ5ScyMzN r1sjByrcHM9+05KoBoXWa9IXUJWtBAC4C/3+BBd+t1QddJPC+PG3IrrjIsHy4wlaYnfd x69Q== X-Gm-Message-State: AHYfb5ggpUFPNbAqpvECeEJK71+MIWOoGLo2nzlnDU9RVqr4WB+7pjUQ DbZP+7vw3MB0ARX0BCp1pw== X-Received: by 10.46.20.88 with SMTP id 24mr444658lju.161.1504032482176; Tue, 29 Aug 2017 11:48:02 -0700 (PDT) Received: from localhost (mobile-access-5d6aa6-119.dhcp.inet.fi. [93.106.166.119]) by smtp.gmail.com with ESMTPSA id k29sm740809lje.6.2017.08.29.11.48.00 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 29 Aug 2017 11:48:01 -0700 (PDT) From: Jani Nikula To: David Bremner , David Bremner , notmuch@notmuchmail.org, notmuch@freelists.org Subject: Re: [Patch v2] build: add target to run cppcheck In-Reply-To: <87mv6ikyq7.fsf@nikula.org> References: <87pobhl8wc.fsf@nikula.org> <20170829113526.10435-1-david@tethera.net> <87mv6ikyq7.fsf@nikula.org> Date: Tue, 29 Aug 2017 21:47:59 +0300 Message-ID: <87k21mky74.fsf@nikula.org> MIME-Version: 1.0 Content-Type: text/plain X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 29 Aug 2017 18:48:05 -0000 On Tue, 29 Aug 2017, Jani Nikula wrote: > On Tue, 29 Aug 2017, David Bremner wrote: >> The advantage of having a target as opposed to running cppcheck by >> hand >> >> - reuse list of source files >> - output errors in a format parsable, e.g. by emacs >> - returns exit code 1 on any error, for possibly use in other >> targets. >> >> For the moment, leave this as an optional target. If desired, it can >> be added to e.g. the release targets in the same way as the test >> target. >> >> Using two levels of directory for the stamps is arguably >> overengineering, but it doesn't really cost anything, and leaves open >> the possibility of putting other kinds of stamp files there. >> >> This only checks "new" source files (w.r.t. their last check). A future target >> (cppcheck-all ?) could blow away the stamp files first. >> >> --- >> >> Two notable changes from the first version: 1) support parallel build, >> inspired by id:87pobhl8wc.fsf@nikula.org; 2) use the predefined 'gcc' >> template. It's still an optional target, as that felt most comfortable >> as a workflow to me. > > This is nice. LGTM. I might have left out --error-exitcode=1 myself but > no strong feelings. Ah, I realize without --error-exitcode=1 you won't see the errors anymore. Nevermind. The fixes LGTM good. BR, Jani. > > I thought the quiet build lines like > > CPPCHECK .stamps/cppcheck/util/error_util.c > > were a bit ugly, so I came up with [1]. With that plus this change: > > - $(call quiet,CPPCHECK) --template=gcc --error-exitcode=1 --quiet $< > + $(call quiet,CPPCHECK,$<) --template=gcc --error-exitcode=1 --quiet $< > > you get > > CPPCHECK util/error_util.c > > > BR, > Jani. > > > [1] id:20170829182709.26841-2-jani@nikula.org > >> >> Makefile.local | 18 ++++++++++++++++++ >> configure | 11 +++++++++++ >> 2 files changed, 29 insertions(+) >> >> diff --git a/Makefile.local b/Makefile.local >> index af12ca7f..c6ad0047 100644 >> --- a/Makefile.local >> +++ b/Makefile.local >> @@ -199,6 +199,14 @@ quiet ?= $($(shell echo $1 | sed -e s'/ .*//')) >> @mkdir -p $(patsubst %/.,%,.deps/$(@D)) >> $(call quiet,CC $(CPPFLAGS) $(CFLAGS)) -c $(FINAL_CFLAGS) $< -o $@ -MD -MP -MF .deps/$*.d >> >> +CPPCHECK=cppcheck >> +.stamps/cppcheck/%: % >> + @mkdir -p $(@D) >> + $(call quiet,CPPCHECK) --template=gcc --error-exitcode=1 --quiet $< >> + @touch $@ >> + >> +CLEAN := $(CLEAN) .stamps >> + >> .PHONY : clean >> clean: >> rm -rf $(CLEAN); rm -rf .deps >> @@ -283,6 +291,16 @@ CLEAN := $(CLEAN) version.stamp notmuch-*.tar.gz.tmp >> >> DISTCLEAN := $(DISTCLEAN) .first-build-message Makefile.config sh.config >> >> +CPPCHECK_STAMPS := $(SRCS:%=.stamps/cppcheck/%) >> +.PHONY: cppcheck >> +ifeq ($(HAVE_CPPCHECK),1) >> +cppcheck: ${CPPCHECK_STAMPS} >> +else >> +cppcheck: >> + @echo "No cppcheck found during configure; skipping static checking" >> +endif >> + >> + >> DEPS := $(SRCS:%.c=.deps/%.d) >> DEPS := $(DEPS:%.cc=.deps/%.d) >> -include $(DEPS) >> diff --git a/configure b/configure >> index c5e2ffed..364854f3 100755 >> --- a/configure >> +++ b/configure >> @@ -646,6 +646,14 @@ if [ $WITH_DESKTOP = "1" ]; then >> fi >> fi >> >> +printf "Checking for cppcheck... " >> +if command -v cppcheck > /dev/null; then >> + have_cppcheck=1 >> + printf "Yes.\n" >> +else >> + printf "No.\n" >> +fi >> + >> libdir_in_ldconfig=0 >> >> printf "Checking which platform we are on... " >> @@ -1065,6 +1073,9 @@ zsh_completion_dir = ${ZSHCOMLETIONDIR:=\$(prefix)/share/zsh/functions/Completio >> # build its own version) >> HAVE_CANONICALIZE_FILE_NAME = ${have_canonicalize_file_name} >> >> +# Whether the cppcheck static checker is available >> +HAVE_CPPCHECK = ${have_cppcheck} >> + >> # Whether the getline function is available (if not, then notmuch will >> # build its own version) >> HAVE_GETLINE = ${have_getline} >> -- >> 2.14.1