[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v2] build: Fix make warning if there is no cppcheck


  • To: Bertrand Marquis <Bertrand.Marquis@xxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Fri, 20 May 2022 15:56:46 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Ynqs+BSk2t9/Jj2XX7dHUyBhK73T24oGcZM40uf9Hfs=; b=VPK/XOnBeD2C5028OrXBMwd3Pp5Mab/9oWfkH+V8OiP7/tbAfuQDzNI3VJFpTjsXURnyPJMOcZo9YncAcig9FKvYwPd1TWX7ADn5aVLgz+OUzLp/EfbSyJrJrrf+xSrjyoUme947lxuMvxOaMQItW7H/PR/JtF9NWqiXswZgXxvS72bETPkjxJx8PQSXMwVAcuQNcs+yF5W/mQXCz9lm2qS6D+eg33WP3DLPWHyD4aoHq0+CNTzYSvoFvNzZui46JmnVRrKv1ZS/CJ1EjASfGTtLnB56a3JkXGJ5RXNDJm4cQn6nZwc1Gp5m/B6whvO7M59BWQU29CjMrHc0RwIKUw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KWlzHHqmrvVo/4Y+AnJqf4ZKXyLWGYLe32HkIEV+UbWsUhQzBBTkkHefHmsFD0mtcSdyJ5BZfB3kR5F9DcL2qrvEookr5Ajky1xDMRNCTOXyr/AP72VoHEYQwW4vxY1c9/KrZGpIC262sJG1gzW17ZnIpGsZ05C05d8Jp5Kb0dEnEV8U16p07nY8s9jw78ZvRe7GJzrBIOo9Gtx5SRneIEbMCOm09EHrx5rYhD1Er6Oxihdojiv5moSfGb8CQ+bxn0uIVArAcaMBeU5HoQMJO/rkHBJPcgA08kr2I67GjrqwG8wKiVv9EnLbk8DVlLW1KI3bsh3M5zY7+6LOeEVn0g==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Fri, 20 May 2022 13:57:01 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 20.05.2022 15:23, Bertrand Marquis wrote:
>> On 20 May 2022, at 13:51, Jan Beulich <jbeulich@xxxxxxxx> wrote:
>> On 20.05.2022 14:14, Bertrand Marquis wrote:
>>> --- a/xen/Makefile
>>> +++ b/xen/Makefile
>>> @@ -694,12 +694,14 @@ $(objtree)/%.c.cppcheck: $(srctree)/%.c 
>>> $(objtree)/include/generated/autoconf.h
>>>     $(call if_changed,cppcheck_xml)
>>>
>>> cppcheck-version:
>>> -ifeq ($(shell which $(CPPCHECK)),)
>>> -   $(error Cannot find cppcheck executable: $(CPPCHECK))
>>> -endif
>>> -ifeq ($(shell $(CPPCHECK) --version | awk '{print ($$2 < 2.7)}'),1)
>>> -   $(error Please upgrade your cppcheck to version 2.7 or greater)
>>> -endif
>>> +   @if ! which $(CPPCHECK) > /dev/null 2>&1; then \
>>> +           echo "Cannot find cppcheck executable: $(CPPCHECK)"; \
>>> +           exit 1; \
>>> +   fi
>>> +   @if [ "$$($(CPPCHECK) --version | awk '{print ($$2 < 2.7)}')" -eq 1 ]; 
>>> then \
>>> +           echo "Please upgrade your cppcheck to version 2.7 or greater"; \
>>> +           exit 1; \
>>> +   fi
>>>
>>> # Put this in generated headers this way it is cleaned by include/Makefile
>>> $(objtree)/include/generated/compiler-def.h:
>>
>> Fine with me, even if - as said on v1 - I would have preferred $(if ...).
> 
> Could you explain why and what you mean exactly ?

I generally think that make scripts should resort to shell language
only if things cannot reasonably be expressed in make language.

> I thought the code would be more complex and less clear using if and I
> do not see how it would solve the issue with which being called.

The problem to deal with was to move the shell invocation from
makefile parsing time to rule execution time. Hence I don't see
why

cppcheck-version:
        $(if $(shell which ...),,$(error ...))

wouldn't deal with the problem equally well. But I guess I may
not be understanding your question / concern.

>> One question though: Wouldn't it better be $(Q) instead of the two plain
>> @? Preferably with that adjustment (which I guess can be made while
>> committing):
> 
> I thought of it but who would be interested in actually seeing those
> commands which are not “building” anything.

You never know what's relevant to see when hunting down some
obscure build system issue.

Jan




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.