unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: Jani Nikula <jani@nikula.org>
To: David Bremner <david@tethera.net>,
	David Bremner <david@tethera.net>,
	notmuch@notmuchmail.org, notmuch@freelists.org
Subject: Re: [Patch v2] build: add target to run cppcheck
Date: Tue, 29 Aug 2017 21:47:59 +0300	[thread overview]
Message-ID: <87k21mky74.fsf@nikula.org> (raw)
In-Reply-To: <87mv6ikyq7.fsf@nikula.org>

On Tue, 29 Aug 2017, Jani Nikula <jani@nikula.org> wrote:
> On Tue, 29 Aug 2017, David Bremner <david@tethera.net> 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

  reply	other threads:[~2017-08-29 18:48 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-26 14:41 make notmuch cppcheck clean David Bremner
2017-08-26 14:41 ` [PATCH 1/5] build: add target to run cppcheck David Bremner
2017-08-27  8:20   ` Jani Nikula
2017-08-29 11:35     ` [Patch v2] " David Bremner
2017-08-29 18:36       ` Jani Nikula
2017-08-29 18:47         ` Jani Nikula [this message]
2017-08-30 23:28         ` David Bremner
2017-08-26 14:41 ` [PATCH 2/5] cppcheck: close files during shutdown David Bremner
2017-08-26 14:41 ` [PATCH 3/5] cppcheck: call va_end in _internal_error David Bremner
2017-08-26 14:41 ` [PATCH 4/5] test/smtp-dummy: uncrustify David Bremner
2017-08-26 14:41 ` [PATCH 5/5] test/smtp-dummy: convert to 'goto DONE' style David Bremner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://notmuchmail.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87k21mky74.fsf@nikula.org \
    --to=jani@nikula.org \
    --cc=david@tethera.net \
    --cc=notmuch@freelists.org \
    --cc=notmuch@notmuchmail.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).