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

[PATCH] build: correct cppcheck-misra make rule


  • To: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Fri, 9 Sep 2022 15:41:11 +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=Ggjmk5fUGkioYbiuHrpgmwF5jPPRaUl0+tSSXX+oN4A=; b=fpYrhEGNFb8FVF1UsoFossv9KQ0aTwM9IZm4JdoaFT52QPRGhPWUtH96So/UlKPDYl2rAW7LH1JbRHGUZ7inxlVL8giPW5oi24LS2WTEYsTzdoeqIl4y+nwHmvpZcfAqACQcjhICrpJPG/RrfW0KnjUFPmvg7UGinrVitzNXyvc4HbYwpiKby1d85iZG9cNDT0ejYBaF8onNOLW76kbDqhXx4HX4657hyxCurJ+YMAV7E7FqwnF7CVgA+FThZChA160oBvv+3UjabXcy7jFRHrEUHQ6Op27AYHZs3Wnv/ZYSRSUjjgwh7BpI2Qvn0Go4PJzCAW6RnXrzJFBnKOL2kQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IOS/JwIw6TCcU4PQ6qn1oq+VpjFCGjLlScw6LqiQ+4CAuqqFcuV5t6IRdygZUmsWbaRvBkzr5WbtSiYmheoEmXgew52Il9EaNh4gJpOKer9Y8VBSG6usppNwjf7XGkSz4kkeGWcfurMysNe6OnkepdXBI/5T02rpSRcQVERpwv84SuIuVfPmrwhAKPCy+6Lch+FLs8UBxbC4adUDpwQc0QURmDjAbaoyDhv0asZsT0rEtuvOHCWXnzTQ1t2jjfOGOEqdVAVX5MJwwH0DpYze+EQFK/kOT9P2FTUX9l5hgkxZgFuDJwXVDXXSdoSg+hz8K/hmJ4iKfQWeBr3U1v9mUQ==
  • 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>, Bertrand Marquis <bertrand.marquis@xxxxxxx>, Anthony Perard <anthony.perard@xxxxxxxxxx>
  • Delivery-date: Fri, 09 Sep 2022 13:41:22 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

It has been bothering me for a while that I made a bad suggestion during
review: Having cppcheck-misra.json depend on cppcheck-misra.txt does not
properly address the multiple targets problem. If cppcheck-misra.json
is deleted from the build tree but cppcheck-misra.txt is still there,
nothing will re-generate cppcheck-misra.json.

With GNU make 4.3 or newer we could use the &: grouped target separator,
but since we support older make as well we need to use some other
mechanism. Convert the rule to a pattern one (with "cppcheck"
arbitrarily chosen as the stem), thus making known to make that both
files are created by a single command invocation. Since, as a result,
the JSON file is now "intermediate" from make's perspective, prevent it
being deleted again by making it a prereq of .PRECIOUS.

Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
---
I've not been able to spot where / how cppcheck-misra.txt is used. If
it's indeed unused, a perhaps better alternative would be to convert the
original rule to specify cppcheck-misra.json as (the only) target. One
might then even consider using "-o /dev/null" instead of producing an
unused *.txt file.

--- a/xen/Makefile
+++ b/xen/Makefile
@@ -746,11 +746,9 @@ cppcheck-version:
 # documentation file. Also generate a json file with the right arguments for
 # cppcheck in json format including the list of rules to ignore.
 #
-cppcheck-misra.txt: $(XEN_ROOT)/docs/misra/rules.rst 
$(srctree)/tools/convert_misra_doc.py
-       $(Q)$(PYTHON) $(srctree)/tools/convert_misra_doc.py -i $< -o $@ -j 
$(@:.txt=.json)
-
-# convert_misra_doc is generating both files.
-cppcheck-misra.json: cppcheck-misra.txt
+.PRECIOUS: %-misra.json
+%-misra.txt %-misra.json: $(XEN_ROOT)/docs/misra/rules.rst 
$(srctree)/tools/convert_misra_doc.py
+       $(Q)$(PYTHON) $(srctree)/tools/convert_misra_doc.py -i $< -o 
$*-misra.txt -j $*-misra.json
 
 # Put this in generated headers this way it is cleaned by include/Makefile
 $(objtree)/include/generated/compiler-def.h:



 


Rackspace

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