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 883D06DE0352 for ; Sun, 27 Aug 2017 01:20:12 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at cworth.org X-Spam-Flag: NO X-Spam-Score: 0.034 X-Spam-Level: X-Spam-Status: No, score=0.034 tagged_above=-999 required=5 tests=[AWL=0.054, 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 DWZLo3c6RuIx for ; Sun, 27 Aug 2017 01:20:08 -0700 (PDT) Received: from mail-lf0-f42.google.com (mail-lf0-f42.google.com [209.85.215.42]) by arlo.cworth.org (Postfix) with ESMTPS id 2B9A36DE0350 for ; Sun, 27 Aug 2017 01:20:08 -0700 (PDT) Received: by mail-lf0-f42.google.com with SMTP id y15so12385578lfd.0 for ; Sun, 27 Aug 2017 01:20:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nikula-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:in-reply-to:references:date:message-id :mime-version; bh=FY5/58rP9kG3N3FA5W3zcT7w6AWzvJUb/xA1mr3nrtg=; b=D4wYcPo3iZhbgOk4uhR2smHeA1gdN2W6EwQvNxWfRii0Lnm1w1QF1+53vMuGPEtQdc Cpx/gJwqhdb1qk2H67Khu/5J4686Gy93qkDgzLlLXipazZFH11eM1fUzyE764bU9xDQr CLBbdjrN5fsHLUZuIzpCpzWmWiVCO8JX1G1B/8K9XIlC6qpLmnpbNA+9qEfGMPO66mtO dIOTy0xs5/bw/FkBwgZuyFxoUsc8MeYwro8OayyPRpfaEfldQuKVfksPeNoWzZev+DUt WTTpdCXMcgnbU26ZmrsrjeZv6CXOHduUYR12KqAtm2pVrcQfVIy0zuMv8MyWhj4yW62c 3QgQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:in-reply-to:references:date :message-id:mime-version; bh=FY5/58rP9kG3N3FA5W3zcT7w6AWzvJUb/xA1mr3nrtg=; b=k3zps9o6PfSeed2sc7+gCFhDAr61dLfjGd1ctxxtuo8wzoFpv754NDSv5BuGfHKUPT EfITAOdgb7HVq8tNh4oGLWoAU9vhdUPflHuPoxK5AUxVl6/vwVlvRjk9Ib0v958Yk5I6 AKYxmyaNCYXWcttQFJJmNJkGML/SlkuT/kQPmT5H9QB8Us+hjp/V5GFkLIxnDasrj55M rfbpialtIVckqgi4UH0Cq6Kccr/RWtcvqDopezLzBYLSV+3rpHCAabpBWcnQUrvN4tFY y6XIljo1u/U/SqeWOp0UFTd0geddMJBGtZEzDlZopNG1uxIrUKEm8VddUxiuMMpiXgIz wPRQ== X-Gm-Message-State: AHYfb5h046ihGllkQzV+iNhIaRwVncqaJD9TTfhrzravtU+gnLjI6KTJ BdbUXLuLz6/pD1fl X-Received: by 10.25.56.80 with SMTP id d16mr1228363lfj.115.1503822006036; Sun, 27 Aug 2017 01:20:06 -0700 (PDT) Received: from localhost (mobile-access-5d6aa6-119.dhcp.inet.fi. [93.106.166.119]) by smtp.gmail.com with ESMTPSA id j125sm1808398lfg.28.2017.08.27.01.20.04 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 27 Aug 2017 01:20:05 -0700 (PDT) From: Jani Nikula To: David Bremner , notmuch@notmuchmail.org, notmuch@freelists.org Subject: Re: [PATCH 1/5] build: add target to run cppcheck In-Reply-To: <20170826144141.11140-2-david@tethera.net> References: <20170826144141.11140-1-david@tethera.net> <20170826144141.11140-2-david@tethera.net> Date: Sun, 27 Aug 2017 11:20:03 +0300 Message-ID: <87pobhl8wc.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: Sun, 27 Aug 2017 08:20:12 -0000 On Sat, 26 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. > > Things not addressed here > > - parallelism. Doing this correctly seems like a rabbit-hole. > > - what target to invoke this from. The 8s delay (on my machine) seems > acceptable, but not necessarily the resulting fragility in > autobuilders. Perhaps something could be build around something like below. It addresses the parallelism, but it's not without problems either. Only the files that need to be built would get checked; OTOH that may be beneficial while developing. Clearly we don't want to run cppcheck unconditionally when it's available. Would it be a configure option that would not be enabled by default? Or a make variable passed on the command like, say 'make CPPCHECK=1'? Food for thought; I'm not opposed to applying the patch at hand either. BR, Jani. diff --git a/Makefile.local b/Makefile.local index 6a5168f16427..fd59feafcd44 100644 --- a/Makefile.local +++ b/Makefile.local @@ -191,12 +191,20 @@ endif # Otherwise, print the full command line. quiet ?= $($(shell echo $1 | sed -e s'/ .*//')) +CPPCHECK=cppcheck + %.o: %.cc $(global_deps) @mkdir -p $(patsubst %/.,%,.deps/$(@D)) +ifeq ($(HAVE_CPPCHECK),1) + $(call quiet,CPPCHECK) --template="{file}:{line}: {severity}: {message}" --quiet --error-exitcode=1 $< +endif $(call quiet,CXX $(CPPFLAGS) $(CXXFLAGS)) -c $(FINAL_CXXFLAGS) $< -o $@ -MD -MP -MF .deps/$*.d %.o: %.c $(global_deps) @mkdir -p $(patsubst %/.,%,.deps/$(@D)) +ifeq ($(HAVE_CPPCHECK),1) + $(call quiet,CPPCHECK) --template="{file}:{line}: {severity}: {message}" --quiet --error-exitcode=1 $< +endif $(call quiet,CC $(CPPFLAGS) $(CFLAGS)) -c $(FINAL_CFLAGS) $< -o $@ -MD -MP -MF .deps/$*.d .PHONY : clean > --- > Makefile.local | 10 ++++++++++ > configure | 11 +++++++++++ > 2 files changed, 21 insertions(+) > > diff --git a/Makefile.local b/Makefile.local > index af12ca7f..6a5168f1 100644 > --- a/Makefile.local > +++ b/Makefile.local > @@ -283,6 +283,16 @@ CLEAN := $(CLEAN) version.stamp notmuch-*.tar.gz.tmp > > DISTCLEAN := $(DISTCLEAN) .first-build-message Makefile.config sh.config > > +CLEAN := $(CLEAN) cppcheck.stamp > +cppcheck: cppcheck.stamp > +cppcheck.stamp: $(SRCS) > +ifeq ($(HAVE_CPPCHECK),1) > + cppcheck --template="{file}:{line}: {severity}: {message}" --quiet --error-exitcode=1 ${SRCS} > + touch $@ > +else > + @echo No cppcheck installed; 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